use of com.hazelcast.internal.serialization.impl.InternalGenericRecord in project hazelcast by hazelcast.
the class PortableGetter method getValue.
@Override
Object getValue(Object target, String fieldPath) throws Exception {
InternalGenericRecord record;
if (target instanceof PortableGenericRecord) {
record = (InternalGenericRecord) target;
} else {
record = serializationService.readAsInternalGenericRecord((Data) target);
}
GenericRecordQueryReader reader = new GenericRecordQueryReader(record);
return reader.read(fieldPath);
}
use of com.hazelcast.internal.serialization.impl.InternalGenericRecord in project hazelcast by hazelcast.
the class CompactGetter method getValue.
@Override
Object getValue(Object target, String fieldPath) throws Exception {
InternalGenericRecord record;
if (target instanceof CompactInternalGenericRecord) {
record = (InternalGenericRecord) target;
} else {
record = serializationService.readAsInternalGenericRecord((Data) target);
}
GenericRecordQueryReader reader = new GenericRecordQueryReader(record);
return reader.read(fieldPath);
}
use of com.hazelcast.internal.serialization.impl.InternalGenericRecord in project hazelcast by hazelcast.
the class PortableUpsertTargetTest method when_typeIsObject_then_allValuesAreAllowed.
@Test
@Parameters(method = "objectClassDefinitions")
public void when_typeIsObject_then_allValuesAreAllowed(ClassDefinition classDefinition, Object value, Function<InternalGenericRecord, Object> valueExtractor) throws IOException {
UpsertTarget target = new PortableUpsertTarget(classDefinition);
UpsertInjector injector = target.createInjector("object", QueryDataType.OBJECT);
target.init();
injector.set(value);
Object portable = target.conclude();
InternalSerializationService ss = new DefaultSerializationServiceBuilder().build();
InternalGenericRecord record = ss.readAsInternalGenericRecord(ss.toData(portable));
assertThat(valueExtractor.apply(record)).isEqualTo(value);
}
use of com.hazelcast.internal.serialization.impl.InternalGenericRecord in project hazelcast by hazelcast.
the class SqlCompactTest method test_insertNulls.
@Test
public void test_insertNulls() throws IOException {
String name = randomName();
sqlService.execute("CREATE MAPPING " + name + " (" + "__key INT " + ", b BOOLEAN " + ", st VARCHAR " + ", bt TINYINT " + ", s SMALLINT " + ", i INTEGER " + ", l BIGINT " + ", bd DECIMAL " + ", f REAL " + ", d DOUBLE " + ", t TIME " + ", dt DATE " + ", tmstmp TIMESTAMP " + ", tmstmpTz TIMESTAMP WITH TIME ZONE " + ") " + "TYPE " + IMapSqlConnector.TYPE_NAME + ' ' + "OPTIONS (" + '\'' + OPTION_KEY_FORMAT + "'='integer'" + ", '" + OPTION_VALUE_FORMAT + "'='" + COMPACT_FORMAT + '\'' + ", '" + OPTION_VALUE_COMPACT_TYPE_NAME + "'='" + PERSON_TYPE_NAME + '\'' + ")").updateCount();
sqlService.execute("SINK INTO " + name + " VALUES (1, null, null, null, " + "null, null, null, null, null, null, null, null, null, null )").updateCount();
Entry<Data, Data> entry = randomEntryFrom(name);
InternalGenericRecord valueRecord = serializationService.readAsInternalGenericRecord(entry.getValue());
assertThat(valueRecord.getNullableBoolean("b")).isNull();
assertThat(valueRecord.getString("st")).isNull();
assertThat(valueRecord.getNullableInt8("bt")).isNull();
assertThat(valueRecord.getNullableInt16("s")).isNull();
assertThat(valueRecord.getNullableInt32("i")).isNull();
assertThat(valueRecord.getNullableInt64("l")).isNull();
assertThat(valueRecord.getDecimal("bd")).isNull();
assertThat(valueRecord.getNullableFloat32("f")).isNull();
assertThat(valueRecord.getNullableFloat64("d")).isNull();
assertThat(valueRecord.getTime("t")).isNull();
assertThat(valueRecord.getDate("dt")).isNull();
assertThat(valueRecord.getTimestamp("tmstmp")).isNull();
assertThat(valueRecord.getTimestampWithTimezone("tmstmpTz")).isNull();
assertRowsAnyOrder("SELECT * FROM " + name, singletonList(new Row(1, null, null, null, null, null, null, null, null, null, null, null, null, null)));
}
use of com.hazelcast.internal.serialization.impl.InternalGenericRecord in project hazelcast by hazelcast.
the class SqlPortableTest method test_fieldsShadowing.
@Test
public void test_fieldsShadowing() throws IOException {
String name = randomName();
sqlService.execute("CREATE MAPPING " + name + ' ' + "TYPE " + IMapSqlConnector.TYPE_NAME + ' ' + "OPTIONS (" + '\'' + OPTION_KEY_FORMAT + "'='" + PORTABLE_FORMAT + '\'' + ", '" + OPTION_KEY_FACTORY_ID + "'='" + PERSON_ID_FACTORY_ID + '\'' + ", '" + OPTION_KEY_CLASS_ID + "'='" + PERSON_ID_CLASS_ID + '\'' + ", '" + OPTION_KEY_CLASS_VERSION + "'='" + PERSON_ID_CLASS_VERSION + '\'' + ", '" + OPTION_VALUE_FORMAT + "'='" + PORTABLE_FORMAT + '\'' + ", '" + OPTION_VALUE_FACTORY_ID + "'='" + PERSON_FACTORY_ID + '\'' + ", '" + OPTION_VALUE_CLASS_ID + "'='" + PERSON_CLASS_ID + '\'' + ", '" + OPTION_VALUE_CLASS_VERSION + "'='" + PERSON_CLASS_VERSION + '\'' + ")");
sqlService.execute("SINK INTO " + name + " (id, name) VALUES (1, 'Alice')");
Entry<Data, Data> entry = randomEntryFrom(name);
InternalGenericRecord keyRecord = serializationService.readAsInternalGenericRecord(entry.getKey());
assertThat(keyRecord.getInt32("id")).isEqualTo(1);
InternalGenericRecord valueRecord = serializationService.readAsInternalGenericRecord(entry.getValue());
assertThat(valueRecord.getInt32("id")).isEqualTo(0);
assertThat(valueRecord.getString("name")).isEqualTo("Alice");
assertRowsAnyOrder("SELECT * FROM " + name, singletonList(new Row(1, "Alice")));
}
Aggregations