Search in sources :

Example 1 with ConstantTableStatistics

use of com.hazelcast.sql.impl.schema.ConstantTableStatistics in project hazelcast by hazelcast.

the class IMapSqlConnector method createTable.

@Nonnull
@Override
public Table createTable(@Nonnull NodeEngine nodeEngine, @Nonnull String schemaName, @Nonnull String mappingName, @Nonnull String externalName, @Nonnull Map<String, String> options, @Nonnull List<MappingField> resolvedFields) {
    InternalSerializationService ss = (InternalSerializationService) nodeEngine.getSerializationService();
    KvMetadata keyMetadata = METADATA_RESOLVERS.resolveMetadata(true, resolvedFields, options, ss);
    KvMetadata valueMetadata = METADATA_RESOLVERS.resolveMetadata(false, resolvedFields, options, ss);
    List<TableField> fields = concat(keyMetadata.getFields().stream(), valueMetadata.getFields().stream()).collect(toList());
    MapService service = nodeEngine.getService(MapService.SERVICE_NAME);
    MapServiceContext context = service.getMapServiceContext();
    MapContainer container = context.getExistingMapContainer(externalName);
    long estimatedRowCount = estimatePartitionedMapRowCount(nodeEngine, context, externalName);
    boolean hd = container != null && container.getMapConfig().getInMemoryFormat() == InMemoryFormat.NATIVE;
    List<MapTableIndex> indexes = container != null ? MapTableUtils.getPartitionedMapIndexes(container, fields) : emptyList();
    return new PartitionedMapTable(schemaName, mappingName, externalName, fields, new ConstantTableStatistics(estimatedRowCount), keyMetadata.getQueryTargetDescriptor(), valueMetadata.getQueryTargetDescriptor(), keyMetadata.getUpsertTargetDescriptor(), valueMetadata.getUpsertTargetDescriptor(), indexes, hd);
}
Also used : TableField(com.hazelcast.sql.impl.schema.TableField) KvMetadata(com.hazelcast.jet.sql.impl.connector.keyvalue.KvMetadata) ConstantTableStatistics(com.hazelcast.sql.impl.schema.ConstantTableStatistics) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) MapContainer(com.hazelcast.map.impl.MapContainer) MapTableIndex(com.hazelcast.sql.impl.schema.map.MapTableIndex) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) MapService(com.hazelcast.map.impl.MapService) Nonnull(javax.annotation.Nonnull)

Example 2 with ConstantTableStatistics

use of com.hazelcast.sql.impl.schema.ConstantTableStatistics in project hazelcast by hazelcast.

the class KafkaSqlConnector method createTable.

@Nonnull
@Override
public Table createTable(@Nonnull NodeEngine nodeEngine, @Nonnull String schemaName, @Nonnull String mappingName, @Nonnull String externalName, @Nonnull Map<String, String> options, @Nonnull List<MappingField> resolvedFields) {
    KvMetadata keyMetadata = METADATA_RESOLVERS.resolveMetadata(true, resolvedFields, options, null);
    KvMetadata valueMetadata = METADATA_RESOLVERS.resolveMetadata(false, resolvedFields, options, null);
    List<TableField> fields = concat(keyMetadata.getFields().stream(), valueMetadata.getFields().stream()).collect(toList());
    return new KafkaTable(this, schemaName, mappingName, fields, new ConstantTableStatistics(0), externalName, options, keyMetadata.getQueryTargetDescriptor(), keyMetadata.getUpsertTargetDescriptor(), valueMetadata.getQueryTargetDescriptor(), valueMetadata.getUpsertTargetDescriptor());
}
Also used : TableField(com.hazelcast.sql.impl.schema.TableField) KvMetadata(com.hazelcast.jet.sql.impl.connector.keyvalue.KvMetadata) ConstantTableStatistics(com.hazelcast.sql.impl.schema.ConstantTableStatistics) Nonnull(javax.annotation.Nonnull)

Example 3 with ConstantTableStatistics

use of com.hazelcast.sql.impl.schema.ConstantTableStatistics in project hazelcast by hazelcast.

the class ParserOperationsTest method createContext.

private static OptimizerContext createContext() {
    PartitionedMapTable partitionedMapTable = new PartitionedMapTable("public", "t", "t", Arrays.asList(field("a"), field("b")), new ConstantTableStatistics(100L), null, null, null, null, null, false);
    TableResolver resolver = TestTableResolver.create("public", partitionedMapTable);
    List<TableResolver> tableResolvers = Collections.singletonList(resolver);
    List<List<String>> searchPaths = QueryUtils.prepareSearchPaths(emptyList(), tableResolvers);
    return OptimizerContext.create(new SqlCatalog(tableResolvers), searchPaths, emptyList(), 1, name -> null);
}
Also used : SqlCatalog(com.hazelcast.sql.impl.schema.SqlCatalog) TableResolver(com.hazelcast.sql.impl.schema.TableResolver) TestTableResolver(com.hazelcast.jet.sql.impl.TestTableResolver) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) ConstantTableStatistics(com.hazelcast.sql.impl.schema.ConstantTableStatistics)

Example 4 with ConstantTableStatistics

use of com.hazelcast.sql.impl.schema.ConstantTableStatistics in project hazelcast by hazelcast.

the class ParserNameResolutionTest method createContext.

private static OptimizerContext createContext() {
    PartitionedMapTable table1 = new PartitionedMapTable(SCHEMA_1, TABLE_1, TABLE_1, Arrays.asList(field(FIELD_1), field(FIELD_2)), new ConstantTableStatistics(100L), null, null, null, null, null, false);
    PartitionedMapTable table2 = new PartitionedMapTable(SCHEMA_2, TABLE_2, TABLE_2, Arrays.asList(field(FIELD_1), field(FIELD_2)), new ConstantTableStatistics(100L), null, null, null, null, null, false);
    TableResolver resolver1 = TestTableResolver.create(SCHEMA_1, table1);
    TableResolver resolver2 = TestTableResolver.create(SCHEMA_2, table2);
    List<TableResolver> tableResolvers = Arrays.asList(resolver1, resolver2);
    List<List<String>> searchPaths = QueryUtils.prepareSearchPaths(emptyList(), tableResolvers);
    return OptimizerContext.create(new SqlCatalog(tableResolvers), searchPaths, emptyList(), 1, name -> null);
}
Also used : SqlCatalog(com.hazelcast.sql.impl.schema.SqlCatalog) TableResolver(com.hazelcast.sql.impl.schema.TableResolver) TestTableResolver(com.hazelcast.jet.sql.impl.TestTableResolver) PartitionedMapTable(com.hazelcast.sql.impl.schema.map.PartitionedMapTable) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) SqlNodeList(org.apache.calcite.sql.SqlNodeList) ConstantTableStatistics(com.hazelcast.sql.impl.schema.ConstantTableStatistics)

Aggregations

ConstantTableStatistics (com.hazelcast.sql.impl.schema.ConstantTableStatistics)4 PartitionedMapTable (com.hazelcast.sql.impl.schema.map.PartitionedMapTable)3 TestTableResolver (com.hazelcast.jet.sql.impl.TestTableResolver)2 KvMetadata (com.hazelcast.jet.sql.impl.connector.keyvalue.KvMetadata)2 SqlCatalog (com.hazelcast.sql.impl.schema.SqlCatalog)2 TableField (com.hazelcast.sql.impl.schema.TableField)2 TableResolver (com.hazelcast.sql.impl.schema.TableResolver)2 Collections.emptyList (java.util.Collections.emptyList)2 List (java.util.List)2 Nonnull (javax.annotation.Nonnull)2 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 MapTableIndex (com.hazelcast.sql.impl.schema.map.MapTableIndex)1 SqlNodeList (org.apache.calcite.sql.SqlNodeList)1