use of com.hazelcast.internal.serialization.impl.portable.PortableGenericRecord 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.portable.PortableGenericRecord in project hazelcast by hazelcast.
the class Extractors method instantiateGetter.
private Getter instantiateGetter(Object targetObject, String attributeName, boolean failOnMissingReflectiveAttribute) {
String attributeNameWithoutArguments = extractAttributeNameNameWithoutArguments(attributeName);
ValueExtractor valueExtractor = extractors.get(attributeNameWithoutArguments);
if (valueExtractor != null) {
Object arguments = argumentsParser.parse(extractArgumentsFromAttributeName(attributeName));
return new ExtractorGetter(ss, valueExtractor, arguments);
} else if (targetObject instanceof Data) {
return instantiateGetterForData((Data) targetObject);
} else if (targetObject instanceof HazelcastJsonValue) {
return JsonGetter.INSTANCE;
} else if (targetObject instanceof PortableGenericRecord) {
if (portableGetter == null) {
// will be initialised a couple of times in the worst case
portableGetter = new PortableGetter(ss);
}
return portableGetter;
} else if (targetObject instanceof CompactGenericRecord) {
if (compactGetter == null) {
// will be initialised a couple of times in the worst case
compactGetter = new CompactGetter(ss);
}
return compactGetter;
} else {
return ReflectionHelper.createGetter(targetObject, attributeName, failOnMissingReflectiveAttribute);
}
}
use of com.hazelcast.internal.serialization.impl.portable.PortableGenericRecord in project hazelcast by hazelcast.
the class SampleMetadataResolver method resolve.
@Nullable
@SuppressWarnings("checkstyle:returncount")
static Metadata resolve(InternalSerializationService ss, Object target, boolean key) {
try {
if (target instanceof Data) {
Data data = (Data) target;
if (data.isPortable()) {
ClassDefinition classDefinition = ss.getPortableContext().lookupClassDefinition(data);
return resolvePortable(classDefinition, key);
} else if (data.isCompact()) {
return resolveCompact(ss.extractSchemaFromData(data), key);
} else if (data.isJson()) {
return null;
} else {
return resolveJava(ss.toObject(data).getClass(), key);
}
} else if (target instanceof VersionedPortable) {
VersionedPortable portable = (VersionedPortable) target;
ClassDefinition classDefinition = ss.getPortableContext().lookupClassDefinition(portable.getFactoryId(), portable.getClassId(), portable.getClassVersion());
return resolvePortable(classDefinition, key);
} else if (target instanceof Portable) {
Portable portable = (Portable) target;
ClassDefinition classDefinition = ss.getPortableContext().lookupClassDefinition(portable.getFactoryId(), portable.getClassId(), 0);
return resolvePortable(classDefinition, key);
} else if (target instanceof PortableGenericRecord) {
return resolvePortable(((PortableGenericRecord) target).getClassDefinition(), key);
} else if (target instanceof CompactGenericRecord) {
return resolveCompact(((CompactGenericRecord) target).getSchema(), key);
} else if (ss.isCompactSerializable(target)) {
Schema schema = ss.extractSchemaFromObject(target);
return resolveCompact(schema, key);
} else if (target instanceof HazelcastJsonValue) {
return null;
} else {
return resolveJava(target.getClass(), key);
}
} catch (Exception e) {
return null;
}
}
Aggregations