use of org.apache.ignite.internal.schema.NativeTypes.INT32 in project ignite-3 by apache.
the class RecordViewOperationsTest method recordView.
/**
* Creates RecordView.
*/
private RecordViewImpl<TestObjectWithAllTypes> recordView() {
ClusterService clusterService = Mockito.mock(ClusterService.class, RETURNS_DEEP_STUBS);
Mockito.when(clusterService.topologyService().localMember().address()).thenReturn(DummyInternalTableImpl.ADDR);
TxManager txManager = new TxManagerImpl(clusterService, new HeapLockManager());
MessagingService messagingService = MessagingServiceTestUtils.mockMessagingService(txManager);
Mockito.when(clusterService.messagingService()).thenReturn(messagingService);
DummyInternalTableImpl table = new DummyInternalTableImpl(new VersionedRowStore(new ConcurrentHashMapPartitionStorage(), txManager), txManager);
Mapper<TestObjectWithAllTypes> recMapper = Mapper.of(TestObjectWithAllTypes.class);
Column[] valCols = { new Column("primitiveByteCol".toUpperCase(), INT8, false), new Column("primitiveShortCol".toUpperCase(), INT16, false), new Column("primitiveIntCol".toUpperCase(), INT32, false), new Column("primitiveFloatCol".toUpperCase(), FLOAT, false), new Column("primitiveDoubleCol".toUpperCase(), DOUBLE, false), new Column("byteCol".toUpperCase(), INT8, true), new Column("shortCol".toUpperCase(), INT16, true), new Column("intCol".toUpperCase(), INT32, true), new Column("longCol".toUpperCase(), INT64, true), new Column("nullLongCol".toUpperCase(), INT64, true), new Column("floatCol".toUpperCase(), FLOAT, true), new Column("doubleCol".toUpperCase(), DOUBLE, true), new Column("dateCol".toUpperCase(), DATE, true), new Column("timeCol".toUpperCase(), time(), true), new Column("dateTimeCol".toUpperCase(), datetime(), true), new Column("timestampCol".toUpperCase(), timestamp(), true), new Column("uuidCol".toUpperCase(), NativeTypes.UUID, true), new Column("bitmaskCol".toUpperCase(), NativeTypes.bitmaskOf(42), true), new Column("stringCol".toUpperCase(), STRING, true), new Column("nullBytesCol".toUpperCase(), BYTES, true), new Column("bytesCol".toUpperCase(), BYTES, true), new Column("numberCol".toUpperCase(), NativeTypes.numberOf(12), true), new Column("decimalCol".toUpperCase(), NativeTypes.decimalOf(19, 3), true) };
SchemaDescriptor schema = new SchemaDescriptor(1, new Column[] { new Column("primitiveLongCol".toUpperCase(), NativeTypes.INT64, false) }, valCols);
// Validate all types are tested.
Set<NativeTypeSpec> testedTypes = Arrays.stream(valCols).map(c -> c.type().spec()).collect(Collectors.toSet());
Set<NativeTypeSpec> missedTypes = Arrays.stream(NativeTypeSpec.values()).filter(t -> !testedTypes.contains(t)).collect(Collectors.toSet());
assertEquals(Collections.emptySet(), missedTypes);
return new RecordViewImpl<>(table, new DummySchemaManagerImpl(schema), recMapper);
}
use of org.apache.ignite.internal.schema.NativeTypes.INT32 in project ignite-3 by apache.
the class KeyValueViewOperationsTest method kvView.
/**
* Creates key-value view.
*/
private KeyValueViewImpl<TestKeyObject, TestObjectWithAllTypes> kvView() {
ClusterService clusterService = Mockito.mock(ClusterService.class, RETURNS_DEEP_STUBS);
Mockito.when(clusterService.topologyService().localMember().address()).thenReturn(DummyInternalTableImpl.ADDR);
TxManager txManager = new TxManagerImpl(clusterService, new HeapLockManager());
MessagingService messagingService = MessagingServiceTestUtils.mockMessagingService(txManager);
Mockito.when(clusterService.messagingService()).thenReturn(messagingService);
DummyInternalTableImpl table = new DummyInternalTableImpl(new VersionedRowStore(new ConcurrentHashMapPartitionStorage(), txManager), txManager);
Mapper<TestKeyObject> keyMapper = Mapper.of(TestKeyObject.class);
Mapper<TestObjectWithAllTypes> valMapper = Mapper.of(TestObjectWithAllTypes.class);
Column[] valCols = { new Column("primitiveByteCol".toUpperCase(), INT8, false), new Column("primitiveShortCol".toUpperCase(), INT16, false), new Column("primitiveIntCol".toUpperCase(), INT32, false), new Column("primitiveLongCol".toUpperCase(), INT64, false), new Column("primitiveFloatCol".toUpperCase(), FLOAT, false), new Column("primitiveDoubleCol".toUpperCase(), DOUBLE, false), new Column("byteCol".toUpperCase(), INT8, true), new Column("shortCol".toUpperCase(), INT16, true), new Column("intCol".toUpperCase(), INT32, true), new Column("longCol".toUpperCase(), INT64, true), new Column("nullLongCol".toUpperCase(), INT64, true), new Column("floatCol".toUpperCase(), FLOAT, true), new Column("doubleCol".toUpperCase(), DOUBLE, true), new Column("dateCol".toUpperCase(), DATE, true), new Column("timeCol".toUpperCase(), time(), true), new Column("dateTimeCol".toUpperCase(), datetime(), true), new Column("timestampCol".toUpperCase(), timestamp(), true), new Column("uuidCol".toUpperCase(), NativeTypes.UUID, true), new Column("bitmaskCol".toUpperCase(), NativeTypes.bitmaskOf(42), true), new Column("stringCol".toUpperCase(), STRING, true), new Column("nullBytesCol".toUpperCase(), BYTES, true), new Column("bytesCol".toUpperCase(), BYTES, true), new Column("numberCol".toUpperCase(), NativeTypes.numberOf(12), true), new Column("decimalCol".toUpperCase(), NativeTypes.decimalOf(19, 3), true) };
SchemaDescriptor schema = new SchemaDescriptor(1, new Column[] { new Column("id".toUpperCase(), NativeTypes.INT64, false) }, valCols);
// Validate all types are tested.
Set<NativeTypeSpec> testedTypes = Arrays.stream(valCols).map(c -> c.type().spec()).collect(Collectors.toSet());
Set<NativeTypeSpec> missedTypes = Arrays.stream(NativeTypeSpec.values()).filter(t -> !testedTypes.contains(t)).collect(Collectors.toSet());
assertEquals(Collections.emptySet(), missedTypes);
return new KeyValueViewImpl<>(table, new DummySchemaManagerImpl(schema), keyMapper, valMapper);
}
use of org.apache.ignite.internal.schema.NativeTypes.INT32 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