com.lucidera.farrago
Class LucidDbSessionPersonality

java.lang.Object
  extended by net.sf.farrago.defimpl.FarragoDefaultSessionPersonality
      extended by com.lucidera.farrago.LucidDbSessionPersonality
All Implemented Interfaces:
FarragoSessionPersonality, FarragoStreamFactoryProvider

public class LucidDbSessionPersonality
extends FarragoDefaultSessionPersonality

Customizes Farrago session personality with LucidDB behavior.

Version:
$Id: //open/dev/farrago/src/com/lucidera/farrago/LucidDbSessionPersonality.java#72 $
Author:
John V. Sichi

Nested Class Summary
private static class LucidDbSessionPersonality.LucidDbPlanner
           
 
Nested classes/interfaces inherited from class net.sf.farrago.defimpl.FarragoDefaultSessionPersonality
FarragoDefaultSessionPersonality.ParamValidator
 
Field Summary
private  boolean defaultLucidDb
          If true, this session's underlying default personality is LucidDb, as opposed to one that was switched from some other personality to LucidDb.
private  boolean enableIndexOnlyScans
          If true, enable index only scan rules
static String ERROR_LOG_MAX
           
static String ERROR_LOG_MAX_DEFAULT
           
static String ERROR_MAX
           
static String ERROR_MAX_DEFAULT
           
static String ETL_ACTION_ID
           
static String ETL_ACTION_ID_DEFAULT
           
static String ETL_PROCESS_ID
           
static String ETL_PROCESS_ID_DEFAULT
           
static String LAST_ROWS_REJECTED
           
static String LAST_ROWS_REJECTED_DEFAULT
           
static String LAST_UPSERT_ROWS_INSERTED
           
static String LAST_UPSERT_ROWS_INSERTED_DEFAULT
           
static String LOG_DIR
           
static String[] LOG_DIR_DEFAULT
           
static String REDUCE_NON_CORRELATED_SUBQUERIES_LUCIDDB_DFLT
           
 
Fields inherited from class net.sf.farrago.defimpl.FarragoDefaultSessionPersonality
CACHE_STATEMENTS, CACHE_STATEMENTS_DEFAULT, database, DEGREE_OF_PARALLELISM, DEGREE_OF_PARALLELISM_DEFAULT, LABEL, LABEL_DEFAULT, paramValidator, REDUCE_NON_CORRELATED_SUBQUERIES, REDUCE_NON_CORRELATED_SUBQUERIES_FARRAGO_DEFAULT, SQUEEZE_JDBC_NUMERIC, SQUEEZE_JDBC_NUMERIC_DEFAULT, VALIDATE_DDL_ON_PREPARE, VALIDATE_DDL_ON_PREPARE_DEFAULT
 
Constructor Summary
protected LucidDbSessionPersonality(FarragoDbSession session, FarragoSessionPersonality defaultPersonality, boolean enableIndexOnlyScans)
           
 
Method Summary
private  void applyPushDownFilterRules(HepProgramBuilder builder)
          Applies rules that push filters past various RelNodes.
private  void applyPushDownProjectRules(HepProgramBuilder builder)
          Applies rules that push projects past various RelNodes.
private  HepProgram createHepProgram(boolean fennelEnabled, CalcVirtualMachine calcVM, Collection<RelOptRule> medPluginRules, boolean alterTable)
           
 FarragoSessionVariables createInheritedSessionVariables(FarragoSessionVariables variables)
          Creates a set of session variables for use in a cloned session.
 String getDefaultLocalDataServerName(FarragoSessionStmtValidator stmtValidator)
          Gets the name of the local data server to use for tables when none is specified by CREATE TABLE.
 void getRowCounts(ResultSet resultSet, List<Long> rowCounts, TableModificationRelBase.Operation tableModOp)
          Gives this personality the opportunity to retrieve rowcount information returned by a DML operation.
 SqlOperatorTable getSqlOperatorTable(FarragoSessionPreparingStmt preparingStmt)
          Gets the SQL operator table to use for validating a statement.
 boolean isAlterTableAddColumnIncremental()
          Tests whether this session personality implements ALTER TABLE ADD COLUMN in an incremental fashion (only adding on the new column as opposed to reformatting existing rows).
 boolean isDefaultLucidDbPersonality()
           
 void loadDefaultSessionVariables(FarragoSessionVariables variables)
          Loads variables from the session personality into a session variables object.
private  FarragoSessionPlanner newHepPlanner(FarragoSessionPreparingStmt stmt)
           
 FarragoSessionPlanner newPlanner(FarragoSessionPreparingStmt stmt, boolean init)
          Creates a new planner.
 FarragoSessionPreparingStmt newPreparingStmt(FarragoSessionStmtContext stmtContext, FarragoSessionStmtValidator stmtValidator)
          Creates a new preparing statement tied to this session and its underlying database.
 FarragoSessionRuntimeContext newRuntimeContext(FarragoSessionRuntimeParams params)
          Creates a new runtime context.
 RelDataTypeFactory newTypeFactory(FarragoRepos repos)
          Creates a new type factory.
 void registerRelMetadataProviders(ChainedRelMetadataProvider chain)
          Gives this personality a chance to register one or more RelMetadataProviders in the chain which will be used to answer relational expression metadata queries during optimization.
 void resetRowCounts(FemAbstractColumnSet table)
          Gives this personality the opportunity to reset rowcount information in the catalog tables for a specified table
 boolean shouldReplacePreserveOriginalSql()
          Tests whether this personality wants original SQL to be preserved for dependent objects where possible during the revalidation triggered by CREATE OR REPLACE.
 boolean supportsFeature(org.eigenbase.resgen.ResourceDefinition feature)
          Tests whether a feature is supported in this personality.
 void updateIndexRoot(FemLocalIndex index, FarragoDataWrapperCache wrapperCache, FarragoSessionIndexMap baseIndexMap, Long newRoot)
          Gives the personality the opportunity to update an index root page when the index is rebuilt
 long updateRowCounts(FarragoSession session, List<String> tableName, List<Long> rowCounts, TableModificationRelBase.Operation tableModOp, FarragoSessionRuntimeContext runningContext)
          Gives this personality the opportunity to update rowcount information in the catalog tables for a specified table as a result of a particular DML operation.
 
Methods inherited from class net.sf.farrago.defimpl.FarragoDefaultSessionPersonality
addRowCount, defineDdlHandlers, definePlannerListeners, definePrivileges, getOJRexImplementorTable, getRuntimeContextClass, initPreparingStmt, isJavaUdxRestartable, isSupportedType, newComponentImpl, newDdlValidator, newJmiQueryProcessor, newParser, newPreparingStmt, newPreparingStmt, registerStreamFactories, validateSessionVariable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_DIR

public static final String LOG_DIR
See Also:
Constant Field Values

LOG_DIR_DEFAULT

public static final String[] LOG_DIR_DEFAULT

ETL_PROCESS_ID

public static final String ETL_PROCESS_ID
See Also:
Constant Field Values

ETL_PROCESS_ID_DEFAULT

public static final String ETL_PROCESS_ID_DEFAULT

ETL_ACTION_ID

public static final String ETL_ACTION_ID
See Also:
Constant Field Values

ETL_ACTION_ID_DEFAULT

public static final String ETL_ACTION_ID_DEFAULT

ERROR_MAX

public static final String ERROR_MAX
See Also:
Constant Field Values

ERROR_MAX_DEFAULT

public static final String ERROR_MAX_DEFAULT
See Also:
Constant Field Values

ERROR_LOG_MAX

public static final String ERROR_LOG_MAX
See Also:
Constant Field Values

ERROR_LOG_MAX_DEFAULT

public static final String ERROR_LOG_MAX_DEFAULT

LAST_UPSERT_ROWS_INSERTED

public static final String LAST_UPSERT_ROWS_INSERTED
See Also:
Constant Field Values

LAST_UPSERT_ROWS_INSERTED_DEFAULT

public static final String LAST_UPSERT_ROWS_INSERTED_DEFAULT

LAST_ROWS_REJECTED

public static final String LAST_ROWS_REJECTED
See Also:
Constant Field Values

LAST_ROWS_REJECTED_DEFAULT

public static final String LAST_ROWS_REJECTED_DEFAULT

REDUCE_NON_CORRELATED_SUBQUERIES_LUCIDDB_DFLT

public static final String REDUCE_NON_CORRELATED_SUBQUERIES_LUCIDDB_DFLT
See Also:
Constant Field Values

defaultLucidDb

private boolean defaultLucidDb
If true, this session's underlying default personality is LucidDb, as opposed to one that was switched from some other personality to LucidDb. Note that this will still be true if the underlying personality is LucidDb, but a variation of the default LucidDb personality is used.


enableIndexOnlyScans

private boolean enableIndexOnlyScans
If true, enable index only scan rules

Constructor Detail

LucidDbSessionPersonality

protected LucidDbSessionPersonality(FarragoDbSession session,
                                    FarragoSessionPersonality defaultPersonality,
                                    boolean enableIndexOnlyScans)
Method Detail

isDefaultLucidDbPersonality

public boolean isDefaultLucidDbPersonality()
Returns:
true if the underlying personality is a LucidDB personality

getDefaultLocalDataServerName

public String getDefaultLocalDataServerName(FarragoSessionStmtValidator stmtValidator)
Description copied from interface: FarragoSessionPersonality
Gets the name of the local data server to use for tables when none is specified by CREATE TABLE.

Specified by:
getDefaultLocalDataServerName in interface FarragoSessionPersonality
Overrides:
getDefaultLocalDataServerName in class FarragoDefaultSessionPersonality
Parameters:
stmtValidator - validator for statement being prepared
Returns:
server name

isAlterTableAddColumnIncremental

public boolean isAlterTableAddColumnIncremental()
Description copied from interface: FarragoSessionPersonality
Tests whether this session personality implements ALTER TABLE ADD COLUMN in an incremental fashion (only adding on the new column as opposed to reformatting existing rows). For example, a column store can just create a new vertical partition; a smart row store may be able to transform old tuple formats during queries by filling in default values on the fly.

Specified by:
isAlterTableAddColumnIncremental in interface FarragoSessionPersonality
Overrides:
isAlterTableAddColumnIncremental in class FarragoDefaultSessionPersonality
Returns:
true iff the incremental optimization is implemented

getSqlOperatorTable

public SqlOperatorTable getSqlOperatorTable(FarragoSessionPreparingStmt preparingStmt)
Description copied from interface: FarragoSessionPersonality
Gets the SQL operator table to use for validating a statement.

Specified by:
getSqlOperatorTable in interface FarragoSessionPersonality
Overrides:
getSqlOperatorTable in class FarragoDefaultSessionPersonality
Parameters:
preparingStmt - statement being prepared
Returns:
table of builtin SQL operators and functions to use for validation; user-defined functions are not included here

supportsFeature

public boolean supportsFeature(org.eigenbase.resgen.ResourceDefinition feature)
Description copied from interface: FarragoSessionPersonality
Tests whether a feature is supported in this personality.

Specified by:
supportsFeature in interface FarragoSessionPersonality
Overrides:
supportsFeature in class FarragoDefaultSessionPersonality
Parameters:
feature - EigenbaseResource resource definition representing the feature to be tested
Returns:
true iff feature is supported

shouldReplacePreserveOriginalSql

public boolean shouldReplacePreserveOriginalSql()
Description copied from interface: FarragoSessionPersonality
Tests whether this personality wants original SQL to be preserved for dependent objects where possible during the revalidation triggered by CREATE OR REPLACE.

Specified by:
shouldReplacePreserveOriginalSql in interface FarragoSessionPersonality
Overrides:
shouldReplacePreserveOriginalSql in class FarragoDefaultSessionPersonality
Returns:
true iff an attempt should be made to preserve original SQL

newPlanner

public FarragoSessionPlanner newPlanner(FarragoSessionPreparingStmt stmt,
                                        boolean init)
Description copied from interface: FarragoSessionPersonality
Creates a new planner.

Specified by:
newPlanner in interface FarragoSessionPersonality
Overrides:
newPlanner in class FarragoDefaultSessionPersonality
Parameters:
stmt - stmt on whose behalf planner will operate
init - whether to initialize default rules in new planner
Returns:
new planner

registerRelMetadataProviders

public void registerRelMetadataProviders(ChainedRelMetadataProvider chain)
Description copied from interface: FarragoSessionPersonality
Gives this personality a chance to register one or more RelMetadataProviders in the chain which will be used to answer relational expression metadata queries during optimization. Personalities which define their own relational expressions will generally need to supply corresponding metadata providers.

Specified by:
registerRelMetadataProviders in interface FarragoSessionPersonality
Overrides:
registerRelMetadataProviders in class FarragoDefaultSessionPersonality
Parameters:
chain - receives personality's custom providers, if any

newHepPlanner

private FarragoSessionPlanner newHepPlanner(FarragoSessionPreparingStmt stmt)

createHepProgram

private HepProgram createHepProgram(boolean fennelEnabled,
                                    CalcVirtualMachine calcVM,
                                    Collection<RelOptRule> medPluginRules,
                                    boolean alterTable)

applyPushDownFilterRules

private void applyPushDownFilterRules(HepProgramBuilder builder)
Applies rules that push filters past various RelNodes.

Parameters:
builder - HEP program builder

applyPushDownProjectRules

private void applyPushDownProjectRules(HepProgramBuilder builder)
Applies rules that push projects past various RelNodes.

Parameters:
builder - HEP program builder

loadDefaultSessionVariables

public void loadDefaultSessionVariables(FarragoSessionVariables variables)
Description copied from interface: FarragoSessionPersonality
Loads variables from the session personality into a session variables object. Each personality uses on its own variables. This method allows the personality to declare its variables and set default values for them. If any variables already have values, then they will not be overwritten.

This method should be called when initializing a new session or when loading a new session personality for an existing session. This method "leaves a mark", as it has the side effect of permanently updating the session variables. Even if the session personality is swapped out, the changes will remain.

Specified by:
loadDefaultSessionVariables in interface FarragoSessionPersonality
Overrides:
loadDefaultSessionVariables in class FarragoDefaultSessionPersonality
Parameters:
variables - the session variables object

createInheritedSessionVariables

public FarragoSessionVariables createInheritedSessionVariables(FarragoSessionVariables variables)
Description copied from interface: FarragoSessionPersonality
Creates a set of session variables for use in a cloned session. Default implementation is to just return variables.cloneVariables(), but personalities may override, e.g. to reset some variables which should never be inherited.

Specified by:
createInheritedSessionVariables in interface FarragoSessionPersonality
Overrides:
createInheritedSessionVariables in class FarragoDefaultSessionPersonality
Parameters:
variables - set of variables to be inherited
Returns:
result of variable inheritance

newRuntimeContext

public FarragoSessionRuntimeContext newRuntimeContext(FarragoSessionRuntimeParams params)
Description copied from interface: FarragoSessionPersonality
Creates a new runtime context. The object returned must be assignable to the result of getRuntimeContextClass().

Specified by:
newRuntimeContext in interface FarragoSessionPersonality
Overrides:
newRuntimeContext in class FarragoDefaultSessionPersonality
Parameters:
params - context initialization parameters
Returns:
new context

newPreparingStmt

public FarragoSessionPreparingStmt newPreparingStmt(FarragoSessionStmtContext stmtContext,
                                                    FarragoSessionStmtValidator stmtValidator)
Description copied from interface: FarragoSessionPersonality
Creates a new preparing statement tied to this session and its underlying database. Used to construct and implement an internal query plan.

Specified by:
newPreparingStmt in interface FarragoSessionPersonality
Overrides:
newPreparingStmt in class FarragoDefaultSessionPersonality
Parameters:
stmtContext - embracing stmt context, if any; otherwise, null.
stmtValidator - generic stmt validator
Returns:
a new FarragoSessionPreparingStmt.

newTypeFactory

public RelDataTypeFactory newTypeFactory(FarragoRepos repos)
Description copied from interface: FarragoSessionPersonality
Creates a new type factory.

Specified by:
newTypeFactory in interface FarragoSessionPersonality
Overrides:
newTypeFactory in class FarragoDefaultSessionPersonality
Parameters:
repos - a repository containing Farrago metadata
Returns:
a new type factory

getRowCounts

public void getRowCounts(ResultSet resultSet,
                         List<Long> rowCounts,
                         TableModificationRelBase.Operation tableModOp)
                  throws SQLException
Description copied from interface: FarragoSessionPersonality
Gives this personality the opportunity to retrieve rowcount information returned by a DML operation.

Specified by:
getRowCounts in interface FarragoSessionPersonality
Overrides:
getRowCounts in class FarragoDefaultSessionPersonality
Parameters:
resultSet - result set returned by DML operation
rowCounts - list of rowcounts returned by the DML operation
tableModOp - table modification operation that caused the rowcounts to be modified
Throws:
SQLException

updateRowCounts

public long updateRowCounts(FarragoSession session,
                            List<String> tableName,
                            List<Long> rowCounts,
                            TableModificationRelBase.Operation tableModOp,
                            FarragoSessionRuntimeContext runningContext)
Description copied from interface: FarragoSessionPersonality
Gives this personality the opportunity to update rowcount information in the catalog tables for a specified table as a result of a particular DML operation.

Specified by:
updateRowCounts in interface FarragoSessionPersonality
Overrides:
updateRowCounts in class FarragoDefaultSessionPersonality
Parameters:
session - session that needs to update rowcounts
tableName - fully qualified table name for which rowcounts will be updated
rowCounts - list of row counts returned by the DML statement
tableModOp - table modification operation that caused the rowcounts to be modified
runningContext - the currently running session context.
Returns:
number of rows affected by the DML operation

resetRowCounts

public void resetRowCounts(FemAbstractColumnSet table)
Description copied from interface: FarragoSessionPersonality
Gives this personality the opportunity to reset rowcount information in the catalog tables for a specified table

Specified by:
resetRowCounts in interface FarragoSessionPersonality
Overrides:
resetRowCounts in class FarragoDefaultSessionPersonality
Parameters:
table - column set corresponding to table

updateIndexRoot

public void updateIndexRoot(FemLocalIndex index,
                            FarragoDataWrapperCache wrapperCache,
                            FarragoSessionIndexMap baseIndexMap,
                            Long newRoot)
Description copied from interface: FarragoSessionPersonality
Gives the personality the opportunity to update an index root page when the index is rebuilt

Specified by:
updateIndexRoot in interface FarragoSessionPersonality
Overrides:
updateIndexRoot in class FarragoDefaultSessionPersonality
Parameters:
index - index whose root is being updated
wrapperCache - cache for looking up data wrappers
baseIndexMap - map for managing index storage
newRoot - index's new root page