Package org.apache.calcite.adapter.java
Class ReflectiveSchema
- java.lang.Object
-
- org.apache.calcite.schema.impl.AbstractSchema
-
- org.apache.calcite.adapter.java.ReflectiveSchema
-
- All Implemented Interfaces:
Schema
public class ReflectiveSchema extends AbstractSchema
Implementation ofSchema
that exposes the public fields and methods in a Java object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ReflectiveSchema.Factory
Factory that creates a schema by instantiating an object and looking at its public fields.private static class
ReflectiveSchema.FieldSelector
Function that returns an array of a given object's field values.private static class
ReflectiveSchema.FieldTable<T>
Table based on a Java field.private static class
ReflectiveSchema.MethodTableMacro
Table macro based on a Java method.private static class
ReflectiveSchema.ReflectiveTable
Table that is implemented by reading from a Java object.-
Nested classes/interfaces inherited from interface org.apache.calcite.schema.Schema
Schema.TableType
-
-
Constructor Summary
Constructors Constructor Description ReflectiveSchema(java.lang.Object target)
Creates a ReflectiveSchema.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private com.google.common.collect.Multimap<java.lang.String,Function>
createFunctionMap()
private java.util.Map<java.lang.String,Table>
createTableMap()
private <T> Table
fieldRelation(java.lang.reflect.Field field)
Returns a table based on a particular field of this schema.private static java.lang.reflect.Type
getElementType(java.lang.Class clazz)
Deduces the element type of a collection; same logic astoEnumerable(java.lang.Object)
protected com.google.common.collect.Multimap<java.lang.String,Function>
getFunctionMultimap()
Returns a multi-map of functions in this schema by name.protected java.util.Map<java.lang.String,Table>
getTableMap()
Returns a map of tables in this schema by name.java.lang.Object
getTarget()
Returns the wrapped object.(package private) Expression
getTargetExpression(SchemaPlus parentSchema, java.lang.String name)
Returns an expression for the object wrapped by this schema (not the schema itself).private static Enumerable
toEnumerable(java.lang.Object o)
java.lang.String
toString()
-
Methods inherited from class org.apache.calcite.schema.impl.AbstractSchema
getExpression, getFunctionNames, getFunctions, getSubSchema, getSubSchemaMap, getSubSchemaNames, getTable, getTableNames, getType, getTypeMap, getTypeNames, isMutable, snapshot
-
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getTarget
public java.lang.Object getTarget()
Returns the wrapped object.May not appear to be used, but is used in generated code via
BuiltInMethod.REFLECTIVE_SCHEMA_GET_TARGET
.
-
getTableMap
protected java.util.Map<java.lang.String,Table> getTableMap()
Description copied from class:AbstractSchema
Returns a map of tables in this schema by name.The implementations of
AbstractSchema.getTableNames()
andAbstractSchema.getTable(String)
depend on this map. The default implementation of this method returns the empty map. Override this method to change their behavior.- Overrides:
getTableMap
in classAbstractSchema
- Returns:
- Map of tables in this schema by name
-
createTableMap
private java.util.Map<java.lang.String,Table> createTableMap()
-
getFunctionMultimap
protected com.google.common.collect.Multimap<java.lang.String,Function> getFunctionMultimap()
Description copied from class:AbstractSchema
Returns a multi-map of functions in this schema by name. It is a multi-map because functions are overloaded; there may be more than one function in a schema with a given name (as long as they have different parameter lists).The implementations of
AbstractSchema.getFunctionNames()
andSchema.getFunctions(String)
depend on this map. The default implementation of this method returns the empty multi-map. Override this method to change their behavior.- Overrides:
getFunctionMultimap
in classAbstractSchema
- Returns:
- Multi-map of functions in this schema by name
-
createFunctionMap
private com.google.common.collect.Multimap<java.lang.String,Function> createFunctionMap()
-
getTargetExpression
Expression getTargetExpression(SchemaPlus parentSchema, java.lang.String name)
Returns an expression for the object wrapped by this schema (not the schema itself).
-
fieldRelation
private <T> Table fieldRelation(java.lang.reflect.Field field)
Returns a table based on a particular field of this schema. If the field is not of the right type to be a relation, returns null.
-
getElementType
private static java.lang.reflect.Type getElementType(java.lang.Class clazz)
Deduces the element type of a collection; same logic astoEnumerable(java.lang.Object)
-
toEnumerable
private static Enumerable toEnumerable(java.lang.Object o)
-
-