当前位置: 首页>>代码示例>>Java>>正文


Java CalciteSchema类代码示例

本文整理汇总了Java中org.apache.calcite.jdbc.CalciteSchema的典型用法代码示例。如果您正苦于以下问题:Java CalciteSchema类的具体用法?Java CalciteSchema怎么用?Java CalciteSchema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CalciteSchema类属于org.apache.calcite.jdbc包,在下文中一共展示了CalciteSchema类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: schemas

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
Enumerable<MetaSchema> schemas(String catalog) {
    return Linq4j.asEnumerable(
            getConnection().getCalciteRootSchema().getSubSchemaMap().values())
            .select(
                    new Function1<CalciteSchema, MetaSchema>() {
                        public MetaSchema apply(CalciteSchema calciteSchema) {
                            return new CalciteMetaSchema(
                                    calciteSchema,
                                    connection.getCatalog(),
                                    calciteSchema.getName());
                        }
                    })
            .orderBy(
                    new Function1<MetaSchema, Comparable>() {
                        public Comparable apply(MetaSchema metaSchema) {
                            return (Comparable) FlatLists.of(
                                    Util.first(metaSchema.tableCatalog, ""),
                                    metaSchema.tableSchem);
                        }
                    });
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:22,代码来源:CalciteMetaImpl.java

示例2: connect

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/**
 * Creates an internal connection.
 */
CalciteConnection connect(CalciteSchema rootSchema,
                          JavaTypeFactory typeFactory) {
    /*
    return (CalciteConnection) ((CalciteFactory) factory)
            .newConnection(this, factory, CONNECT_STRING_PREFIX, new Properties(),
                    rootSchema, typeFactory);
                    */

    System.out.println("********************************************************************");
    System.out.println("********************************************************************");
    System.out.println("********************************************************************");
    System.out.println("********************************************************************");
    System.out.println("********************************************************************");
    return (CalciteConnection) ((CalciteFactory) factory)
            .newConnection(this, factory, CONNECT_STRING_PREFIX, new Properties(),
                    (CalciteSchema) SchemaManager.getSingletonInstance(null).getCurrentSchema(),
                    typeFactory);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:22,代码来源:Driver.java

示例3: CalciteConnectionImpl

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/**
 * Creates a CalciteConnectionImpl.
 * <p/>
 * <p>Not public; method is called only from the driver.</p>
 *
 * @param driver      Driver
 * @param factory     Factory for JDBC objects
 * @param url         Server URL
 * @param info        Other connection properties
 * @param rootSchema  Root schema, or null
 * @param typeFactory Type factory, or null
 */
protected CalciteConnectionImpl(Driver driver, AvaticaFactory factory,
                                String url, Properties info, CalciteSchema rootSchema,
                                JavaTypeFactory typeFactory) {
    super(driver, factory, url, info);
    CalciteConnectionConfig cfg = new CalciteConnectionConfigImpl(info);
    this.prepareFactory = driver.getPrepareFactory();
    if (typeFactory != null) {
        this.typeFactory = typeFactory;
    } else {
        final RelDataTypeSystem typeSystem =
                cfg.typeSystem(RelDataTypeSystem.class, RelDataTypeSystem.DEFAULT);
        this.typeFactory = new JavaTypeFactoryImpl(typeSystem);
    }
    this.rootSchema =
            Preconditions.checkNotNull(rootSchema != null
                    ? rootSchema
                    : CalciteSchema.createRootSchema(true));
    Preconditions.checkArgument(this.rootSchema.isRoot(), "must be root schema");
    this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive());
    this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing());
    this.properties.put(InternalProperty.QUOTED_CASING, cfg.quotedCasing());
    this.properties.put(InternalProperty.QUOTING, cfg.quoting());
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:36,代码来源:CalciteConnectionImpl.java

示例4: populateMaterializationsAndLattice

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
private void populateMaterializationsAndLattice(
    QuarkMaterializeCluster.RelOptPlannerHolder plannerHolder,
    CalciteSchema rootSchema) {
  if (materializations == null) {
    materializations =
        MaterializationService.instance().query(rootSchema);
  }
  Materializer materializer = new Materializer(materializations);

  materializer.populateMaterializations(context.getPrepareContext(), plannerHolder);

  List<CalciteSchema.LatticeEntry> lattices = Schemas.getLatticeEntries(rootSchema);

  for (CalciteSchema.LatticeEntry lattice : lattices) {
    final CalciteSchema.TableEntry starTable = lattice.getStarTable();
    final JavaTypeFactory typeFactory = context.getTypeFactory();
    final RelOptTableImpl starRelOptTable =
        RelOptTableImpl.create(catalogReader,
            starTable.getTable().getRowType(typeFactory), starTable, null);
    plannerHolder.getPlanner().addLattice(
        new RelOptLattice(lattice.getLattice(), starRelOptTable));
  }
}
 
开发者ID:qubole,项目名称:quark,代码行数:24,代码来源:SqlWorker.java

示例5: populateMaterializations

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
protected void populateMaterializations(Context context,
                                        RelOptPlanner planner, Prepare.Materialization materialization) {
  // REVIEW: initialize queryRel and tableRel inside MaterializationService,
  // not here?
  try {
    final CalciteSchema schema = materialization.materializedTable.schema;
    CalciteCatalogReader catalogReader =
        new CalciteCatalogReader(
            schema.root(),
            context.config().caseSensitive(),
            materialization.viewSchemaPath,
            context.getTypeFactory());
    final CalciteMaterializer materializer =
        new CalciteMaterializer(this, context, catalogReader, schema, planner,
            createConvertletTable());
    materializer.populate(materialization);
  } catch (Exception e) {
    throw new RuntimeException("While populating materialization "
        + materialization.materializedTable.path(), e);
  }
}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:CalcitePrepareImpl.java

示例6: perform

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/** Executes a prepare action. */
public <R> R perform(CalciteServerStatement statement,
    Frameworks.PrepareAction<R> action) {
  final CalcitePrepare.Context prepareContext =
      statement.createPrepareContext();
  final JavaTypeFactory typeFactory = prepareContext.getTypeFactory();
  final CalciteSchema schema =
      action.getConfig().getDefaultSchema() != null
          ? CalciteSchema.from(action.getConfig().getDefaultSchema())
          : prepareContext.getRootSchema();
  CalciteCatalogReader catalogReader =
      new CalciteCatalogReader(schema.root(),
          prepareContext.config().caseSensitive(),
          schema.path(null),
          typeFactory);
  final RexBuilder rexBuilder = new RexBuilder(typeFactory);
  final RelOptPlanner planner =
      createPlanner(prepareContext,
          action.getConfig().getContext(),
          action.getConfig().getCostFactory());
  final RelOptCluster cluster = createCluster(planner, rexBuilder);
  return action.apply(cluster, catalogReader,
      prepareContext.getRootSchema().plus(), statement);
}
 
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:CalcitePrepareImpl.java

示例7: CalcitePreparingStmt

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
public CalcitePreparingStmt(CalcitePrepareImpl prepare,
    Context context,
    CatalogReader catalogReader,
    RelDataTypeFactory typeFactory,
    CalciteSchema schema,
    EnumerableRel.Prefer prefer,
    RelOptPlanner planner,
    Convention resultConvention,
    SqlRexConvertletTable convertletTable) {
  super(context, catalogReader, resultConvention);
  this.prepare = prepare;
  this.schema = schema;
  this.prefer = prefer;
  this.planner = planner;
  this.typeFactory = typeFactory;
  this.convertletTable = convertletTable;
  this.rexBuilder = new RexBuilder(typeFactory);
}
 
开发者ID:apache,项目名称:kylin,代码行数:19,代码来源:CalcitePrepareImpl.java

示例8: execute

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
public void execute(CalcitePrepare.Context context) {
  final Pair<CalciteSchema, String> pair =
      SqlDdlNodes.schema(context, true, name);
  final SchemaPlus schemaPlus = pair.left.plus();
  for (Function function : schemaPlus.getFunctions(pair.right)) {
    if (function.getParameters().isEmpty()) {
      if (!getReplace()) {
        throw SqlUtil.newContextException(name.getParserPosition(),
            RESOURCE.viewExists(pair.right));
      }
      pair.left.removeFunction(pair.right);
    }
  }
  final SqlNode q = SqlDdlNodes.renameColumns(columnList, query);
  final String sql = q.toSqlString(CalciteSqlDialect.DEFAULT).getSql();
  final ViewTableMacro viewTableMacro =
      ViewTable.viewMacro(schemaPlus, sql, pair.left.path(null),
          context.getObjectPath(), false);
  final TranslatableTable x = viewTableMacro.apply(ImmutableList.of());
  Util.discard(x);
  schemaPlus.add(pair.right, viewTableMacro);
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:SqlCreateView.java

示例9: execute

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
@Override public void execute(CalcitePrepare.Context context) {
  final Pair<CalciteSchema, String> pair =
      SqlDdlNodes.schema(context, true, name);
  final Table table = pair.left.plus().getTable(pair.right);
  if (table != null) {
    // Materialized view exists.
    super.execute(context);
    if (table instanceof Wrapper) {
      final MaterializationKey materializationKey =
          ((Wrapper) table).unwrap(MaterializationKey.class);
      if (materializationKey != null) {
        MaterializationService.instance()
            .removeMaterialization(materializationKey);
      }
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlDropMaterializedView.java

示例10: visit

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
public void visit(JsonLattice jsonLattice) {
  try {
    checkRequiredAttributes(jsonLattice, "name", "sql");
    final SchemaPlus schema = currentSchema();
    if (!schema.isMutable()) {
      throw new RuntimeException("Cannot define lattice; parent schema '"
          + currentSchemaName()
          + "' is not a SemiMutableSchema");
    }
    CalciteSchema calciteSchema = CalciteSchema.from(schema);
    Lattice.Builder latticeBuilder =
        Lattice.builder(calciteSchema, jsonLattice.getSql())
            .auto(jsonLattice.auto)
            .algorithm(jsonLattice.algorithm);
    if (jsonLattice.rowCountEstimate != null) {
      latticeBuilder.rowCountEstimate(jsonLattice.rowCountEstimate);
    }
    if (jsonLattice.statisticProvider != null) {
      latticeBuilder.statisticProvider(jsonLattice.statisticProvider);
    }
    populateLattice(jsonLattice, latticeBuilder);
    schema.add(jsonLattice.name, latticeBuilder.build());
  } catch (Exception e) {
    throw new RuntimeException("Error instantiating " + jsonLattice, e);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:ModelHandler.java

示例11: useStar

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/** Converts a relational expression to use a
 * {@link org.apache.calcite.schema.impl.StarTable} defined in {@code schema}.
 * Uses the first star table that fits. */
private Iterable<Callback> useStar(CalciteSchema schema, RelNode queryRel) {
  List<CalciteSchema.TableEntry> starTables =
      Schemas.getStarTables(schema.root());
  if (starTables.isEmpty()) {
    // Don't waste effort converting to leaf-join form.
    return ImmutableList.of();
  }
  final List<Callback> list = Lists.newArrayList();
  final RelNode rel2 =
      RelOptMaterialization.toLeafJoinForm(queryRel);
  for (CalciteSchema.TableEntry starTable : starTables) {
    final Table table = starTable.getTable();
    assert table instanceof StarTable;
    RelOptTableImpl starRelOptTable =
        RelOptTableImpl.create(catalogReader, table.getRowType(typeFactory),
            starTable, null);
    final RelNode rel3 =
        RelOptMaterialization.tryUseStar(rel2, starRelOptTable);
    if (rel3 != null) {
      list.add(new Callback(rel3, starTable, starRelOptTable));
    }
  }
  return list;
}
 
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:CalciteMaterializer.java

示例12: populateMaterializations

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
protected void populateMaterializations(Context context,
    RelOptPlanner planner, Prepare.Materialization materialization) {
  // REVIEW: initialize queryRel and tableRel inside MaterializationService,
  // not here?
  try {
    final CalciteSchema schema = materialization.materializedTable.schema;
    CalciteCatalogReader catalogReader =
        new CalciteCatalogReader(
            schema.root(),
            materialization.viewSchemaPath,
            context.getTypeFactory(),
            context.config());
    final CalciteMaterializer materializer =
        new CalciteMaterializer(this, context, catalogReader, schema, planner,
            createConvertletTable());
    materializer.populate(materialization);
  } catch (Exception e) {
    throw new RuntimeException("While populating materialization "
        + materialization.materializedTable.path(), e);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:CalcitePrepareImpl.java

示例13: perform

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
/** Executes a prepare action. */
public <R> R perform(CalciteServerStatement statement,
    Frameworks.PrepareAction<R> action) {
  final CalcitePrepare.Context prepareContext =
      statement.createPrepareContext();
  final JavaTypeFactory typeFactory = prepareContext.getTypeFactory();
  final CalciteSchema schema =
      action.getConfig().getDefaultSchema() != null
          ? CalciteSchema.from(action.getConfig().getDefaultSchema())
          : prepareContext.getRootSchema();
  CalciteCatalogReader catalogReader =
      new CalciteCatalogReader(schema.root(),
          schema.path(null),
          typeFactory,
          prepareContext.config());
  final RexBuilder rexBuilder = new RexBuilder(typeFactory);
  final RelOptPlanner planner =
      createPlanner(prepareContext,
          action.getConfig().getContext(),
          action.getConfig().getCostFactory());
  final RelOptCluster cluster = createCluster(planner, rexBuilder);
  return action.apply(cluster, catalogReader,
      prepareContext.getRootSchema().plus(), statement);
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:CalcitePrepareImpl.java

示例14: CalcitePreparingStmt

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
CalcitePreparingStmt(CalcitePrepareImpl prepare,
    Context context,
    CatalogReader catalogReader,
    RelDataTypeFactory typeFactory,
    CalciteSchema schema,
    EnumerableRel.Prefer prefer,
    RelOptPlanner planner,
    Convention resultConvention,
    SqlRexConvertletTable convertletTable) {
  super(context, catalogReader, resultConvention);
  this.prepare = prepare;
  this.schema = schema;
  this.prefer = prefer;
  this.planner = planner;
  this.typeFactory = typeFactory;
  this.convertletTable = convertletTable;
  this.rexBuilder = new RexBuilder(typeFactory);
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:CalcitePrepareImpl.java

示例15: toRel

import org.apache.calcite.jdbc.CalciteSchema; //导入依赖的package包/类
RelNode toRel(Queryable<T> queryable) {
  if (queryable instanceof QueryableDefaults.Replayable) {
    //noinspection unchecked
    ((QueryableDefaults.Replayable) queryable).replay(this);
    return rel;
  }
  if (queryable instanceof AbstractTableQueryable) {
    final AbstractTableQueryable tableQueryable =
        (AbstractTableQueryable) queryable;
    final QueryableTable table = tableQueryable.table;
    final CalciteSchema.TableEntry tableEntry =
        CalciteSchema.from(tableQueryable.schema)
            .add(tableQueryable.tableName, tableQueryable.table);
    final RelOptTableImpl relOptTable =
        RelOptTableImpl.create(null, table.getRowType(translator.typeFactory),
            tableEntry, null);
    if (table instanceof TranslatableTable) {
      return ((TranslatableTable) table).toRel(translator, relOptTable);
    } else {
      return LogicalTableScan.create(translator.cluster, relOptTable);
    }
  }
  return translator.translate(queryable.getExpression());
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:QueryableRelBuilder.java


注:本文中的org.apache.calcite.jdbc.CalciteSchema类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。