use of com.hazelcast.sql.impl.schema.Table in project hazelcast by hazelcast.
the class TableResolverImpl method getTables.
@Nonnull
@Override
public List<Table> getTables() {
Collection<Object> objects = tableStorage.allObjects();
List<Table> tables = new ArrayList<>(objects.size() + 3);
for (Object o : objects) {
if (o instanceof Mapping) {
tables.add(toTable((Mapping) o));
} else if (o instanceof View) {
tables.add(toTable((View) o));
} else {
throw new RuntimeException("Unexpected: " + o);
}
}
Collection<Mapping> mappings = objects.stream().filter(o -> o instanceof Mapping).map(m -> (Mapping) m).collect(Collectors.toList());
Collection<View> views = objects.stream().filter(o -> o instanceof View).map(v -> (View) v).collect(Collectors.toList());
tables.add(new TablesTable(CATALOG, SCHEMA_NAME_INFORMATION_SCHEMA, SCHEMA_NAME_PUBLIC, mappings, views));
tables.add(new MappingsTable(CATALOG, SCHEMA_NAME_INFORMATION_SCHEMA, SCHEMA_NAME_PUBLIC, mappings));
tables.add(new MappingColumnsTable(CATALOG, SCHEMA_NAME_INFORMATION_SCHEMA, SCHEMA_NAME_PUBLIC, mappings, views));
tables.add(new ViewsTable(CATALOG, SCHEMA_NAME_INFORMATION_SCHEMA, SCHEMA_NAME_PUBLIC, views));
return tables;
}
use of com.hazelcast.sql.impl.schema.Table in project hazelcast by hazelcast.
the class TestAbstractSqlConnector method fullScanReader.
@Nonnull
@Override
public Vertex fullScanReader(@Nonnull DAG dag, @Nonnull Table table_, @Nullable Expression<Boolean> predicate, @Nonnull List<Expression<?>> projection, @Nullable FunctionEx<ExpressionEvalContext, EventTimePolicy<JetSqlRow>> eventTimePolicyProvider) {
TestTable table = (TestTable) table_;
List<Object[]> rows = table.rows;
boolean streaming = table.streaming;
FunctionEx<Context, TestDataGenerator> createContextFn = ctx -> {
ExpressionEvalContext evalContext = ExpressionEvalContext.from(ctx);
EventTimePolicy<JetSqlRow> eventTimePolicy = eventTimePolicyProvider == null ? EventTimePolicy.noEventTime() : eventTimePolicyProvider.apply(evalContext);
return new TestDataGenerator(rows, predicate, projection, evalContext, eventTimePolicy, streaming);
};
ProcessorMetaSupplier pms = createProcessorSupplier(createContextFn);
return dag.newUniqueVertex(table.toString(), pms);
}
use of com.hazelcast.sql.impl.schema.Table in project hazelcast by hazelcast.
the class TestAllTypesSqlConnector method fullScanReader.
@Nonnull
@Override
public Vertex fullScanReader(@Nonnull DAG dag, @Nonnull Table table, @Nullable Expression<Boolean> predicate, @Nonnull List<Expression<?>> projection, @Nullable FunctionEx<ExpressionEvalContext, EventTimePolicy<JetSqlRow>> eventTimePolicyProvider) {
if (eventTimePolicyProvider != null) {
throw QueryException.error("Ordering function are not supported for " + TYPE_NAME + " mappings");
}
BatchSource<JetSqlRow> source = SourceBuilder.batch("batch", ExpressionEvalContext::from).<JetSqlRow>fillBufferFn((ctx, buf) -> {
JetSqlRow row = ExpressionUtil.evaluate(predicate, projection, VALUES, ctx);
if (row != null) {
buf.add(row);
}
buf.close();
}).build();
ProcessorMetaSupplier pms = ((BatchSourceTransform<JetSqlRow>) source).metaSupplier;
return dag.newUniqueVertex(table.toString(), pms);
}
use of com.hazelcast.sql.impl.schema.Table in project hazelcast by hazelcast.
the class PlanCacheChecker method check.
public void check() {
if (planCache.size() == 0) {
return;
}
// Collect object IDs
SqlCatalog catalog = new SqlCatalog(tableResolvers);
Set<PlanObjectKey> objectKeys = new HashSet<>();
for (Map<String, Table> tableMap : catalog.getSchemas().values()) {
for (Table table : tableMap.values()) {
PlanObjectKey objectKey = table.getObjectKey();
if (objectKey != null) {
objectKeys.add(objectKey);
}
}
}
// Prepare partition distribution
Map<UUID, PartitionIdSet> partitions = QueryUtils.createPartitionMap(nodeEngine, null, false);
// Do check
planCache.check(new PlanCheckContext(objectKeys, partitions));
}
use of com.hazelcast.sql.impl.schema.Table in project hazelcast by hazelcast.
the class CreateDagVisitor method onMapIndexScan.
public Vertex onMapIndexScan(IndexScanMapPhysicalRel rel) {
Table table = rel.getTable().unwrap(HazelcastTable.class).getTarget();
collectObjectKeys(table);
return SqlConnectorUtil.<IMapSqlConnector>getJetSqlConnector(table).indexScanReader(dag, localMemberAddress, table, rel.getIndex(), rel.filter(parameterMetadata), rel.projection(parameterMetadata), rel.getIndexFilter(), rel.getComparator(), rel.isDescending());
}
Aggregations