LogoRobo.js
Framework

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(): Catalog

Returns

Catalog

Methods

[iterator]()

iterator: IterableIterator<CatalogEntry, any, any>

Iterate over all entries.

Returns

IterableIterator<CatalogEntry, any, any>


addEntry()

addEntry(
   id, 
   chunkId, 
   recordSize?): void

Add a regular chunked record to the catalog.

Parameters

ParameterTypeDescription
idstringRecord ID
chunkIdnumberChunk where record is stored
recordSize?numberOptional estimated size of record in bytes

Returns

void


addSegmentedEntry()

addSegmentedEntry(id, segmentIds): void

Add a segmented (large) record to the catalog.

Parameters

ParameterTypeDescription
idstringRecord ID
segmentIdsstring[]Array of segment IDs

Returns

void


clear()

clear(): void

Clear all entries.

Returns

void


getAllIds()

getAllIds(): string[]

Get all record IDs in the catalog.

Returns

string[]

Array of all record IDs


getChunkCount()

getChunkCount(chunkId): number

Get the count of records in a specific chunk.

Parameters

ParameterTypeDescription
chunkIdnumberChunk ID

Returns

number

Record count in chunk


getChunkFor()

getChunkFor(id): number

Get the chunk ID for a record.

Parameters

ParameterTypeDescription
idstringRecord 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): number

Get the estimated size of a specific chunk in bytes.

Parameters

ParameterTypeDescription
chunkIdnumberChunk ID

Returns

number

Estimated size in bytes


getCount()

getCount(): number

Get the total count of records.

Returns

number

Record count


getEntry()

getEntry(id): CatalogEntry

Get the full entry for a record.

Parameters

ParameterTypeDescription
idstringRecord ID

Returns

CatalogEntry

Catalog entry or undefined


getSampleIds()

getSampleIds(n): string[]

Get sample IDs for verification purposes.

Parameters

ParameterTypeDescription
nnumberNumber of samples

Returns

string[]

Array of sample IDs


getSegmentedCount()

getSegmentedCount(): number

Get the count of segmented records.

Returns

number

Count of segmented records


has()

has(id): boolean

Check if a record exists in the catalog.

Parameters

ParameterTypeDescription
idstringRecord 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): boolean

Check if a record is stored as segments.

Parameters

ParameterTypeDescription
idstringRecord ID

Returns

boolean

True if record is segmented


removeEntry()

removeEntry(id): boolean

Remove a record from the catalog.

Parameters

ParameterTypeDescription
idstringRecord ID

Returns

boolean

True if removed


serialize()

serialize(): CatalogData

Serialize catalog for storage (v2 format).

Returns

CatalogData

Serialized catalog data


setChunkSize()

setChunkSize(chunkId, size): void

Update the size of a chunk (useful when loading/saving chunks).

Parameters

ParameterTypeDescription
chunkIdnumberChunk ID
sizenumberNew size in bytes

Returns

void


deserialize()

static deserialize(data): Catalog

Deserialize catalog from storage. Supports both v1 and v2 formats (automatic migration).

Parameters

ParameterTypeDescription
dataCatalogDataStored catalog data

Returns

Catalog

Catalog instance


empty()

static empty(): Catalog

Create an empty catalog.

Returns

Catalog

New empty catalog

On this page