org.apache.calcite.tools.Frameworks.withPrepare()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.apache.calcite.tools.Frameworks.withPrepare()方法的一些代码示例,展示了Frameworks.withPrepare()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Frameworks.withPrepare()方法的具体详情如下:
包路径:org.apache.calcite.tools.Frameworks
类名称:Frameworks
方法名:withPrepare

Frameworks.withPrepare介绍

[英]Initializes a container then calls user-specified code with a planner and statement.
[中]

代码示例

代码示例来源:origin: apache/hive

/** Creates a RelBuilder. */
public static HiveSubQRemoveRelBuilder create(FrameworkConfig config) {
 final RelOptCluster[] clusters = {null};
 final RelOptSchema[] relOptSchemas = {null};
 Frameworks.withPrepare(
   new Frameworks.PrepareAction<Void>(config) {
    public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
             SchemaPlus rootSchema, CalciteServerStatement statement) {
     clusters[0] = cluster;
     relOptSchemas[0] = relOptSchema;
     return null;
    }
   });
 return new HiveSubQRemoveRelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}

代码示例来源:origin: apache/hive

/** Creates a RelBuilder. */
public static RelBuilder create(FrameworkConfig config) {
 final RelOptCluster[] clusters = {null};
 final RelOptSchema[] relOptSchemas = {null};
 Frameworks.withPrepare(
   new Frameworks.PrepareAction<Void>(config) {
    public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
      SchemaPlus rootSchema, CalciteServerStatement statement) {
     clusters[0] = cluster;
     relOptSchemas[0] = relOptSchema;
     return null;
    }
   });
 return new HiveRelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}

代码示例来源:origin: apache/drill

/** Creates a RelBuilder. */
public static HiveSubQRemoveRelBuilder create(FrameworkConfig config) {
 final RelOptCluster[] clusters = {null};
 final RelOptSchema[] relOptSchemas = {null};
 Frameworks.withPrepare(
     new Frameworks.PrepareAction<Void>(config) {
      public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
               SchemaPlus rootSchema, CalciteServerStatement statement) {
       clusters[0] = cluster;
       relOptSchemas[0] = relOptSchema;
       return null;
      }
     });
 return new HiveSubQRemoveRelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}

代码示例来源:origin: apache/drill

/** Creates a RelBuilder. */
public static RelBuilder create(FrameworkConfig config) {
 final RelOptCluster[] clusters = {null};
 final RelOptSchema[] relOptSchemas = {null};
 Frameworks.withPrepare(
   new Frameworks.PrepareAction<Void>(config) {
    public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
      SchemaPlus rootSchema, CalciteServerStatement statement) {
     clusters[0] = cluster;
     relOptSchemas[0] = relOptSchema;
     return null;
    }
   });
 return new HiveRelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}

代码示例来源:origin: Qihoo360/Quicksql

/**
 * Initializes a container then calls user-specified code with a planner.
 *
 * @param action Callback containing user-specified code
 * @param config FrameworkConfig to use for planner action.
 * @return Return value from action
 */
public static <R> R withPlanner(final PlannerAction<R> action, //
  final FrameworkConfig config) {
 return withPrepare(
   new Frameworks.PrepareAction<R>(config) {
    public R apply(RelOptCluster cluster, RelOptSchema relOptSchema,
      SchemaPlus rootSchema, CalciteServerStatement statement) {
     final CalciteSchema schema =
       CalciteSchema.from(
         Util.first(config.getDefaultSchema(), rootSchema));
     return action.apply(cluster, relOptSchema, schema.root().plus());
    }
   });
}

代码示例来源:origin: org.apache.calcite/calcite-core

/**
 * Initializes a container then calls user-specified code with a planner.
 *
 * @param action Callback containing user-specified code
 * @param config FrameworkConfig to use for planner action.
 * @return Return value from action
 */
public static <R> R withPlanner(final PlannerAction<R> action, //
  final FrameworkConfig config) {
 return withPrepare(
   new Frameworks.PrepareAction<R>(config) {
    public R apply(RelOptCluster cluster, RelOptSchema relOptSchema,
      SchemaPlus rootSchema, CalciteServerStatement statement) {
     final CalciteSchema schema =
       CalciteSchema.from(
         Util.first(config.getDefaultSchema(), rootSchema));
     return action.apply(cluster, relOptSchema, schema.root().plus());
    }
   });
}

代码示例来源:origin: org.apache.calcite/calcite-core

protected void check(final Action action) throws Exception {
 Frameworks.withPrepare(
   new Frameworks.PrepareAction<Void>() {
    public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
      SchemaPlus rootSchema, CalciteServerStatement statement) {
     final RexBuilder rexBuilder = cluster.getRexBuilder();
     DataContext dataContext =
       Schemas.createDataContext(statement.getConnection(), rootSchema);
     final RexExecutorImpl executor = new RexExecutorImpl(dataContext);
     action.check(rexBuilder, executor);
     return null;
    }
   });
}

代码示例来源:origin: Qihoo360/Quicksql

protected void check(final Action action) throws Exception {
 Frameworks.withPrepare(
   new Frameworks.PrepareAction<Void>() {
    public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
      SchemaPlus rootSchema, CalciteServerStatement statement) {
     final RexBuilder rexBuilder = cluster.getRexBuilder();
     DataContext dataContext =
       Schemas.createDataContext(statement.getConnection(), rootSchema);
     final RexExecutorImpl executor = new RexExecutorImpl(dataContext);
     action.check(rexBuilder, executor);
     return null;
    }
   });
}

代码示例来源:origin: Qihoo360/Quicksql

private void checkTypeSystem(final int expected, FrameworkConfig config) {
 Frameworks.withPrepare(
   new Frameworks.PrepareAction<Void>(config) {
    @Override public Void apply(RelOptCluster cluster,
      RelOptSchema relOptSchema, SchemaPlus rootSchema,
      CalciteServerStatement statement) {
     final RelDataType type =
       cluster.getTypeFactory()
         .createSqlType(SqlTypeName.DECIMAL, 30, 2);
     final RexLiteral literal =
       cluster.getRexBuilder().makeExactLiteral(BigDecimal.ONE, type);
     final RexNode call =
       cluster.getRexBuilder().makeCall(SqlStdOperatorTable.PLUS,
         literal,
         literal);
     assertEquals(expected, call.getType().getPrecision());
     return null;
    }
   });
}

代码示例来源:origin: org.apache.calcite/calcite-core

private void checkTypeSystem(final int expected, FrameworkConfig config) {
 Frameworks.withPrepare(
   new Frameworks.PrepareAction<Void>(config) {
    @Override public Void apply(RelOptCluster cluster,
      RelOptSchema relOptSchema, SchemaPlus rootSchema,
      CalciteServerStatement statement) {
     final RelDataType type =
       cluster.getTypeFactory()
         .createSqlType(SqlTypeName.DECIMAL, 30, 2);
     final RexLiteral literal =
       cluster.getRexBuilder().makeExactLiteral(BigDecimal.ONE, type);
     final RexNode call =
       cluster.getRexBuilder().makeCall(SqlStdOperatorTable.PLUS,
         literal,
         literal);
     assertEquals(expected, call.getType().getPrecision());
     return null;
    }
   });
}

代码示例来源:origin: Qihoo360/Quicksql

/** Creates a RelBuilder. */
public static RelBuilder create(FrameworkConfig config) {
 final RelOptCluster[] clusters = {null};
 final RelOptSchema[] relOptSchemas = {null};
 Frameworks.withPrepare(
   new Frameworks.PrepareAction<Void>(config) {
    public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
      SchemaPlus rootSchema, CalciteServerStatement statement) {
     clusters[0] = cluster;
     relOptSchemas[0] = relOptSchema;
     return null;
    }
   });
 return new RelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}

代码示例来源:origin: org.apache.calcite/calcite-core

/** Creates a RelBuilder. */
public static RelBuilder create(FrameworkConfig config) {
 final RelOptCluster[] clusters = {null};
 final RelOptSchema[] relOptSchemas = {null};
 Frameworks.withPrepare(
   new Frameworks.PrepareAction<Void>(config) {
    public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
      SchemaPlus rootSchema, CalciteServerStatement statement) {
     clusters[0] = cluster;
     relOptSchemas[0] = relOptSchema;
     return null;
    }
   });
 return new RelBuilder(config.getContext(), clusters[0], relOptSchemas[0]);
}

代码示例来源:origin: org.apache.calcite/calcite-core

Frameworks.withPrepare(
  new Frameworks.PrepareAction<Void>() {
   public Void apply(RelOptCluster cluster,

代码示例来源:origin: Qihoo360/Quicksql

Frameworks.withPrepare(
  new Frameworks.PrepareAction<Void>() {
   public Void apply(RelOptCluster cluster,

相关文章