Documentation ¶
Index ¶
- Variables
- func CallMethod(ctx *core.Context, stateName, funcName string, dt ...data.Value) (data.Value, error)
- func MustRegisterPyUDF(udfName string, modulePath string, moduleName string, funcName string)
- func MustRegisterPyUDSCreator(typeName string, modulePath string, moduleName string, className string, ...)
- func New(baseParams *BaseParams, params data.Map) (core.SharedState, error)
- type Base
- func (s *Base) Call(funcName string, dt ...data.Value) (data.Value, error)
- func (s *Base) CheckTermination() error
- func (s *Base) Load(ctx *core.Context, r io.Reader, params data.Map) error
- func (s *Base) Save(ctx *core.Context, w io.Writer, params data.Map) error
- func (s *Base) Terminate(ctx *core.Context) error
- func (s *Base) Write(ctx *core.Context, t *core.Tuple) error
- type BaseLoadParams
- type BaseParams
- type Creator
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyTerminated = errors.New("pystate is already terminated")
ErrAlreadyTerminated is occurred when called some python method after the SharedState is terminated.
Functions ¶
func CallMethod ¶
func CallMethod(ctx *core.Context, stateName, funcName string, dt ...data.Value) ( data.Value, error)
CallMethod calls an instance method and returns its value.
func MustRegisterPyUDF ¶
MustRegisterPyUDF is like MustRegisterGlobalUDF for Python module method.
func MustRegisterPyUDSCreator ¶
func MustRegisterPyUDSCreator(typeName string, modulePath string, moduleName string, className string, writeMethodName string)
MustRegisterPyUDSCreator is like MustRegisterGlobalUDSCreator for Python instance, just an alias of pystate.
func New ¶
func New(baseParams *BaseParams, params data.Map) (core.SharedState, error)
New creates `core.SharedState` for python constructor.
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
Base is a wrapper of a UDS written in Python. It has common implementations that can be shared with State, WritableState, and other wrappers. Base doesn't acquire lock and the caller should provide concurrency control over them. Each method describes what kind of lock it requires.
func NewBase ¶
func NewBase(baseParams *BaseParams, params data.Map) (*Base, error)
NewBase creates a new Base state.
func (*Base) Call ¶
Call calls an instance method and returns its value.
Although this call may modify the state of the Python UDS, it doesn't change this Base Go instance itself. Therefore, this method requires read-lock.
func (*Base) CheckTermination ¶
CheckTermination checks if the Base is already terminated. It returns nil if the Base is still working. It returns ErrAlreadyTerminated if the Base has already been terminated.
This method requires read-lock.
func (*Base) Load ¶
Load loads the model of the state. It reads the header of the saved file and calls 'load' static method of the Python UDS. 'load' static method creates a new instance of the Python UDS.
This method requires write-lock.
func (*Base) Save ¶
Save saves the model of the state. It saves its internal state and also calls 'save' method of the Python UDS. The Python UDS must save all the information necessary to reconstruct the current state including parameters passed by CREATE STATE statement.
This method requires read-Lock.
type BaseLoadParams ¶
type BaseLoadParams struct { }
BaseLoadParams has parameters for Base given in SET clause of LOAD STATE statement.
func ExtractBaseLoadParams ¶
func ExtractBaseLoadParams(params data.Map, removeBaseKeys bool) (*BaseLoadParams, error)
ExtractBaseLoadParams extracts parameters for Base from parameters given in a SET clause of LOAD STATE statement. If removeBaseKeys is true, this function removes base parameters from params and only other parameters remain in the map when this function succeeds. If this function fails, all parameters including base parameters remain in the map.
type BaseParams ¶
type BaseParams struct { // ModulePath is a path at where the target Python module is located. // This parameter can be set as "module_path" in a WITH clause. This is // a required parameter. ModulePath string `codec:"module_path"` // ModuleName is a name of a Python module to be loaded. This parameter // can be set as "module_name" in a WITH clause. This is a required parameter. ModuleName string `codec:"module_name"` // ClassName is a name of a class in the Python module to be loaded. This // parameter can be set as "class_name" in a WITH clause. This is a required // parameter. ClassName string `codec:"class_name"` // WriteMethodName is a name of a method which handles Write calls, which // is mostly done by 'uds' Sink. When this parameter is specified, a UDS // will be writable. Otherwise, it doesn't support Write. WriteMethodName string `codec:"write_method"` }
BaseParams has parameters for Base given in WITH clause of CREATE STATE statement.
func ExtractBaseParams ¶
func ExtractBaseParams(params data.Map, removeBaseKeys bool) (*BaseParams, error)
ExtractBaseParams extracts parameters for Base from parameters given in a WITH clause of a CREATE STATE statement. If removeBaseKeys is true, this function removes base parameters from params and only other parameters remain in the map when this function succeeds. If this function fails, all parameters including base parameters remain in the map.
type Creator ¶
type Creator struct { }
Creator is used by BQL to create state as a UDS.
func (*Creator) CreateState ¶
CreateState creates `core.SharedState` of a UDS written in Python. If params has parameters other than the ones defined in BaseParams, they will be directly passed to 'create' static method of the Python UDS.