|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.util.CompoundClosableAllocation net.sf.farrago.util.FarragoCompoundAllocation net.sf.farrago.runtime.FarragoRuntimeContext
public class FarragoRuntimeContext
FarragoRuntimeContext defines runtime support routines needed by generated code.
Nested Class Summary | |
---|---|
private static class |
FarragoRuntimeContext.StreamOwner
Inner class for taking care of closing streams without deallocating them. |
Fields inherited from class org.eigenbase.util.CompoundClosableAllocation |
---|
allocations |
Constructor Summary | |
---|---|
FarragoRuntimeContext(FarragoSessionRuntimeParams params)
Creates a new FarragoRuntimeContext. |
Method Summary | |
---|---|
void |
addAllocation(ClosableAllocation allocation)
Assigns ownership of a ClosableAllocation to this owner. |
void |
cancel()
Requests cancellation of this execution (either for asynchronous abort, or because execution has ended). |
void |
checkCancel()
Throws an exception if execution has been canceled. |
void |
checkNotNull(String targetName,
NullableValue nullableValue)
Called when a nullable value is cast to a NOT NULL type. |
void |
checkNotNull(String targetName,
Object obj)
Called when a nullable value is cast to a NOT NULL type. |
void |
closeAllocation()
Closes this object. |
private void |
closeStreamGraph()
|
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. |
void |
detachMdrSession()
Detaches the current MDR session from the running thread. |
Object |
dummyArray(Object[] dummyArray)
Stupid helper for code generated by FennelMultipleRel . |
Object |
dummyPair(Object dummy1,
Object dummy2)
Stupid helper for code generated by FennelDoubleRel . |
FarragoTransform |
findFarragoTransform(String key)
|
boolean |
forgetAllocation(ClosableAllocation allocation)
Forgets an allocation without closing it. |
String |
getContextVariable_CURRENT_CATALOG()
Called from generated code. |
Date |
getContextVariable_CURRENT_DATE()
Called from generated code. |
String |
getContextVariable_CURRENT_PATH()
Called from generated code. |
String |
getContextVariable_CURRENT_ROLE()
Called from generated code. |
String |
getContextVariable_CURRENT_SCHEMA()
Called from generated code. |
Time |
getContextVariable_CURRENT_TIME()
Called from generated code. |
Timestamp |
getContextVariable_CURRENT_TIMESTAMP()
Called from generated code. |
String |
getContextVariable_CURRENT_USER()
Called from generated code. |
Time |
getContextVariable_LOCALTIME()
Called from generated code. |
Timestamp |
getContextVariable_LOCALTIMESTAMP()
Called from generated code. |
String |
getContextVariable_SESSION_USER()
Called from generated code. |
String |
getContextVariable_SYSTEM_USER()
Called from generated code. |
String |
getContextVariable_USER()
Called from generated code. |
protected long |
getCurrentTime()
|
Object |
getDataServerRuntimeSupport(String serverMofId,
Object param)
Gets an object needed to support the implementation of foreign data access. |
Object |
getDynamicParamValue(int paramIndex)
Gets the value bound to a dynamic parameter. |
FennelDbHandle |
getFennelDbHandle()
|
FennelStreamGraph |
getFennelStreamGraph()
|
FennelTxnContext |
getFennelTxnContext()
|
long |
getIndexRoot(long pageOwnerId)
Looks up the root PageId of an index. |
private static List<FarragoUdrInvocationFrame> |
getInvocationStack()
|
long |
getJavaStreamHandle(int streamId)
Looks up the handle of a JavaTupleStream by its ID. |
String |
getRefMofId(RefBaseObject refObj)
Gets the MofId for a RefBaseObject, or null if the object is null. |
RelOptSchema |
getRelOptSchema()
Returns the schema underlying this connection. |
FarragoRepos |
getRepos()
|
RelDataType |
getRowTypeForResultSet(String resultSetName)
Gets the row type for instantiating a result set. |
FarragoSequenceAccessor |
getSequenceAccessor(String mofId)
|
FarragoSession |
getSession()
|
protected FennelStreamGraph |
getStreamGraph()
Returns the stream graph. |
FennelStreamHandle |
getStreamHandle(String globalStreamName,
boolean isInput)
Retrieves the FennelStreamHandle corresponding to a stream |
(package private) static FarragoUdrInvocationFrame |
getUdrInvocationFrame()
|
FarragoWarningQueue |
getWarningQueue()
|
RuntimeException |
handleRoutineInvocationException(Throwable ex,
String methodName)
Handles an exception caught by invocation of a routine. |
Object |
handleRowError(String[] columnNames,
Object[] columnValues,
RuntimeException ex,
int columnIndex,
String tag,
boolean isWarning)
Handles a runtime exception based on an array of column values rather than on a SyntheticObject |
Object |
handleRowError(String[] columnNames,
Object[] columnValues,
RuntimeException ex,
int columnIndex,
String tag,
boolean isWarning,
String errorCode,
String columnName)
Handles runtime exception; if errorCode is non-null, exceptions are deferred until all errors on a row are processed; not currently implemented |
Object |
handleRowError(String source,
boolean isWarning,
String msg,
ByteBuffer byteBuffer,
int index)
Handles a Fennel row exception |
Object |
handleRowError(SyntheticObject row,
RuntimeException ex,
int columnIndex,
String tag)
Handles an exception encountered by a stream while processing an input row. |
Object |
handleRowError(SyntheticObject row,
RuntimeException ex,
int columnIndex,
String tag,
boolean isWarning)
Handles a runtime exception, but allows warnings as well. |
void |
handleRowErrorCompletion(RuntimeException ex,
String tag)
Handles exception for row errors with deferred exceptions; not currently implemented |
private EigenbaseException |
handleRowErrorHelper(String row,
RuntimeException ex,
int columnIndex,
String tag,
boolean isWarning)
Helper for various handleRowError methods |
boolean |
hasAllocations()
|
static boolean |
inUdr()
|
void |
loadFennelPlan(String xmiFennelPlan)
Loads the Fennel portion of an execution plan (either creating a new XO graph or reusing a cached instance). |
protected EigenbaseException |
makeRowError(RuntimeException ex,
String row,
int index,
String field)
Makes a row error based on conventions for column index |
static Connection |
newConnection()
Creates a new default connection attached to the session of the current thread. |
TupleIter |
newFennelTransformTupleIter(FennelTupleReader tupleReader,
String streamName,
String inputStreamName,
FarragoTransform.InputBinding[] inputBindings,
Object dummies)
Creates a FennelTupleIter for executing a plan represented as XML. |
TupleIter |
newFennelTupleIter(FennelTupleReader tupleReader,
String streamName,
int streamId,
Object dummies)
Creates a FennelTupleIter for executing a plan represented as XML. |
void |
openStreams()
Opens all streams, including the Fennel portion of the execution plan. |
private static FarragoUdrInvocationFrame |
peekStackFrame(List<FarragoUdrInvocationFrame> stack)
|
void |
popRoutineInvocation()
Pops a routine invocation from the context stack. |
protected FennelStreamGraph |
prepareStreamGraph(String xmiFennelPlan)
|
void |
pushRoutineInvocation(FarragoSessionUdrContext udrContext,
boolean allowSql)
Pushes a routine invocation onto the context stack. |
void |
reattachMdrSession()
Re-attaches a detached MDR session to the currently running thread, if any was previously detached. |
void |
registerFarragoTransform(String key,
FarragoTransform xform)
Associates a FarragoTransform instance with its class name, so that it can be retrieved by a native method later. |
protected void |
registerJavaStream(int streamId,
Object stream)
Associates a stream id with a java stream object, so that it can be retrieved by a native method later. |
protected void |
registerJavaStream(int streamId,
Object stream,
FarragoCompoundAllocation owner)
Associates a stream id with a java stream object, so that it can be retrieved by a native method later. |
void |
setCursorState(boolean active)
Sets the state of the top-level cursor associated with this context. |
void |
setExecutionHandle(FennelExecutionHandle execHandle)
Associates an execution handle with the runtime context. |
void |
setStatementClassLoader(ClassLoader statementClassLoader)
Configures a custom class loader used to load extra classes that may be needed during statement runtime. |
Class |
statementClassForName(String statementClassName)
|
void |
waitForCursor()
Waits for cursor state to be reset to active=false (returns immediately if cursor is not currently active). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Logger tracer
private static final ThreadLocal<List<FarragoUdrInvocationFrame>> threadInvocationStack
private final FarragoSession session
private final FarragoRepos repos
protected final FarragoObjectCache codeCache
private final Map<String,FarragoObjectCache.Entry> txnCodeCache
private final FennelTxnContext fennelTxnContext
private final FarragoWarningQueue warningQueue
protected final Object cursorMonitor
private boolean cursorActive
private FennelExecutionHandle execHandle
private final Map<Integer,FennelJavaHandle> streamIdToHandleMap
private final Map<String,FarragoTransform> transformMap
protected final Object[] dynamicParamValues
protected FennelStreamGraph streamGraph
protected final FarragoCompoundAllocation streamOwner
private final FarragoSessionIndexMap indexMap
private final FarragoSessionVariables sessionVariables
protected final FarragoDataWrapperCache dataWrapperCache
private final FarragoStreamFactoryProvider streamFactoryProvider
private final boolean isDml
private long currentTime
private boolean isCanceled
protected boolean isClosed
private ClassLoader statementClassLoader
protected Map<String,RelDataType> resultSetTypeMap
protected long stmtId
private NativeRuntimeContext nativeContext
private EnkiMDSession detachedSession
Constructor Detail |
---|
public FarragoRuntimeContext(FarragoSessionRuntimeParams params)
params
- constructor paramsMethod Detail |
---|
public FarragoWarningQueue getWarningQueue()
getWarningQueue
in interface FarragoSessionRuntimeContext
protected FennelStreamGraph getStreamGraph()
public RelOptSchema getRelOptSchema()
RelOptConnection
public static Schema
getRelOptSchemaStatic()
.
getRelOptSchema
in interface RelOptConnection
public void closeAllocation()
ClosableAllocation
closeAllocation
in interface ClosableAllocation
closeAllocation
in class CompoundClosableAllocation
private void closeStreamGraph()
public void addAllocation(ClosableAllocation allocation)
ClosableAllocationOwner
addAllocation
in interface ClosableAllocationOwner
addAllocation
in class CompoundClosableAllocation
allocation
- the ClosableAllocation to take overpublic boolean forgetAllocation(ClosableAllocation allocation)
CompoundClosableAllocation
forgetAllocation
in class CompoundClosableAllocation
allocation
- the allocation to forget
public boolean hasAllocations()
hasAllocations
in class CompoundClosableAllocation
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 Object getDataServerRuntimeSupport(String serverMofId, Object param)
serverMofId
- MOFID of foreign server being accessedparam
- server-specific runtime parameter
public String getRefMofId(RefBaseObject refObj)
refObj
- RefBaseObject for which to get the MofId
public Object getDynamicParamValue(int paramIndex)
paramIndex
- 0-based index of parameter
public String getContextVariable_USER()
public String getContextVariable_CURRENT_USER()
public String getContextVariable_SYSTEM_USER()
public String getContextVariable_SESSION_USER()
public String getContextVariable_CURRENT_ROLE()
public String getContextVariable_CURRENT_CATALOG()
public String getContextVariable_CURRENT_SCHEMA()
public String getContextVariable_CURRENT_PATH()
protected long getCurrentTime()
public Date getContextVariable_CURRENT_DATE()
public Time getContextVariable_CURRENT_TIME()
public Timestamp getContextVariable_CURRENT_TIMESTAMP()
public Time getContextVariable_LOCALTIME()
public Timestamp getContextVariable_LOCALTIMESTAMP()
protected void registerJavaStream(int streamId, Object stream)
protected void registerJavaStream(int streamId, Object stream, FarragoCompoundAllocation owner)
public void registerFarragoTransform(String key, FarragoTransform xform)
public FarragoTransform findFarragoTransform(String key)
public Object dummyPair(Object dummy1, Object dummy2)
FennelDoubleRel
.
dummy1
- a dummydummy2
- another dummy
public Object dummyArray(Object[] dummyArray)
FennelMultipleRel
.
dummyArray
- array of dummies
public void loadFennelPlan(String xmiFennelPlan)
FarragoSessionRuntimeContext
loadFennelPlan
in interface FarragoSessionRuntimeContext
xmiFennelPlan
- XMI representation of plan definitionpublic void openStreams()
FarragoSessionRuntimeContext
openStreams
in interface FarragoSessionRuntimeContext
public FennelStreamGraph getFennelStreamGraph()
getFennelStreamGraph
in interface FarragoSessionRuntimeContext
public TupleIter newFennelTupleIter(FennelTupleReader tupleReader, String streamName, int streamId, Object dummies)
tupleReader
- object providing FennelTupleReader implementationstreamName
- name of stream from which to read (globally unique)streamId
- id of stream from which to read (unique within statement)dummies
- a dummy parameter to give non-Fennel children a place to
generate code
public TupleIter newFennelTransformTupleIter(FennelTupleReader tupleReader, String streamName, String inputStreamName, FarragoTransform.InputBinding[] inputBindings, Object dummies)
Note: The semantics of streamName and streamId differ from newFennelTupleIter(FennelTupleReader, String, int, Object)
. The iter is
not registered as the java peer of the fennel stream; the registered peer
of the stream is instead the specially generated FarragoTransform. (See
FarragoTransformDef.init(net.sf.farrago.session.FarragoSessionRuntimeContext)
.)
tupleReader
- object providing FennelTupleReader implementationstreamName
- name of the JavaExecTransformStream we're reading on
behalf ofinputStreamName
- the global name of a stream to readdummies
- a dummy parameter to give non-Fennel children a place to
generate code
public FennelStreamHandle getStreamHandle(String globalStreamName, boolean isInput)
FarragoSessionRuntimeContext
getStreamHandle
in interface FarragoSessionRuntimeContext
globalStreamName
- name of the stream that you are searching for
protected FennelStreamGraph prepareStreamGraph(String xmiFennelPlan)
public long getJavaStreamHandle(int streamId)
FennelJavaStreamMap
getJavaStreamHandle
in interface FennelJavaStreamMap
streamId
- ID of stream to find
public long getIndexRoot(long pageOwnerId)
FennelJavaStreamMap
getIndexRoot
in interface FennelJavaStreamMap
pageOwnerId
- the identifier for the indexpublic FennelDbHandle getFennelDbHandle()
public FennelTxnContext getFennelTxnContext()
public FarragoRepos getRepos()
getRepos
in interface FarragoSessionRuntimeContext
public void checkNotNull(String targetName, NullableValue nullableValue)
targetName
- target expressionnullableValue
- source valuepublic void checkNotNull(String targetName, Object obj)
targetName
- target expressionobj
- source valuepublic void pushRoutineInvocation(FarragoSessionUdrContext udrContext, boolean allowSql)
FarragoSessionRuntimeContext
pushRoutineInvocation
in interface FarragoSessionRuntimeContext
udrContext
- context holder for routine invocation instance within
statement being executedallowSql
- whether SQL execution should be allowed in this routinepublic void popRoutineInvocation()
FarragoSessionRuntimeContext
popRoutineInvocation
in interface FarragoSessionRuntimeContext
public void cancel()
FarragoSessionRuntimeContext
cancel
in interface FarragoSessionRuntimeContext
public void checkCancel()
FarragoSessionRuntimeContext
checkCancel
in interface FarragoSessionRuntimeContext
public void setExecutionHandle(FennelExecutionHandle execHandle)
FarragoSessionRuntimeContext
setExecutionHandle
in interface FarragoSessionRuntimeContext
execHandle
- the execution handlepublic void setCursorState(boolean active)
FarragoSessionRuntimeContext
FarragoSessionRuntimeContext.checkCancel()
is called both before the fetch request
(active=true) and after the fetch (active=false). Not called for internal
cursors such as UDX inputs and cursors opened via reentrant SQL from
UDRs.
setCursorState
in interface FarragoSessionRuntimeContext
active
- true if cursor is beginning a fetch request; false if
cursor is ending a fetch requestpublic void waitForCursor()
FarragoSessionRuntimeContext
waitForCursor
in interface FarragoSessionRuntimeContext
public RuntimeException handleRoutineInvocationException(Throwable ex, String methodName)
FarragoSessionRuntimeContext
handleRoutineInvocationException
in interface FarragoSessionRuntimeContext
ex
- exceptionmethodName
- name of external Java method
private static List<FarragoUdrInvocationFrame> getInvocationStack()
static FarragoUdrInvocationFrame getUdrInvocationFrame()
private static FarragoUdrInvocationFrame peekStackFrame(List<FarragoUdrInvocationFrame> stack)
public static Connection newConnection()
public void setStatementClassLoader(ClassLoader statementClassLoader)
FarragoSessionRuntimeContext
setStatementClassLoader
in interface FarragoSessionRuntimeContext
public Class statementClassForName(String statementClassName)
public RelDataType getRowTypeForResultSet(String resultSetName)
FarragoSessionRuntimeContext
getRowTypeForResultSet
in interface FarragoSessionRuntimeContext
resultSetName
- name of result set stored by optimizer
public FarragoSequenceAccessor getSequenceAccessor(String mofId)
public FarragoSession getSession()
getSession
in interface FarragoSessionRuntimeContext
public Object handleRowError(SyntheticObject row, RuntimeException ex, int columnIndex, String tag)
row
- the input row objectex
- the exception encounteredcolumnIndex
- index for the output column being calculated when an
exception was encountered, or zero if the filter condition was being
evaluated. This parameter may be -1 if not appropriate for the exceptiontag
- an error handling tag specific to the runtime context. This
parameter may also be null
public Object handleRowError(SyntheticObject row, RuntimeException ex, int columnIndex, String tag, boolean isWarning)
handleRowError(SyntheticObject, RuntimeException, int, String)
public Object handleRowError(String[] columnNames, Object[] columnValues, RuntimeException ex, int columnIndex, String tag, boolean isWarning)
public Object handleRowError(String[] columnNames, Object[] columnValues, RuntimeException ex, int columnIndex, String tag, boolean isWarning, String errorCode, String columnName)
public void handleRowErrorCompletion(RuntimeException ex, String tag)
private EigenbaseException handleRowErrorHelper(String row, RuntimeException ex, int columnIndex, String tag, boolean isWarning)
protected EigenbaseException makeRowError(RuntimeException ex, String row, int index, String field)
ex
- the runtime exception encounteredrow
- string representing the row on which an exception occurredindex
- index of the column being processed at the time the
exception was encountered, or 0 for an error processing a conditional
expression, or -1 for a non-specific errorfield
- optional column name, used in constructing the error message
when columnIndex > 0
public Object handleRowError(String source, boolean isWarning, String msg, ByteBuffer byteBuffer, int index)
FennelJavaErrorTarget
handleRowError
in interface FennelJavaErrorTarget
source
- the unique Fennel stream nameisWarning
- true if the exception is only a warningmsg
- the exception stringbyteBuffer
- the Fennel format byte buffer containing an error
record for the row that failed. The error record must conform to the row
type specified for the source with FennelRelImplementor.setErrorRecordType(net.sf.farrago.query.FennelRel, net.sf.farrago.fem.fennel.FemExecutionStreamDef, org.eigenbase.reltype.RelDataType)
index
- position of the column whose processing caused the exception
to occur. -1 indicates that no column was culpable. 0 indicates that a
filter condition was being processed. Otherwise this parameter should be
a 1-indexed column position.public static boolean inUdr()
public void detachMdrSession()
FarragoSessionRuntimeContext
detachMdrSession
in interface FarragoSessionRuntimeContext
public void reattachMdrSession()
FarragoSessionRuntimeContext
reattachMdrSession
in interface FarragoSessionRuntimeContext
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |