Message

Usage

use Message;

or

import Message;
enum MsgType { NORMAL, WARNING, ERROR }
enum constant NORMAL
enum constant WARNING
enum constant ERROR
enum MsgFormat { STRING, BINARY }
enum constant STRING
enum constant BINARY
enum ObjectType { PDARRAY, SEGSTRING, LIST, DICT, VALUE, DATETIME, TIMEDELTA }
enum constant PDARRAY
enum constant SEGSTRING
enum constant LIST
enum constant DICT
enum constant VALUE
enum constant DATETIME
enum constant TIMEDELTA
record MsgTuple
  • Encapsulates the message string and message type.

var msg: string
var msgType: MsgType
class ReplyMsg
  • Encapsulates state corresponding to a reply message sent back to

  • the Arkouda client.

var msg: string
var msgType: MsgType
var msgFormat: MsgFormat
var user: string
record RequestMsg
  • Encapsulates state corresponding to a client request sent to the Arkouda server.

var user: string
var token: string
var cmd: string
var format: string
var args: string
var size: int
record ParameterObj
  • Encapsulate parameter for a request sent to the Arkouda server

  • Note - Only used when args is in JSON format.

  • Note - during the transition from space delimited string to JSON formated string, this object is not part of RequestMsg,

  • but will be once all messages are transitioned to JSON arguments.

var key: string
var val: string
var objType: ObjectType
var dtype: string
proc init()
proc init(key: string, val: string, objType: ObjectType, dtype: string)
proc asMap() throws
proc getJSON() throws
proc ref setKey(value: string)
proc ref setVal(value: string)
proc ref setObjType(value: ObjectType)
proc ref setDType(value: string)
proc getObjType()
  • Return the objType value

  • Returns str

proc getDType()
  • Return the Dtype value as NumpyDtype

  • Returns Dtype

proc getValue()
  • Return the raw string value

  • Returns string

proc getScalarValue(type t): t throws
  • Attempt to cast the value to the provided type

  • Throw and error if the cast isn’t possible

proc getIntValue(): int throws
  • Return the value as int64

  • Returns int

proc getPositiveIntValue(max: int): int throws
  • Return the value as a positive int64

  • If the value is negative, return ‘value + max + 1’, otherwise return the value

  • This is useful for implementing Python’s negative indexing rules

  • Returns int

proc getUIntValue(): uint throws
  • Return the value as uint64

  • Returns uint

proc getUInt8Value(): uint(8) throws
proc getRealValue(): real throws
  • Return the value as float64

  • Returns real

proc getBoolValue(): bool throws
  • Return the value as bool

  • Returns bool

proc getBigIntValue(): bigint throws
proc getValueAsType(type t = string): t throws
  • Return the value as the provided type

proc getList(size: int) throws

Parse value as a list of strings. :size: int: number of values in the list Note - not yet able to handle list of pdarray or SegString names

proc getListAs(type t, size: int) throws
proc getTuple(param size: int): size*int throws

Parse value as a tuple of integers with the given size

proc getJSON(size: int) throws
class MessageArgs

Container class for the message arguments formatted as json :param_list: array of ParameterObj :size: int - number of parameters contained in list

var param_list: list(ParameterObj)
var size: int
proc init()
proc init(param_list: list(ParameterObj))
proc getJSON(keys: list(string) = list(string)): string throws
proc get(key: string) throws
  • Identify the parameter with the provided key and return it

  • Returns ParameterObj with the provided key

  • Throws KeyNotFound error if the provide key does not exist.

proc getValueOf(key: string) throws
proc items()

Return “iterable” of ParameterObj

proc keys()

Return a list of all keys

proc vals()

Return a list of all values

proc contains(key: string): bool

Return bool if param_list contains given key name

proc parseParameter(payload: string) throws

Parse and individual parameter components into a ParameterObj

proc parseMessageArgs(json_str: string, size: int) throws

Parse arguments formatted as json string into objects

proc deserialize(ref msg: RequestMsg, request: string) throws
  • Deserializes a JSON-formatted string to a RequestMsg object, where the

  • JSON format is as follows (size is only set for json args. Otherwise, -1):

  • {“user”: “user”, “token”: “token”, “cmd”: “cmd”, “format”: “STRING”, “args”: “arg1 arg2”, “size”: “-1”}

proc serialize(msg: string, msgType: MsgType, msgFormat: MsgFormat, user: string): string throws
  • Generates a ReplyMsg object and serializes it into a JSON-formatted reply message

proc jsonToPdArray(json: string, size: int) throws
  • Converts the JSON array to a pdarray

proc parseJsonTuple(json: string, param size: int): size*int throws

Helper function to parse a JSON string as a tuple of integers