|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.oj.stmt.OJPreparingStmt net.sf.farrago.query.FarragoPreparingStmt
public class FarragoPreparingStmt
FarragoPreparingStmt subclasses OJPreparingStmt to implement the FarragoSessionPreparingStmt
interface.
Nested Class Summary | |
---|---|
protected static class |
FarragoPreparingStmt.InvalidPlanException
Exception describing why a plan is invalid. |
protected class |
FarragoPreparingStmt.PermutingRelOptTable
Transform which permutes the columns of an input table, applying casts amd renaming columns if necessary, to make the output rowtype match the desired rowtype. |
protected static class |
FarragoPreparingStmt.ValidatorTable
|
Nested classes/interfaces inherited from class org.eigenbase.oj.stmt.OJPreparingStmt |
---|
OJPreparingStmt.Argument, OJPreparingStmt.JavaRelFinder |
Fields inherited from class org.eigenbase.oj.stmt.OJPreparingStmt |
---|
connection, connectionVariable, containsJava, env, javaCompiler, timingTracer |
Constructor Summary | |
---|---|
FarragoPreparingStmt(FarragoSessionStmtContext rootStmtContext,
FarragoSessionStmtValidator stmtValidator,
String sql)
Creates a new FarragoPreparingStmt object. |
Method Summary | |
---|---|
void |
addDependency(CwmModelElement supplier,
PrivilegedAction action)
|
(package private) void |
addJarUrl(String jarUrl)
|
(package private) void |
analyzeRoutineDependencies(SqlNode sqlNode)
|
void |
analyzeSql(SqlNode sqlNode,
FarragoSessionAnalyzedSql analyzedSql)
Analyzes an SQL expression, and returns information about it. |
void |
clearDmlValidation()
|
void |
closeAllocation()
Closes this object. |
protected BoundMethod |
compileAndBind(ClassDeclaration decl,
ParseTree parseTree,
OJPreparingStmt.Argument[] arguments)
|
protected Class |
compileClass(String packageName,
String className,
String source)
Compile a single class with the given source in the given package. |
Object |
contentsAsArray(String qualifier,
String tableName)
In theory, this method returns the contents of tableName as
an array; in practice, it is a placeholder recognized by the optimizer to
do something much more efficient. |
protected RelDataType |
createTableRowType(CwmNamedColumnSet table)
Creates a row-type for a given table. |
protected RelNode |
decorrelate(SqlNode query,
RelNode rootRel)
|
private void |
definePackageName()
|
void |
disableStatementCaching()
Disables caching for the statement |
void |
enablePartialImplementation()
Tells this statement not to throw an exception if optimizer can't find a valid physical plan. |
(package private) RexNode |
expandInvocationExpression(SqlNode sqlExpr,
FarragoRoutineInvocation invocation)
|
protected RelNode |
expandView(RelDataType rowType,
String queryString)
Returns a relational expression which is to be substituted for an access to a SQL view. |
void |
finalizeRelMetadata(RelNode rootRel)
|
protected RelNode |
flattenTypes(RelNode rootRel,
boolean restructure)
|
List<SqlMoniker> |
getAllSchemaObjectNames(List<String> names)
Gets schema object names as specified. |
protected String |
getClassRoot()
|
protected String |
getCompilerClassName()
|
Variable |
getConnectionVariable()
|
FarragoTypeFactory |
getFarragoTypeFactory()
|
FennelDbHandle |
getFennelDbHandle()
|
private FarragoMedColumnSet |
getForeignTableFromNamespace(FarragoSessionResolvedObject<CwmNamedColumnSet> resolved)
|
protected OJPreparingStmt.Argument[] |
getImplementingArgs()
|
protected ClassDeclaration |
getImplementingClassDecl()
|
FarragoSessionIndexMap |
getIndexMap()
|
protected Map<String,RelDataType> |
getIterCalcTypeMap()
|
protected String |
getJavaRoot()
|
RelDataType |
getNamedType(SqlIdentifier typeName)
Finds a user-defined type with the given name, possibly qualified. |
protected File |
getPackageDir()
|
protected RelDataType |
getParamRowType()
|
FarragoPreparingStmt |
getParentStmt()
|
FarragoSessionPlanner |
getPlanner()
|
protected Map<String,String> |
getReferencedObjectTimestampMap()
|
JavaRelImplementor |
getRelImplementor(RexBuilder rexBuilder)
Protected method to allow subclasses to override construction of JavaRelImplementor. |
RelOptCluster |
getRelOptCluster()
|
RelOptSchema |
getRelOptSchema()
Returns the schema underlying this connection. |
FarragoRepos |
getRepos()
|
protected Map<String,RelDataType> |
getResultSetTypeMap()
|
FarragoSessionStmtContext |
getRootStmtContext()
|
FarragoUserDefinedRoutineLookup |
getRoutineLookup()
|
String |
getSchemaName()
Returns the name of the current schema. |
FarragoSession |
getSession()
|
String |
getSql()
|
SqlOperatorTable |
getSqlOperatorTable()
|
SqlToRelConverter |
getSqlToRelConverter()
|
protected SqlToRelConverter |
getSqlToRelConverter(SqlValidator validator,
RelOptConnection connection)
Protected method to allow subclasses to override construction of SqlToRelConverter. |
SqlValidator |
getSqlValidator()
|
FarragoSessionStmtValidator |
getStmtValidator()
|
SqlValidatorTable |
getTable(String[] names)
Finds a table with the given name, possibly qualified. |
protected TableAccessMap |
getTableAccessMap()
|
RelOptTable |
getTableForMember(String[] names)
Retrieves a RelOptTable based upon a member access. |
RelOptTable |
getTableForMember(String[] names,
String datasetName,
boolean[] usedDataset)
Retrieves a RelOptTable based upon a member access, using a
sample dataset if it exists. |
protected String |
getTempClassName()
|
protected String |
getTempMethodName()
|
protected String |
getTempPackageName()
|
protected List<FarragoTransformDef> |
getTransformDefs()
|
RelDataTypeFactory |
getTypeFactory()
Returns the type factory used to generate
types for this schema. |
boolean |
hasSqlValidator()
|
protected FarragoSessionExecutableStmt |
implement(PreparedResult preparedResult)
|
FarragoSessionExecutableStmt |
implement(RelNode rootRel,
SqlKind sqlKind,
boolean logical)
Implements a logical or physical query plan but does not execute it. |
protected void |
initClassDecl()
|
private void |
initializeQueryColumnSet(RelOptTable relOptTable,
CwmNamedColumnSet cwmColumnSet)
|
boolean |
isExpandingDefinition()
|
RelOptTable |
loadColumnSet(SqlIdentifier name)
Looks up a named ColumnSet and loads its optimizer representation. |
private FarragoMedDataServer |
loadDataServerFromCache(FemDataServer femServer)
|
void |
mapIterCalcType(String iterCalcName,
RelDataType rowType)
|
void |
mapResultSetType(String resultSetName,
RelDataType rowType)
|
boolean |
mayCacheImplementation()
Test if the implementation may be saved for reuse. |
protected FarragoRelImplementor |
newRelImplementor(RexBuilder rexBuilder)
|
protected SqlValidatorTable |
newValidatorTable(String[] qualifiedName,
RelDataType rowType,
SqlAccessType allowedAccess,
ModalityType modality)
Factory method, creates a table. |
protected RelNode |
optimize(RelDataType rowType,
RelNode rootRel)
Optimizes a query plan. |
void |
postValidate(SqlNode sqlNode)
Performs post-validation work after SqlValidator has been called. |
void |
preImplement()
Sets up the environment the FarragoPreparingStmt needs in order to implement (i.e. |
FarragoSessionExecutableStmt |
prepare(SqlNode sqlNode,
SqlNode sqlNodeOriginal)
Prepares (translates and implements) a parsed query or DML statement, but does not execute it. |
protected void |
prepareForCompilation()
|
void |
registerRules(RelOptPlanner planner)
Registers all of the rules supported by this schema. |
void |
setDmlValidation(SqlIdentifier target,
PrivilegedAction action)
|
void |
setParentStmt(FarragoPreparingStmt parentStmt)
Sets the parent FarragoPreparingStmt corresponding to this statement. |
void |
setPlanner(FarragoSessionPlanner planner)
|
protected boolean |
shouldAlwaysWriteJavaFile()
|
protected boolean |
shouldSetConnectionInfo()
|
protected boolean |
treeContainsJava(RelNode rootRel)
Determines if the RelNode tree contains Java RelNodes. |
protected void |
validatePlan(RelNode rel,
RelTraitSet desiredTraits)
|
Methods inherited from class org.eigenbase.oj.stmt.OJPreparingStmt |
---|
addDecl, bindArgument, createCompiler, getDesiredRootTraitSet, getEnvironment, init, initSub, prepareSql, prepareSql, prepareSql, setResultCallingConvention |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger dynamicTracer
private static final Logger streamGraphTracer
private static final Logger planDumpTracer
private static final AtomicLong idGen
private final String sql
private final FarragoSessionStmtValidator stmtValidator
private boolean needRestore
protected SqlToRelConverter sqlToRelConverter
private OJClass savedDeclarer
private FarragoAllocation javaCodeDir
protected SqlValidatorImpl sqlValidator
private final Set<CwmModelElement> directDependencies
protected final Set<CwmModelElement> allDependencies
private final Set<URL> jarUrlSet
protected SqlOperatorTable sqlOperatorTable
private final FarragoUserDefinedRoutineLookup routineLookup
private int expansionDepth
private RelDataType originalRowType
private SqlIdentifier dmlTarget
private PrivilegedAction dmlAction
private TableAccessMap tableAccessMap
protected ChainedRelMetadataProvider relMetadataProvider
private boolean allowPartialImplementation
private final Map<String,RelDataType> resultSetTypeMap
private final Map<String,RelDataType> iterCalcTypeMap
private boolean cachingDisabled
private FarragoPreparingStmt parentStmt
private final FarragoSessionStmtContext rootStmtContext
private String packageName
private File packageDir
private File classesRoot
private ClassDeclaration implementingClassDecl
private OJPreparingStmt.Argument[] implementingArgs
private Set<String> loadedServerClassNameSet
private FarragoSessionPlanner planner
private FarragoRelImplementor relImplementor
Constructor Detail |
---|
public FarragoPreparingStmt(FarragoSessionStmtContext rootStmtContext, FarragoSessionStmtValidator stmtValidator, String sql)
rootStmtContext
- the root statement contextstmtValidator
- generic stmt validatorsql
- SQL text of statement being preparedMethod Detail |
---|
public boolean mayCacheImplementation()
FarragoSessionPreparingStmt
mayCacheImplementation
in interface FarragoSessionPreparingStmt
public void disableStatementCaching()
FarragoSessionPreparingStmt
disableStatementCaching
in interface FarragoSessionPreparingStmt
public FarragoSessionStmtContext getRootStmtContext()
getRootStmtContext
in interface FarragoSessionPreparingStmt
public FarragoSessionStmtValidator getStmtValidator()
getStmtValidator
in interface FarragoSessionPreparingStmt
public FarragoPreparingStmt getParentStmt()
public void setParentStmt(FarragoPreparingStmt parentStmt)
parentStmt
- the parent of this statementpublic void setPlanner(FarragoSessionPlanner planner)
public void enablePartialImplementation()
public FarragoSessionPlanner getPlanner()
public SqlOperatorTable getSqlOperatorTable()
getSqlOperatorTable
in interface FarragoSessionPreparingStmt
public boolean hasSqlValidator()
public SqlValidator getSqlValidator()
getSqlValidator
in interface FarragoSessionPreparingStmt
public FarragoSessionExecutableStmt prepare(SqlNode sqlNode, SqlNode sqlNodeOriginal)
FarragoSessionPreparingStmt
prepare
in interface FarragoSessionPreparingStmt
sqlNode
- top-level node of parsed statementsqlNodeOriginal
- original form of sqlNode if it has been rewritten
by validation; otherwise, same as sqlNode
public void preImplement()
FarragoSessionPreparingStmt
FarragoSessionPreparingStmt.prepare(org.eigenbase.sql.SqlNode, org.eigenbase.sql.SqlNode)
) this happens automatically. But when
implementing a query presented as a query plan (by calling FarragoSessionPreparingStmt.implement(org.eigenbase.rel.RelNode, org.eigenbase.sql.SqlKind, boolean)
), you must call this method first, even before constructing
the query plan.
preImplement
in interface FarragoSessionPreparingStmt
protected void initClassDecl()
protected ClassDeclaration getImplementingClassDecl()
protected OJPreparingStmt.Argument[] getImplementingArgs()
protected TableAccessMap getTableAccessMap()
protected Map<String,RelDataType> getResultSetTypeMap()
protected Map<String,RelDataType> getIterCalcTypeMap()
protected List<FarragoTransformDef> getTransformDefs()
public void postValidate(SqlNode sqlNode)
FarragoSessionPreparingStmt
postValidate
in interface FarragoSessionPreparingStmt
sqlNode
- output of SqlValidatorpublic FarragoSessionExecutableStmt implement(RelNode rootRel, SqlKind sqlKind, boolean logical)
FarragoSessionPreparingStmt
FarragoSessionPreparingStmt.preImplement()
first, in fact before constructing the
query plan.
implement
in interface FarragoSessionPreparingStmt
rootRel
- root of query plan (relational expression)sqlKind
- SqlKind for the relational expression: only
SqlKind.Explain and SqlKind.Dml are special cases.logical
- true for a logical query plan (still needs to be
optimized), false for a physical plan.
public FarragoUserDefinedRoutineLookup getRoutineLookup()
void addJarUrl(String jarUrl)
protected void prepareForCompilation()
private void definePackageName()
protected Class compileClass(String packageName, String className, String source)
OJPreparingStmt
compileClass
in class OJPreparingStmt
packageName
- package name, if null the className must be fully
qualifiedclassName
- simple class name unless packageName is nullsource
- source code for the class
protected BoundMethod compileAndBind(ClassDeclaration decl, ParseTree parseTree, OJPreparingStmt.Argument[] arguments)
compileAndBind
in class OJPreparingStmt
protected boolean treeContainsJava(RelNode rootRel)
OJPreparingStmt
treeContainsJava
in class OJPreparingStmt
rootRel
- root of the RelNode tree
protected FarragoSessionExecutableStmt implement(PreparedResult preparedResult)
public void analyzeSql(SqlNode sqlNode, FarragoSessionAnalyzedSql analyzedSql)
FarragoSessionPreparingStmt
analyzeSql
in interface FarragoSessionPreparingStmt
sqlNode
- SQL expression to be analyzedanalyzedSql
- receives analysis resultvoid analyzeRoutineDependencies(SqlNode sqlNode)
protected Map<String,String> getReferencedObjectTimestampMap()
public SqlToRelConverter getSqlToRelConverter()
getSqlToRelConverter
in interface FarragoSessionPreparingStmt
public RelOptCluster getRelOptCluster()
getRelOptCluster
in interface FarragoSessionPreparingStmt
protected RelNode flattenTypes(RelNode rootRel, boolean restructure)
flattenTypes
in class OJPreparingStmt
protected RelNode decorrelate(SqlNode query, RelNode rootRel)
decorrelate
in class OJPreparingStmt
protected RelNode optimize(RelDataType rowType, RelNode rootRel)
OJPreparingStmt
optimize
in class OJPreparingStmt
rowType
- logical row type of relational expression (before
struct fields are flattened, or field names are renamed for uniqueness)rootRel
- root of a relational expression
protected void validatePlan(RelNode rel, RelTraitSet desiredTraits) throws FarragoPreparingStmt.InvalidPlanException
FarragoPreparingStmt.InvalidPlanException
public void finalizeRelMetadata(RelNode rootRel)
protected RelDataType getParamRowType()
public void closeAllocation()
ClosableAllocation
closeAllocation
in interface ClosableAllocation
protected RelNode expandView(RelDataType rowType, String queryString)
rowType
- Row type of the viewqueryString
- Body of the view
RexNode expandInvocationExpression(SqlNode sqlExpr, FarragoRoutineInvocation invocation)
public void setDmlValidation(SqlIdentifier target, PrivilegedAction action)
public void clearDmlValidation()
public boolean isExpandingDefinition()
protected SqlToRelConverter getSqlToRelConverter(SqlValidator validator, RelOptConnection connection)
OJPreparingStmt
getSqlToRelConverter
in class OJPreparingStmt
public JavaRelImplementor getRelImplementor(RexBuilder rexBuilder)
OJPreparingStmt
getRelImplementor
in interface FarragoSessionPreparingStmt
getRelImplementor
in class OJPreparingStmt
rexBuilder
- RexBuilder to use for constructing row expressions
protected FarragoRelImplementor newRelImplementor(RexBuilder rexBuilder)
public FarragoRepos getRepos()
getRepos
in interface FarragoSessionPreparingStmt
public FennelDbHandle getFennelDbHandle()
getFennelDbHandle
in interface FarragoSessionPreparingStmt
public FarragoTypeFactory getFarragoTypeFactory()
getFarragoTypeFactory
in interface FarragoSessionPreparingStmt
public FarragoSessionIndexMap getIndexMap()
getIndexMap
in interface FarragoSessionPreparingStmt
public FarragoSession getSession()
getSession
in interface FarragoSessionPreparingStmt
public String getSql()
getSql
in interface FarragoSessionPreparingStmt
public RelOptSchema getRelOptSchema()
RelOptConnection
public static Schema
getRelOptSchemaStatic()
.
getRelOptSchema
in interface RelOptConnection
getRelOptSchema
in class OJPreparingStmt
public Object contentsAsArray(String qualifier, String tableName)
RelOptConnection
tableName
as
an array; in practice, it is a placeholder recognized by the optimizer to
do something much more efficient. This involves calling RelOptSchema.getTableForMember(java.lang.String[])
(qualifier,tableName).RelOptTable.toRel(org.eigenbase.relopt.RelOptCluster, org.eigenbase.relopt.RelOptConnection)
(cluster, exp)
.
contentsAsArray
in interface RelOptConnection
public RelOptTable loadColumnSet(SqlIdentifier name)
FarragoSessionPreparingStmt
loadColumnSet
in interface FarragoSessionPreparingStmt
name
- name of ColumnSet
public RelOptTable getTableForMember(String[] names)
RelOptSchema
RelOptTable
based upon a member access.
For example, the Saffron expression salesSchema.emps
would be resolved using a call to salesSchema.getTableForMember(new
String[]{"emps" })
.
Note that name.length is only greater than 1 for queries originating from JDBC.
getTableForMember
in interface RelOptSchema
public RelOptTable getTableForMember(String[] names, String datasetName, boolean[] usedDataset)
RelOptSchemaWithSampling
RelOptTable
based upon a member access, using a
sample dataset if it exists.
getTableForMember
in interface RelOptSchemaWithSampling
names
- Compound name of tabledatasetName
- Name of sample dataset to substitute, if it exists;
null to not look for a sampleusedDataset
- Output parameter which is set to true if a sample
dataset is found; may be null
private void initializeQueryColumnSet(RelOptTable relOptTable, CwmNamedColumnSet cwmColumnSet)
private FarragoMedColumnSet getForeignTableFromNamespace(FarragoSessionResolvedObject<CwmNamedColumnSet> resolved)
private FarragoMedDataServer loadDataServerFromCache(FemDataServer femServer)
public RelDataTypeFactory getTypeFactory()
RelOptSchema
type factory
used to generate
types for this schema.
getTypeFactory
in interface RelOptSchema
public void registerRules(RelOptPlanner planner)
RelOptSchema
RelOptPlanner.registerSchema(org.eigenbase.relopt.RelOptSchema)
.
registerRules
in interface RelOptSchema
public SqlValidatorTable getTable(String[] names)
SqlValidatorCatalogReader
getTable
in interface SqlValidatorCatalogReader
names
- Name of table
protected RelDataType createTableRowType(CwmNamedColumnSet table)
table
- Repository table
protected SqlValidatorTable newValidatorTable(String[] qualifiedName, RelDataType rowType, SqlAccessType allowedAccess, ModalityType modality)
public RelDataType getNamedType(SqlIdentifier typeName)
SqlValidatorCatalogReader
NOTE jvs 12-Feb-2005: the reason this method is defined here instead of on RelDataTypeFactory is that it has to take into account context-dependent information such as SQL schema path, whereas a type factory is context-independent.
getNamedType
in interface SqlValidatorCatalogReader
typeName
- Name of type
public List<SqlMoniker> getAllSchemaObjectNames(List<String> names)
SqlValidatorCatalogReader
getAllSchemaObjectNames
in interface SqlValidatorCatalogReader
names
- the array contains either 2 elements representing a
partially qualified object name in the format of 'schema.object', or an
unqualified name in the format of 'object'
public String getSchemaName()
SqlValidatorCatalogReader
getSchemaName
in interface SqlValidatorCatalogReader
public void addDependency(CwmModelElement supplier, PrivilegedAction action)
public void mapResultSetType(String resultSetName, RelDataType rowType)
public void mapIterCalcType(String iterCalcName, RelDataType rowType)
public Variable getConnectionVariable()
protected String getCompilerClassName()
getCompilerClassName
in class OJPreparingStmt
protected boolean shouldSetConnectionInfo()
shouldSetConnectionInfo
in class OJPreparingStmt
protected boolean shouldAlwaysWriteJavaFile()
shouldAlwaysWriteJavaFile
in class OJPreparingStmt
protected File getPackageDir()
protected String getClassRoot()
getClassRoot
in class OJPreparingStmt
protected String getJavaRoot()
getJavaRoot
in class OJPreparingStmt
protected String getTempPackageName()
getTempPackageName
in class OJPreparingStmt
protected String getTempClassName()
getTempClassName
in class OJPreparingStmt
protected String getTempMethodName()
getTempMethodName
in class OJPreparingStmt
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |