Package org.apache.calcite.jdbc
Class CachingCalciteSchema
- java.lang.Object
-
- org.apache.calcite.jdbc.CalciteSchema
-
- org.apache.calcite.jdbc.CachingCalciteSchema
-
- Direct Known Subclasses:
CalciteRootSchema
class CachingCalciteSchema extends CalciteSchema
Concrete implementation ofCalciteSchema
that caches tables, functions and sub-schemas.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
CachingCalciteSchema.AbstractCached<T>
Implementation ofCachingCalciteSchema.Cached
that drives fromcache
.private static interface
CachingCalciteSchema.Cached<T>
Strategy for caching the value of an object and re-creating it if its value is out of date as of a given timestamp.private static class
CachingCalciteSchema.SubSchemaCache
Information about the implicit sub-schemas of anCalciteSchema
.-
Nested classes/interfaces inherited from class org.apache.calcite.jdbc.CalciteSchema
CalciteSchema.Entry, CalciteSchema.FunctionEntry, CalciteSchema.FunctionEntryImpl, CalciteSchema.LatticeEntry, CalciteSchema.LatticeEntryImpl, CalciteSchema.TableEntry, CalciteSchema.TableEntryImpl, CalciteSchema.TypeEntry, CalciteSchema.TypeEntryImpl
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
cache
private CachingCalciteSchema.Cached<NameSet>
implicitFunctionCache
private CachingCalciteSchema.Cached<CachingCalciteSchema.SubSchemaCache>
implicitSubSchemaCache
private CachingCalciteSchema.Cached<NameSet>
implicitTableCache
private CachingCalciteSchema.Cached<NameSet>
implicitTypeCache
-
Fields inherited from class org.apache.calcite.jdbc.CalciteSchema
functionMap, functionNames, latticeMap, name, nullaryFunctionMap, schema, subSchemaMap, tableMap, typeMap
-
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
CachingCalciteSchema(CalciteSchema parent, Schema schema, java.lang.String name)
Creates a CachingCalciteSchema.private
CachingCalciteSchema(CalciteSchema parent, Schema schema, java.lang.String name, NameMap<CalciteSchema> subSchemaMap, NameMap<CalciteSchema.TableEntry> tableMap, NameMap<CalciteSchema.LatticeEntry> latticeMap, NameMap<CalciteSchema.TypeEntry> typeMap, NameMultimap<CalciteSchema.FunctionEntry> functionMap, NameSet functionNames, NameMap<CalciteSchema.FunctionEntry> nullaryFunctionMap, java.util.List<? extends java.util.List<java.lang.String>> path)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CalciteSchema
add(java.lang.String name, Schema schema)
Adds a child schema of this schema.protected void
addImplicitFuncNamesToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<java.lang.String> builder)
Adds implicit function names to a builder.protected void
addImplicitFunctionsToBuilder(com.google.common.collect.ImmutableList.Builder<Function> builder, java.lang.String name, boolean caseSensitive)
Adds implicit functions to a builder.protected void
addImplicitSubSchemaToBuilder(com.google.common.collect.ImmutableSortedMap.Builder<java.lang.String,CalciteSchema> builder)
Adds implicit sub-schemas to a builder.protected void
addImplicitTablesBasedOnNullaryFunctionsToBuilder(com.google.common.collect.ImmutableSortedMap.Builder<java.lang.String,Table> builder)
Adds implicit table functions to a builder.protected void
addImplicitTableToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<java.lang.String> builder)
Adds implicit tables to a builder.protected void
addImplicitTypeNamesToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<java.lang.String> builder)
Adds implicit type names to a builder.protected CalciteSchema
getImplicitSubSchema(java.lang.String schemaName, boolean caseSensitive)
Returns a sub-schema with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toCalciteSchema.add(String, Schema)
), or null.protected CalciteSchema.TableEntry
getImplicitTable(java.lang.String tableName, boolean caseSensitive)
Returns a table with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toCalciteSchema.add(String, Table)
), or null.protected CalciteSchema.TableEntry
getImplicitTableBasedOnNullaryFunction(java.lang.String tableName, boolean caseSensitive)
Returns table function with a given name and zero arguments that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toCalciteSchema.add(String, Function)
), or null.protected CalciteSchema.TypeEntry
getImplicitType(java.lang.String name, boolean caseSensitive)
Returns a type with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toCalciteSchema.add(String, RelProtoDataType)
), or null.protected boolean
isCacheEnabled()
boolean
removeFunction(java.lang.String name)
boolean
removeTable(java.lang.String name)
void
setCache(boolean cache)
protected CalciteSchema
snapshot(CalciteSchema parent, SchemaVersion version)
Returns a snapshot representation of this CalciteSchema.-
Methods inherited from class org.apache.calcite.jdbc.CalciteSchema
add, add, add, createRootSchema, createRootSchema, createRootSchema, createSnapshot, find, find, from, getFunctionNames, getFunctions, getLatticeMap, getName, getPath, getSubSchema, getSubSchemaMap, getTable, getTableBasedOnNullaryFunction, getTableBySql, getTableNames, getTablesBasedOnNullaryFunctions, getType, getTypeNames, isRoot, path, plus, removeSubSchema, removeType, root, tableEntry, typeEntry
-
-
-
-
Field Detail
-
implicitSubSchemaCache
private final CachingCalciteSchema.Cached<CachingCalciteSchema.SubSchemaCache> implicitSubSchemaCache
-
implicitTableCache
private final CachingCalciteSchema.Cached<NameSet> implicitTableCache
-
implicitFunctionCache
private final CachingCalciteSchema.Cached<NameSet> implicitFunctionCache
-
implicitTypeCache
private final CachingCalciteSchema.Cached<NameSet> implicitTypeCache
-
cache
private boolean cache
-
-
Constructor Detail
-
CachingCalciteSchema
CachingCalciteSchema(CalciteSchema parent, Schema schema, java.lang.String name)
Creates a CachingCalciteSchema.
-
CachingCalciteSchema
private CachingCalciteSchema(CalciteSchema parent, Schema schema, java.lang.String name, NameMap<CalciteSchema> subSchemaMap, NameMap<CalciteSchema.TableEntry> tableMap, NameMap<CalciteSchema.LatticeEntry> latticeMap, NameMap<CalciteSchema.TypeEntry> typeMap, NameMultimap<CalciteSchema.FunctionEntry> functionMap, NameSet functionNames, NameMap<CalciteSchema.FunctionEntry> nullaryFunctionMap, java.util.List<? extends java.util.List<java.lang.String>> path)
-
-
Method Detail
-
setCache
public void setCache(boolean cache)
- Specified by:
setCache
in classCalciteSchema
-
isCacheEnabled
protected boolean isCacheEnabled()
- Specified by:
isCacheEnabled
in classCalciteSchema
-
getImplicitSubSchema
protected CalciteSchema getImplicitSubSchema(java.lang.String schemaName, boolean caseSensitive)
Description copied from class:CalciteSchema
Returns a sub-schema with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toCalciteSchema.add(String, Schema)
), or null.- Specified by:
getImplicitSubSchema
in classCalciteSchema
-
add
public CalciteSchema add(java.lang.String name, Schema schema)
Adds a child schema of this schema.- Specified by:
add
in classCalciteSchema
-
getImplicitTable
protected CalciteSchema.TableEntry getImplicitTable(java.lang.String tableName, boolean caseSensitive)
Description copied from class:CalciteSchema
Returns a table with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toCalciteSchema.add(String, Table)
), or null.- Specified by:
getImplicitTable
in classCalciteSchema
-
getImplicitType
protected CalciteSchema.TypeEntry getImplicitType(java.lang.String name, boolean caseSensitive)
Description copied from class:CalciteSchema
Returns a type with a given name that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toCalciteSchema.add(String, RelProtoDataType)
), or null.- Specified by:
getImplicitType
in classCalciteSchema
-
addImplicitSubSchemaToBuilder
protected void addImplicitSubSchemaToBuilder(com.google.common.collect.ImmutableSortedMap.Builder<java.lang.String,CalciteSchema> builder)
Description copied from class:CalciteSchema
Adds implicit sub-schemas to a builder.- Specified by:
addImplicitSubSchemaToBuilder
in classCalciteSchema
-
addImplicitTableToBuilder
protected void addImplicitTableToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<java.lang.String> builder)
Description copied from class:CalciteSchema
Adds implicit tables to a builder.- Specified by:
addImplicitTableToBuilder
in classCalciteSchema
-
addImplicitFunctionsToBuilder
protected void addImplicitFunctionsToBuilder(com.google.common.collect.ImmutableList.Builder<Function> builder, java.lang.String name, boolean caseSensitive)
Description copied from class:CalciteSchema
Adds implicit functions to a builder.- Specified by:
addImplicitFunctionsToBuilder
in classCalciteSchema
-
addImplicitFuncNamesToBuilder
protected void addImplicitFuncNamesToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<java.lang.String> builder)
Description copied from class:CalciteSchema
Adds implicit function names to a builder.- Specified by:
addImplicitFuncNamesToBuilder
in classCalciteSchema
-
addImplicitTypeNamesToBuilder
protected void addImplicitTypeNamesToBuilder(com.google.common.collect.ImmutableSortedSet.Builder<java.lang.String> builder)
Description copied from class:CalciteSchema
Adds implicit type names to a builder.- Specified by:
addImplicitTypeNamesToBuilder
in classCalciteSchema
-
addImplicitTablesBasedOnNullaryFunctionsToBuilder
protected void addImplicitTablesBasedOnNullaryFunctionsToBuilder(com.google.common.collect.ImmutableSortedMap.Builder<java.lang.String,Table> builder)
Description copied from class:CalciteSchema
Adds implicit table functions to a builder.- Specified by:
addImplicitTablesBasedOnNullaryFunctionsToBuilder
in classCalciteSchema
-
getImplicitTableBasedOnNullaryFunction
protected CalciteSchema.TableEntry getImplicitTableBasedOnNullaryFunction(java.lang.String tableName, boolean caseSensitive)
Description copied from class:CalciteSchema
Returns table function with a given name and zero arguments that is defined implicitly (that is, by the underlyingSchema
object, not explicitly by a call toCalciteSchema.add(String, Function)
), or null.- Specified by:
getImplicitTableBasedOnNullaryFunction
in classCalciteSchema
-
snapshot
protected CalciteSchema snapshot(CalciteSchema parent, SchemaVersion version)
Description copied from class:CalciteSchema
Returns a snapshot representation of this CalciteSchema.- Specified by:
snapshot
in classCalciteSchema
-
removeTable
public boolean removeTable(java.lang.String name)
- Overrides:
removeTable
in classCalciteSchema
-
removeFunction
public boolean removeFunction(java.lang.String name)
- Overrides:
removeFunction
in classCalciteSchema
-
-