本文整理汇总了Java中org.apache.calcite.jdbc.CalciteSchema.TableEntry方法的典型用法代码示例。如果您正苦于以下问题:Java CalciteSchema.TableEntry方法的具体用法?Java CalciteSchema.TableEntry怎么用?Java CalciteSchema.TableEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.jdbc.CalciteSchema
的用法示例。
在下文中一共展示了CalciteSchema.TableEntry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
}
示例2: 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());
}
示例3: getTable
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
public Prepare.PreparingTable getTable(final List<String> names) {
// First look in the default schema, if any.
// If not found, look in the root schema.
CalciteSchema.TableEntry entry = SqlValidatorUtil.getTableEntry(this, names);
if (entry != null) {
final Table table = entry.getTable();
if (table instanceof Wrapper) {
final Prepare.PreparingTable relOptTable =
((Wrapper) table).unwrap(Prepare.PreparingTable.class);
if (relOptTable != null) {
return relOptTable;
}
}
return RelOptTableImpl.create(this,
table.getRowType(typeFactory), entry, null);
}
return null;
}
示例4: findTable
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
private Table findTable(CalciteSchema schema, String tableName, boolean caseSensitive) {
CalciteSchema.TableEntry entry = schema.getTable(tableName, caseSensitive);
if (entry != null) {
return entry.getTable();
}
// Check sub schemas
for (CalciteSchema subSchema : schema.getSubSchemaMap().values()) {
Table table = findTable(subSchema, tableName, caseSensitive);
if (table != null) {
return table;
}
}
return null;
}
示例5: getTableEntry
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
/**
* Finds a {@link org.apache.calcite.jdbc.CalciteSchema.TableEntry} in a
* given catalog reader whose table has the given name, possibly qualified.
*
* <p>Uses the case-sensitivity policy of the specified catalog reader.
*
* <p>If not found, returns null.
*
* @param catalogReader accessor to the table metadata
* @param names Name of table, may be qualified or fully-qualified
*
* @return TableEntry with a table with the given name, or null
*/
public static CalciteSchema.TableEntry getTableEntry(
SqlValidatorCatalogReader catalogReader, List<String> names) {
// First look in the default schema, if any.
// If not found, look in the root schema.
for (List<String> schemaPath : catalogReader.getSchemaPaths()) {
CalciteSchema schema =
getSchema(catalogReader.getRootSchema(),
Iterables.concat(schemaPath, Util.skipLast(names)),
catalogReader.nameMatcher());
if (schema == null) {
continue;
}
CalciteSchema.TableEntry entry =
getTableEntryFrom(schema, Util.last(names),
catalogReader.nameMatcher().isCaseSensitive());
if (entry != null) {
return entry;
}
}
return null;
}
示例6: Materialization
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
/** Creates a materialization.
*
* @param key Unique identifier of this materialization
* @param materializedTable Table that currently materializes the query.
* That is, executing "select * from table" will
* give the same results as executing the query.
* May be null when the materialization is created;
* materialization service will change the value as
* @param sql Query that is materialized
* @param rowType Row type
*/
Materialization(MaterializationKey key,
CalciteSchema rootSchema,
CalciteSchema.TableEntry materializedTable,
String sql,
RelDataType rowType,
List<String> viewSchemaPath) {
this.key = key;
this.rootSchema = Preconditions.checkNotNull(rootSchema);
Preconditions.checkArgument(rootSchema.isRoot(), "must be root schema");
this.materializedTable = materializedTable; // may be null
this.sql = sql;
this.rowType = rowType;
this.viewSchemaPath = viewSchemaPath;
}
示例7: compare
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
public int compare(Pair<CalciteSchema.TableEntry, TileKey> o0,
Pair<CalciteSchema.TableEntry, TileKey> o1) {
// We prefer rolling up from the table with the fewest rows.
final Table t0 = o0.left.getTable();
final Table t1 = o1.left.getTable();
int c = Double.compare(t0.getStatistic().getRowCount(),
t1.getStatistic().getRowCount());
if (c != 0) {
return c;
}
// Tie-break based on table name.
return o0.left.name.compareTo(o1.left.name);
}
示例8: checkValid
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
/** Checks whether a materialization is valid, and if so, returns the table
* where the data are stored. */
public CalciteSchema.TableEntry checkValid(MaterializationKey key) {
final MaterializationActor.Materialization materialization =
actor.keyMap.get(key);
if (materialization != null) {
return materialization.materializedTable;
}
return null;
}
示例9: Callback
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
Callback(RelNode rel,
CalciteSchema.TableEntry starTable,
RelOptTableImpl starRelOptTable) {
this.rel = rel;
this.starTable = starTable;
this.starRelOptTable = starRelOptTable;
}
示例10: create
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
public static RelOptTableImpl create(RelOptSchema schema, RelDataType rowType,
final CalciteSchema.TableEntry tableEntry, Double rowCount) {
final Table table = tableEntry.getTable();
Function<Class, Expression> expressionFunction =
getClassExpressionFunction(tableEntry, table);
return new RelOptTableImpl(schema, rowType, tableEntry.path(),
table, expressionFunction, rowCount);
}
示例11: Materialization
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
public Materialization(CalciteSchema.TableEntry materializedTable,
String sql, List<String> viewSchemaPath) {
assert materializedTable != null;
assert sql != null;
this.materializedTable = materializedTable;
this.sql = sql;
this.viewSchemaPath = viewSchemaPath;
}
示例12: getTableEntryFrom
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
private static CalciteSchema.TableEntry getTableEntryFrom(
CalciteSchema schema, String name, boolean caseSensitive) {
CalciteSchema.TableEntry entry =
schema.getTable(name, caseSensitive);
if (entry == null) {
entry = schema.getTableBasedOnNullaryFunction(name,
caseSensitive);
}
return entry;
}
示例13: toRel
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
@Override public RelNode toRel(RelOptTable.ToRelContext context,
RelOptTable relOptTable) {
final CalciteSchema.TableEntry tableEntry =
MaterializationService.instance().checkValid(key);
if (tableEntry != null) {
Table materializeTable = tableEntry.getTable();
if (materializeTable instanceof TranslatableTable) {
TranslatableTable table = (TranslatableTable) materializeTable;
return table.toRel(context, relOptTable);
}
}
return super.toRel(context, relOptTable);
}
示例14: defineMaterialization
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
/** Defines a new materialization. Returns its key. */
public MaterializationKey defineMaterialization(final CalciteSchema schema,
TileKey tileKey, String viewSql, List<String> viewSchemaPath,
String suggestedTableName, TableFactory tableFactory, boolean create,
boolean existing) {
final MaterializationActor.QueryKey queryKey =
new MaterializationActor.QueryKey(viewSql, schema, viewSchemaPath);
final MaterializationKey existingKey = actor.keyBySql.get(queryKey);
if (existingKey != null) {
return existingKey;
}
if (!create) {
return null;
}
final CalciteConnection connection =
CalciteMetaImpl.connect(schema.root(), null);
CalciteSchema.TableEntry tableEntry;
// If the user says the materialization exists, first try to find a table
// with the name and if none can be found, lookup a view in the schema
if (existing) {
tableEntry = schema.getTable(suggestedTableName, true);
if (tableEntry == null) {
tableEntry = schema.getTableBasedOnNullaryFunction(suggestedTableName, true);
}
} else {
tableEntry = null;
}
if (tableEntry == null) {
tableEntry = schema.getTableBySql(viewSql);
}
RelDataType rowType = null;
if (tableEntry == null) {
Table table = tableFactory.createTable(schema, viewSql, viewSchemaPath);
final String tableName = Schemas.uniqueTableName(schema,
Util.first(suggestedTableName, "m"));
tableEntry = schema.add(tableName, table, ImmutableList.of(viewSql));
Hook.CREATE_MATERIALIZATION.run(tableName);
rowType = table.getRowType(connection.getTypeFactory());
}
if (rowType == null) {
// If we didn't validate the SQL by populating a table, validate it now.
final CalcitePrepare.ParseResult parse =
Schemas.parse(connection, schema, viewSchemaPath, viewSql);
rowType = parse.rowType;
}
final MaterializationKey key = new MaterializationKey();
final MaterializationActor.Materialization materialization =
new MaterializationActor.Materialization(key, schema.root(),
tableEntry, viewSql, rowType, viewSchemaPath);
actor.keyMap.put(materialization.key, materialization);
actor.keyBySql.put(queryKey, materialization.key);
if (tileKey != null) {
actor.keyByTile.put(tileKey, materialization.key);
}
return key;
}
示例15: getClassExpressionFunction
import org.apache.calcite.jdbc.CalciteSchema; //导入方法依赖的package包/类
private static Function<Class, Expression> getClassExpressionFunction(
CalciteSchema.TableEntry tableEntry, Table table) {
return getClassExpressionFunction(tableEntry.schema.plus(), tableEntry.name,
table);
}