use of com.hazelcast.sql.impl.extract.QueryPath in project hazelcast by hazelcast.
the class MetadataPortableResolver method resolveAndValidateFields.
@Override
public Stream<MappingField> resolveAndValidateFields(boolean isKey, List<MappingField> userFields, Map<String, String> options, InternalSerializationService serializationService) {
Map<QueryPath, MappingField> userFieldsByPath = extractFields(userFields, isKey);
ClassDefinition classDefinition = findClassDefinition(isKey, options, serializationService);
return userFields.isEmpty() ? resolveFields(isKey, classDefinition) : resolveAndValidateFields(isKey, userFieldsByPath, classDefinition);
}
use of com.hazelcast.sql.impl.extract.QueryPath in project hazelcast by hazelcast.
the class MetadataPortableResolver method resolveMetadata.
private static KvMetadata resolveMetadata(boolean isKey, List<MappingField> resolvedFields, Map<QueryPath, MappingField> fieldsByPath, @Nonnull ClassDefinition clazz) {
List<TableField> fields = new ArrayList<>();
for (Entry<QueryPath, MappingField> entry : fieldsByPath.entrySet()) {
QueryPath path = entry.getKey();
QueryDataType type = entry.getValue().type();
String name = entry.getValue().name();
fields.add(new MapTableField(name, type, false, path));
}
maybeAddDefaultField(isKey, resolvedFields, fields, QueryDataType.OBJECT);
return new KvMetadata(fields, GenericQueryTargetDescriptor.DEFAULT, new PortableUpsertTargetDescriptor(clazz));
}
use of com.hazelcast.sql.impl.extract.QueryPath in project hazelcast by hazelcast.
the class KvRowProjector method createExtractors.
private static QueryExtractor[] createExtractors(QueryPath[] paths, QueryDataType[] types, QueryTarget keyTarget, QueryTarget valueTarget) {
QueryExtractor[] extractors = new QueryExtractor[paths.length];
for (int i = 0; i < paths.length; i++) {
QueryPath path = paths[i];
QueryDataType type = types[i];
extractors[i] = path.isKey() ? keyTarget.createExtractor(path.getPath(), type) : valueTarget.createExtractor(path.getPath(), type);
}
return extractors;
}
use of com.hazelcast.sql.impl.extract.QueryPath in project hazelcast by hazelcast.
the class MetadataJsonResolver method resolveMetadata.
@Override
public KvMetadata resolveMetadata(boolean isKey, List<MappingField> resolvedFields, Map<String, String> options, InternalSerializationService serializationService) {
Map<QueryPath, MappingField> externalFieldsByPath = extractFields(resolvedFields, isKey);
List<TableField> fields = new ArrayList<>();
for (Entry<QueryPath, MappingField> entry : externalFieldsByPath.entrySet()) {
QueryPath path = entry.getKey();
QueryDataType type = entry.getValue().type();
String name = entry.getValue().name();
fields.add(new MapTableField(name, type, false, path));
}
maybeAddDefaultField(isKey, resolvedFields, fields, QueryDataType.OBJECT);
return new KvMetadata(fields, HazelcastJsonQueryTargetDescriptor.INSTANCE, HazelcastJsonUpsertTargetDescriptor.INSTANCE);
}
use of com.hazelcast.sql.impl.extract.QueryPath in project hazelcast by hazelcast.
the class QueryUtil method toPredicate.
@SuppressWarnings({ "unchecked", "rawtypes" })
static Predicate<Object, Object> toPredicate(JetSqlRow left, int[] leftEquiJoinIndices, int[] rightEquiJoinIndices, QueryPath[] rightPaths) {
PredicateBuilder builder = Predicates.newPredicateBuilder();
EntryObject entryObject = builder.getEntryObject();
for (int i = 0; i < leftEquiJoinIndices.length; i++) {
Comparable leftValue = asComparable(left.get(leftEquiJoinIndices[i]));
// might need a change when/if IS NOT DISTINCT FROM is supported
if (leftValue == null) {
return null;
}
QueryPath rightPath = rightPaths[rightEquiJoinIndices[i]];
EntryObject object;
if (rightPath.isKey()) {
object = rightPath.isTop() ? entryObject.key() : entryObject.key().get(rightPath.getPath());
} else {
object = rightPath.isTop() ? entryObject.get(rightPath.toString()) : entryObject.get(QueryPath.VALUE).get(rightPath.getPath());
}
if (i == 0) {
object.equal(leftValue);
} else {
builder.and(object.equal(leftValue));
}
}
return builder;
}
Aggregations