Catalog
Class: Catalog
Catalog class for managing ID -> chunk mappings.
The catalog is authoritative:
- If a record is in the catalog, it exists
- If a record is not in the catalog, it doesn't exist
- Derived structures (filter, indexes) are rebuilt from catalog + chunks
Constructors
new Catalog()
new Catalog(): CatalogReturns
Methods
[iterator]()
iterator: IterableIterator<CatalogEntry, any, any>Iterate over all entries.
Returns
IterableIterator<CatalogEntry, any, any>
addEntry()
addEntry(
id,
chunkId,
recordSize?): voidAdd a regular chunked record to the catalog.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Record ID |
chunkId | number | Chunk where record is stored |
recordSize? | number | Optional estimated size of record in bytes |
Returns
void
addSegmentedEntry()
addSegmentedEntry(id, segmentIds): voidAdd a segmented (large) record to the catalog.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Record ID |
segmentIds | string[] | Array of segment IDs |
Returns
void
clear()
clear(): voidClear all entries.
Returns
void
getAllIds()
getAllIds(): string[]Get all record IDs in the catalog.
Returns
string[]
Array of all record IDs
getChunkCount()
getChunkCount(chunkId): numberGet the count of records in a specific chunk.
Parameters
| Parameter | Type | Description |
|---|---|---|
chunkId | number | Chunk ID |
Returns
number
Record count in chunk
getChunkFor()
getChunkFor(id): numberGet the chunk ID for a record.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Record ID |
Returns
number
Chunk ID or null if not found
getChunkIds()
getChunkIds(): number[]Get all chunk IDs that contain records.
Returns
number[]
Array of chunk IDs
getChunkSize()
getChunkSize(chunkId): numberGet the estimated size of a specific chunk in bytes.
Parameters
| Parameter | Type | Description |
|---|---|---|
chunkId | number | Chunk ID |
Returns
number
Estimated size in bytes
getCount()
getCount(): numberGet the total count of records.
Returns
number
Record count
getEntry()
getEntry(id): CatalogEntryGet the full entry for a record.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Record ID |
Returns
Catalog entry or undefined
getSampleIds()
getSampleIds(n): string[]Get sample IDs for verification purposes.
Parameters
| Parameter | Type | Description |
|---|---|---|
n | number | Number of samples |
Returns
string[]
Array of sample IDs
getSegmentedCount()
getSegmentedCount(): numberGet the count of segmented records.
Returns
number
Count of segmented records
has()
has(id): booleanCheck if a record exists in the catalog.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Record ID |
Returns
boolean
True if exists
ids()
ids(): IterableIterator<string, any, any>Get all record IDs.
Returns
IterableIterator<string, any, any>
Iterator of record IDs
isSegmented()
isSegmented(id): booleanCheck if a record is stored as segments.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Record ID |
Returns
boolean
True if record is segmented
removeEntry()
removeEntry(id): booleanRemove a record from the catalog.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Record ID |
Returns
boolean
True if removed
serialize()
serialize(): CatalogDataSerialize catalog for storage (v2 format).
Returns
Serialized catalog data
setChunkSize()
setChunkSize(chunkId, size): voidUpdate the size of a chunk (useful when loading/saving chunks).
Parameters
| Parameter | Type | Description |
|---|---|---|
chunkId | number | Chunk ID |
size | number | New size in bytes |
Returns
void
deserialize()
static deserialize(data): CatalogDeserialize catalog from storage. Supports both v1 and v2 formats (automatic migration).
Parameters
| Parameter | Type | Description |
|---|---|---|
data | CatalogData | Stored catalog data |
Returns
Catalog instance
empty()
static empty(): CatalogCreate an empty catalog.
Returns
New empty catalog
