.. default-domain:: chpl .. module:: MultiTypeSymbolTable MultiTypeSymbolTable ==================== **Usage** .. code-block:: chapel use MultiTypeSymbolTable; or .. code-block:: chapel import MultiTypeSymbolTable; .. data:: const mtLogger = new Logger(logLevel, logChannel) .. class:: SymTab symbol table .. attribute:: var registry = new owned RegTab() Similar to the Symbol Table but for register object tracking .. attribute:: var tab: map(string, shared AbstractSymEntry) Map indexed by strings .. attribute:: var serverid = "id_" + generateToken(8) + "_" .. attribute:: var nid = 0 .. method:: proc nextName(): string Gives out symbol names. .. method:: proc addEntry(name: string, shape: int ...?N, type t): borrowed SymEntry(t, N) throws where isSupportedType(t) Takes args and creates a new SymEntry. :arg name: name of the array :type name: string :arg shape: length of array in each dimension :type shape: int :arg t: type of array :returns: borrow of newly created `SymEntry(t)` .. method:: proc addEntry(name: string, shape: ?ND*int, type t): borrowed SymEntry(t, ND) throws .. method:: proc addEntry(name: string, shape: int ...?N, type t): borrowed SymEntry(t, N) throws where !isSupportedType(t) .. method:: proc addEntry(name: string, in entry: shared AbstractSymEntry): borrowed AbstractSymEntry throws Takes an already created AbstractSymEntry and creates a new AbstractSymEntry. :arg name: name of the array :type name: string :arg entry: AbstractSymEntry to convert :type entry: AbstractSymEntry :returns: borrow of newly created AbstractSymEntry .. method:: proc addEntry(name: string, shape: int ...?ND, dtype: DType): borrowed AbstractSymEntry throws Creates a symEntry from array name, length, and DType :arg name: name of the array :type name: string :arg shape: length of array in each dimension :type shape: int :arg dtype: type of array :returns: borrow of newly created GenSymEntry .. method:: proc addEntry(name: string, shape: ?ND*int, dtype: DType): borrowed AbstractSymEntry throws .. method:: proc deleteEntry(name: string): bool throws Removes an unregistered entry from the symTable :arg name: name of the array :type name: string :returns: bool indicating whether the deletion occurred .. method:: proc clear() throws Clears all unregistered entries from the symTable .. method:: proc lookup(name: string): borrowed AbstractSymEntry throws * * Returns the AbstractSymEntry associated with the provided name, if the AbstractSymEntry exists * :arg name: string to index/query in the sym table * :type name: string * :returns: AbstractSymEntry or throws on error * :throws: `unkownSymbolError(name)` .. method:: proc checkTable(name: string, calling_func = "check") throws * * checks to see if a symbol is defined if it is not it throws an exception .. method:: proc pretty() throws * * Prints the SymTable in a pretty format (name,SymTable[name]) .. method:: proc memUsed(): int * * :returns: total bytes in arrays in the symbol table .. method:: proc dump(name: string): string throws Attempts to format and return sym entries mapped to the provided string into JSON format. Pass __AllSymbols__ to process the entire sym table. :arg name: name of entry to be processed :type name: string .. method:: proc info(names: string): string throws Returns verbose attributes of the sym entries at the given string, if the string is a JSON formmated list of entry names. Pass __AllSymbols__ to process all sym entries in the sym table. Pass __RegisteredSymbols__ to process all registered sym entries. Returns: name, dtype, size, ndim, shape, item size, and registration status for each entry in names :arg names: list containing names of entries to be processed :type names: string :returns: JSON formatted list containing info for each entry in names .. method:: proc parseJson(names: string): [] string throws Convert JSON formmated list of entry names into a [] string object :arg names: JSON formatted list containing entry names :type names: string :returns: [] string of entry names .. method:: proc getEntries(infoList): [] string throws Returns an array of JSON formatted strings for each entry in infoList (tab, registry, or [names]) :arg infoList: Iterable containing sym entries to be returned by info :type infoList: domain(string) or [] string for registry and [names] :returns: array of JSON formatted strings .. method:: proc getEntries(infoList: map(string, shared AbstractSymEntry)): [] string throws Returns an array of JSON formatted strings for each entry in infoList (tab, registry, or [names]) :arg infoList: Iterable containing sym entries to be returned by info :type infoList: map(string, shared GenSymEntry) for tab :returns: array of JSON formatted strings .. method:: proc formatEntry(name: string, abstractEntry: borrowed AbstractSymEntry): string throws Returns formatted string for an info entry. :arg name: name of entry to be formatted :type name: string :arg item: AbstractSymEntry to be formatted (tab[name]) :type item: AbstractSymEntry :returns: JSON formatted dictionary .. method:: proc attrib(name: string): string throws Returns raw attributes of the sym entry at the given string, if the string maps to an entry. Returns: name, dtype, size, ndim, shape, and item size :arg name: name of entry to be processed :type name: string :returns: s (string) containing info .. method:: proc datastr(name: string, thresh: int): string throws Attempts to find a sym entry mapped to the provided string, then returns the data in the entry up to the specified threshold. Arrays of size less than threshold will be printed in their entirety. Arrays of size greater than or equal to threshold will print the first 3 and last 3 elements :arg name: name of entry to be processed :type name: string :arg thresh: threshold for data to return :type thresh: int :returns: s (string) containing the array data .. method:: proc datarepr(name: string, thresh: int): string throws Attempts to find a sym entry mapped to the provided string, then returns the data in the entry up to the specified threshold. This method returns the data in form "array([])". Arrays of size less than threshold will be printed in their entirety. Arrays of size greater than or equal to threshold will print the first 3 and last 3 elements :arg name: name of entry to be processed :type name: string :arg thresh: threshold for data to return :type thresh: int :returns: s (string) containing the array data .. method:: proc contains(name: string): bool Attempts to find a sym entry mapped to the provided string, then returns a boolean value signfying the provided string's sym entry existance :arg name: name of entry to be checked :type name: string :returns: bool signifying existance of the sym entry .. method:: proc findAll(pattern: string): [] string throws Attempts to find all sym entries that match the provided regex string, then returns a string array of matching names :arg pattern: regex string to search for :type pattern: string :returns: string array containing matching entry names .. function:: proc getGenericTypedArrayEntry(name: string, st: borrowed SymTab): borrowed GenSymEntry throws * * Convenience proc to retrieve GenSymEntry from SymTab * Performs conversion from AbstractSymEntry to GenSymEntry * You can pass a logger from the calling function for better error reporting. .. function:: proc getSegStringEntry(name: string, st: borrowed SymTab): borrowed SegStringSymEntry throws * * Convenience proc to retrieve SegStringSymEntry from SymTab * Performs conversion from AbstractySymEntry to SegStringSymEntry * You can pass a logger from the calling function for better error reporting.