public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl implements GremlinScriptEngine
ScriptEngine
implementation is
heavily adapted from the GroovyScriptEngineImpl
to include some additional functionality.GremlinExecutor
Modifier and Type | Field and Description |
---|---|
static String |
COLLECTED_BOUND_VARS_MAP_VARNAME
Name of variable that holds local variables to be globally bound if "interpreter mode" is enabled with
InterpreterModeGroovyCustomizer . |
static ThreadLocal<Map<String,Object>> |
COMPILE_OPTIONS |
static String |
COMPILE_OPTIONS_VAR_TYPES
An "internal" key for sandboxing the script engine - technically not for public use.
|
static String |
KEY_REFERENCE_TYPE
The attribute key (passed as a binding on the context) for how to cache scripts.
|
static String |
REFERENCE_TYPE_HARD
A value to the
KEY_REFERENCE_TYPE that makes the evaluated script available in the cache for the life
of the JVM. |
static String |
REFERENCE_TYPE_PHANTOM
A value to the
KEY_REFERENCE_TYPE that immediately garbage collects the script after evaluation. |
static String |
REFERENCE_TYPE_SOFT
A value to the
KEY_REFERENCE_TYPE that retains the script until memory is "low" and therefore
should be reclaimed before an OutOfMemoryError occurs. |
static String |
REFERENCE_TYPE_WEAK
A value to the
KEY_REFERENCE_TYPE that marks the script as one that can be garbage collected
even when memory is abundant. |
HIDDEN_G
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME
Constructor and Description |
---|
GremlinGroovyScriptEngine()
Creates a new instance using no
Customizer . |
GremlinGroovyScriptEngine(Customizer... customizers) |
Modifier and Type | Method and Description |
---|---|
CompiledScript |
compile(Reader reader) |
CompiledScript |
compile(String scriptSource) |
Bindings |
createBindings()
Create bindings to be used by this
ScriptEngine . |
Traversal.Admin |
eval(Bytecode bytecode,
Bindings bindings,
String traversalSource)
|
Object |
eval(Reader reader,
ScriptContext context) |
Object |
eval(String script,
ScriptContext context) |
double |
getClassCacheAverageLoadPenalty()
Gets the average time spent compiling new scripts.
|
long |
getClassCacheEstimatedSize()
Gets the estimated size of the class cache for compiled scripts.
|
long |
getClassCacheEvictionCount()
Gets the number of times a script compiled to a class has been evicted from the cache.
|
long |
getClassCacheEvictionWeight()
Gets the sum of the weights of evicted entries from the class cache.
|
long |
getClassCacheHitCount()
Gets the number of times cache look up for a compiled script returned a cached value.
|
double |
getClassCacheHitRate()
Gets the hit rate of the class cache.
|
long |
getClassCacheLoadCount()
Gets the total number of times the cache lookup method attempted to compile new scripts.
|
long |
getClassCacheLoadFailureCount()
Gets the total number of times the cache lookup method failed to compile a new script.
|
double |
getClassCacheLoadFailureRate()
Gets the ratio of script compilation attempts that failed.
|
long |
getClassCacheLoadSuccessCount()
Gets the total number of times the cache lookup method succeeded to compile a new script.
|
long |
getClassCacheLongRunCompilationCount()
Gets the number of compilations that extended beyond the
expectedCompilationTime . |
long |
getClassCacheMissCount()
Gets the total number of times the cache lookup method returned a newly compiled script.
|
double |
getClassCacheMissRate()
Gets the ratio of script compilation attempts that were misses.
|
long |
getClassCacheRequestCount()
Gets the total number of times the cache lookup method returned a cached or uncached value.
|
long |
getClassCacheTotalLoadTime()
Gets the total number of nanoseconds that the cache spent compiling scripts.
|
GremlinScriptEngineFactory |
getFactory() |
<T> T |
getInterface(Class<T> clazz) |
<T> T |
getInterface(Object thiz,
Class<T> clazz) |
protected ClassLoader |
getParentLoader() |
Set |
getPlugins()
Get the list of loaded plugins.
|
protected ScriptContext |
getScriptContext(Bindings nn)
Creates the
ScriptContext using a GremlinScriptContext which avoids a significant amount of
additional object creation on script evaluation. |
Object |
invokeFunction(String name,
Object... args) |
Object |
invokeMethod(Object thiz,
String name,
Object... args) |
void |
reset()
Resets the entire
GremlinGroovyScriptEngine by clearing script caches, recreating the classloader,
clearing bindings. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
eval
eval, eval, eval, eval, get, getBindings, getContext, put, setBindings, setContext
public static final String COMPILE_OPTIONS_VAR_TYPES
public static final String KEY_REFERENCE_TYPE
public static final String REFERENCE_TYPE_PHANTOM
KEY_REFERENCE_TYPE
that immediately garbage collects the script after evaluation.public static final String REFERENCE_TYPE_WEAK
KEY_REFERENCE_TYPE
that marks the script as one that can be garbage collected
even when memory is abundant.public static final String REFERENCE_TYPE_SOFT
KEY_REFERENCE_TYPE
that retains the script until memory is "low" and therefore
should be reclaimed before an OutOfMemoryError
occurs.public static final String REFERENCE_TYPE_HARD
KEY_REFERENCE_TYPE
that makes the evaluated script available in the cache for the life
of the JVM.public static final String COLLECTED_BOUND_VARS_MAP_VARNAME
InterpreterModeGroovyCustomizer
.public static final ThreadLocal<Map<String,Object>> COMPILE_OPTIONS
public GremlinGroovyScriptEngine()
Customizer
.public GremlinGroovyScriptEngine(Customizer... customizers)
public Set getPlugins()
public Traversal.Admin eval(Bytecode bytecode, Bindings bindings, String traversalSource) throws ScriptException
GremlinScriptEngine
Traversal
Bytecode
with the specified Bindings
. These Bindings
supplied to this method will be merged with global engine bindings and override them where keys match.eval
in interface GremlinScriptEngine
ScriptException
public void reset()
GremlinGroovyScriptEngine
by clearing script caches, recreating the classloader,
clearing bindings.protected ScriptContext getScriptContext(Bindings nn)
ScriptContext
using a GremlinScriptContext
which avoids a significant amount of
additional object creation on script evaluation.public Object eval(Reader reader, ScriptContext context) throws ScriptException
eval
in interface ScriptEngine
ScriptException
public Object eval(String script, ScriptContext context) throws ScriptException
eval
in interface ScriptEngine
ScriptException
public Bindings createBindings()
ScriptEngine
. In this case, SimpleBindings
are returned.createBindings
in interface ScriptEngine
public GremlinScriptEngineFactory getFactory()
getFactory
in interface ScriptEngine
getFactory
in interface GremlinScriptEngine
public CompiledScript compile(String scriptSource) throws ScriptException
ScriptException
public CompiledScript compile(Reader reader) throws ScriptException
ScriptException
public Object invokeFunction(String name, Object... args) throws ScriptException, NoSuchMethodException
ScriptException
NoSuchMethodException
public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException
ScriptException
NoSuchMethodException
public <T> T getInterface(Class<T> clazz)
public long getClassCacheLongRunCompilationCount()
expectedCompilationTime
.public long getClassCacheEstimatedSize()
public double getClassCacheAverageLoadPenalty()
public long getClassCacheEvictionCount()
public long getClassCacheEvictionWeight()
public long getClassCacheHitCount()
public double getClassCacheHitRate()
public long getClassCacheLoadCount()
public long getClassCacheLoadFailureCount()
public double getClassCacheLoadFailureRate()
public long getClassCacheLoadSuccessCount()
public long getClassCacheMissCount()
public double getClassCacheMissRate()
public long getClassCacheRequestCount()
public long getClassCacheTotalLoadTime()
protected ClassLoader getParentLoader()
Copyright © 2013–2022 Apache Software Foundation. All rights reserved.