Class ParameterSession

All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable, LivenessManager, LivenessNode, LivenessReferent, ScriptSession, ParameterScope, Serializable

public class ParameterSession extends LivenessArtifact implements ParameterScope, ScriptSession
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 Details

    • ParameterSession

      public ParameterSession(io.deephaven.enterprise.auth.UserContext userContext)
  • Method Details

    • getLong

      public long getLong(@NotNull String name)
      Description copied from interface: ParameterScope
      Get the named parameter as a long
      Specified by:
      getLong in interface ParameterScope
      Parameters:
      name - the name of the parameter
      Returns:
      the value of the named parameter as a long.
    • getLongSet

      public long[] getLongSet(@NotNull String name)
      Description copied from interface: ParameterScope
      Get the named parameter as an array of longs
      Specified by:
      getLongSet in interface ParameterScope
      Parameters:
      name - the name of the parameter
      Returns:
      the value as an array of longs
    • getDouble

      public double getDouble(@NotNull String name)
      Description copied from interface: ParameterScope
      Get the named parameter as a double
      Specified by:
      getDouble in interface ParameterScope
      Parameters:
      name - the name of the parameter
      Returns:
      the value of the named parameter as a double.
    • getDoubleSet

      public double[] getDoubleSet(@NotNull String name)
      Description copied from interface: ParameterScope
      Get the named parameter as an array of doubles
      Specified by:
      getDoubleSet in interface ParameterScope
      Parameters:
      name - the name of the parameter
      Returns:
      the value as an array of doubles
    • getString

      public String getString(@NotNull String name)
      Description copied from interface: ParameterScope
      Get the named parameter as a String
      Specified by:
      getString in interface ParameterScope
      Parameters:
      name - the name of the parameter
      Returns:
      the value of the named parameter as an int.
    • getStringSet

      public String[] getStringSet(@NotNull String name)
      Description copied from interface: ParameterScope
      Get the named parameter as an array of Strings
      Specified by:
      getStringSet in interface ParameterScope
      Parameters:
      name - the name of the parameter
      Returns:
      the value as an array of Strings
    • getDateTime

      public DBDateTime getDateTime(@NotNull String name)
      Description copied from interface: ParameterScope
      Get the named parameter as a DBDateTime
      Specified by:
      getDateTime in interface ParameterScope
      Parameters:
      name - the name of the parameter
      Returns:
      the value of the named parameter as a DBDateTime.
    • getDateTimeSet

      public DBDateTime[] getDateTimeSet(@NotNull String name)
      Description copied from interface: ParameterScope
      Get the named parameter as an array of DBDateTimes
      Specified by:
      getDateTimeSet in interface ParameterScope
      Parameters:
      name - the name of the parameter
      Returns:
      the value as an array of DBDateTimes
    • getBoolean

      public boolean getBoolean(@NotNull String name)
      Description copied from interface: ParameterScope
      Get the named parameter as a boolean
      Specified by:
      getBoolean in interface ParameterScope
      Parameters:
      name - the name of the parameter
      Returns:
      the value of the named parameter as an boolean.
    • isPresent

      public boolean isPresent(@NotNull String name)
      Description copied from interface: ParameterScope
      Check if the specified parameter has been assigned a value.
      Specified by:
      isPresent in interface ParameterScope
      Parameters:
      name - the parameter name
      Returns:
      true if the parameter has been given a value, false otherwise.
    • getPermissionFilterProvider

      public PermissionFilterProvider getPermissionFilterProvider()
      Description copied from interface: ParameterScope
      Gets the PermissionFilterProvider associated with the user running the ParameterizedQuery.
      Specified by:
      getPermissionFilterProvider in interface ParameterScope
      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 interface ParameterScope
      Returns:
      UserContext for the parameterized query.
    • getAuthenticatedUser

      public String getAuthenticatedUser()
      Description copied from interface: ParameterScope
      Convenience method to return the authenticated user of the UserContext directly.
      Specified by:
      getAuthenticatedUser in interface ParameterScope
      Returns:
      The authenticated user
    • getEffectiveUser

      public String getEffectiveUser()
      Description copied from interface: ParameterScope
      Convenience method to return the effective user of the UserContext directly.
      Specified by:
      getEffectiveUser in interface ParameterScope
      Returns:
      The authenticated user
    • fetchTableIntraday

      public Table fetchTableIntraday(Database database, String namespace, String tableName)
      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 interface ParameterScope
      Parameters:
      database - The database of a Deephaven console session, exposed as db.
      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

      public Table fetchTableHistorical(Database database, String namespace, String tableName)
      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 interface ParameterScope
      Parameters:
      database - The database of a Deephaven console session, exposed as db.
      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

      public <T> void setResult(@NotNull String name, T value)
      Set the value of a named result. These may not overwrite parameter values
      Specified by:
      setResult in interface ParameterScope
      Type Parameters:
      T - the type.
      Parameters:
      name - the name of the result
      value - the value to set it to.
    • getAllResultNamesOf

      public <T> List<String> getAllResultNamesOf(Class<T> type)
      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 class ReferenceCountedLivenessNode
    • getVariable

      public Object getVariable(String name) throws QueryScope.MissingVariableException
      Description copied from interface: ScriptSession
      Retrieve a variable from the script session's bindings.
      Specified by:
      getVariable in interface ScriptSession
      Parameters:
      name - the variable to retrieve
      Returns:
      the variable
      Throws:
      QueryScope.MissingVariableException - if the variable does not exist
    • getVariable

      public <T> T getVariable(String name, T defaultValue)
      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 interface ScriptSession
      Type Parameters:
      T - the type of the variable
      Parameters:
      name - the variable to retrieve
      defaultValue - 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

      public void evaluate(String command)
      Description copied from interface: ScriptSession
      Evaluates command in the context of the current ScriptSession.
      Specified by:
      evaluate in interface ScriptSession
      Parameters:
      command - the command to evaluate
    • evaluate

      public void evaluate(String command, @Nullable String scriptName)
      Description copied from interface: ScriptSession
      Evaluates command in the context of the current ScriptSession.
      Specified by:
      evaluate in interface ScriptSession
      Parameters:
      command - the command to evaluate
      scriptName - an optional script name, which may be ignored by the implementation, or used improve error messages or for other internal purposes
    • getVariables

      public Map<String,Object> 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 interface ScriptSession
      Returns:
      an unmodifiable map with variable names as the keys, and the Objects as the result
    • getVariableNames

      public Set<String> getVariableNames()
      Description copied from interface: ScriptSession
      Retrieves all of the variable names present in the session's scope
      Specified by:
      getVariableNames in interface ScriptSession
      Returns:
      an unmodifiable set of variable names
    • hasVariableName

      public boolean hasVariableName(String name)
      Description copied from interface: ScriptSession
      Check if the scope has the given variable name
      Specified by:
      hasVariableName in interface ScriptSession
      Parameters:
      name - the variable name
      Returns:
      True iff the scope has the given variable name
    • setVariable

      public void setVariable(String name, Object value)
      Description copied from interface: ScriptSession
      Inserts a value into the script's scope.
      Specified by:
      setVariable in interface ScriptSession
      Parameters:
      name - the variable name to set
      value - the new value of the variable
    • scriptType

      public String scriptType()
      Specified by:
      scriptType in interface ScriptSession
      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 interface ScriptSession
    • onPersistentQueryInitializationEnd

      public void onPersistentQueryInitializationEnd()
      Description copied from interface: ScriptSession
      Called after PersistentQuery initialization.
      Specified by:
      onPersistentQueryInitializationEnd in interface ScriptSession
    • setScriptPathLoader

      public void setScriptPathLoader(Supplier<ScriptPathLoader> scriptPathLoader, boolean caching)
      Description copied from interface: ScriptSession
      Sets the scriptPathLoader that is in use for this session.
      Specified by:
      setScriptPathLoader in interface ScriptSession
      Parameters:
      scriptPathLoader - a supplier of a script path loader
      caching - 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 interface ScriptSession
    • 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 interface ScriptSession
      Parameters:
      useOriginal - whether to use the script loader state at persistent query initialization
    • setPermissionFilterProvider

      public void setPermissionFilterProvider(PermissionFilterProvider permissionFilterProvider)