use of org.apache.calcite.plan.HazelcastRelOptCluster in project hazelcast by hazelcast.
the class OptimizerContext method createCluster.
private static HazelcastRelOptCluster createCluster(VolcanoPlanner planner, DistributionTraitDef distributionTraitDef) {
HazelcastRelOptCluster cluster = HazelcastRelOptCluster.create(planner, HazelcastRexBuilder.INSTANCE, distributionTraitDef);
// Wire up custom metadata providers.
cluster.setMetadataProvider(JaninoRelMetadataProvider.of(METADATA_PROVIDER));
return cluster;
}
use of org.apache.calcite.plan.HazelcastRelOptCluster in project hazelcast by hazelcast.
the class SlidingWindow method windowPolicyProvider.
public final FunctionEx<ExpressionEvalContext, SlidingWindowPolicy> windowPolicyProvider() {
QueryParameterMetadata parameterMetadata = ((HazelcastRelOptCluster) getCluster()).getParameterMetadata();
RexToExpressionVisitor visitor = new RexToExpressionVisitor(FAILING_FIELD_TYPE_PROVIDER, parameterMetadata);
if (operator() == HazelcastSqlOperatorTable.TUMBLE) {
Expression<?> windowSizeExpression = operand(2).accept(visitor);
return context -> tumblingWinPolicy(WindowUtils.extractMillis(windowSizeExpression, context));
} else if (operator() == HazelcastSqlOperatorTable.HOP) {
Expression<?> windowSizeExpression = operand(2).accept(visitor);
Expression<?> slideSizeExpression = operand(3).accept(visitor);
return context -> slidingWinPolicy(WindowUtils.extractMillis(windowSizeExpression, context), WindowUtils.extractMillis(slideSizeExpression, context));
} else {
throw new IllegalArgumentException();
}
}
use of org.apache.calcite.plan.HazelcastRelOptCluster in project hazelcast by hazelcast.
the class SlidingWindowAggregatePhysicalRel method timestampExpression.
public Expression<?> timestampExpression() {
QueryParameterMetadata parameterMetadata = ((HazelcastRelOptCluster) getCluster()).getParameterMetadata();
RexVisitor<Expression<?>> visitor = OptUtils.createRexToExpressionVisitor(schema(parameterMetadata), parameterMetadata);
return timestampExpression.accept(visitor);
}
use of org.apache.calcite.plan.HazelcastRelOptCluster in project hazelcast by hazelcast.
the class OptimizerContext method create.
public static OptimizerContext create(HazelcastSchema rootSchema, List<List<String>> schemaPaths, List<Object> arguments, int memberCount, IMapResolver iMapResolver) {
DistributionTraitDef distributionTraitDef = new DistributionTraitDef(memberCount);
Prepare.CatalogReader catalogReader = createCatalogReader(rootSchema, schemaPaths);
HazelcastSqlValidator validator = new HazelcastSqlValidator(catalogReader, arguments, iMapResolver);
VolcanoPlanner volcanoPlanner = createPlanner(distributionTraitDef);
HazelcastRelOptCluster cluster = createCluster(volcanoPlanner, distributionTraitDef);
QueryParser parser = new QueryParser(validator);
QueryConverter converter = new QueryConverter(validator, catalogReader, cluster);
QueryPlanner planner = new QueryPlanner(volcanoPlanner);
return new OptimizerContext(cluster, parser, converter, planner);
}
Aggregations