use of com.hazelcast.sql.impl.schema.map.PartitionedMapTable in project hazelcast by hazelcast.
the class IMapSqlConnector method indexScanReader.
@Nonnull
@SuppressWarnings("checkstyle:ParameterNumber")
public Vertex indexScanReader(@Nonnull DAG dag, @Nonnull Address localMemberAddress, @Nonnull Table table0, @Nonnull MapTableIndex tableIndex, @Nullable Expression<Boolean> remainingFilter, @Nonnull List<Expression<?>> projection, @Nullable IndexFilter indexFilter, @Nullable ComparatorEx<JetSqlRow> comparator, boolean descending) {
PartitionedMapTable table = (PartitionedMapTable) table0;
MapIndexScanMetadata indexScanMetadata = new MapIndexScanMetadata(table.getMapName(), tableIndex.getName(), table.getKeyDescriptor(), table.getValueDescriptor(), Arrays.asList(table.paths()), Arrays.asList(table.types()), indexFilter, projection, remainingFilter, comparator, descending);
Vertex scanner = dag.newUniqueVertex("Index(" + toString(table) + ")", readMapIndexSupplier(indexScanMetadata));
// LP must be 1 - one local index contains all local partitions, if there are 2 local processors,
// the index will be scanned twice and each time half of the partitions will be thrown out.
scanner.localParallelism(1);
if (tableIndex.getType() == IndexType.SORTED) {
Vertex sorter = dag.newUniqueVertex("SortCombine", ProcessorMetaSupplier.forceTotalParallelismOne(ProcessorSupplier.of(mapP(FunctionEx.identity())), localMemberAddress));
assert comparator != null;
dag.edge(between(scanner, sorter).ordered(comparator).distributeTo(localMemberAddress).allToOne(""));
return sorter;
}
return scanner;
}
use of com.hazelcast.sql.impl.schema.map.PartitionedMapTable 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);
}
use of com.hazelcast.sql.impl.schema.map.PartitionedMapTable in project hazelcast by hazelcast.
the class IMapSqlConnector method nestedLoopReader.
@Nonnull
@Override
public VertexWithInputConfig nestedLoopReader(@Nonnull DAG dag, @Nonnull Table table0, @Nullable Expression<Boolean> predicate, @Nonnull List<Expression<?>> projections, @Nonnull JetJoinInfo joinInfo) {
PartitionedMapTable table = (PartitionedMapTable) table0;
KvRowProjector.Supplier rightRowProjectorSupplier = KvRowProjector.supplier(table.paths(), table.types(), table.getKeyDescriptor(), table.getValueDescriptor(), predicate, projections);
return Joiner.join(dag, table.getMapName(), toString(table), joinInfo, rightRowProjectorSupplier);
}
use of com.hazelcast.sql.impl.schema.map.PartitionedMapTable in project hazelcast by hazelcast.
the class SinkMapPhysicalRel method entriesFn.
public Function<ExpressionEvalContext, Map<Object, Object>> entriesFn() {
PartitionedMapTable table = table();
List<ExpressionValues> values = this.values;
return evalContext -> {
KvProjector projector = KvProjector.supplier(table.paths(), table.types(), (UpsertTargetDescriptor) table.getKeyJetMetadata(), (UpsertTargetDescriptor) table.getValueJetMetadata(), true).get(evalContext.getSerializationService());
return values.stream().flatMap(vs -> vs.toValues(evalContext)).map(projector::project).collect(toMap(Entry::getKey, Entry::getValue));
};
}
use of com.hazelcast.sql.impl.schema.map.PartitionedMapTable in project hazelcast by hazelcast.
the class IndexScanMapPhysicalRule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
FullScanLogicalRel logicalScan = call.rel(0);
PartitionedMapTable table = table(logicalScan);
for (RelNode indexScan : IndexResolver.createIndexScans(logicalScan, table.getIndexes())) {
call.transformTo(indexScan);
}
}
Aggregations