NDJSON

NDJSON

The namespace for NDJSON utility functions.

Source:

Methods

(static) diff(arg0_id, arg1_timestamp) → {Promise.<(Object|null)>}

Returns a diff over .history.keyframes for the ID in question.

Source:
Parameters:
Name Type Description
arg0_id string
arg1_timestamp Object
Returns:
Type:
Promise.<(Object|null)>

(static) diffAll(arg0_timestamp) → {Promise.<Array.<Object>>}

Diffs all .history.keyframes for all Objects for a given ID, so long as they have that field.

Source:
Parameters:
Name Type Description
arg0_timestamp number | string
Returns:
Type:
Promise.<Array.<Object>>

(static) diffBBox(arg0_optionsopt) → {Promise.<Array.<Object>>}

Returns diffs over .history.keyframes for entities intersecting the bounding box at the given timestamp.

Source:
Parameters:
Name Type Attributes Description
arg0_options Object <optional>
Name Type Attributes Description
bbox Array.<number> <optional>

[min_x, min_y, max_x, max_y]

timestamp number | string
zoom number <optional>
Returns:
Type:
Promise.<Array.<Object>>

(static) getCacheDirectory(arg0_file_pathopt) → {string}

Returns the unified cache partition directory in saves/.cache.

Source:
Parameters:
Name Type Attributes Description
arg0_file_path string <optional>
Returns:
Type:
string

(static) getCacheDirectory(arg0_file_pathopt) → {string}

Returns the cache partition directory in saves/.cache.

Source:
Parameters:
Name Type Attributes Description
arg0_file_path string <optional>
Returns:
Type:
string

(static) getDiagnostics() → {Promise.<Array.<{worker_id: number, rss: number, heapUsed: number, heapTotal: number, heapLimit: number, percentage: number}>>}

Resolves active RAM diagnostic percentage statistics from every worker in the pool.

Source:
Returns:
Type:
Promise.<Array.<{worker_id: number, rss: number, heapUsed: number, heapTotal: number, heapLimit: number, percentage: number}>>

(static) getDiffs(arg0_ids, arg1_timestamp) → {Promise.<Array.<(Object|null)>>}

Returns diffs over .history.keyframes for multiple IDs in 1-pass.

Source:
Parameters:
Name Type Description
arg0_ids Array.<string>
arg1_timestamp number
Returns:
Type:
Promise.<Array.<(Object|null)>>

(static) getFilePath() → {string}

Returns the resolved base file path for the active NDJSON / savefile database.

Source:
Returns:
Type:
string

(static) getKeyframes(arg0_id) → {Promise.<Object>}

Returns processed .history.keyframes for a given key.

Source:
Parameters:
Name Type Description
arg0_id string
Returns:
Type:
Promise.<Object>

(static) getTimestamps() → {Promise.<Array.<number>>}

Returns all unique global timestamps from all partitions.

Source:
Returns:
Type:
Promise.<Array.<number>>

(static) getValue(arg0_id) → {Promise.<Object>}

Returns the Object value of a single ID.

Source:
Parameters:
Name Type Description
arg0_id string
Returns:
Type:
Promise.<Object>

(static) getValues(arg0_ids) → {Promise.<Array.<(Object|null)>>}

Returns the Object values of multiple IDs in 1-pass.

Source:
Parameters:
Name Type Description
arg0_ids Array.<string>
Returns:
Type:
Promise.<Array.<(Object|null)>>

(static) getWorkerID(arg0_id, arg1_pool_length) → {number}

Returns the Worker ID that holds a particular ID's partition.

Source:
Parameters:
Name Type Description
arg0_id string
arg1_pool_length number
Returns:
Type:
number

(static) getWorkerPool(arg0_max_workersopt) → {Array.<NodeWorker>}

Returns the current NDJSON worker pool managing DBs.

Source:
Parameters:
Name Type Attributes Default Description
arg0_max_workers number <optional>
os.cpus().length - 1
Returns:
Type:
Array.<NodeWorker>

(static) load(arg0_file_path, arg1_optionsopt) → {Promise.<string>}

Loads a regular JSON / .naissance file and streams it into partitioned NDJSON shard files.

Source:
Parameters:
Name Type Attributes Description
arg0_file_path string
arg1_options Object <optional>
Name Type Attributes Description
dynamic_max_workers number <optional>
Returns:
Type:
Promise.<string>

(static) partitionFile(arg0_file_path) → {Promise.<void>}

Partitions a given file into multiple NDJSON files for use. Internal helper function.

Source:
Parameters:
Name Type Description
arg0_file_path string
Returns:
Type:
Promise.<void>

(static) processSegment()

Processes a segment. Internal helper function for parsing NDJSON.

Source:

(static) query(arg0_optionsopt) → {Promise.<Array.<Object>>}

Queries an NDJSON file. [WIP] - Should be refactored so that only arg1_options is present.

Source:
Parameters:
Name Type Attributes Description
arg0_options Object <optional>
Name Type Attributes Default Description
limit_end number <optional>
limit_start number <optional>
0
query_obj Object <optional>

Key/value pairs to match for.

Returns:
Type:
Promise.<Array.<Object>>

(static) removeValue(arg0_id) → {Promise.<boolean>}

Removes a value from the NDJSON file.

Source:
Parameters:
Name Type Description
arg0_id string
Returns:
Type:
Promise.<boolean>

(static) removeValues(arg0_ids) → {Promise.<boolean>}

Removes multiple values from the NDJSON file.

Source:
Parameters:
Name Type Description
arg0_ids Array.<string>
Returns:
Type:
Promise.<boolean>

(static) save(arg0_target_pathopt) → {Promise.<string>}

Saves the NDJSON partitions back into a 100% compliant .naissance file.

Source:
Parameters:
Name Type Attributes Description
arg0_target_path string <optional>
Returns:
Type:
Promise.<string>

(static) setKeyframe(arg0_id, arg1_date, arg2_keyframe) → {Promise.<boolean>}

Sets a single keyframe for a specific entity ID in its partition worker.

Source:
Parameters:
Name Type Description
arg0_id string
arg1_date number | Object | string
arg2_keyframe Object
Returns:
Type:
Promise.<boolean>

(static) setKeyframesDiff(arg0_id, arg1_diff) → {Promise.<boolean>}

Sets multiple modified keyframes differentially for an entity ID in its partition worker.

Source:
Parameters:
Name Type Description
arg0_id string
arg1_diff Object
Returns:
Type:
Promise.<boolean>

(static) setValue(arg0_id, arg1_value) → {Promise.<boolean>}

Sets a key-value pair in the NDJSON file.

Source:
Parameters:
Name Type Description
arg0_id string
arg1_value Object
Returns:
Type:
Promise.<boolean>

(static) setValues(arg0_update_map) → {Promise.<boolean>}

Sets multiple key-value pairs for the NDJSON file.

Source:
Parameters:
Name Type Description
arg0_update_map Object
Returns:
Type:
Promise.<boolean>

(static) setWorkerPoolSize(arg0_count) → {Promise.<number>}

Adjusts the concurrent thread pool size for DB workers dynamically.

Source:
Parameters:
Name Type Description
arg0_count number
Returns:
Type:
Promise.<number>

(static) task(arg0_target, arg1_message) → {Promise.<(any|Array.<any>)>}

Internal dispatcher to handle messaging and promise queues across worker pools.

Source:
Parameters:
Name Type Description
arg0_target number | Array.<number> | string

Target worker ID, array of IDs, partition ID string, or "all".

arg1_message Object | function

Message payload, or a factory function returning payload.

Returns:
Type:
Promise.<(any|Array.<any>)>

(static) terminate() → {Promise.<void>}

Terminates all workers in the NDJSON worker pool cleanly.

Source:
Returns:
Type:
Promise.<void>

NDJSON

The namespace for NDJSON utility functions.

Source:

Methods

(static) diff(arg0_id, arg1_timestamp) → {Promise.<(Object|null)>}

Returns a diff over .history.keyframes for the ID in question.

Source:
Parameters:
Name Type Description
arg0_id string
arg1_timestamp Object
Returns:
Type:
Promise.<(Object|null)>

(static) diffAll(arg0_timestamp) → {Promise.<Array.<Object>>}

Diffs all .history.keyframes for all Objects for a given ID, so long as they have that field.

Source:
Parameters:
Name Type Description
arg0_timestamp number | string
Returns:
Type:
Promise.<Array.<Object>>

(static) diffBBox(arg0_optionsopt) → {Promise.<Array.<Object>>}

Returns diffs over .history.keyframes for entities intersecting the bounding box at the given timestamp.

Source:
Parameters:
Name Type Attributes Description
arg0_options Object <optional>
Name Type Attributes Description
bbox Array.<number> <optional>

[min_x, min_y, max_x, max_y]

timestamp number | string
zoom number <optional>
Returns:
Type:
Promise.<Array.<Object>>

(static) getCacheDirectory(arg0_file_pathopt) → {string}

Returns the unified cache partition directory in saves/.cache.

Source:
Parameters:
Name Type Attributes Description
arg0_file_path string <optional>
Returns:
Type:
string

(static) getCacheDirectory(arg0_file_pathopt) → {string}

Returns the cache partition directory in saves/.cache.

Source:
Parameters:
Name Type Attributes Description
arg0_file_path string <optional>
Returns:
Type:
string

(static) getDiagnostics() → {Promise.<Array.<{worker_id: number, rss: number, heapUsed: number, heapTotal: number, heapLimit: number, percentage: number}>>}

Resolves active RAM diagnostic percentage statistics from every worker in the pool.

Source:
Returns:
Type:
Promise.<Array.<{worker_id: number, rss: number, heapUsed: number, heapTotal: number, heapLimit: number, percentage: number}>>

(static) getDiffs(arg0_ids, arg1_timestamp) → {Promise.<Array.<(Object|null)>>}

Returns diffs over .history.keyframes for multiple IDs in 1-pass.

Source:
Parameters:
Name Type Description
arg0_ids Array.<string>
arg1_timestamp number
Returns:
Type:
Promise.<Array.<(Object|null)>>

(static) getFilePath() → {string}

Returns the resolved base file path for the active NDJSON / savefile database.

Source:
Returns:
Type:
string

(static) getKeyframes(arg0_id) → {Promise.<Object>}

Returns processed .history.keyframes for a given key.

Source:
Parameters:
Name Type Description
arg0_id string
Returns:
Type:
Promise.<Object>

(static) getTimestamps() → {Promise.<Array.<number>>}

Returns all unique global timestamps from all partitions.

Source:
Returns:
Type:
Promise.<Array.<number>>

(static) getValue(arg0_id) → {Promise.<Object>}

Returns the Object value of a single ID.

Source:
Parameters:
Name Type Description
arg0_id string
Returns:
Type:
Promise.<Object>

(static) getValues(arg0_ids) → {Promise.<Array.<(Object|null)>>}

Returns the Object values of multiple IDs in 1-pass.

Source:
Parameters:
Name Type Description
arg0_ids Array.<string>
Returns:
Type:
Promise.<Array.<(Object|null)>>

(static) getWorkerID(arg0_id, arg1_pool_length) → {number}

Returns the Worker ID that holds a particular ID's partition.

Source:
Parameters:
Name Type Description
arg0_id string
arg1_pool_length number
Returns:
Type:
number

(static) getWorkerPool(arg0_max_workersopt) → {Array.<NodeWorker>}

Returns the current NDJSON worker pool managing DBs.

Source:
Parameters:
Name Type Attributes Default Description
arg0_max_workers number <optional>
os.cpus().length - 1
Returns:
Type:
Array.<NodeWorker>

(static) load(arg0_file_path, arg1_optionsopt) → {Promise.<string>}

Loads a regular JSON / .naissance file and streams it into partitioned NDJSON shard files.

Source:
Parameters:
Name Type Attributes Description
arg0_file_path string
arg1_options Object <optional>
Name Type Attributes Description
dynamic_max_workers number <optional>
Returns:
Type:
Promise.<string>

(static) partitionFile(arg0_file_path) → {Promise.<void>}

Partitions a given file into multiple NDJSON files for use. Internal helper function.

Source:
Parameters:
Name Type Description
arg0_file_path string
Returns:
Type:
Promise.<void>

(static) processSegment()

Processes a segment. Internal helper function for parsing NDJSON.

Source:

(static) query(arg0_optionsopt) → {Promise.<Array.<Object>>}

Queries an NDJSON file. [WIP] - Should be refactored so that only arg1_options is present.

Source:
Parameters:
Name Type Attributes Description
arg0_options Object <optional>
Name Type Attributes Default Description
limit_end number <optional>
limit_start number <optional>
0
query_obj Object <optional>

Key/value pairs to match for.

Returns:
Type:
Promise.<Array.<Object>>

(static) removeValue(arg0_id) → {Promise.<boolean>}

Removes a value from the NDJSON file.

Source:
Parameters:
Name Type Description
arg0_id string
Returns:
Type:
Promise.<boolean>

(static) removeValues(arg0_ids) → {Promise.<boolean>}

Removes multiple values from the NDJSON file.

Source:
Parameters:
Name Type Description
arg0_ids Array.<string>
Returns:
Type:
Promise.<boolean>

(static) save(arg0_target_pathopt) → {Promise.<string>}

Saves the NDJSON partitions back into a 100% compliant .naissance file.

Source:
Parameters:
Name Type Attributes Description
arg0_target_path string <optional>
Returns:
Type:
Promise.<string>

(static) setKeyframe(arg0_id, arg1_date, arg2_keyframe) → {Promise.<boolean>}

Sets a single keyframe for a specific entity ID in its partition worker.

Source:
Parameters:
Name Type Description
arg0_id string
arg1_date number | Object | string
arg2_keyframe Object
Returns:
Type:
Promise.<boolean>

(static) setKeyframesDiff(arg0_id, arg1_diff) → {Promise.<boolean>}

Sets multiple modified keyframes differentially for an entity ID in its partition worker.

Source:
Parameters:
Name Type Description
arg0_id string
arg1_diff Object
Returns:
Type:
Promise.<boolean>

(static) setValue(arg0_id, arg1_value) → {Promise.<boolean>}

Sets a key-value pair in the NDJSON file.

Source:
Parameters:
Name Type Description
arg0_id string
arg1_value Object
Returns:
Type:
Promise.<boolean>

(static) setValues(arg0_update_map) → {Promise.<boolean>}

Sets multiple key-value pairs for the NDJSON file.

Source:
Parameters:
Name Type Description
arg0_update_map Object
Returns:
Type:
Promise.<boolean>

(static) setWorkerPoolSize(arg0_count) → {Promise.<number>}

Adjusts the concurrent thread pool size for DB workers dynamically.

Source:
Parameters:
Name Type Description
arg0_count number
Returns:
Type:
Promise.<number>

(static) task(arg0_target, arg1_message) → {Promise.<(any|Array.<any>)>}

Internal dispatcher to handle messaging and promise queues across worker pools.

Source:
Parameters:
Name Type Description
arg0_target number | Array.<number> | string

Target worker ID, array of IDs, partition ID string, or "all".

arg1_message Object | function

Message payload, or a factory function returning payload.

Returns:
Type:
Promise.<(any|Array.<any>)>

(static) terminate() → {Promise.<void>}

Terminates all workers in the NDJSON worker pool cleanly.

Source:
Returns:
Type:
Promise.<void>