Search in sources :

Example 1 with QueryPath

use of com.hazelcast.sql.impl.extract.QueryPath in project hazelcast by hazelcast.

the class JoinByEquiJoinProcessorSupplier method get.

@Nonnull
@Override
public Collection<? extends Processor> get(int count) {
    List<Processor> processors = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        PartitionIdSet partitions = this.partitions == null ? null : new PartitionIdSet(partitionCount, this.partitions);
        QueryPath[] rightPaths = rightRowProjectorSupplier.paths();
        KvRowProjector rightProjector = rightRowProjectorSupplier.get(evalContext, extractors);
        Processor processor = new TransformP<JetSqlRow, JetSqlRow>(joinFn(joinInfo, map, partitions, rightPaths, rightProjector, evalContext)) {

            @Override
            public boolean isCooperative() {
                return false;
            }
        };
        processors.add(processor);
    }
    return processors;
}
Also used : QueryPath(com.hazelcast.sql.impl.extract.QueryPath) KvRowProjector(com.hazelcast.jet.sql.impl.connector.keyvalue.KvRowProjector) Processor(com.hazelcast.jet.core.Processor) TransformP(com.hazelcast.jet.impl.processor.TransformP) PartitionIdSet(com.hazelcast.internal.util.collection.PartitionIdSet) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

Example 2 with QueryPath

use of com.hazelcast.sql.impl.extract.QueryPath in project hazelcast by hazelcast.

the class MetadataCompactResolver method resolveMetadata.

@Override
public KvMetadata resolveMetadata(boolean isKey, List<MappingField> resolvedFields, Map<String, String> options, InternalSerializationService serializationService) {
    Map<QueryPath, MappingField> fieldsByPath = extractFields(resolvedFields, isKey);
    String typeNameProperty = isKey ? OPTION_KEY_COMPACT_TYPE_NAME : OPTION_VALUE_COMPACT_TYPE_NAME;
    String typeName = options.get(typeNameProperty);
    List<TableField> fields = new ArrayList<>(fieldsByPath.size());
    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);
    Schema schema = resolveSchema(typeName, fieldsByPath);
    return new KvMetadata(fields, GenericQueryTargetDescriptor.DEFAULT, new CompactUpsertTargetDescriptor(schema));
}
Also used : QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) Schema(com.hazelcast.internal.serialization.impl.compact.Schema) ArrayList(java.util.ArrayList) CompactUpsertTargetDescriptor(com.hazelcast.jet.sql.impl.inject.CompactUpsertTargetDescriptor) MappingField(com.hazelcast.sql.impl.schema.MappingField) TableField(com.hazelcast.sql.impl.schema.TableField) MapTableField(com.hazelcast.sql.impl.schema.map.MapTableField) KvMetadata(com.hazelcast.jet.sql.impl.connector.keyvalue.KvMetadata) MapTableField(com.hazelcast.sql.impl.schema.map.MapTableField) QueryPath(com.hazelcast.sql.impl.extract.QueryPath)

Example 3 with QueryPath

use of com.hazelcast.sql.impl.extract.QueryPath in project hazelcast by hazelcast.

the class MetadataCompactResolver method resolveSchema.

private Schema resolveSchema(String typeName, Map<QueryPath, MappingField> fields) {
    SchemaWriter schemaWriter = new SchemaWriter(typeName);
    for (Entry<QueryPath, MappingField> entry : fields.entrySet()) {
        String name = entry.getKey().getPath();
        QueryDataType type = entry.getValue().type();
        schemaWriter.addField(new FieldDescriptor(name, resolveToCompactKind(type.getTypeFamily())));
    }
    return schemaWriter.build();
}
Also used : QueryPath(com.hazelcast.sql.impl.extract.QueryPath) QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) MappingField(com.hazelcast.sql.impl.schema.MappingField) SchemaWriter(com.hazelcast.internal.serialization.impl.compact.SchemaWriter) FieldDescriptor(com.hazelcast.internal.serialization.impl.compact.FieldDescriptor)

Example 4 with QueryPath

use of com.hazelcast.sql.impl.extract.QueryPath in project hazelcast by hazelcast.

the class MetadataPortableResolver method resolveFields.

Stream<MappingField> resolveFields(boolean isKey, @Nullable ClassDefinition clazz) {
    if (clazz == null || clazz.getFieldCount() == 0) {
        // ClassDefinition does not exist, or it is empty, map the whole value
        String name = isKey ? KEY : VALUE;
        return Stream.of(new MappingField(name, QueryDataType.OBJECT, name));
    }
    return clazz.getFieldNames().stream().map(name -> {
        QueryPath path = new QueryPath(name, isKey);
        QueryDataType type = resolvePortableType(clazz.getFieldType(name));
        return new MappingField(name, type, path.toString());
    });
}
Also used : QueryPath(com.hazelcast.sql.impl.extract.QueryPath) QueryDataType(com.hazelcast.sql.impl.type.QueryDataType) MappingField(com.hazelcast.sql.impl.schema.MappingField)

Example 5 with QueryPath

use of com.hazelcast.sql.impl.extract.QueryPath in project hazelcast by hazelcast.

the class MetadataPortableResolver method resolveMetadata.

@Override
public KvMetadata resolveMetadata(boolean isKey, List<MappingField> resolvedFields, Map<String, String> options, InternalSerializationService serializationService) {
    Map<QueryPath, MappingField> fieldsByPath = extractFields(resolvedFields, isKey);
    ClassDefinition clazz = resolveClassDefinition(isKey, options, fieldsByPath.values(), serializationService);
    return resolveMetadata(isKey, resolvedFields, fieldsByPath, clazz);
}
Also used : QueryPath(com.hazelcast.sql.impl.extract.QueryPath) MappingField(com.hazelcast.sql.impl.schema.MappingField) ClassDefinition(com.hazelcast.nio.serialization.ClassDefinition)

Aggregations

QueryPath (com.hazelcast.sql.impl.extract.QueryPath)35 QueryDataType (com.hazelcast.sql.impl.type.QueryDataType)22 MappingField (com.hazelcast.sql.impl.schema.MappingField)19 MapTableField (com.hazelcast.sql.impl.schema.map.MapTableField)17 TableField (com.hazelcast.sql.impl.schema.TableField)13 ArrayList (java.util.ArrayList)10 HazelcastTable (com.hazelcast.jet.sql.impl.schema.HazelcastTable)6 KvMetadata (com.hazelcast.jet.sql.impl.connector.keyvalue.KvMetadata)4 OptimizerTestSupport (com.hazelcast.jet.sql.impl.opt.OptimizerTestSupport)3 Parameters (junitparams.Parameters)3 Test (org.junit.Test)3 FullScanPhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.FullScanPhysicalRel)2 IndexScanMapPhysicalRel (com.hazelcast.jet.sql.impl.opt.physical.IndexScanMapPhysicalRel)2 ClassDefinition (com.hazelcast.nio.serialization.ClassDefinition)2 ImmutableList (com.google.common.collect.ImmutableList)1 IndexConfig (com.hazelcast.config.IndexConfig)1 ArrayDataSerializableFactory (com.hazelcast.internal.serialization.impl.ArrayDataSerializableFactory)1 FieldDescriptor (com.hazelcast.internal.serialization.impl.compact.FieldDescriptor)1 Schema (com.hazelcast.internal.serialization.impl.compact.Schema)1 SchemaWriter (com.hazelcast.internal.serialization.impl.compact.SchemaWriter)1