use of org.apache.ignite.internal.schema.ByteBufferRow in project ignite-3 by apache.
the class RocksDbSortedIndexStorage method range.
@Override
public Cursor<IndexRow> range(IndexRowPrefix lowerBound, IndexRowPrefix upperBound) {
RocksIterator iter = indexCf.newIterator();
iter.seekToFirst();
return new RocksIteratorAdapter<>(iter) {
@Nullable
private PrefixComparator lowerBoundComparator = new PrefixComparator(descriptor, lowerBound);
private final PrefixComparator upperBoundComparator = new PrefixComparator(descriptor, upperBound);
@Override
public boolean hasNext() {
while (super.hasNext()) {
var row = new ByteBufferRow(it.key());
if (lowerBoundComparator != null) {
// if lower comparator is not null, then the lower bound has not yet been reached
if (lowerBoundComparator.compare(row) < 0) {
it.next();
continue;
} else {
// once the lower bound is reached, we no longer need to check it
lowerBoundComparator = null;
}
}
return upperBoundComparator.compare(row) <= 0;
}
return false;
}
@Override
protected IndexRow decodeEntry(byte[] key, byte[] value) {
return new BinaryIndexRow(key, value);
}
};
}
use of org.apache.ignite.internal.schema.ByteBufferRow in project ignite-3 by apache.
the class UpgradingRowAdapterTest method testVariousColumnTypes.
@Test
public void testVariousColumnTypes() {
SchemaDescriptor schema = new SchemaDescriptor(1, new Column[] { new Column("keyUuidCol", NativeTypes.UUID, false) }, new Column[] { new Column("valByteCol", INT8, true), new Column("valShortCol", INT16, true), new Column("valIntCol", INT32, true), new Column("valLongCol", INT64, true), new Column("valFloatCol", FLOAT, true), new Column("valDoubleCol", DOUBLE, true), new Column("valDateCol", DATE, true), new Column("valTimeCol", time(), true), new Column("valDateTimeCol", datetime(), true), new Column("valTimeStampCol", timestamp(), true), new Column("valBitmask1Col", NativeTypes.bitmaskOf(22), true), new Column("valBytesCol", BYTES, false), new Column("valStringCol", STRING, false), new Column("valNumberCol", NativeTypes.numberOf(20), false), new Column("valDecimalCol", NativeTypes.decimalOf(25, 5), false) });
SchemaDescriptor schema2 = new SchemaDescriptor(2, new Column[] { new Column("keyUuidCol", NativeTypes.UUID, false) }, new Column[] { new Column("added", INT8, true), new Column("valByteCol", INT8, true), new Column("valShortCol", INT16, true), new Column("valIntCol", INT32, true), new Column("valLongCol", INT64, true), new Column("valFloatCol", FLOAT, true), new Column("valDoubleCol", DOUBLE, true), new Column("valDateCol", DATE, true), new Column("valTimeCol", time(), true), new Column("valDateTimeCol", datetime(), true), new Column("valTimeStampCol", timestamp(), true), new Column("valBitmask1Col", NativeTypes.bitmaskOf(22), true), new Column("valBytesCol", BYTES, false), new Column("valStringCol", STRING, false), new Column("valNumberCol", NativeTypes.numberOf(20), false), new Column("valDecimalCol", NativeTypes.decimalOf(25, 5), false) });
int addedColumnIndex = schema2.column("added").schemaIndex();
schema2.columnMapping(new ColumnMapper() {
@Override
public ColumnMapper add(@NotNull Column col) {
return null;
}
@Override
public ColumnMapper add(int from, int to) {
return null;
}
@Override
public int map(int idx) {
return idx < addedColumnIndex ? idx : idx == addedColumnIndex ? -1 : idx - 1;
}
@Override
public Column mappedColumn(int idx) {
return idx == addedColumnIndex ? schema2.column(idx) : null;
}
});
List<Object> values = generateRowValues(schema);
ByteBufferRow row = new ByteBufferRow(serializeValuesToRow(schema, values));
// Validate row.
validateRow(values, new SchemaRegistryImpl(1, v -> v == 1 ? schema : schema2, () -> INITIAL_SCHEMA_VERSION), row);
// Validate upgraded row.
values.add(addedColumnIndex, null);
validateRow(values, new SchemaRegistryImpl(2, v -> v == 1 ? schema : schema2, () -> INITIAL_SCHEMA_VERSION), row);
}
Aggregations