MultiTypeSymEntry

Usage

use MultiTypeSymEntry;

or

import MultiTypeSymEntry;
const genLogger = new Logger(logLevel, logChannel)
enum SymbolEntryType { AbstractSymEntry, TypedArraySymEntry, PrimitiveTypedArraySymEntry, ComplexTypedArraySymEntry, GenSymEntry, SegStringSymEntry, CompositeSymEntry, GeneratorSymEntry, AnythingSymEntry, UnknownSymEntry, None }
  • Internal Types we can use to build our Symbol type hierarchy.

  • We are making the types a little more concrete than using Strings

enum constant AbstractSymEntry
enum constant TypedArraySymEntry
enum constant PrimitiveTypedArraySymEntry
enum constant ComplexTypedArraySymEntry
enum constant GenSymEntry
enum constant SegStringSymEntry
enum constant CompositeSymEntry
enum constant GeneratorSymEntry
enum constant AnythingSymEntry
enum constant UnknownSymEntry
enum constant None
class AbstractSymEntry
  • This is the root of our SymbolTable Entry / Typing system.

  • All other SymEntry classes should inherit from this class

  • or one of its ancestors and ultimately everything should

  • be assignable/coercible to this class.

  • All subclasses should set & add their type to the assignableTypes

  • set so we can maintain & determine the type hierarchy.

var entryType: SymbolEntryType
var assignableTypes: set(SymbolEntryType)
var name = ""
proc init()
proc init(input)
proc setName(name: string)

Sets the name of the entry when it is added to the Symbol Table

proc isAssignableTo(entryType: SymbolEntryType): bool
  • This can be used to help determine if a class can be

  • assigned / coerced / cast to another one in its hierarchy.

proc getSizeEstimate(): int
  • This is a hook for the ServerConfig.overMemLimit procedure

  • All concrete classes should override this method

proc entry__str__(thresh: int = 1, prefix: string = "", suffix: string = "", baseFormat: string = ""): string throws
  • Formats and returns data in this 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 thresh

    threshold for data to return

  • type thresh

    int

  • arg prefix

    String to prepend to the front of the data string

  • type prefix

    string

  • arg suffix

    String to append to the tail of the data string

  • type suffix

    string

  • arg baseFormat

    String which represents the base format string for the data type

  • type baseFormat

    string

  • returns

    s (string) containing the array data

proc toSymEntry(gse: borrowed GenSymEntry, type etype, param dimensions = 1)

Casts a GenSymEntry to the specified type and returns it.

Arguments

gse – generic sym entry

class GenSymEntry: AbstractSymEntry

This is a dummy class to avoid having to talk about specific instantiations of SymEntry. GenSymEntries can contain multiple SymEntries, but they represent a singular object. For example, SegArray contains the offsets and values array, but only the values are considered data.

var dtype: DType
var itemsize: int
var size: int = 0
var ndim: int = 1
var shape: string = "[0]"
override proc getSizeEstimate(): int
proc toSymEntry(type etype, param dimensions = 1)

Cast this GenSymEntry to borrowed SymEntry(etype)

This function will halt if the cast fails.

Arguments

etype : typeSymEntry type parameter

override proc entry__str__(thresh: int = 1, prefix: string = "", suffix: string = "", baseFormat: string = ""): string throws

Formats and returns data in this 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 thresh

threshold for data to return

type thresh

int

arg prefix

String to prepend to the front of the data string

type prefix

string

arg suffix

String to append to the tail of the data string

type suffix

string

arg baseFormat

String which represents the base format string for the data type

type baseFormat

string

returns

s (string) containing the array data

class SymEntry: GenSymEntry

Symbol table entry

type etype

generic element type array etype is different from dtype (chapel vs numpy)

param dimensions: int

number of dimensions, to be passed back to the GenSymEntry so that we are able to make it visible to the Python client

var tupShape: dimensions*int

the actual shape of the array, this has to live here, since GenSymEntry has to stay generic

var a = makeDistArray(...tupShape, etype)

‘a’ is the distributed array whose value and type are defined by makeDist{Dom,Array}() to support varying distributions

proc aD

Removed domain accessor, use a.domain instead

var max_bits: int = -1

only used with bigint pdarrays

proc init(a: [?D] ?etype)  where MyDmap != Dmap.defaultRectangular && a.isDefaultRectangular()

This init takes an array whose type is defaultRectangular (convenience function for creating a distributed array from a non-distributed one)

Arguments

a : [] ?etype – array

proc deinit()

Verbose flag utility method

override proc entry__str__(thresh: int = 6, prefix: string = "[", suffix: string = "]", baseFormat: string = "%\?"): string throws

Formats and returns data in this 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 thresh

threshold for data to return

type thresh

int

arg prefix

String to pre-pend to the front of the data string

type prefix

string

arg suffix

String to append to the tail of the data string

type suffix

string

arg baseFormat

String which represents the base format string for the data type

type baseFormat

string

returns

s (string) containing the array data

proc createSymEntry(shape: int ..., type etype) throws
proc createSymEntry(in a: [?D] ?etype, max_bits = -1) throws
class CompositeSymEntry: AbstractSymEntry

Base class for any entry that consists of multiple SymEntries that have varying types. These entries are related, but do not represent a single object. For Example, group by contains multiple SymEntries that are all considered part of the dataset.

var ndim: int = 1
var size: int = 0
proc init(len: int = 0)
proc createTypedSymEntry(len: int, type t) throws
  • Factory method for creating a typed SymEntry and checking mem limits

  • arg len

    the number of elements to allocate

  • type len

    int

  • arg t

    the element type

  • type t

    type

class SegStringSymEntry: GenSymEntry
type etype = string
var offsetsEntry: shared SymEntry(int, 1)
var bytesEntry: shared SymEntry(uint(8), 1)
proc init(offsetsSymEntry: shared SymEntry(int), bytesSymEntry: shared SymEntry(uint(8)), type etype)
override proc getSizeEstimate(): int
override proc entry__str__(thresh: int = 1, prefix: string = "", suffix: string = "", baseFormat: string = ""): string throws
  • Formats and returns data in this 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 thresh

    threshold for data to return

  • type thresh

    int

  • arg prefix

    String to prepend to the front of the data string

  • type prefix

    string

  • arg suffix

    String to append to the tail of the data string

  • type suffix

    string

  • arg baseFormat

    String which represents the base format string for the data type

  • type baseFormat

    string

  • returns

    s (string) containing the array data

class GeneratorSymEntry: AbstractSymEntry
type etype
var generator: randomStream(etype)
var state: int
proc init(generator: randomStream(?etype), state: int = 1)
proc toGenSymEntry(entry: borrowed AbstractSymEntry) throws
  • Helper proc to cast AbstrcatSymEntry to GenSymEntry

proc toCompositeSymEntry(entry: borrowed AbstractSymEntry) throws
  • Helper proc to cast AbstractSymEntry to CompositeSymEntry

proc toSegStringSymEntry(entry: borrowed AbstractSymEntry) throws
  • Helper proc to cast AbstractSymEntry to SegStringSymEntry

proc toGeneratorSymEntry(entry: borrowed AbstractSymEntry, type t) throws
  • Helper proc to cast AbstractSymEntry to GeneratorSymEntry

proc getArraySpecFromEntry(entry: borrowed AbstractSymEntry) throws
  • Temporary shim to ease transition to Typed Symbol Table Entries.

  • This attempts to retrieve the Dtype, size/array-length, and itemsize from a SymbolTable

  • entry if the entry type supports it. Returns default tuple of valuse otherwise.

  • arg entry

    AbstractSymEntry or descendant

  • type entry

    borrowed AbstractSymEntry

  • retruns

    tuple of (dtype, entry.size, entry.itemsize)

  • Note: entry.size is generally the number of elements in the array

  • and is more synonymous with length

proc tupShapeString(shape): string

Create a string to represent a JSON tuple of an array’s shape

proc tupShapeString(val: int, ndim: int): string