Package io.deephaven.engine.context
Interface QueryScope
- All Superinterfaces:
LivenessManager
,LivenessNode
,LivenessReferent
,LogOutputAppendable
- All Known Implementing Classes:
AbstractScriptSession.ScriptSessionQueryScope
,EmptyQueryScope
,PoisonedQueryScope
,StandaloneQueryScope
Variable scope used to resolve parameter values during query execution and to expose named objects to users. Objects
passed in will have their liveness managed by the scope.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
A type of RuntimeException thrown when a variable referenced within theQueryScope
is not defined or, more likely, has not been added to the scope.static interface
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> void
Adds a parameter to the default instanceQueryScope
, or updates the value of an existing parameter.default LogOutput
<T> QueryScopeParam<T>
createParam
(String name) Get a QueryScopeParam by name.Get all known scope variable names.default QueryScopeParam<?>[]
getParams
(Collection<String> names) Get an array of Params by name.static <T> T
getParamValue
(String name) Gets a parameter from the default instanceQueryScope
.boolean
hasParamName
(String name) Check if the scope has the given name.<T> void
Add a parameter to the scope.<T> T
readParamValue
(String name) Get the value of a given scope parameter by name.<T> T
readParamValue
(String name, T defaultValue) Get the value of a given scope parameter by name.toMap
(@NotNull QueryScope.ParamFilter<Object> filter) Returns a mutable map with all objects in the scope.toMap
(@NotNull Function<Object, T> valueMapper, @NotNull QueryScope.ParamFilter<T> filter) Returns a mutable map with all objects in the scope.default Object
unwrapObject
(@Nullable Object object) Removes any wrapping that exists on a scope param object so that clients can fetch them.Methods inherited from interface io.deephaven.engine.liveness.LivenessManager
manage, tryManage
Methods inherited from interface io.deephaven.engine.liveness.LivenessNode
tryUnmanage, tryUnmanage, unmanage, unmanage
Methods inherited from interface io.deephaven.engine.liveness.LivenessReferent
dropReference, getReferentDescription, getWeakReference, retainReference, tryRetainReference
-
Method Details
-
addParam
Adds a parameter to the default instanceQueryScope
, or updates the value of an existing parameter. Objects passed in will have their liveness managed by the scope.- Type Parameters:
T
- type of the parameter/value.- Parameters:
name
- String name of the parameter to add.value
- value to assign to the parameter.
-
getParamValue
Gets a parameter from the default instanceQueryScope
.- Type Parameters:
T
- parameter type.- Parameters:
name
- parameter name.- Returns:
- parameter value.
- Throws:
QueryScope.MissingVariableException
- variable name is not defined.
-
getParams
default QueryScopeParam<?>[] getParams(Collection<String> names) throws QueryScope.MissingVariableException Get an array of Params by name. See createParam(name) implementations for details.- Parameters:
names
- parameter names- Returns:
- A newly-constructed array of newly-constructed Params.
- Throws:
QueryScope.MissingVariableException
- If any of the named scope variables does not exist.
-
getParamNames
Get all known scope variable names.- Returns:
- A caller-owned mutable collection of scope variable names.
-
hasParamName
Check if the scope has the given name.- Parameters:
name
- param name- Returns:
- True iff the scope has the given param name
-
createParam
Get a QueryScopeParam by name.- Parameters:
name
- parameter name- Returns:
- newly-constructed QueryScopeParam (name + value-snapshot pair).
- Throws:
QueryScope.MissingVariableException
- If any of the named scope variables does not exist.
-
readParamValue
Get the value of a given scope parameter by name. Callers may want to unwrap language-specific values usingunwrapObject(Object)
before using them.- Parameters:
name
- parameter name.- Returns:
- parameter value.
- Throws:
QueryScope.MissingVariableException
- If no such scope parameter exists.
-
readParamValue
Get the value of a given scope parameter by name. Callers may want to unwrap language-specific values usingunwrapObject(Object)
before using them.- Parameters:
name
- parameter name.defaultValue
- default parameter value.- Returns:
- parameter value, or the default parameter value, if the value is not present.
-
putParam
Add a parameter to the scope. Objects passed in will have their liveness managed by the scope.- Parameters:
name
- parameter name.value
- parameter value.
-
toMap
Returns a mutable map with all objects in the scope. Callers may want to unwrap language-specific values usingunwrapObject(Object)
before using them. This returned map is owned by the caller.- Parameters:
filter
- a predicate to filter the map entries- Returns:
- a caller-owned mutable map with all known variables and their values.
-
toMap
<T> Map<String,T> toMap(@NotNull @NotNull Function<Object, T> valueMapper, @NotNull @NotNull QueryScope.ParamFilter<T> filter) Returns a mutable map with all objects in the scope.Callers may want to pass in a valueMapper of
unwrapObject(Object)
which would unwrap values before filtering. The returned map is owned by the caller.- Type Parameters:
T
- the type of the mapped values- Parameters:
valueMapper
- a function to map the valuesfilter
- a predicate to filter the map entries- Returns:
- a caller-owned mutable map with all known variables and their values.
-
unwrapObject
Removes any wrapping that exists on a scope param object so that clients can fetch them. Defaults to returning the object itself.- Parameters:
object
- the scoped object- Returns:
- an obj which can be consumed by a client
-
append
- Specified by:
append
in interfaceLogOutputAppendable
-