/** Creates a {@link RelBuilderFactory} that uses a given set of factories. */ public static RelBuilderFactory proto(Object... factories) { return proto(Contexts.of(factories)); }
/** * Creates an AbstractRelOptPlanner. */ protected AbstractRelOptPlanner(RelOptCostFactory costFactory, Context context) { assert costFactory != null; this.costFactory = costFactory; if (context == null) { context = Contexts.empty(); } this.context = context; final CancelFlag cancelFlag = context.unwrap(CancelFlag.class); this.cancelFlag = cancelFlag != null ? cancelFlag.atomicBoolean : new AtomicBoolean(); // Add abstract RelNode classes. No RelNodes will ever be registered with // these types, but some operands may use them. classes.add(RelNode.class); classes.add(RelSubset.class); }
private static Context chain(Iterable<? extends Context> contexts) { // Flatten any chain contexts in the list, and remove duplicates final List<Context> list = new ArrayList<>(); for (Context context : contexts) { build(list, context); } switch (list.size()) { case 0: return empty(); case 1: return list.get(0); default: return new ChainContext(ImmutableList.copyOf(list)); } }
/** Returns a context that wraps a list of contexts. * * <p>A call to {@code unwrap(C)} will return the first object that is an * instance of {@code C}. * * <p>If any of the contexts is a {@link Context}, recursively looks in that * object. Thus this method can be used to chain contexts. */ public static Context chain(Context... contexts) { return chain(ImmutableList.copyOf(contexts)); }
/** Recursively populates a list of contexts. */ private static void build(List<Context> list, Context context) { if (context == EMPTY_CONTEXT || list.contains(context)) { return; } if (context instanceof ChainContext) { ChainContext chainContext = (ChainContext) context; for (Context child : chainContext.contexts) { build(list, child); } } else { list.add(context); } }
/** * Creates an AbstractRelOptPlanner. */ protected AbstractRelOptPlanner(RelOptCostFactory costFactory, Context context) { assert costFactory != null; this.costFactory = costFactory; if (context == null) { context = Contexts.empty(); } this.context = context; final CancelFlag cancelFlag = context.unwrap(CancelFlag.class); this.cancelFlag = cancelFlag != null ? cancelFlag.atomicBoolean : new AtomicBoolean(); // Add abstract RelNode classes. No RelNodes will ever be registered with // these types, but some operands may use them. classes.add(RelNode.class); classes.add(RelSubset.class); }
private static Context chain(Iterable<? extends Context> contexts) { // Flatten any chain contexts in the list, and remove duplicates final List<Context> list = new ArrayList<>(); for (Context context : contexts) { build(list, context); } switch (list.size()) { case 0: return empty(); case 1: return list.get(0); default: return new ChainContext(ImmutableList.copyOf(list)); } }
/** Returns a context that wraps a list of contexts. * * <p>A call to {@code unwrap(C)} will return the first object that is an * instance of {@code C}. * * <p>If any of the contexts is a {@link Context}, recursively looks in that * object. Thus this method can be used to chain contexts. */ public static Context chain(Context... contexts) { return chain(ImmutableList.copyOf(contexts)); }
/** Recursively populates a list of contexts. */ private static void build(List<Context> list, Context context) { if (context == EMPTY_CONTEXT || list.contains(context)) { return; } if (context instanceof ChainContext) { ChainContext chainContext = (ChainContext) context; for (Context child : chainContext.contexts) { build(list, child); } } else { list.add(context); } }
/** Creates a {@link RelBuilderFactory} that uses a given set of factories. */ public static RelBuilderFactory proto(Object... factories) { return proto(Contexts.of(factories)); }
/** * Creates a TesterImpl. * * @param diffRepos Diff repository * @param enableDecorrelate Whether to decorrelate * @param enableTrim Whether to trim unused fields * @param enableExpand Whether to expand sub-queries * @param catalogReaderFactory Function to create catalog reader, or null * @param clusterFactory Called after a cluster has been created */ protected TesterImpl(DiffRepository diffRepos, boolean enableDecorrelate, boolean enableTrim, boolean enableExpand, boolean enableLateDecorrelate, SqlTestFactory.MockCatalogReaderFactory catalogReaderFactory, Function<RelOptCluster, RelOptCluster> clusterFactory) { this(diffRepos, enableDecorrelate, enableTrim, enableExpand, enableLateDecorrelate, catalogReaderFactory, clusterFactory, SqlToRelConverter.Config.DEFAULT, SqlConformanceEnum.DEFAULT, Contexts.empty()); }
/** Returns a context that contains a * {@link org.apache.calcite.config.CalciteConnectionConfig}. * * @deprecated Use {@link #of} */ @Deprecated // to be removed before 2.0 public static Context withConfig(CalciteConnectionConfig config) { return of(config); }
/** * Creates a TesterImpl. * * @param diffRepos Diff repository * @param enableDecorrelate Whether to decorrelate * @param enableTrim Whether to trim unused fields * @param enableExpand Whether to expand sub-queries * @param catalogReaderFactory Function to create catalog reader, or null * @param clusterFactory Called after a cluster has been created */ protected TesterImpl(DiffRepository diffRepos, boolean enableDecorrelate, boolean enableTrim, boolean enableExpand, boolean enableLateDecorrelate, SqlTestFactory.MockCatalogReaderFactory catalogReaderFactory, Function<RelOptCluster, RelOptCluster> clusterFactory) { this(diffRepos, enableDecorrelate, enableTrim, enableExpand, enableLateDecorrelate, catalogReaderFactory, clusterFactory, SqlToRelConverter.Config.DEFAULT, SqlConformanceEnum.DEFAULT, Contexts.empty()); }
/** Returns a context that contains a * {@link org.apache.calcite.config.CalciteConnectionConfig}. * * @deprecated Use {@link #of} */ @Deprecated // to be removed before 2.0 public static Context withConfig(CalciteConnectionConfig config) { return of(config); }
protected Tester createTester() { return new TesterImpl(getDiffRepos(), false, false, true, false, null, null, SqlToRelConverter.Config.DEFAULT, SqlConformanceEnum.DEFAULT, Contexts.empty()); }
@Deprecated // to be removed before 2.0 public JoinProjectTransposeRule(RelOptRuleOperand operand, String description, ProjectFactory projectFactory) { this(operand, description, false, RelBuilder.proto(Contexts.of(projectFactory))); }
protected Tester createTester() { return new TesterImpl(getDiffRepos(), false, false, true, false, null, null, SqlToRelConverter.Config.DEFAULT, SqlConformanceEnum.DEFAULT, Contexts.empty()); }
@Deprecated // to be removed before 2.0 public JoinPushTransitivePredicatesRule(Class<? extends Join> clazz, RelFactories.FilterFactory filterFactory) { this(clazz, RelBuilder.proto(Contexts.of(filterFactory))); }