Enum Class WorkerPythonEnvironment

java.lang.Object
java.lang.Enum<WorkerPythonEnvironment>
com.illumon.iris.db.util.WorkerPythonEnvironment
All Implemented Interfaces:
Serializable, Comparable<WorkerPythonEnvironment>, java.lang.constant.Constable

public enum WorkerPythonEnvironment extends Enum<WorkerPythonEnvironment>
This class is the support infrastructure for running Python remote queries.

It is a singleton that contains an instance of a PythonHolder. All of the specially handled db operations from a remote Python session should execute queries which interact with this class. The script sessions that run for PersistentQueries or consoles are handled separately by the IrisDbPythonSession.

  • Enum Constant Details

  • Method Details

    • values

      public static WorkerPythonEnvironment[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static WorkerPythonEnvironment valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • pushClass

      public boolean pushClass(PythonPushClassQuery pythonPushClassQuery)
      Loads a class that was dilled by the remote Python process into our environment.
      Parameters:
      pythonPushClassQuery - the query containing the dilled Python object
      Returns:
      true if successful (because remote queries need to have a return value)
    • doEval

      public Boolean doEval(PythonEvalQuery pythonEvalQuery)
      Evaluates one or more statements in the context of our python environment.

      Intended for debugging problems with your remote Python session.

      Parameters:
      pythonEvalQuery - the remote query containing the python String to evaluate.
      Returns:
      true if successful (because remote queries need to have a return value)
    • fetch

      public Object fetch(String name)
      Retrieves a value from our Python holder's globals.

      When the object is a convertible PyObject; we return the PyObject. Otherwise, we'll return a PythonRemoteQuery.PickledResult, which is suitable for unpickling by the remote side.

      The caller should never serialize an unconverted PyObject; it contains a raw pointer and will result in a Hotspot or memory corruption on the remote side.

      Parameters:
      name - the variable to retrieve
      Returns:
      the variable as a Java object; or pickled
    • doQuery

      public Object doQuery(Database db, com.fishlib.io.logger.Logger log, PythonRemoteQuery pythonRemoteQuery)
      Executes a Remote Query sent by Python.

      The PythonRemoteQuery object contains the dilledObject from the remote side; and through the magic of duck typing anything that contains an execute method just happens to be a remote query.

      We set the database, decode the original object and call the execute method with db as a parameter. The return value is stuck in a variable, which we then fetch and return as the result.

      Parameters:
      db - the database to execute against
      log - our log object
      pythonRemoteQuery - the remote query containing the Python dilled object
      Returns:
      the result of the execute method from within Python, appropriate converted for sending over the wire