use of org.apache.ignite.internal.storage.index.SortedIndexDescriptor.ColumnDescriptor in project ignite-3 by apache.
the class PrefixComparator method compare.
/**
* Compares a given row with the configured prefix.
*
* @param binaryRow Row to compare.
* @return the value {@code 0} if the given row starts with the configured prefix;
* a value less than {@code 0} if the row's prefix is smaller than the prefix; and
* a value greater than {@code 0} if the row's prefix is larger than the prefix.
*/
int compare(BinaryRow binaryRow) {
var row = new Row(descriptor.asSchemaDescriptor(), binaryRow);
for (int i = 0; i < prefix.length; ++i) {
ColumnDescriptor columnDescriptor = descriptor.indexRowColumns().get(i);
int compare = compare(columnDescriptor.column(), row, prefix[i]);
if (compare != 0) {
return columnDescriptor.asc() ? compare : -compare;
}
}
return 0;
}
use of org.apache.ignite.internal.storage.index.SortedIndexDescriptor.ColumnDescriptor in project ignite-3 by apache.
the class IndexRowWrapper method randomRow.
/**
* Creates an Entry with a random key that satisfies the given schema and a random value.
*/
static IndexRowWrapper randomRow(SortedIndexStorage indexStorage) {
var random = new Random();
Object[] columns = indexStorage.indexDescriptor().indexRowColumns().stream().map(ColumnDescriptor::column).map(column -> generateRandomValue(random, column.type())).toArray();
var primaryKey = new ByteArraySearchRow(randomBytes(random, 25));
IndexRow row = indexStorage.indexRowFactory().createIndexRow(columns, primaryKey);
return new IndexRowWrapper(indexStorage, row, columns);
}
Aggregations