private int FindNodeByKey(object?originalKey)
{
int x, c;
if (_indexFields.Length != 1)
{
throw ExceptionBuilder.IndexKeyLength(_indexFields.Length, 1);
}
x = _records.root;
if (IndexTree.NIL != x)
{
// otherwise storage may not exist
DataColumn column = _indexFields[0].Column;
object? key = column.ConvertValue(originalKey);
x = _records.root;
if (_indexFields[0].IsDescending)
{
while (IndexTree.NIL != x)
{
c = column.CompareValueTo(_records.Key(x), key);
if (c == 0)
{
break;
}
if (c < 0)
{
x = _records.Left(x);
} // < for decsending
else
{
x = _records.Right(x);
}
}
}
else
{
while (IndexTree.NIL != x)
{
c = column.CompareValueTo(_records.Key(x), key);
if (c == 0)
{
break;
}
if (c > 0)
{
x = _records.Left(x);
} // > for ascending
else
{
x = _records.Right(x);
}
}
}
}
return(x);
}