Package io.deephaven.engine.util
Class AbstractScriptSession<S extends AbstractScriptSession.Snapshot>
java.lang.Object
io.deephaven.util.referencecounting.ReferenceCounted
io.deephaven.engine.liveness.ReferenceCountedLivenessReferent
io.deephaven.engine.liveness.ReferenceCountedLivenessNode
io.deephaven.engine.liveness.LivenessScope
io.deephaven.engine.util.AbstractScriptSession<S>
- All Implemented Interfaces:
LogOutputAppendable,LivenessManager,LivenessNode,LivenessReferent,ReleasableLivenessManager,ScriptSession,VariableProvider,Serializable
- Direct Known Subclasses:
GroovyDeephavenSession,NoLanguageDeephavenSession,PythonDeephavenSession
public abstract class AbstractScriptSession<S extends AbstractScriptSession.Snapshot>
extends LivenessScope
implements ScriptSession, VariableProvider
This class exists to make all script sessions to be liveness artifacts, and provide a default implementation for
evaluateScript which handles liveness and diffs in a consistent way.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprotected static interfacestatic classstatic classNested classes/interfaces inherited from interface io.deephaven.engine.util.ScriptSession
ScriptSession.Changes, ScriptSession.Listener -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractScriptSession(UpdateGraph updateGraph, OperationInitializer operationInitializer, ObjectTypeLookup objectTypeLookup, @Nullable ScriptSession.Listener changeListener) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyVariableChangeToDiff(ScriptSession.Changes diff, String name, @Nullable Object fromValue, @Nullable Object toValue) protected abstract ScriptSession.ChangescreateDiff(S from, S to, RuntimeException e) static voidprotected voiddestroy()Attempt to release (destructively when necessary) resources held by this object.protected abstract Sprotected abstract voidEvaluates command in the context of the current ScriptSession.final ScriptSession.ChangesevaluateScript(String script, @Nullable String scriptName) Evaluates the script and manages liveness of objects that are exported to the user.evaluateScript(Path scriptPath) Evaluates the script and manages liveness of objects that are exported to the user.Obtain anExecutionContextinstance for the current script session.getTableDefinition(String var) AVariableProviderinstance, for services like autocomplete which may want a limited "just the variables" view of our session state.Class<?>getVariableType(String var) protected abstract QueryScopevoidObserve (and report viaonScopeChanges) any changes to this ScriptSession'sQueryScopethat may have been made externally, rather than duringscript evaluation.protected voidprotected abstract SMethods inherited from class io.deephaven.engine.liveness.LivenessScope
release, transferToMethods inherited from class io.deephaven.engine.liveness.ReferenceCountedLivenessNode
getWeakReference, initializeTransientFieldsForLiveness, onReferenceCountAtZero, tryManage, tryUnmanage, tryUnmanageMethods inherited from class io.deephaven.engine.liveness.ReferenceCountedLivenessReferent
dropReference, tryRetainReferenceMethods inherited from class io.deephaven.util.referencecounting.ReferenceCounted
append, decrementReferenceCount, forceReferenceCountToZero, getReferenceCountDebug, incrementReferenceCount, resetReferenceCount, toString, tryDecrementReferenceCount, tryIncrementReferenceCountMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.deephaven.engine.liveness.LivenessManager
manage, tryManageMethods inherited from interface io.deephaven.engine.liveness.LivenessNode
tryUnmanage, tryUnmanage, unmanage, unmanageMethods inherited from interface io.deephaven.engine.liveness.LivenessReferent
dropReference, getReferentDescription, getWeakReference, retainReference, tryRetainReferenceMethods inherited from interface io.deephaven.engine.liveness.ReleasableLivenessManager
releaseMethods inherited from interface io.deephaven.engine.util.ScriptSession
evaluateScript, getVariable, getVariable, getVariableNames, getVariables, hasVariableName, sanitizeThrowable, scriptType, setVariable, unwrapObjectMethods inherited from interface io.deephaven.engine.util.VariableProvider
getVariable, getVariableNames
-
Field Details
-
executionContext
-
-
Constructor Details
-
AbstractScriptSession
protected AbstractScriptSession(UpdateGraph updateGraph, OperationInitializer operationInitializer, ObjectTypeLookup objectTypeLookup, @Nullable @Nullable ScriptSession.Listener changeListener)
-
-
Method Details
-
createScriptCache
public static void createScriptCache() -
getExecutionContext
Description copied from interface:ScriptSessionObtain anExecutionContextinstance for the current script session. This is the execution context that is used when executing scripts.- Specified by:
getExecutionContextin interfaceScriptSession
-
publishInitial
protected void publishInitial() -
observeScopeChanges
public void observeScopeChanges()Description copied from interface:ScriptSessionObserve (and report viaonScopeChanges) any changes to this ScriptSession'sQueryScopethat may have been made externally, rather than duringscript evaluation.- Specified by:
observeScopeChangesin interfaceScriptSession
-
emptySnapshot
-
takeSnapshot
-
createDiff
-
evaluateScript
public final ScriptSession.Changes evaluateScript(String script, @Nullable @Nullable String scriptName) Description copied from interface:ScriptSessionEvaluates the script and manages liveness of objects that are exported to the user. This method should be called from the serial executor as it manipulates static state.- Specified by:
evaluateScriptin interfaceScriptSession- Parameters:
script- the code to executescriptName- an optional script name, which may be ignored by the implementation, or used improve error messages or for other internal purposes- Returns:
- the changes made to the exportable objects
-
applyVariableChangeToDiff
protected void applyVariableChangeToDiff(ScriptSession.Changes diff, String name, @Nullable @Nullable Object fromValue, @Nullable @Nullable Object toValue) -
evaluateScript
Description copied from interface:ScriptSessionEvaluates the script and manages liveness of objects that are exported to the user. This method should be called from the serial executor as it manipulates static state.- Specified by:
evaluateScriptin interfaceScriptSession- Parameters:
scriptPath- the path to the script to execute- Returns:
- the changes made to the exportable objects
-
destroy
protected void destroy()Description copied from class:ReferenceCountedLivenessReferentAttempt 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:
destroyin classReferenceCountedLivenessReferent
-
evaluate
Evaluates command in the context of the current ScriptSession.- 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
-
newQueryScope
- Returns:
- a query scope for this session; only invoked during construction
-
getVariableType
- Specified by:
getVariableTypein interfaceVariableProvider
-
getTableDefinition
- Specified by:
getTableDefinitionin interfaceVariableProvider
-
getVariableProvider
Description copied from interface:ScriptSessionAVariableProviderinstance, for services like autocomplete which may want a limited "just the variables" view of our session state.- Specified by:
getVariableProviderin interfaceScriptSession- Returns:
- a VariableProvider instance backed by the global/binding context of this script session.
-