Class ParameterSession
java.lang.Object
com.illumon.util.referencecounting.ReferenceCounted
com.illumon.iris.db.util.liveness.ReferenceCountedLivenessNode
com.illumon.iris.db.util.liveness.LivenessArtifact
io.deephaven.query.parameterized.impl.ParameterSession
- All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable
,LivenessManager
,LivenessNode
,LivenessReferent
,ScriptSession
,ParameterScope
,Serializable
A self-contained "parallel universe" for
ParameterizedQuery
instances
to operate within.
User provided methods must interact with one of these to retrieve parameters and assign computational results.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Removes the currently configured script path loader from this script.protected void
destroy()
Attempt to release (destructively when necessary) resources held by this object.void
Evaluates command in the context of the current ScriptSession.void
Evaluates command in the context of the current ScriptSession.fetchTableHistorical
(Database database, String namespace, String tableName) Retrieve a historical table from within the willDo scope of a ParameterizedQuery.fetchTableIntraday
(Database database, String namespace, String tableName) Retrieve an intraday table from within the willDo scope of a ParameterizedQuery.getAllResultNamesOf
(Class<T> type) Retrieve all result names for the specified type.Convenience method to return the authenticated user of the UserContext directly.boolean
getBoolean
(String name) Get the named parameter as a booleangetDateTime
(String name) Get the named parameter as aDBDateTime
getDateTimeSet
(String name) Get the named parameter as an array ofDBDateTime
sdouble
Get the named parameter as a doubledouble[]
getDoubleSet
(String name) Get the named parameter as an array of doublesConvenience method to return the effective user of the UserContext directly.long
Get the named parameter as a longlong[]
getLongSet
(String name) Get the named parameter as an array of longsGets the PermissionFilterProvider associated with the user running the ParameterizedQuery.Get the named parameter as a StringString[]
getStringSet
(String name) Get the named parameter as an array of Stringsio.deephaven.enterprise.auth.UserContext
Gets the UserContext, which has the authenticated and effective user ids.getVariable
(String name) Retrieve a variable from the script session's bindings.<T> T
getVariable
(String name, T defaultValue) Retrieve a variable from the script session's bindings.Retrieves all of the variable names present in the session's scopeRetrieves all of the variables present in the session's scope (e.g., Groovy binding, Python globals()).boolean
hasVariableName
(String name) Check if the scope has the given variable nameboolean
Check if the specified parameter has been assigned a value.void
onPersistentQueryInitializationBegin
(Supplier<ScriptPathLoader> pathLoader, ScriptPathLoaderState scriptLoaderState) Called before PersistentQuery initialization, should setup sourcing from the controller (as required).void
Called after PersistentQuery initialization.void
setPermissionFilterProvider
(PermissionFilterProvider permissionFilterProvider) <T> void
Set the value of a named result.void
setScriptPathLoader
(Supplier<ScriptPathLoader> scriptPathLoader, boolean caching) Sets the scriptPathLoader that is in use for this session.boolean
setUseOriginalScriptLoaderState
(boolean useOriginal) Informs the session whether or not we should be using the original ScriptLoaderState for source commands.void
setVariable
(String name, Object value) Inserts a value into the script's scope.Methods inherited from class com.illumon.iris.db.util.liveness.LivenessArtifact
manageWithCurrentScope, unmanage, unmanage
Methods inherited from class com.illumon.iris.db.util.liveness.ReferenceCountedLivenessNode
dropReference, getWeakReference, initializeTransientFieldsForLiveness, onReferenceCountAtZero, tryManage, tryRetainReference
Methods inherited from class com.illumon.util.referencecounting.ReferenceCounted
append, decrementReferenceCount, incrementReferenceCount, resetReferenceCount, toString, tryDecrementReferenceCount, tryIncrementReferenceCount
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.util.liveness.LivenessManager
manage
Methods inherited from interface com.illumon.iris.db.util.liveness.LivenessReferent
getReferentDescription, retainReference
Methods inherited from interface com.illumon.iris.db.util.ScriptSession
getWrappedSession, isInteractiveConsoleSession, sanitizeThrowable
-
Constructor Details
-
ParameterSession
public ParameterSession(io.deephaven.enterprise.auth.UserContext userContext)
-
-
Method Details
-
getLong
Description copied from interface:ParameterScope
Get the named parameter as a long- Specified by:
getLong
in interfaceParameterScope
- Parameters:
name
- the name of the parameter- Returns:
- the value of the named parameter as a long.
-
getLongSet
Description copied from interface:ParameterScope
Get the named parameter as an array of longs- Specified by:
getLongSet
in interfaceParameterScope
- Parameters:
name
- the name of the parameter- Returns:
- the value as an array of longs
-
getDouble
Description copied from interface:ParameterScope
Get the named parameter as a double- Specified by:
getDouble
in interfaceParameterScope
- Parameters:
name
- the name of the parameter- Returns:
- the value of the named parameter as a double.
-
getDoubleSet
Description copied from interface:ParameterScope
Get the named parameter as an array of doubles- Specified by:
getDoubleSet
in interfaceParameterScope
- Parameters:
name
- the name of the parameter- Returns:
- the value as an array of doubles
-
getString
Description copied from interface:ParameterScope
Get the named parameter as a String- Specified by:
getString
in interfaceParameterScope
- Parameters:
name
- the name of the parameter- Returns:
- the value of the named parameter as an int.
-
getStringSet
Description copied from interface:ParameterScope
Get the named parameter as an array of Strings- Specified by:
getStringSet
in interfaceParameterScope
- Parameters:
name
- the name of the parameter- Returns:
- the value as an array of Strings
-
getDateTime
Description copied from interface:ParameterScope
Get the named parameter as aDBDateTime
- Specified by:
getDateTime
in interfaceParameterScope
- Parameters:
name
- the name of the parameter- Returns:
- the value of the named parameter as a
DBDateTime
.
-
getDateTimeSet
Description copied from interface:ParameterScope
Get the named parameter as an array ofDBDateTime
s- Specified by:
getDateTimeSet
in interfaceParameterScope
- Parameters:
name
- the name of the parameter- Returns:
- the value as an array of
DBDateTime
s
-
getBoolean
Description copied from interface:ParameterScope
Get the named parameter as a boolean- Specified by:
getBoolean
in interfaceParameterScope
- Parameters:
name
- the name of the parameter- Returns:
- the value of the named parameter as an boolean.
-
isPresent
Description copied from interface:ParameterScope
Check if the specified parameter has been assigned a value.- Specified by:
isPresent
in interfaceParameterScope
- Parameters:
name
- the parameter name- Returns:
- true if the parameter has been given a value, false otherwise.
-
getPermissionFilterProvider
Description copied from interface:ParameterScope
Gets the PermissionFilterProvider associated with the user running the ParameterizedQuery.- Specified by:
getPermissionFilterProvider
in interfaceParameterScope
- Returns:
- The PermissionFilterProvider.
-
getUserContext
public io.deephaven.enterprise.auth.UserContext getUserContext()Description copied from interface:ParameterScope
Gets the UserContext, which has the authenticated and effective user ids.- Specified by:
getUserContext
in interfaceParameterScope
- Returns:
- UserContext for the parameterized query.
-
getAuthenticatedUser
Description copied from interface:ParameterScope
Convenience method to return the authenticated user of the UserContext directly.- Specified by:
getAuthenticatedUser
in interfaceParameterScope
- Returns:
- The authenticated user
-
getEffectiveUser
Description copied from interface:ParameterScope
Convenience method to return the effective user of the UserContext directly.- Specified by:
getEffectiveUser
in interfaceParameterScope
- Returns:
- The authenticated user
-
fetchTableIntraday
Description copied from interface:ParameterScope
Retrieve an intraday table from within the willDo scope of a ParameterizedQuery. The table is retrieved from the underlying data store with the UserContext of the query’s owner. After the owner’s row and column ACL application, the executing user’s context are applied. This results in the resulting table having only data that both the query’s owner and the executing user may see.- Specified by:
fetchTableIntraday
in interfaceParameterScope
- Parameters:
database
- The database of a Deephaven console session, exposed asdb
.namespace
- The namespace of the table to be retrieved.tableName
- The name of the table to be retrieved.- Returns:
- The intraday table subject to ACL constraints described above.
-
fetchTableHistorical
Description copied from interface:ParameterScope
Retrieve a historical table from within the willDo scope of a ParameterizedQuery. The table is retrieved from the underlying data store with the UserContext of the query’s owner. After the owner’s row and column ACL application, the executing user’s context are applied. This results in the resulting table having only data that both the query’s owner and the executing user may see.- Specified by:
fetchTableHistorical
in interfaceParameterScope
- Parameters:
database
- The database of a Deephaven console session, exposed asdb
.namespace
- The namespace of the table to be retrieved.tableName
- The name of the table to be retrieved.- Returns:
- The historical table subject to ACL constraints described above.
-
setResult
Set the value of a named result. These may not overwrite parameter values- Specified by:
setResult
in interfaceParameterScope
- Type Parameters:
T
- the type.- Parameters:
name
- the name of the resultvalue
- the value to set it to.
-
getAllResultNamesOf
Retrieve all result names for the specified type.- Type Parameters:
T
- the type parameter to cast back to- Parameters:
type
- the type- Returns:
- a list of all of the result names of the specified type.
-
destroy
protected void destroy()Description copied from class:ReferenceCountedLivenessNode
Attempt to release (destructively when necessary) resources held by this object. This may render the object unusable for subsequent operations. Implementations should be sure to call super.destroy().
This is intended to only ever be used as a side effect of decreasing the reference count to 0.
- Overrides:
destroy
in classReferenceCountedLivenessNode
-
getVariable
Description copied from interface:ScriptSession
Retrieve a variable from the script session's bindings.- Specified by:
getVariable
in interfaceScriptSession
- Parameters:
name
- the variable to retrieve- Returns:
- the variable
- Throws:
QueryScope.MissingVariableException
- if the variable does not exist
-
getVariable
Description copied from interface:ScriptSession
Retrieve a variable from the script session's bindings. If the variable is not present, return defaultValue. If the variable is present, but is not of type (T), a ClassCastException may result.- Specified by:
getVariable
in interfaceScriptSession
- Type Parameters:
T
- the type of the variable- Parameters:
name
- the variable to retrievedefaultValue
- the value to use when no value is present in the session's scope- Returns:
- the value of the variable, or defaultValue if not present
-
evaluate
Description copied from interface:ScriptSession
Evaluates command in the context of the current ScriptSession.- Specified by:
evaluate
in interfaceScriptSession
- Parameters:
command
- the command to evaluate
-
evaluate
Description copied from interface:ScriptSession
Evaluates command in the context of the current ScriptSession.- Specified by:
evaluate
in interfaceScriptSession
- Parameters:
command
- the command to evaluatescriptName
- an optional script name, which may be ignored by the implementation, or used improve error messages or for other internal purposes
-
getVariables
Description copied from interface:ScriptSession
Retrieves all of the variables present in the session's scope (e.g., Groovy binding, Python globals()).- Specified by:
getVariables
in interfaceScriptSession
- Returns:
- an unmodifiable map with variable names as the keys, and the Objects as the result
-
getVariableNames
Description copied from interface:ScriptSession
Retrieves all of the variable names present in the session's scope- Specified by:
getVariableNames
in interfaceScriptSession
- Returns:
- an unmodifiable set of variable names
-
hasVariableName
Description copied from interface:ScriptSession
Check if the scope has the given variable name- Specified by:
hasVariableName
in interfaceScriptSession
- Parameters:
name
- the variable name- Returns:
- True iff the scope has the given variable name
-
setVariable
Description copied from interface:ScriptSession
Inserts a value into the script's scope.- Specified by:
setVariable
in interfaceScriptSession
- Parameters:
name
- the variable name to setvalue
- the new value of the variable
-
scriptType
- Specified by:
scriptType
in interfaceScriptSession
- Returns:
- a textual description of this script session's language for use in messages.
-
onPersistentQueryInitializationBegin
public void onPersistentQueryInitializationBegin(Supplier<ScriptPathLoader> pathLoader, ScriptPathLoaderState scriptLoaderState) Description copied from interface:ScriptSession
Called before PersistentQuery initialization, should setup sourcing from the controller (as required).- Specified by:
onPersistentQueryInitializationBegin
in interfaceScriptSession
-
onPersistentQueryInitializationEnd
public void onPersistentQueryInitializationEnd()Description copied from interface:ScriptSession
Called after PersistentQuery initialization.- Specified by:
onPersistentQueryInitializationEnd
in interfaceScriptSession
-
setScriptPathLoader
Description copied from interface:ScriptSession
Sets the scriptPathLoader that is in use for this session.- Specified by:
setScriptPathLoader
in interfaceScriptSession
- Parameters:
scriptPathLoader
- a supplier of a script path loadercaching
- whether the source operation should cache results
-
clearScriptPathLoader
public void clearScriptPathLoader()Description copied from interface:ScriptSession
Removes the currently configured script path loader from this script.- Specified by:
clearScriptPathLoader
in interfaceScriptSession
-
setUseOriginalScriptLoaderState
public boolean setUseOriginalScriptLoaderState(boolean useOriginal) Description copied from interface:ScriptSession
Informs the session whether or not we should be using the original ScriptLoaderState for source commands.- Specified by:
setUseOriginalScriptLoaderState
in interfaceScriptSession
- Parameters:
useOriginal
- whether to use the script loader state at persistent query initialization
-
setPermissionFilterProvider
-