0.1.0
Loading a data into a table.
Class that represents the header of a Table. Constructs an instance of a Header by reading its properties from the beginning of the specified memory block.
(MemoryBlock)
The memory containing the table header. The table header must be at the beginning.
The length in bytes of a header's meta (without the columns)
Type: number
The length in bytes of a column's meta (without counting its name)
Type: number
Convenience function to build a header descriptor from an array of column descriptors.
(Array<ColumnDescriptor>)
The columns to initialize the header with
(number?
= 0
)
The length of the memory where the table will reside. Defaults to 0
(MemoryLayout?
= Header.memoryLayout.RELATIONAL
)
The layout of the table. Defaults to RELATIONAL
HeaderDescriptor
:
Convenience function to build a binary header from an array of column descriptors.
(Array<ColumnDescriptor>)
The columns to initialize the header with
(number?
= 0
)
The length of the memory where the table will reside. Defaults to 0
(MemoryLayout?
= Header.memoryLayout.RELATIONAL
)
The layout of the table. Defaults to RELATIONAL
ArrayBuffer
:
Convenience function to build a binary buffer containing the header info from an object descriptor.
(HeaderDescriptor)
Object describing the properties of the header
ArrayBuffer
:
The number of rows that the table linked to this header should contain.
Type: number
The number of bytes a pointer needs to shift to move from one row to the next.
Type: number
The length, in bytes, of the data contained in the table this header is describing.
Type: number
The memory layout of the table.
Type: MemoryLayout
Class that represents a table in binary memory.
(MemoryBlock)
The MemoryBlock containing the table's data
Crates a new empty Table with the specified columns in the supplied memory. The table will be able to grow as big as the memory that contains it.
(Array<ColumnDescriptor>)
The columns for the new Table
(MemoryBlock)
The memory where the new Table will live
(MemoryLayout?
= Header.memoryLayout.RELATIONAL
)
The memory layout to use for the new table. Defaults to RELATIONAL
Table
:
Crates a new empty Table with the specified header descriptor in the supplied memory. The table will be able to grow as big as the memory that contains it.
(HeaderDescriptor)
The header descriptor tu use
(MemoryBlock)
The memory where the new Table will live
Table
:
Crates a new empty Table with the specified binary header in the supplied memory. The table will be able to grow as big as the memory that contains it.
(ArrayBuffer)
The binary header to use
(MemoryBlock)
The memory where the new Table will live
Table
:
Destroys this table instance and frees the memory associated with it. This method must be called when the memory associated to this table is no longer needed to avoid memory leaks in kruda's internal memory management system.
The header of this table. Contains column names, order in memory, original order and type information.
Type: Header
The memory block that contains this table's layout and data.
Type: MemoryBlock
The offset, in bytes, from the beginning of this table to the row data.
Type: number
Gets a new Row instance pointing at the row at the specified index.
NOTE: The returned row can be moved to point to a different row by changing its index
property.
(number)
The index of the row to get the data from.
(Row?
= new Row(this,index)
)
An optional row, belonging to this table, to reuse. Useful to reduce garbage collection.
Row
:
Gets a new Row instance pointing at the row at the specified index. The resulting row will return
ByteString instances for the column fields which are strings. ByteStrings are faster to work with but are
not replacements for JavaScript strings.
NOTE: The returned row can be moved to point to a different row by changing its index
property.
(number)
The index of the row to get the data from.
(Row?
= new Row(this,index,true)
)
An optional row, belonging to this table, to reuse. Useful to reduce garbage collection.
Row
:
Iterates through all the rows in this table and invokes the provided callback itr
on each iteration.
WARNING: This function is designed to avoid garbage collection and improve performance so the row passed to the
itr
callback is reused, the row cannot be stored as its contents will change. If you need to store unique rows
consider using the getRow
method.
Class to read and write values of a row in a Table.
Constructs an instance of a row in the given table at the specified index.
Each Row instance automatically adds new properties with the names of the columns to its fields
object for
easy access.
WARNING: String returned by a row will mutate when the row's address changes, if strings with constant values are
needed, either copy of the string or create a JS string from it by calling toString
on it.
(Table)
The table this row belongs to.
(number?)
the row index at which this instance will read data. Defaults to 0.
(boolean?)
Should this row return binary strings.
The number of bytes the internal pointer shifts in order to move to the next/previous row in the data.
Type: number
An object containing properties to get and set the values for the fields in this row based on their column names. NOTE: Setting values is not implemented yet.
Type: object
The internal pointer this row uses to access its memory. Changing the location of this pointer will result in the contents of the row being updated. WARNING: Setting the address of this pointer to a memory address that does not represent the beginning of a row in a table will result in undefined behaviour.
Type: Pointer
Class that fetches the data from a source table based on the index numbers of another table, usually resulting from a filter operation.
(Table)
The table from which the values will be read.
(Table)
The table containing the indices to fetch.
Destroys this table instance and frees the memory associated with it. This method must be called when the memory associated to this table is no longer needed to avoid memory leaks in kruda's internal memory management system. WARNING: While this method destroys its index table, it does not destroy its source table. DEV NOTE: Implementing a reference counting system could make it more intuitive and allow users to leave memory management to kruda (although retaining and releasing instances would still be the user's responsibility).
The table containing the indices to access the data from the source table.
Type: Table
The table which will be proxied using the indices in the index table.
Type: Table
The header of the source data table. Contains column names, order in memory, original order and type information.
Type: Header
The header of the index data table. Contains column names, order in memory, original order and type information.
Type: Header
The memory block that contains the index table's layout and data.
Type: MemoryBlock
The memory block that contains the source data table's layout and data.
Type: MemoryBlock
The offset, in bytes, from the beginning of the index table to the row data.
Type: number
The offset, in bytes, from the beginning of the source data table to the row data.
Type: number
Gets a new Row instance pointing at the row at the specified index.
NOTE: The returned row can be moved to point to a different row by changing its index
property.
(number)
The index of the row to get the data from.
(ProxyRow?
= new ProxyRow(this,index)
)
An optional row, belonging to this table, to reuse. Useful to reduce garbage collection.
ProxyRow
:
Gets a new Row instance pointing at the row at the specified index. The resulting row will return
ByteString instances for the column fields which are strings. ByteStrings are faster to work with but are
not replacements for JavaScript strings.
NOTE: The returned row can be moved to point to a different row by changing its index
property.
(number)
The index of the row to get the data from.
(ProxyRow?
= new ProxyRow(this,index,true)
)
An optional row, belonging to this table, to reuse. Useful to reduce garbage collection.
ProxyRow
:
Iterates through all the rows in this table and invokes the provided callback itr
on each iteration.
WARNING: This function is designed to avoid garbage collection and improve performance so the row passed to the
itr
callback is reused, the row cannot be stored as its contents will change. If you need to store unique rows
consider using the getRow
method.
Class to read and write values of a row in a ProxyTable.
Constructs an instance of a row in the given table at the specified index.
Each Row instance automatically adds new properties with the names of the columns to its fields
object for
easy access.
WARNING: String returned by a row will mutate when the row's address changes, if strings with constant values are
needed, either copy of the string or create a JS string from it by calling toString
on it.
(ProxyTable)
The table this row belongs to.
(number?)
the row index at which this instance will read data. Defaults to 0.
(boolean?)
Should this row return binary strings.
An object containing properties to get and set the values for the fields in this row based on their column names. NOTE: Setting values is not implemented yet.
Type: object
The internal pointer this row uses to access its memory. Changing the location of this pointer will result in the contents of the row being updated. WARNING: Setting the address of this pointer to a memory address that does not represent the beginning of a row in a table will result in undefined behaviour.
Type: Pointer
Creates a Table instance and fills its contents from the specified local CSV file.
(File)
A file instance, representing the file to load.
(Heap)
The heap where the loaded table will be stored.
Table
:
Filtering, aggregation, etc.
Class to create and run filters on tables. Creates a Filter instance bound to the specified table.
(Table)
The table this filter will be bound to.
(number?)
The number of workers to spawn, should be the same as physical cores in the system, defaults to automatically detected.
(Heap?)
The heap to use to allocate the filter results memory, defaults to using the same heap where the table is allocated.
Utility function to create an object describing a result field for the column with the specified name.
If the columnName
parameter is omitted or is set to null
, an object that adds the index of the resulting row
will be returned.
((string | null)?
= null
)
The name of the column for which to create a result field object. Defaults to
null
.
Object
:
Utility function to create an object describing a result field for the column with the specified index.
If the columnIndex
parameter is omitted or is set to null
, an object that adds the index of the resulting row
will be returned.
((number | null)?
= null
)
The index of the column for which to create a result field object. Defaults to
null
.
Object
:
Runs this filter with the specified set of rules.
(FilterExpression)
The rules to run this filter with.
(FilterExpressionMode?
= FilterExpressionMode.DNF
)
The mode in which the specified rules should be interpreted.
Promise<(Table | ProxyTable)>
:
Class to process filters on Tables. This class is meant to be used by filter workers, but it is safe to use on the main thread as well. Creates a new instance and reconstructs the Heap, Memory Object and Table specified in the config object. NOTE: Heap, MemoryBlock and Table classes are thread safe.
Sets the memory this filter processor should use during processing. Useful when SharedArrayBuffer is not available.
Fetches the memory from this filter processor and invalidates all objects linked to it. WARNING: This filter worker will not work after this function is called and before a new memory block is set.
(ArrayBuffer | SharedArrayBuffer)
:
A set of clauses that describe a filter. How it will be interpreted depends in the FilterExpressionMode used at runtime.
Type: Array<FilterClause>
Group of rules used by this filter, it will interpreted either as a conjunction or disjunction, depending on the FilterExpressionMode used at runtime.
Type: Array<FilterRule>
Object describing a single rule used in a filter.
Type: Object
Enum containing the different operations that a filter can perform.
Indicates that string-based values contains the given value, or that collection-based values contain the given value
Indicates that string-based values dose not contain the given value, or that collection-based values do not contain the given value
Indicates that the row value is part of the given array of values
Indicates that row value is not in the given array of values
Filters for rows where the target field equals the value
Filters for rows where the target field is not equal to the value
Filters for rows where the value is greater than the given value
Filters for rows where the value is greater than the given value
Filters for rows where the value is less than the given value
Filters for rows where the value is less than the given value
Filters for rows where the string value starts with the given value
Filters for rows where the string value ends with the given value
Enum that represents the different modes in which a filter can be interpreted.
Can be "conjunctive normal form" boolean logic: https://en.wikipedia.org/wiki/Conjunctive_normal_form or "disjunctive normal form" boolean logic: https://en.wikipedia.org/wiki/Disjunctive_normal_form
Short form for conjunctive normal form.
Same as conjunctiveNormalForm
Long form for conjunctive normal form.
Same as CNF
Short form for disjunctive normal form.
Same as disjunctiveNormalForm
Long form for disjunctive normal form.
Same as DNF
Type: _ByteString
Creates a new ByteString instance based on the provided arguments. Using the more specific fromPointer
,
fromBuffer
and fromString
functions is recommended.
(number?
= 0
)
An offset, if needed for the resulting instance. Defaults to 0.
(number?
= 255
)
The maximum size, if needed, of the resulting instance. Defaults to 255.
ByteStringBase
:
Creates a new ByteString instance based on the provided arguments. Using the more specific fromPointer
,
fromBuffer
and fromString
functions is recommended.
(number?
= 0
)
An offset, if needed for the resulting instance. Defaults to 0.
(number?
= 255
)
The maximum size, if needed, of the resulting instance. Defaults to 255.
ByteStringBase
:
Creates a ByteString instance from a pointer.
(Pointer)
The pointer to read the string data from.
(number?
= 0
)
The offset, from the location of the pointer, to read the data from. Defaults to 0.
(number?
= 255
)
The maximum size of this string in bytes. Defaults to 255.
ByteStringPtr
:
Creates a ByteString instance from a pointer.
(Pointer)
The pointer to read the string data from.
(number?
= 0
)
The offset, from the location of the pointer, to read the data from. Defaults to 0.
(number?
= 255
)
The maximum size of this string in bytes. Defaults to 255.
ByteStringPtr
:
Creates a ByteString instance from an ArrayBuffer
(ArrayBufferLike)
The ArrayBuffer object where this string resides.
(number?
= 0
)
The offset, in bytes, within the buffer where the string resides. Defaults to 0.
(number?
= 255
)
The maximum size of this string in bytes. Defaults to 255.
ByteStringBuffer
:
Creates a ByteString instance from an ArrayBuffer
(ArrayBufferLike)
The ArrayBuffer object where this string resides.
(number?
= 0
)
The offset, in bytes, within the buffer where the string resides. Defaults to 0.
(number?
= 255
)
The maximum size of this string in bytes. Defaults to 255.
ByteStringBuffer
:
Creates a byte string from a JS string.
(string)
The string to copy during creation.
ByteStringBuffer
:
Creates a byte string from a JS string.
(string)
The string to copy during creation.
ByteStringBuffer
:
Base class for all byte string classes. Cannot be used directly. Constructs a ByteString instance of the given size.
(number)
The maximum size of this string.
Type: ArrayBufferLike
Checks if two byte strings are equal. Case sensitive.
(ByteStringBase)
The string to test against.
boolean
:
Checks if two byte strings are equal. Case insensitive.
(ByteStringBase)
The string to test against.
boolean
:
Checks if this byte strings contains another string. Case sensitive.
(ByteStringBase)
The string to test against.
boolean
:
Checks if this byte strings contains another string. Case insensitive.
(ByteStringBase)
The string to test against.
boolean
:
ByteString implementation using pointers. If the underlying pointer changes location the contents of this string are automatically updated to reflect the data contained at the new location. Constructs a byte string instance backed by a Pointer.
(Pointer)
The pointer to read the string data from.
(number?)
The offset, from the location of the pointer, to read the data from. Defaults to 0.
(number?)
The maximum size of this string in bytes. Defaults to 255.
ByteString implementation using ArrayBuffers. This implementation is useful for quick off-heap strings. It also guarantees that it will not change its contents without implicit user interaction. Constructs a byte string backed by an ArrayBuffer.
(ArrayBufferLike)
The ArrayBuffer object where this string resides.
(number?)
The offset, in bytes, within the buffer where the string resides. Defaults to 0.
(number?)
The maximum size of this string in bytes. Defaults to 255.
Type base class, utilities and primitive type definitions.
Type: Object
Creates a new type instance. In DEBUG mode performs checks if the bit and byte sizes are consistent.
Utility function, the same as Type.isType
(Type)
The type to inspect
boolean
:
Utility function, the same as Type.isPrimitive
(Type)
The type to inspect
boolean
:
Utility function, the same as Type.sizeOf
(Type)
The type to inspect
number
:
Utility function, the same as Type.getTypeByName
(string)
The name of the type to look for.
Type
:
Type: _Int8
Type: _Int16
Type: _Int32
Type: _Uint8
Type: _Uint16
Type: _Uint32
Type: _Float32
Type: _Void
Classes dedicated to memory access/management.
Lightweight Heap class used to very naively allocate memory within an ArrayBuffer. Thread safe. Uses a stack approach to memory allocation/deallocation, only when the last memory block in the stack is freed the allocatable memory increases.
((ArrayBuffer | SharedArrayBuffer | number))
The buffer to use or the size in bytes to allocate.
The memory buffer managed by this heap.
Type: (ArrayBuffer | SharedArrayBuffer)
Total memory used. Freeing a memory block does not guarantee that this number will increase.
Type: number
The memory address that will be assigned to the next allocation.
Type: number
Allocates a new memory block. The allocated memory is rounded up to the nearest multiple of 4 and padded by 4 bytes at the end of the block.
(number)
The amount of memory, in bytes, to allocate.
MemoryBlock
:
Allocates a new memory block and guarantees that the memory block will be empty.
(number)
The amount of memory, in bytes, to allocate.
MemoryBlock
:
Frees the specified memory block. Memory is not reusable until the memory stack can be reduced by freeing the last allocated memory block.
(MemoryBlock)
The memory block to free.
Shrinks the specified memory block to the specified size.
(MemoryBlock)
The memory block to shrink.
(number)
The new memory size for the block, must be smaller than the its current size.
Class to encapsulate an ArrayBuffer with utility views to read/write data. Instantiates a memory block in the specified heap, at the memory address and the specified size. Memory blocks can easily be recreated in web workers.
(Heap)
The heap which will contain the memory.
(number)
The byte address of the beginning of the memory.
(number)
The size, in bytes, of this memory block.
The ArrayBuffer this memory is tied to.
Type: (ArrayBuffer | SharedArrayBuffer)
A DataView instance bound to the memory accessible by this memory block.
Type: DataView
Frees this memory block, this function just calls free
on the heap.
This class represents a position in a memory block.
((Heap | MemoryBlock))
The memory to which this Pointer will be bound to.
(number?)
The address of this pointer relative to the memory it is bound to.
(Type?)
The type of this pointer, defaults to Uint8.
Returns the memory this pointer is bound to.
Type: (Heap | MemoryBlock)
DS BIN files utilities.
Multi-threaded DSBIN file loader.
Loads a DSBIN from a local file.
(File)
The local file to load.
(Heap)
The heap where the file will be loaded.
Promise<MemoryBlock>
:
Loads a DSBIN from a URL.
(string)
The URL from which the DSBIN should be loaded.
(Heap)
The heap where the file will be loaded.
Promise<MemoryBlock>
:
Utility class to inflate zlib compressed ArrayBuffers into a custom ArrayBuffer, could be a SharedArrayBuffer.
(Uint8Array)
Buffer where the uncompressed data will be written.
(number?)
The expected final size of the uncompressed data. Defaults to the full size of
outputBuffer
Inflates the inputBuffer
data into the outputBuffer
optionally a final size
can be specified.
(Uint8Array)
The compressed data.
(Uint8Array)
Buffer where the uncompressed data will be written.
(number?
= outputBuffer.length
)
The expected final size of the uncompressed data. Defaults to the full size of
outputBuffer
number
:
Uncategorized or undocumented objects.
Type: (Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray)
Simple wrapper to provide atomics-like functionality in systems that lack the functionality.
Type: (Atomics | AtomicsLike)
Simple stubbing for Atomics. WARNING: Does not implement any kind of synchronization.
Adds a given value at a given position in the array and returns the old value at that position
(IntTypedArray)
The typed array instance where the operation will be performed.
(number)
The index at which the operation will be performed.
(number)
The value to use while performing the operation.
number
:
Computes a bitwise AND with a given value at a given position in the array, and returns the old value at that position.
(IntTypedArray)
The typed array instance where the operation will be performed.
(number)
The index at which the operation will be performed.
(number)
The value to use while performing the operation.
number
:
Exchanges a given replacement value at a given position in the array, if a given expected value equals the old value. It returns the old value at that position whether it was equal to the expected value or not
(IntTypedArray)
The typed array instance where the operation will be performed.
(number)
The index at which the operation will be performed.
(number)
The value to check for equality.
(number)
The number to exchange.
number
:
Stores a given value at a given position in the array and returns the old value at that position.
(IntTypedArray)
The typed array instance where the operation will be performed.
(number)
The index at which the operation will be performed.
(number)
The value to use while performing the operation.
number
:
Returns a value at a given position in the array.
(IntTypedArray)
The typed array instance where the operation will be performed.
(number)
The index at which the operation will be performed.
number
:
Notifies up some agents that are sleeping in the wait queue. WARNING: NOT SUPPORTED IN SYSTEMS WITHOUT Atomics.
(Int32Array)
The typed array instance where the operation will be performed.
(number)
The index at which the operation will be performed.
(number)
The number of threads to be notified.
number
:
Computes a bitwise OR with a given value at a given position in the array, and returns the old value at that position.
(IntTypedArray)
The typed array instance where the operation will be performed.
(number)
The index at which the operation will be performed.
(number)
The value to use while performing the operation.
number
:
Stores a given value at the given position in the array and returns that value.
(IntTypedArray)
The typed array instance where the operation will be performed.
(number)
The index at which the operation will be performed.
(number)
The value to use while performing the operation.
number
:
Substracts a given value at a given position in the array and returns the old value at that position.
(IntTypedArray)
The typed array instance where the operation will be performed.
(number)
The index at which the operation will be performed.
(number)
The value to use while performing the operation.
number
:
Verifies that a given position in an Int32Array still contains a given value and if so sleeps, awaiting a wakeup or a timeout. It returns a string which is either "ok", "not-equal", or "timed-out". WARNING: NOT SUPPORTED IN SYSTEMS WITHOUT Atomics.
(Int32Array)
The typed array instance where the operation will be performed.
(number)
The index at which the operation will be performed.
(number)
The value to use while performing the operation.
(number
= Infinity
)
Time, in milliseconds, to wait before the operation times out.
string
:
Computes a bitwise XOR with a given value at a given position in the array, and returns the old value at that position.
(IntTypedArray)
The typed array instance where the operation will be performed.
(number)
The index at which the operation will be performed.
(number)
The value to use while performing the operation.
number
:
Returns the estimated physical core count in this system.
Promise<number>
:
Extends Type
Extends Type
Extends Type
Extends Type
Extends Type
Extends Type
Extends Type
Void type (not to be confused with the void
value.
Extends Type
Creates a Table instance and fills its contents from the specified remote CSV file.
(string)
The URL from which the CSV file will be loaded.
Promise<Table>
:
Class that represents a column in a Header Constructs a Column by reading its properties from the offsets in the specified memory block.
(MemoryBlock)
The memory to initialize this instance with
(number)
The byte offset for the size, offset and type fields.
(number)
The byte offset for this column's name string.
RELATIONAL: 0 COLUMNAR: 1
Type:
(0
| 1
)
Different memory layouts for a table
Type: Object
The length in bytes of a column's meta (without counting its name)
Type: number
Type: Object
(Array<ColumnDescriptor>)
: The columns in the table
(number)
: Current number of rows in the table.
(number)
: The length, in bytes, of a row in the table.
(number)
: The number of bytes a pointer needs to shift to point at the next/prev row.
(number)
: The total length, in bytes, of the data contained in the table.
(MemoryLayout)
: The layout for the data in this table
The length in bytes of a header's meta (without the columns)
Type: number
ByteString type
Extends Type
Binary type list.
Binary type map.
Base class for all vector classes that implements the convenience functions of the class. Cannot be used directly. Constructs a VectorBase instance.
(number)
The number of components in the vector
Vector class that gets its data from an ArrayBuffer.
(Type)
The type of the components in this vector
(number)
The number of components in the vector
(ArrayBufferLike)
The buffer from which the components will be read
(number?)
The offset, in bytes, where the data resides within the buffer
_Vector type
Extends Type