use of com.hazelcast.internal.serialization.impl.GenericRecordQueryReader 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.GenericRecordQueryReader 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.GenericRecordQueryReader in project hazelcast by hazelcast.
the class CompactStreamSerializerTest method testBits.
@Test
public void testBits() throws IOException {
InternalSerializationService ss1 = createSerializationService();
InternalSerializationService ss2 = createSerializationService();
BitsDTO bitsDTO = new BitsDTO();
bitsDTO.a = true;
bitsDTO.h = true;
bitsDTO.id = 121;
bitsDTO.booleans = new boolean[8];
bitsDTO.booleans[0] = true;
bitsDTO.booleans[4] = true;
Data data = ss1.toData(bitsDTO);
// hash(4) + typeid(4) + schemaId(8) + (4 byte length) + (1 bytes for 8 bits) + (4 bytes for int)
// (4 byte length of byte array) + (1 byte for booleans array of 8 bits) + (1 byte offset bytes)
assertEquals(31, data.toByteArray().length);
GenericRecordQueryReader reader = new GenericRecordQueryReader(ss2.readAsInternalGenericRecord(data));
assertEquals(121, reader.read("id"));
assertTrue((Boolean) reader.read("a"));
assertFalse((Boolean) reader.read("b"));
assertFalse((Boolean) reader.read("c"));
assertFalse((Boolean) reader.read("d"));
assertFalse((Boolean) reader.read("e"));
assertFalse((Boolean) reader.read("f"));
assertFalse((Boolean) reader.read("g"));
assertTrue((Boolean) reader.read("h"));
assertTrue((Boolean) reader.read("booleans[0]"));
assertFalse((Boolean) reader.read("booleans[1]"));
assertFalse((Boolean) reader.read("booleans[2]"));
assertFalse((Boolean) reader.read("booleans[3]"));
assertTrue((Boolean) reader.read("booleans[4]"));
assertFalse((Boolean) reader.read("booleans[5]"));
assertFalse((Boolean) reader.read("booleans[6]"));
assertFalse((Boolean) reader.read("booleans[7]"));
Object object = ss2.toObject(data);
BitsDTO o = (BitsDTO) object;
assertEquals(bitsDTO, o);
}
use of com.hazelcast.internal.serialization.impl.GenericRecordQueryReader in project hazelcast by hazelcast.
the class DefaultPortableReaderQuickTest method reader.
//
// Utilities
//
public GenericRecordQueryReader reader(Portable portable) throws IOException {
SerializationConfig serializationConfig = new SerializationConfig();
serializationConfig.addPortableFactory(TestPortableFactory.ID, new TestPortableFactory());
InternalSerializationService ss = new DefaultSerializationServiceBuilder().setConfig(serializationConfig).build();
ss.toData(NON_EMPTY_PORSCHE);
return new GenericRecordQueryReader(ss.readAsInternalGenericRecord(ss.toData(portable)));
}
use of com.hazelcast.internal.serialization.impl.GenericRecordQueryReader in project hazelcast by hazelcast.
the class PortableTest method testSerializationService_createPortableReader.
@Test
public void testSerializationService_createPortableReader() throws IOException {
InternalSerializationService serializationService = new DefaultSerializationServiceBuilder().build();
long timestamp1 = System.nanoTime();
ChildPortableObject child = new ChildPortableObject(timestamp1);
long timestamp2 = System.currentTimeMillis();
ParentPortableObject parent = new ParentPortableObject(timestamp2, child);
long timestamp3 = timestamp1 + timestamp2;
GrandParentPortableObject grandParent = new GrandParentPortableObject(timestamp3, parent);
Data data = serializationService.toData(grandParent);
GenericRecordQueryReader reader = new GenericRecordQueryReader(serializationService.readAsInternalGenericRecord(data));
assertEquals(grandParent.timestamp, reader.read("timestamp"));
assertEquals(parent.timestamp, reader.read("child.timestamp"));
assertEquals(child.timestamp, reader.read("child.child.timestamp"));
}
Aggregations