@lakutata/orm 3.1.4 → 3.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/README.zh-CN.md +1 -1
- package/dist/cjs/lib/ConnectionOptions.d.ts +3 -1
- package/dist/cjs/lib/ConnectionOptions.js +44 -1
- package/dist/cjs/providers/migration/GenerateMigration.d.ts +1 -5
- package/dist/cjs/providers/migration/GenerateMigration.js +4 -10
- package/dist/esm/lib/ConnectionOptions.js +41 -1
- package/dist/esm/providers/migration/GenerateMigration.js +4 -10
- package/dist/types/lib/ConnectionOptions.d.ts +3 -1
- package/dist/types/providers/migration/GenerateMigration.d.ts +1 -5
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedCollectionStore.js +4 -4
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedCollectionStore.js.map +1 -1
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedCrc32.d.ts +15 -0
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedCrc32.js +44 -0
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedCrc32.js.map +1 -0
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedLog.js +2 -3
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedLog.js.map +1 -1
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedWorkerClient.js +4 -0
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedWorkerClient.js.map +1 -1
- package/dist/vendor/typeorm/driver/mongo-embedded/EmbeddedWorkerCode.js +1 -1
- package/dist/vendor/typeorm/driver/mongodb/MongoDriver.js +4 -0
- package/dist/vendor/typeorm/driver/mongodb/MongoDriver.js.map +1 -1
- package/dist/vendor/typeorm/driver/mongodb/MongoWebCrypto.d.ts +6 -0
- package/dist/vendor/typeorm/driver/mongodb/MongoWebCrypto.js +19 -0
- package/dist/vendor/typeorm/driver/mongodb/MongoWebCrypto.js.map +1 -0
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedCollectionStore.js","sourceRoot":"","sources":["../../../../../vendor/typeorm/driver/mongo-embedded/EmbeddedCollectionStore.ts"],"names":[],"mappings":";;;;AAAA,mCAAoC;AACpC,+CAAwB;AACxB,mDAA4B;AAC5B,2DAAuD;AAEvD,mDAA+C;AAE/C,mDAA8C;AAE9C,+DAA2D;AAC3D,qDAAiD;AACjD,+CAKsB;AAetB;;GAEG;AACH,MAAa,yBAA0B,SAAQ,2BAAY;IAGvD,YACa,UAAkB,EAClB,KAAa,EACb,QAAkC;QAE3C,KAAK,CACD,0CAA0C,UAAU,WAAW,KAAK,aAAa,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAC9G,CAAA;QANQ,eAAU,GAAV,UAAU,CAAQ;QAClB,UAAK,GAAL,KAAK,CAAQ;QACb,aAAQ,GAAR,QAAQ,CAA0B;QALtC,SAAI,GAAG,KAAK,CAAA;IAUrB,CAAC;CACJ;AAZD,8DAYC;AAED;;;GAGG;AACH,MAAa,uBAAwB,SAAQ,2BAAY;IAGrD,YACa,UAAkB,EAClB,KAAa,EACb,IAAY,EACZ,QAAkC;QAE3C,KAAK,CACD,uCAAuC,UAAU,WAAW,KAAK,cAAc,IAAI,QAAQ,CAC9F,CAAA;QAPQ,eAAU,GAAV,UAAU,CAAQ;QAClB,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAA0B;QANtC,SAAI,GAAG,KAAK,CAAA;IAWrB,CAAC;CACJ;AAbD,0DAaC;AAaD;;;;;GAKG;AACH,MAAa,sBAAuB,SAAQ,2BAAY;IAGpD,YACa,WAAiC,EACjC,aAAqB,EACrB,WAAqC;QAE9C,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;QAJnB,gBAAW,GAAX,WAAW,CAAsB;QACjC,kBAAa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,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAClE,CAAC;IAED;;;;;OAKG;IACO,QAAQ,CACd,KAAoB,EACpB,QAA0B;QAE1B,MAAM,KAAK,GAA6B,EAAE,CAAA;QAC1C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;YACrC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,IAAI,CAAA;QAC7D,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ;AAzmCD,0DAymCC","sourcesContent":["import { randomBytes } from \"crypto\"\nimport * as fs from \"fs\"\nimport * as zlib from \"zlib\"\nimport { TypeORMError } from \"../../error/TypeORMError\"\nimport type { EmbeddedBound } from \"./EmbeddedBTree\"\nimport { EmbeddedBTree } from \"./EmbeddedBTree\"\nimport type { EmbeddedCollectionCache } from \"./EmbeddedCache\"\nimport { cachedSizeOf } from \"./EmbeddedCache\"\nimport type { EmbeddedFile } from \"./EmbeddedFile\"\nimport { EmbeddedKeyEncoding } from \"./EmbeddedKeyEncoding\"\nimport { EmbeddedKeydir } from \"./EmbeddedKeydir\"\nimport {\n encodeRecord,\n EmbeddedRecordReader,\n RECORD_HEADER,\n RecordType,\n} from \"./EmbeddedLog\"\nimport type { EmbeddedDocument, EmbeddedValues } from \"./EmbeddedValues\"\n\n/**\n * lakutata: an index of an embedded collection, as MongoDB lists it: its fields and their directions, whether its keys\n * are unique, whether the documents without its fields are left out of it. Its expiration is kept, not applied.\n */\nexport interface EmbeddedIndex {\n name: string\n key: { [field: string]: any }\n unique?: boolean\n sparse?: boolean\n expireAfterSeconds?: number\n}\n\n/**\n * lakutata: the error of a duplicate key, with the code and the message of the one of MongoDB.\n */\nexport class EmbeddedDuplicateKeyError extends TypeORMError {\n readonly code = 11000\n\n constructor(\n readonly collection: string,\n readonly index: string,\n readonly keyValue: { [field: string]: any },\n ) {\n super(\n `E11000 duplicate key error collection: ${collection} index: ${index} dup key: ${JSON.stringify(keyValue)}`,\n )\n }\n}\n\n/**\n * lakutata: the error of a key too large for an index (its values encoded, with the _id, about 1000 bytes at most),\n * with the code of the one of MongoDB before 4.2 (KeyTooLong). The write fails before it is written.\n */\nexport class EmbeddedKeyTooLongError extends TypeORMError {\n readonly code = 17280\n\n constructor(\n readonly collection: string,\n readonly index: string,\n readonly size: number,\n readonly keyValue: { [field: string]: any },\n ) {\n super(\n `Key too large to index: collection: ${collection} index: ${index} key size: ${size} bytes`,\n )\n }\n}\n\n/**\n * lakutata: an error of a document of an insertMany (its duplicate key, or its key too large): its index in the\n * documents, the code and the message of its error, and the fields of its key.\n */\nexport interface EmbeddedWriteError {\n index: number\n code: number\n errmsg: string\n keyValue?: { [field: string]: any }\n}\n\n/**\n * lakutata: the error of an insertMany of which documents were not inserted, with the fields of the MongoBulkWriteError\n * of MongoDB: the code and the message of its first error, its errors (writeErrors), and the number and the _id of the\n * documents inserted (insertedCount, insertedIds by their indexes). Ordered, the documents after the first one failing\n * are not inserted; unordered, the other ones are.\n */\nexport class EmbeddedBulkWriteError extends TypeORMError {\n readonly code: number\n\n constructor(\n readonly writeErrors: EmbeddedWriteError[],\n readonly insertedCount: number,\n readonly insertedIds: { [index: number]: any },\n ) {\n super(writeErrors[0].errmsg)\n this.code = writeErrors[0].code\n }\n}\n\n/**\n * lakutata: a change of a document in a write: its key, its version before (none for an insertion) and after (none\n * for a deletion), and the version after serialized, when it is already.\n */\nexport interface EmbeddedChange {\n key: Buffer\n previous?: EmbeddedDocument\n next?: EmbeddedDocument\n data?: Buffer\n}\n\n/**\n * lakutata: a scan of the file of a collection running: when it read last, and whether it is closed (a compaction\n * began after it was not read for SCAN_TIMEOUT).\n */\nexport interface EmbeddedScan {\n read: number\n closed: boolean\n}\n\n/**\n * lakutata: the time after which a scan not read any more (a cursor not read nor closed) lets its collection be\n * compacted, the scan closed (10 minutes, the timeout of the cursors of MongoDB).\n */\nexport const SCAN_TIMEOUT = 10 * 60 * 1000\n\n/**\n * lakutata: a record of an operation being recovered.\n */\ninterface PendingRecord {\n type: number\n offset: number\n length: number\n key?: Buffer\n payload?: EmbeddedDocument\n}\n\n/**\n * lakutata: the first bytes of a snapshot of a collection. A snapshot holds: these 8 bytes; the CRC-32 of the bytes\n * after it (4 bytes, little endian); the length of its header (4 bytes, little endian); its header (BSON, its format\n * 3, not the one of the files: the version of the keys of the indexes); then the buffers of the keydir and of the trees of the indexes, each one from a\n * multiple of 8 bytes of the file (zero padding before it).\n */\nconst SNAPSHOT_MAGIC = Buffer.from(\"LKEMBSN1\")\n\n/**\n * lakutata: a commit record (all of them are these bytes).\n */\nconst COMMIT_RECORD = encodeRecord(RecordType.Commit, Buffer.alloc(0))\n\n/**\n * lakutata: the bytes read or written by a call of the system (a call reads or writes up to 2^31 - 1 bytes).\n */\nconst IO_CHUNK = 1024 * 1024 * 1024\n\n/**\n * lakutata: the documents read by the build of an index between two yields of the event loop.\n */\nconst BUILD_BATCH = 1000\n\n/**\n * lakutata: a number rounded up to a multiple of 8 (the alignment of the arrays of 8 bytes).\n *\n * @param value\n */\nfunction align(value: number): number {\n return Math.ceil(value / 8) * 8\n}\n\n/**\n * lakutata: the documents of a collection: written to its file (records appended, an operation in one write), read by\n * the offsets of their records kept in its keydir, outside the heap of V8.\n */\nexport class EmbeddedCollectionStore {\n keydir = new EmbeddedKeydir()\n\n /**\n * The id of its file (written in its header record): a snapshot is the one of the file it was written from.\n */\n logId?: string\n\n /**\n * Whether it changed since its snapshot was written or read.\n */\n changed = false\n\n /**\n * How it was opened: from its snapshot (and the records written after it), or from all the records of its file.\n */\n openedFrom: \"snapshot\" | \"records\" = \"records\"\n\n /**\n * The number of its file in the slots of its keydir (0 or 1): a compaction writes a new file, of the other number.\n */\n generation = 0\n\n /**\n * Its file before the compaction running: the documents not copied yet are read from it.\n */\n previous?: EmbeddedFile\n\n /**\n * The compaction running.\n */\n compacting?: Promise<void>\n\n /**\n * Whether its files are closed.\n */\n closed = false\n\n /**\n * The build of an index running: the writes of the collection wait for it.\n */\n building?: Promise<void>\n\n /**\n * The scans of its files running: a compaction does not start while one of them read in the last SCAN_TIMEOUT.\n */\n readonly scans = new Set<EmbeddedScan>()\n\n /**\n * The offset of its file its snapshot is the state of (0 without a snapshot).\n */\n snapshotOffset = 0\n\n /**\n * Whether a snapshot of it is to be written (at the next turn of the event loop).\n */\n snapshotScheduled = false\n\n readonly indexes: EmbeddedIndex[] = []\n\n /**\n * The bytes of the records of the live documents (the rest of the file is the records replaced, deleted, and the\n * records of the operations).\n */\n liveBytes = 0\n\n /**\n * The entries of the indexes (the keys of the values of the documents, then the keys of their _id), by their names.\n */\n readonly trees = new Map<string, EmbeddedBTree>()\n\n /**\n * The indexes a document of which has several keys (the items of an array): their ranges of two bounds are not the\n * ones of the queries, and their order is not the one of the sorts.\n */\n readonly multikey = new Set<string>()\n\n readonly encoding: EmbeddedKeyEncoding\n\n constructor(\n readonly name: string,\n public file: EmbeddedFile,\n readonly values: EmbeddedValues,\n readonly cache: EmbeddedCollectionCache,\n ) {\n this.encoding = new EmbeddedKeyEncoding(values)\n }\n\n /**\n * Creates the file of a collection: its header record.\n *\n * @param name\n * @param file\n * @param values\n * @param cache\n */\n static create(\n name: string,\n file: EmbeddedFile,\n values: EmbeddedValues,\n cache: EmbeddedCollectionCache,\n ): EmbeddedCollectionStore {\n const id = randomBytes(8).toString(\"hex\")\n file.append(\n Buffer.concat([\n encodeRecord(\n RecordType.Header,\n values.bson.BSON.serialize({\n name: name,\n format: 1,\n id: id,\n }),\n ),\n COMMIT_RECORD,\n ]),\n )\n const store = new EmbeddedCollectionStore(name, file, values, cache)\n store.logId = id\n store.changed = true\n return store\n }\n\n /**\n * Opens the file of a collection: its snapshot read when it is the one of the file, then the records written after\n * it applied; else all its records (their CRC-32 checked) applied an operation at a time, its indexes built from\n * its documents. The records after its last operation (cut by a crash) are cut off. A record whose CRC-32 does not\n * match, followed by a whole operation, is the corruption of the file: it fails. Undefined for a file without its\n * header record (cut when it was created).\n *\n * @param file\n * @param values\n * @param cache\n * @param path the path of the file, for the errors\n * @param snapshot the path of its snapshot\n */\n static open(\n file: EmbeddedFile,\n values: EmbeddedValues,\n cache: EmbeddedCollectionCache,\n path: string,\n snapshot?: string,\n ): EmbeddedCollectionStore | undefined {\n const first = new EmbeddedRecordReader(file).next(true)\n if (typeof first === \"string\") return undefined\n if (first.type !== RecordType.Header)\n throw new TypeORMError(\n `The file ${path} is not a file of mongo-embedded`,\n )\n const header = values.deserialize(first.payload)\n const store = new EmbeddedCollectionStore(\n header.name,\n file,\n values,\n cache,\n )\n store.logId = header.id\n const start = snapshot ? store.readSnapshot(snapshot) : undefined\n const replaying = start !== undefined\n const reader = new EmbeddedRecordReader(file, start ?? 0)\n const created: EmbeddedIndex[] = []\n let pending: PendingRecord[] = []\n let committed = start ?? 0\n for (;;) {\n const record = reader.next(true)\n if (record === \"end\" || record === \"torn\") break\n if (record === \"checksum\") {\n if (EmbeddedCollectionStore.isFollowedByCommit(file, reader))\n throw new TypeORMError(\n `The file ${path} of mongo-embedded is corrupted at its offset ${reader.position}`,\n )\n break\n }\n if (record.type === RecordType.Commit) {\n for (const done of pending)\n if (replaying) store.replay(done, created)\n else store.recover(done)\n pending = []\n committed = record.offset + record.length\n continue\n }\n const keyed =\n record.type === RecordType.Put ||\n record.type === RecordType.Delete\n pending.push({\n type: record.type,\n offset: record.offset,\n length: record.length,\n key: keyed ? values.idKeyOf(record.payload) : undefined,\n // The documents replayed after a snapshot update the indexes; read from the start, the indexes are\n // built once the records are read (from the documents read again)\n payload:\n (replaying && record.type === RecordType.Put) || !keyed\n ? values.deserialize(record.payload)\n : undefined,\n })\n }\n if (committed < file.size) {\n file.truncate(committed)\n file.sync()\n }\n if (replaying) {\n store.openedFrom = \"snapshot\"\n store.snapshotOffset = start\n store.buildIndexes(\n created.filter((index) => store.indexes.includes(index)),\n )\n store.changed = committed > start\n } else {\n store.buildIndexes(store.indexes)\n store.changed = true\n }\n return store\n }\n\n /**\n * Writes its snapshot: its keydir and the trees of its indexes as they are in memory, and the offset of its file\n * they are the state of (beside the file, then renamed over it). It is not written to the disk at once (synced): a\n * snapshot cut by a crash is refused when it is read (its CRC-32 and its size), as the one of another file (its\n * id, the commit record at its offset), the file then read from its start.\n *\n * @param path\n */\n writeSnapshot(path: string): void {\n const keydir = this.keydir.export()\n const trees = this.indexes\n .filter((index) => this.trees.has(index.name))\n .map((index) => ({\n name: index.name,\n ...this.trees.get(index.name)!.export(),\n }))\n const header = this.values.bson.BSON.serialize({\n format: 3,\n generation: this.generation,\n logId: this.logId,\n logOffset: this.file.size,\n liveBytes: this.liveBytes,\n indexes: this.indexes,\n multikey: [...this.multikey],\n keydir: {\n state: keydir.state,\n sizes: keydir.buffers.map((buffer) => buffer.byteLength),\n },\n trees: trees.map((tree) => ({\n name: tree.name,\n state: tree.state,\n sizes: tree.buffers.map((buffer) => buffer.byteLength),\n })),\n })\n const length = Buffer.allocUnsafe(4)\n length.writeUInt32LE(header.length)\n const parts: Uint8Array[] = [length, header]\n // The magic, the CRC-32 and the length before the header\n let size = 16 + header.length\n const pad = () => {\n if (size % 8) parts.push(Buffer.alloc(align(size) - size))\n size = align(size)\n }\n pad()\n for (const buffer of [\n ...keydir.buffers,\n ...trees.flatMap((tree) => tree.buffers),\n ]) {\n parts.push(buffer)\n size += buffer.byteLength\n pad()\n }\n let checksum = 0\n for (const part of parts) checksum = zlib.crc32(part, checksum)\n const crc = Buffer.allocUnsafe(4)\n crc.writeUInt32LE(checksum)\n const temporary = `${path}.tmp`\n const descriptor = fs.openSync(temporary, \"w\")\n try {\n for (const part of [SNAPSHOT_MAGIC, crc, ...parts]) {\n let written = 0\n while (written < part.byteLength)\n written += fs.writeSync(\n descriptor,\n part,\n written,\n Math.min(part.byteLength - written, IO_CHUNK),\n )\n }\n } finally {\n fs.closeSync(descriptor)\n }\n fs.renameSync(temporary, path)\n this.changed = false\n this.snapshotOffset = this.file.size\n }\n\n /**\n * Reads its snapshot, when it is whole and the one of its file (its id, an offset of it ending an operation): the\n * offset its records are applied from; undefined otherwise.\n *\n * @param path\n */\n protected readSnapshot(path: string): number | undefined {\n let descriptor: number\n try {\n descriptor = fs.openSync(path, \"r\")\n } catch {\n return undefined\n }\n try {\n // Read a part at a time, each one its own buffer (the buffers of Bun hold up to 4 GiB)\n let position = 0\n let checksum = 0\n const read = (size: number, checked = true): Buffer => {\n const bytes = Buffer.allocUnsafe(size)\n let done = 0\n while (done < size) {\n const count = fs.readSync(\n descriptor,\n bytes,\n done,\n Math.min(size - done, IO_CHUNK),\n position + done,\n )\n if (count === 0) throw new Error(\"The snapshot is cut\")\n done += count\n }\n position += size\n if (checked) checksum = zlib.crc32(bytes, checksum)\n return bytes\n }\n const skipPadding = () => {\n if (position % 8) read(align(position) - position)\n }\n if (!read(8, false).equals(SNAPSHOT_MAGIC)) return undefined\n const expected = read(4, false).readUInt32LE(0)\n const length = read(4).readUInt32LE(0)\n const header = this.values.deserialize(read(length))\n if (\n header.format !== 3 ||\n header.logId !== this.logId ||\n header.logOffset > this.file.size\n )\n return undefined\n const end = Buffer.allocUnsafe(RECORD_HEADER)\n this.file.readInto(\n end,\n 0,\n RECORD_HEADER,\n header.logOffset - RECORD_HEADER,\n )\n if (!end.equals(COMMIT_RECORD)) return undefined\n const take = (size: number): Uint8Array => {\n skipPadding()\n return read(size)\n }\n const keydir = header.keydir.sizes.map(take)\n const trees = header.trees.map((tree: { sizes: number[] }) =>\n tree.sizes.map(take),\n )\n skipPadding()\n if (\n checksum !== expected ||\n position !== fs.fstatSync(descriptor).size\n )\n return undefined\n this.keydir = EmbeddedKeydir.import(header.keydir.state, keydir)\n header.trees.forEach(\n (tree: { name: string; state: number[] }, index: number) =>\n this.trees.set(\n tree.name,\n EmbeddedBTree.import(tree.state, trees[index]),\n ),\n )\n this.indexes.push(...header.indexes)\n for (const name of header.multikey) this.multikey.add(name)\n this.liveBytes = header.liveBytes\n this.generation = header.generation\n return header.logOffset\n } catch {\n this.keydir = new EmbeddedKeydir()\n this.trees.clear()\n this.indexes.length = 0\n this.multikey.clear()\n this.liveBytes = 0\n return undefined\n } finally {\n fs.closeSync(descriptor)\n }\n }\n\n /**\n * Whether whole operations follow a record whose CRC-32 does not match (its length read as it is).\n *\n * @param file\n * @param reader the reader stopped at the record\n */\n protected static isFollowedByCommit(\n file: EmbeddedFile,\n reader: EmbeddedRecordReader,\n ): boolean {\n const header = Buffer.allocUnsafe(RECORD_HEADER)\n if (\n file.readInto(header, 0, RECORD_HEADER, reader.position) <\n RECORD_HEADER\n )\n return false\n const following = new EmbeddedRecordReader(\n file,\n reader.position + RECORD_HEADER + header.readUInt32LE(0),\n )\n for (;;) {\n const record = following.next(true)\n if (typeof record === \"string\") return false\n if (record.type === RecordType.Commit) return true\n }\n }\n\n /**\n * Whether a document of a key is held.\n *\n * @param key\n */\n has(key: Uint8Array): boolean {\n return this.keydir.has(key)\n }\n\n /**\n * The document of a key, cached or read from the file (and cached). It is shared: it must not be changed.\n *\n * @param key\n */\n get(key: Buffer): EmbeddedDocument | undefined {\n const text = key.toString(\"latin1\")\n const cached = this.cache.get(text)\n if (cached) return cached\n const slot = this.keydir.find(key)\n if (slot < 0) return undefined\n const length = this.keydir.lengthAt(slot)\n const offset = this.keydir.offsetAt(slot)\n const record = Buffer.allocUnsafe(length)\n this.fileOf(this.keydir.fileAt(slot)).readInto(record, 0, length, offset)\n const payload = record.subarray(RECORD_HEADER)\n if (\n zlib.crc32(payload, zlib.crc32(record.subarray(8, 9))) !==\n record.readUInt32LE(4)\n )\n throw this.corrupted(offset)\n const document = this.values.deserialize(payload)\n this.cache.set(text, document, cachedSizeOf(length))\n return document\n }\n\n /**\n * The documents of the collection: the ones cached when they all are (as they are when it is called), else the\n * ones of its files read in their order as it is iterated (cached while the cache has room): a document written\n * meanwhile may be missed (updated or deleted before it is read, inserted) or, while the collection is compacted,\n * read twice. They are shared: they must not be changed.\n */\n *documents(): Generator<EmbeddedDocument> {\n if (this.cache.size === this.keydir.size) {\n yield* this.cache.documents()\n return\n }\n // During a compaction, the documents not copied yet are in the previous file\n for (const [file, generation] of this.previous\n ? [\n [this.previous, this.generation ^ 1] as const,\n [this.file, this.generation] as const,\n ]\n : [[this.file, this.generation] as const])\n yield* this.liveDocuments(file, generation)\n }\n\n /**\n * The documents of a file its keydir holds (cached while the cache has room).\n *\n * @param file\n * @param generation\n */\n protected *liveDocuments(\n file: EmbeddedFile,\n generation: number,\n ): Generator<EmbeddedDocument> {\n const reader = new EmbeddedRecordReader(file)\n for (;;) {\n const record = reader.next(true)\n if (record === \"end\") return\n if (typeof record === \"string\") throw this.corrupted(reader.position)\n if (record.type !== RecordType.Put) continue\n const key = this.values.idKeyOf(record.payload)\n const slot = this.keydir.find(key)\n if (\n slot < 0 ||\n this.keydir.fileAt(slot) !== generation ||\n this.keydir.offsetAt(slot) !== record.offset\n )\n continue\n const text = key.toString(\"latin1\")\n let document = this.cache.get(text)\n if (!document) {\n document = this.values.deserialize(record.payload)\n this.cache.offer(text, document, cachedSizeOf(record.length))\n }\n yield document\n }\n }\n\n /**\n * Writes changes of documents as one operation: all of them, or none when one of them has a duplicate key.\n *\n * @param changes\n */\n write(changes: EmbeddedChange[]): void {\n if (!changes.length) return\n const entries = this.indexChanges(changes)\n this.changed = true\n const records: Buffer[] = changes.map((change) =>\n change.next\n ? encodeRecord(\n RecordType.Put,\n change.data ?? this.values.serialize(change.next),\n )\n : encodeRecord(\n RecordType.Delete,\n this.values.serialize({ _id: change.previous!._id }),\n ),\n )\n let offset = this.file.append(\n Buffer.concat([\n ...records,\n encodeRecord(RecordType.Commit, Buffer.alloc(0)),\n ]),\n )\n changes.forEach((change, index) => {\n const text = change.key.toString(\"latin1\")\n if (change.next) {\n this.liveBytes +=\n records[index].length -\n this.keydir.set(\n change.key,\n offset,\n records[index].length,\n this.generation,\n )\n this.cache.set(\n text,\n change.next,\n cachedSizeOf(records[index].length),\n )\n } else {\n this.liveBytes -= this.keydir.delete(change.key)\n this.cache.delete(text)\n }\n offset += records[index].length\n })\n for (const { index, tree, removed, added, id, keys } of entries) {\n for (const key of removed) tree.delete(key, id)\n for (const key of added) tree.insert(key, id)\n if (keys > 1) this.multikey.add(index)\n }\n }\n\n /**\n * The keys of the _id of the documents of the entries of ranges of an index, in its order (or reversed): a\n * document is given once for each of its keys in the ranges.\n *\n * @param index\n * @param ranges\n * @param reverse\n */\n *idsIn(\n index: string,\n ranges: { lower?: EmbeddedBound; upper?: EmbeddedBound }[],\n reverse = false,\n ): Generator<Buffer> {\n const tree = this.trees.get(index)\n if (!tree) return\n for (const range of reverse ? [...ranges].reverse() : ranges)\n for (const [, id] of tree.range(range.lower, range.upper, reverse))\n yield id\n }\n\n /**\n * Adds an index, unless one of its name exists: built from the documents (read from the two files of a compaction\n * whose end it holds), in batches with the event loop yielded between them, while the writes of the collection wait\n * (building) and no compaction starts; it fails on a key of a document too large (EmbeddedKeyTooLongError), and a\n * unique one on the duplicate keys of the documents, the index not added. The queries use it once it is built.\n *\n * @param index\n */\n async createIndex(index: EmbeddedIndex): Promise<void> {\n while (this.building) await this.building\n if (this.indexes.some((existing) => existing.name === index.name))\n return\n let built!: () => void\n this.building = new Promise((resolve) => (built = resolve))\n try {\n // No compaction copying its documents meanwhile (a compaction copied waits for the build to end, and none\n // starts while it runs)\n while (this.compacting) await this.compacting\n const tree = new EmbeddedBTree()\n let multikey = false\n let read = 0\n for (const document of this.documents()) {\n const id = this.values.idKey(document._id)\n const keys = this.keysOf(index, document)\n if (keys.length > 1) multikey = true\n for (const key of keys) {\n if (!EmbeddedBTree.fits(key, id))\n throw new EmbeddedKeyTooLongError(\n this.name,\n index.name,\n key.length,\n this.keyValue(index, document),\n )\n if (index.unique && this.ownerOf(tree, key))\n throw new EmbeddedDuplicateKeyError(\n this.name,\n index.name,\n this.keyValue(index, document),\n )\n tree.insert(key, id)\n }\n if (++read % BUILD_BATCH === 0)\n await new Promise((resolve) => setImmediate(resolve))\n }\n this.trees.set(index.name, tree)\n if (multikey) this.multikey.add(index.name)\n this.changed = true\n this.file.append(\n Buffer.concat([\n encodeRecord(\n RecordType.CreateIndex,\n this.values.bson.BSON.serialize(index),\n ),\n encodeRecord(RecordType.Commit, Buffer.alloc(0)),\n ]),\n )\n this.indexes.push(index)\n } finally {\n this.building = undefined\n built()\n }\n }\n\n /**\n * Removes an index; whether it existed.\n *\n * @param name\n */\n dropIndex(name: string): boolean {\n const position = this.indexes.findIndex((index) => index.name === name)\n if (position < 0) return false\n this.changed = true\n this.file.append(\n Buffer.concat([\n encodeRecord(\n RecordType.DropIndex,\n this.values.bson.BSON.serialize({ name: name }),\n ),\n encodeRecord(RecordType.Commit, Buffer.alloc(0)),\n ]),\n )\n this.indexes.splice(position, 1)\n this.trees.delete(name)\n this.multikey.delete(name)\n return true\n }\n\n /**\n * Whether a scan of its file read in the last SCAN_TIMEOUT; else its scans are closed (their next read fails).\n *\n * @param now\n */\n isScanned(now = Date.now()): boolean {\n for (const scan of this.scans)\n if (now - scan.read < SCAN_TIMEOUT) return true\n for (const scan of this.scans) scan.closed = true\n this.scans.clear()\n return false\n }\n\n /**\n * Whether its file is worth compacting: larger than a size, and a ratio of the bytes of its live documents.\n *\n * @param minimumSize\n * @param ratio\n */\n isWorthCompacting(minimumSize: number, ratio: number): boolean {\n return (\n !this.previous &&\n this.file.size >= minimumSize &&\n this.file.size > this.liveBytes * ratio\n )\n }\n\n /**\n * Starts a compaction: a new file (its header record and the records of its indexes) is written from now on, the\n * live documents of the previous one copied to it then.\n *\n * @param next\n */\n beginCompaction(next: EmbeddedFile): void {\n const id = randomBytes(8).toString(\"hex\")\n next.append(\n Buffer.concat([\n encodeRecord(\n RecordType.Header,\n this.values.bson.BSON.serialize({\n name: this.name,\n format: 1,\n id: id,\n }),\n ),\n ...this.indexes.map((index) =>\n encodeRecord(\n RecordType.CreateIndex,\n this.values.bson.BSON.serialize(index),\n ),\n ),\n COMMIT_RECORD,\n ]),\n )\n this.previous = this.file\n this.file = next\n this.generation ^= 1\n this.logId = id\n this.changed = true\n }\n\n /**\n * Copies the documents of the previous file its keydir still holds there to the current one, a batch (one operation)\n * at a time, yielding between the batches (the writes made meanwhile are written to the current file).\n */\n *copyLiveDocuments(): Generator<void> {\n const previous = this.previous!\n const old = this.generation ^ 1\n const reader = new EmbeddedRecordReader(previous)\n let records: Buffer[] = []\n let keys: Buffer[] = []\n const flush = () => {\n if (!records.length) return\n let offset = this.file.append(\n Buffer.concat([...records, COMMIT_RECORD]),\n )\n records.forEach((record, index) => {\n this.keydir.set(keys[index], offset, record.length, this.generation)\n offset += record.length\n })\n records = []\n keys = []\n }\n for (;;) {\n const record = reader.next(true)\n if (record === \"end\") break\n if (typeof record === \"string\") throw this.corrupted(reader.position)\n if (record.type !== RecordType.Put) continue\n const key = this.values.idKeyOf(record.payload)\n const slot = this.keydir.find(key)\n if (\n slot < 0 ||\n this.keydir.fileAt(slot) !== old ||\n this.keydir.offsetAt(slot) !== record.offset\n )\n continue\n // Copied as it is: the same bytes, its live bytes unchanged. Its keydir slot checked above and set by\n // the flush in one synchronous span (the flush before the yield): a write made meanwhile is not\n // overwritten by its stale copy\n records.push(encodeRecord(RecordType.Put, record.payload))\n keys.push(key)\n if (records.length < 1000) continue\n flush()\n yield\n }\n flush()\n }\n\n /**\n * Ends a compaction: the previous file closed (its documents all copied).\n */\n endCompaction(): void {\n this.previous!.close()\n this.previous = undefined\n }\n\n /**\n * Applies the records of the file of a compaction cut by a crash (written after the ones of its file), then runs\n * the compaction to its end: its documents not copied yet copied.\n *\n * @param next\n * @param path the path of the file, for the errors\n */\n resumeCompaction(next: EmbeddedFile, path: string): void {\n const first = new EmbeddedRecordReader(next).next(true)\n if (typeof first === \"string\" || first.type !== RecordType.Header)\n throw new TypeORMError(\n `The file ${path} is not a file of mongo-embedded`,\n )\n this.previous = this.file\n this.file = next\n this.generation ^= 1\n this.logId = this.values.deserialize(first.payload).id\n const created: EmbeddedIndex[] = []\n const reader = new EmbeddedRecordReader(next, first.offset + first.length)\n let pending: PendingRecord[] = []\n let committed = first.offset + first.length\n for (;;) {\n const record = reader.next(true)\n if (record === \"end\" || record === \"torn\") break\n if (record === \"checksum\") {\n if (EmbeddedCollectionStore.isFollowedByCommit(next, reader))\n throw this.corrupted(reader.position)\n break\n }\n if (record.type === RecordType.Commit) {\n for (const done of pending) this.replay(done, created)\n pending = []\n committed = record.offset + record.length\n continue\n }\n const keyed =\n record.type === RecordType.Put ||\n record.type === RecordType.Delete\n pending.push({\n type: record.type,\n offset: record.offset,\n length: record.length,\n key: keyed ? this.values.idKeyOf(record.payload) : undefined,\n payload:\n record.type !== RecordType.Delete\n ? this.values.deserialize(record.payload)\n : undefined,\n })\n }\n if (committed < next.size) {\n next.truncate(committed)\n next.sync()\n }\n this.buildIndexes(created.filter((index) => this.indexes.includes(index)))\n for (const _ of this.copyLiveDocuments()) continue\n this.changed = true\n }\n\n /**\n * Closes its files (the database closed, or the collection dropped): a compaction running stops, their uses after\n * throw.\n */\n close(): void {\n this.closed = true\n this.cache.close()\n this.previous?.close()\n this.file.close()\n }\n\n /**\n * The file of a number of the slots of the keydir.\n *\n * @param generation\n */\n protected fileOf(generation: number): EmbeddedFile {\n return generation === this.generation ? this.file : this.previous!\n }\n\n /**\n * The error of a record of its file whose CRC-32 does not match.\n *\n * @param offset\n */\n protected corrupted(offset: number): TypeORMError {\n return new TypeORMError(\n `The file ${(this.file as { path?: string }).path ?? this.name} of mongo-embedded is corrupted at its offset ${offset}`,\n )\n }\n\n /**\n * Applies a record of an operation recovered.\n *\n * @param record\n */\n protected recover(record: PendingRecord): void {\n switch (record.type) {\n case RecordType.Put:\n this.liveBytes +=\n record.length -\n this.keydir.set(\n record.key!,\n record.offset,\n record.length,\n this.generation,\n )\n break\n case RecordType.Delete:\n this.liveBytes -= this.keydir.delete(record.key!)\n break\n case RecordType.CreateIndex:\n if (\n !this.indexes.some(\n (index) => index.name === record.payload!.name,\n )\n )\n this.indexes.push(record.payload as EmbeddedIndex)\n break\n case RecordType.DropIndex: {\n const position = this.indexes.findIndex(\n (index) => index.name === record.payload!.name,\n )\n if (position >= 0) this.indexes.splice(position, 1)\n break\n }\n }\n }\n\n /**\n * Applies a record written after the snapshot read: its document in the keydir and the indexes (the indexes created\n * are built once the records are applied).\n *\n * @param record\n * @param created the indexes created by the records\n */\n protected replay(record: PendingRecord, created: EmbeddedIndex[]): void {\n switch (record.type) {\n case RecordType.Put:\n case RecordType.Delete: {\n const previous = this.get(record.key!)\n const next =\n record.type === RecordType.Put ? record.payload : undefined\n const id = record.key!\n for (const index of this.indexes) {\n const tree = this.trees.get(index.name)\n if (!tree) continue\n const before = previous ? this.keysOf(index, previous) : []\n const after = next ? this.keysOf(index, next) : []\n for (const key of before) tree.delete(key, id)\n for (const key of after) tree.insert(key, id)\n if (after.length > 1) this.multikey.add(index.name)\n }\n this.cache.delete(id.toString(\"latin1\"))\n if (next)\n this.liveBytes +=\n record.length -\n this.keydir.set(\n id,\n record.offset,\n record.length,\n this.generation,\n )\n else this.liveBytes -= this.keydir.delete(id)\n break\n }\n case RecordType.CreateIndex:\n if (\n !this.indexes.some(\n (index) => index.name === record.payload!.name,\n )\n ) {\n const index = record.payload as EmbeddedIndex\n this.indexes.push(index)\n created.push(index)\n }\n break\n case RecordType.DropIndex: {\n const position = this.indexes.findIndex(\n (index) => index.name === record.payload!.name,\n )\n if (position >= 0) this.indexes.splice(position, 1)\n this.trees.delete(record.payload!.name)\n this.multikey.delete(record.payload!.name)\n break\n }\n }\n }\n\n /**\n * Builds indexes from the documents, read once; it fails on the duplicate keys of a unique one.\n *\n * @param indexes\n */\n protected buildIndexes(indexes: EmbeddedIndex[]): void {\n if (!indexes.length) return\n const trees = indexes.map(() => new EmbeddedBTree())\n for (const document of this.documents()) {\n const id = this.values.idKey(document._id)\n indexes.forEach((index, position) => {\n const keys = this.keysOf(index, document)\n if (keys.length > 1) this.multikey.add(index.name)\n for (const key of keys) {\n if (index.unique && this.ownerOf(trees[position], key))\n throw new EmbeddedDuplicateKeyError(\n this.name,\n index.name,\n this.keyValue(index, document),\n )\n trees[position].insert(key, id)\n }\n })\n }\n indexes.forEach((index, position) =>\n this.trees.set(index.name, trees[position]),\n )\n }\n\n /**\n * The changes of the entries of the indexes of a write, its unique keys checked (also between its changes).\n *\n * @param changes\n */\n protected indexChanges(changes: EmbeddedChange[]): {\n index: string\n tree: EmbeddedBTree\n removed: Buffer[]\n added: Buffer[]\n id: Buffer\n keys: number\n }[] {\n const entries: {\n index: string\n tree: EmbeddedBTree\n removed: Buffer[]\n added: Buffer[]\n id: Buffer\n keys: number\n }[] = []\n const inserted = new Set<string>()\n // The keys of the unique indexes written: their owners (the keys of their _id), null for the ones removed\n const pending = new Map<string, Map<string, string | null>>()\n for (const change of changes) {\n const owner = change.key.toString(\"latin1\")\n if (!change.previous && change.next) {\n if (this.keydir.has(change.key) || inserted.has(owner))\n throw new EmbeddedDuplicateKeyError(this.name, \"_id_\", {\n _id: change.next._id,\n })\n inserted.add(owner)\n }\n for (const index of this.indexes) {\n const tree = this.trees.get(index.name)!\n const before = change.previous\n ? this.keysOf(index, change.previous)\n : []\n const after = change.next ? this.keysOf(index, change.next) : []\n const kept = new Set(before.map((key) => key.toString(\"latin1\")))\n const now = new Set(after.map((key) => key.toString(\"latin1\")))\n const removed = before.filter(\n (key) => !now.has(key.toString(\"latin1\")),\n )\n const added = after.filter(\n (key) => !kept.has(key.toString(\"latin1\")),\n )\n // Checked before the write is written: an entry not fitting a tree would throw once it is\n for (const key of added)\n if (!EmbeddedBTree.fits(key, change.key))\n throw new EmbeddedKeyTooLongError(\n this.name,\n index.name,\n key.length,\n this.keyValue(index, change.next!),\n )\n if (index.unique) {\n let written = pending.get(index.name)\n if (!written) pending.set(index.name, (written = new Map()))\n for (const key of removed)\n written.set(key.toString(\"latin1\"), null)\n for (const key of added) {\n const text = key.toString(\"latin1\")\n const existing = written.has(text)\n ? written.get(text)\n : this.ownerOf(tree, key)?.toString(\"latin1\")\n if (\n existing !== undefined &&\n existing !== null &&\n existing !== owner\n )\n throw new EmbeddedDuplicateKeyError(\n this.name,\n index.name,\n this.keyValue(index, change.next!),\n )\n written.set(text, owner)\n }\n }\n entries.push({\n index: index.name,\n tree: tree,\n removed: removed,\n added: added,\n id: change.key,\n keys: after.length,\n })\n }\n }\n return entries\n }\n\n /**\n * The key of the _id of the document holding a key in an index, if any.\n *\n * @param tree\n * @param key\n */\n protected ownerOf(tree: EmbeddedBTree, key: Buffer): Buffer | undefined {\n for (const [, id] of tree.range(\n { key: key, inclusive: true },\n { key: key, inclusive: true },\n ))\n return id\n return undefined\n }\n\n /**\n * The keys of a document in an index.\n *\n * @param index\n * @param document\n */\n protected keysOf(index: EmbeddedIndex, document: EmbeddedDocument): Buffer[] {\n return this.encoding.keysOf(index.key, index.sparse, document)\n }\n\n /**\n * The fields of a document in an index, for the message of a duplicate key.\n *\n * @param index\n * @param document\n */\n protected keyValue(\n index: EmbeddedIndex,\n document: EmbeddedDocument,\n ): { [field: string]: any } {\n const value: { [field: string]: any } = {}\n for (const path of Object.keys(index.key))\n value[path] = this.values.valueAt(document, path) ?? null\n return value\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EmbeddedCollectionStore.js","sourceRoot":"","sources":["../../../../../vendor/typeorm/driver/mongo-embedded/EmbeddedCollectionStore.ts"],"names":[],"mappings":";;;;AAAA,mCAAoC;AACpC,+CAAwB;AACxB,2DAAuD;AAEvD,mDAA+C;AAE/C,mDAA8C;AAC9C,mDAAuC;AAEvC,+DAA2D;AAC3D,qDAAiD;AACjD,+CAKsB;AAetB;;GAEG;AACH,MAAa,yBAA0B,SAAQ,2BAAY;IAGvD,YACa,UAAkB,EAClB,KAAa,EACb,QAAkC;QAE3C,KAAK,CACD,0CAA0C,UAAU,WAAW,KAAK,aAAa,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAC9G,CAAA;QANQ,eAAU,GAAV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AC5B,CAAC;gBACL,CAAC;gBACD,OAAO,CAAC,IAAI,CAAC;oBACT,KAAK,EAAE,KAAK,CAAC,IAAI;oBACjB,IAAI,EAAE,IAAI;oBACV,OAAO,EAAE,OAAO;oBAChB,KAAK,EAAE,KAAK;oBACZ,EAAE,EAAE,MAAM,CAAC,GAAG;oBACd,IAAI,EAAE,KAAK,CAAC,MAAM;iBACrB,CAAC,CAAA;YACN,CAAC;QACL,CAAC;QACD,OAAO,OAAO,CAAA;IAClB,CAAC;IAED;;;;;OAKG;IACO,OAAO,CAAC,IAAmB,EAAE,GAAW;QAC9C,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,CAC3B,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,EAC7B,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAChC;YACG,OAAO,EAAE,CAAA;QACb,OAAO,SAAS,CAAA;IACpB,CAAC;IAED;;;;;OAKG;IACO,MAAM,CAAC,KAAoB,EAAE,QAA0B;QAC7D,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAClE,CAAC;IAED;;;;;OAKG;IACO,QAAQ,CACd,KAAoB,EACpB,QAA0B;QAE1B,MAAM,KAAK,GAA6B,EAAE,CAAA;QAC1C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;YACrC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,IAAI,CAAA;QAC7D,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ;AAzmCD,0DAymCC","sourcesContent":["import { randomBytes } from \"crypto\"\nimport * as fs from \"fs\"\nimport { TypeORMError } from \"../../error/TypeORMError\"\nimport type { EmbeddedBound } from \"./EmbeddedBTree\"\nimport { EmbeddedBTree } from \"./EmbeddedBTree\"\nimport type { EmbeddedCollectionCache } from \"./EmbeddedCache\"\nimport { cachedSizeOf } from \"./EmbeddedCache\"\nimport { crc32 } from \"./EmbeddedCrc32\"\nimport type { EmbeddedFile } from \"./EmbeddedFile\"\nimport { EmbeddedKeyEncoding } from \"./EmbeddedKeyEncoding\"\nimport { EmbeddedKeydir } from \"./EmbeddedKeydir\"\nimport {\n encodeRecord,\n EmbeddedRecordReader,\n RECORD_HEADER,\n RecordType,\n} from \"./EmbeddedLog\"\nimport type { EmbeddedDocument, EmbeddedValues } from \"./EmbeddedValues\"\n\n/**\n * lakutata: an index of an embedded collection, as MongoDB lists it: its fields and their directions, whether its keys\n * are unique, whether the documents without its fields are left out of it. Its expiration is kept, not applied.\n */\nexport interface EmbeddedIndex {\n name: string\n key: { [field: string]: any }\n unique?: boolean\n sparse?: boolean\n expireAfterSeconds?: number\n}\n\n/**\n * lakutata: the error of a duplicate key, with the code and the message of the one of MongoDB.\n */\nexport class EmbeddedDuplicateKeyError extends TypeORMError {\n readonly code = 11000\n\n constructor(\n readonly collection: string,\n readonly index: string,\n readonly keyValue: { [field: string]: any },\n ) {\n super(\n `E11000 duplicate key error collection: ${collection} index: ${index} dup key: ${JSON.stringify(keyValue)}`,\n )\n }\n}\n\n/**\n * lakutata: the error of a key too large for an index (its values encoded, with the _id, about 1000 bytes at most),\n * with the code of the one of MongoDB before 4.2 (KeyTooLong). The write fails before it is written.\n */\nexport class EmbeddedKeyTooLongError extends TypeORMError {\n readonly code = 17280\n\n constructor(\n readonly collection: string,\n readonly index: string,\n readonly size: number,\n readonly keyValue: { [field: string]: any },\n ) {\n super(\n `Key too large to index: collection: ${collection} index: ${index} key size: ${size} bytes`,\n )\n }\n}\n\n/**\n * lakutata: an error of a document of an insertMany (its duplicate key, or its key too large): its index in the\n * documents, the code and the message of its error, and the fields of its key.\n */\nexport interface EmbeddedWriteError {\n index: number\n code: number\n errmsg: string\n keyValue?: { [field: string]: any }\n}\n\n/**\n * lakutata: the error of an insertMany of which documents were not inserted, with the fields of the MongoBulkWriteError\n * of MongoDB: the code and the message of its first error, its errors (writeErrors), and the number and the _id of the\n * documents inserted (insertedCount, insertedIds by their indexes). Ordered, the documents after the first one failing\n * are not inserted; unordered, the other ones are.\n */\nexport class EmbeddedBulkWriteError extends TypeORMError {\n readonly code: number\n\n constructor(\n readonly writeErrors: EmbeddedWriteError[],\n readonly insertedCount: number,\n readonly insertedIds: { [index: number]: any },\n ) {\n super(writeErrors[0].errmsg)\n this.code = writeErrors[0].code\n }\n}\n\n/**\n * lakutata: a change of a document in a write: its key, its version before (none for an insertion) and after (none\n * for a deletion), and the version after serialized, when it is already.\n */\nexport interface EmbeddedChange {\n key: Buffer\n previous?: EmbeddedDocument\n next?: EmbeddedDocument\n data?: Buffer\n}\n\n/**\n * lakutata: a scan of the file of a collection running: when it read last, and whether it is closed (a compaction\n * began after it was not read for SCAN_TIMEOUT).\n */\nexport interface EmbeddedScan {\n read: number\n closed: boolean\n}\n\n/**\n * lakutata: the time after which a scan not read any more (a cursor not read nor closed) lets its collection be\n * compacted, the scan closed (10 minutes, the timeout of the cursors of MongoDB).\n */\nexport const SCAN_TIMEOUT = 10 * 60 * 1000\n\n/**\n * lakutata: a record of an operation being recovered.\n */\ninterface PendingRecord {\n type: number\n offset: number\n length: number\n key?: Buffer\n payload?: EmbeddedDocument\n}\n\n/**\n * lakutata: the first bytes of a snapshot of a collection. A snapshot holds: these 8 bytes; the CRC-32 of the bytes\n * after it (4 bytes, little endian); the length of its header (4 bytes, little endian); its header (BSON, its format\n * 3, not the one of the files: the version of the keys of the indexes); then the buffers of the keydir and of the trees of the indexes, each one from a\n * multiple of 8 bytes of the file (zero padding before it).\n */\nconst SNAPSHOT_MAGIC = Buffer.from(\"LKEMBSN1\")\n\n/**\n * lakutata: a commit record (all of them are these bytes).\n */\nconst COMMIT_RECORD = encodeRecord(RecordType.Commit, Buffer.alloc(0))\n\n/**\n * lakutata: the bytes read or written by a call of the system (a call reads or writes up to 2^31 - 1 bytes).\n */\nconst IO_CHUNK = 1024 * 1024 * 1024\n\n/**\n * lakutata: the documents read by the build of an index between two yields of the event loop.\n */\nconst BUILD_BATCH = 1000\n\n/**\n * lakutata: a number rounded up to a multiple of 8 (the alignment of the arrays of 8 bytes).\n *\n * @param value\n */\nfunction align(value: number): number {\n return Math.ceil(value / 8) * 8\n}\n\n/**\n * lakutata: the documents of a collection: written to its file (records appended, an operation in one write), read by\n * the offsets of their records kept in its keydir, outside the heap of V8.\n */\nexport class EmbeddedCollectionStore {\n keydir = new EmbeddedKeydir()\n\n /**\n * The id of its file (written in its header record): a snapshot is the one of the file it was written from.\n */\n logId?: string\n\n /**\n * Whether it changed since its snapshot was written or read.\n */\n changed = false\n\n /**\n * How it was opened: from its snapshot (and the records written after it), or from all the records of its file.\n */\n openedFrom: \"snapshot\" | \"records\" = \"records\"\n\n /**\n * The number of its file in the slots of its keydir (0 or 1): a compaction writes a new file, of the other number.\n */\n generation = 0\n\n /**\n * Its file before the compaction running: the documents not copied yet are read from it.\n */\n previous?: EmbeddedFile\n\n /**\n * The compaction running.\n */\n compacting?: Promise<void>\n\n /**\n * Whether its files are closed.\n */\n closed = false\n\n /**\n * The build of an index running: the writes of the collection wait for it.\n */\n building?: Promise<void>\n\n /**\n * The scans of its files running: a compaction does not start while one of them read in the last SCAN_TIMEOUT.\n */\n readonly scans = new Set<EmbeddedScan>()\n\n /**\n * The offset of its file its snapshot is the state of (0 without a snapshot).\n */\n snapshotOffset = 0\n\n /**\n * Whether a snapshot of it is to be written (at the next turn of the event loop).\n */\n snapshotScheduled = false\n\n readonly indexes: EmbeddedIndex[] = []\n\n /**\n * The bytes of the records of the live documents (the rest of the file is the records replaced, deleted, and the\n * records of the operations).\n */\n liveBytes = 0\n\n /**\n * The entries of the indexes (the keys of the values of the documents, then the keys of their _id), by their names.\n */\n readonly trees = new Map<string, EmbeddedBTree>()\n\n /**\n * The indexes a document of which has several keys (the items of an array): their ranges of two bounds are not the\n * ones of the queries, and their order is not the one of the sorts.\n */\n readonly multikey = new Set<string>()\n\n readonly encoding: EmbeddedKeyEncoding\n\n constructor(\n readonly name: string,\n public file: EmbeddedFile,\n readonly values: EmbeddedValues,\n readonly cache: EmbeddedCollectionCache,\n ) {\n this.encoding = new EmbeddedKeyEncoding(values)\n }\n\n /**\n * Creates the file of a collection: its header record.\n *\n * @param name\n * @param file\n * @param values\n * @param cache\n */\n static create(\n name: string,\n file: EmbeddedFile,\n values: EmbeddedValues,\n cache: EmbeddedCollectionCache,\n ): EmbeddedCollectionStore {\n const id = randomBytes(8).toString(\"hex\")\n file.append(\n Buffer.concat([\n encodeRecord(\n RecordType.Header,\n values.bson.BSON.serialize({\n name: name,\n format: 1,\n id: id,\n }),\n ),\n COMMIT_RECORD,\n ]),\n )\n const store = new EmbeddedCollectionStore(name, file, values, cache)\n store.logId = id\n store.changed = true\n return store\n }\n\n /**\n * Opens the file of a collection: its snapshot read when it is the one of the file, then the records written after\n * it applied; else all its records (their CRC-32 checked) applied an operation at a time, its indexes built from\n * its documents. The records after its last operation (cut by a crash) are cut off. A record whose CRC-32 does not\n * match, followed by a whole operation, is the corruption of the file: it fails. Undefined for a file without its\n * header record (cut when it was created).\n *\n * @param file\n * @param values\n * @param cache\n * @param path the path of the file, for the errors\n * @param snapshot the path of its snapshot\n */\n static open(\n file: EmbeddedFile,\n values: EmbeddedValues,\n cache: EmbeddedCollectionCache,\n path: string,\n snapshot?: string,\n ): EmbeddedCollectionStore | undefined {\n const first = new EmbeddedRecordReader(file).next(true)\n if (typeof first === \"string\") return undefined\n if (first.type !== RecordType.Header)\n throw new TypeORMError(\n `The file ${path} is not a file of mongo-embedded`,\n )\n const header = values.deserialize(first.payload)\n const store = new EmbeddedCollectionStore(\n header.name,\n file,\n values,\n cache,\n )\n store.logId = header.id\n const start = snapshot ? store.readSnapshot(snapshot) : undefined\n const replaying = start !== undefined\n const reader = new EmbeddedRecordReader(file, start ?? 0)\n const created: EmbeddedIndex[] = []\n let pending: PendingRecord[] = []\n let committed = start ?? 0\n for (;;) {\n const record = reader.next(true)\n if (record === \"end\" || record === \"torn\") break\n if (record === \"checksum\") {\n if (EmbeddedCollectionStore.isFollowedByCommit(file, reader))\n throw new TypeORMError(\n `The file ${path} of mongo-embedded is corrupted at its offset ${reader.position}`,\n )\n break\n }\n if (record.type === RecordType.Commit) {\n for (const done of pending)\n if (replaying) store.replay(done, created)\n else store.recover(done)\n pending = []\n committed = record.offset + record.length\n continue\n }\n const keyed =\n record.type === RecordType.Put ||\n record.type === RecordType.Delete\n pending.push({\n type: record.type,\n offset: record.offset,\n length: record.length,\n key: keyed ? values.idKeyOf(record.payload) : undefined,\n // The documents replayed after a snapshot update the indexes; read from the start, the indexes are\n // built once the records are read (from the documents read again)\n payload:\n (replaying && record.type === RecordType.Put) || !keyed\n ? values.deserialize(record.payload)\n : undefined,\n })\n }\n if (committed < file.size) {\n file.truncate(committed)\n file.sync()\n }\n if (replaying) {\n store.openedFrom = \"snapshot\"\n store.snapshotOffset = start\n store.buildIndexes(\n created.filter((index) => store.indexes.includes(index)),\n )\n store.changed = committed > start\n } else {\n store.buildIndexes(store.indexes)\n store.changed = true\n }\n return store\n }\n\n /**\n * Writes its snapshot: its keydir and the trees of its indexes as they are in memory, and the offset of its file\n * they are the state of (beside the file, then renamed over it). It is not written to the disk at once (synced): a\n * snapshot cut by a crash is refused when it is read (its CRC-32 and its size), as the one of another file (its\n * id, the commit record at its offset), the file then read from its start.\n *\n * @param path\n */\n writeSnapshot(path: string): void {\n const keydir = this.keydir.export()\n const trees = this.indexes\n .filter((index) => this.trees.has(index.name))\n .map((index) => ({\n name: index.name,\n ...this.trees.get(index.name)!.export(),\n }))\n const header = this.values.bson.BSON.serialize({\n format: 3,\n generation: this.generation,\n logId: this.logId,\n logOffset: this.file.size,\n liveBytes: this.liveBytes,\n indexes: this.indexes,\n multikey: [...this.multikey],\n keydir: {\n state: keydir.state,\n sizes: keydir.buffers.map((buffer) => buffer.byteLength),\n },\n trees: trees.map((tree) => ({\n name: tree.name,\n state: tree.state,\n sizes: tree.buffers.map((buffer) => buffer.byteLength),\n })),\n })\n const length = Buffer.allocUnsafe(4)\n length.writeUInt32LE(header.length)\n const parts: Uint8Array[] = [length, header]\n // The magic, the CRC-32 and the length before the header\n let size = 16 + header.length\n const pad = () => {\n if (size % 8) parts.push(Buffer.alloc(align(size) - size))\n size = align(size)\n }\n pad()\n for (const buffer of [\n ...keydir.buffers,\n ...trees.flatMap((tree) => tree.buffers),\n ]) {\n parts.push(buffer)\n size += buffer.byteLength\n pad()\n }\n let checksum = 0\n for (const part of parts) checksum = crc32(part, checksum)\n const crc = Buffer.allocUnsafe(4)\n crc.writeUInt32LE(checksum)\n const temporary = `${path}.tmp`\n const descriptor = fs.openSync(temporary, \"w\")\n try {\n for (const part of [SNAPSHOT_MAGIC, crc, ...parts]) {\n let written = 0\n while (written < part.byteLength)\n written += fs.writeSync(\n descriptor,\n part,\n written,\n Math.min(part.byteLength - written, IO_CHUNK),\n )\n }\n } finally {\n fs.closeSync(descriptor)\n }\n fs.renameSync(temporary, path)\n this.changed = false\n this.snapshotOffset = this.file.size\n }\n\n /**\n * Reads its snapshot, when it is whole and the one of its file (its id, an offset of it ending an operation): the\n * offset its records are applied from; undefined otherwise.\n *\n * @param path\n */\n protected readSnapshot(path: string): number | undefined {\n let descriptor: number\n try {\n descriptor = fs.openSync(path, \"r\")\n } catch {\n return undefined\n }\n try {\n // Read a part at a time, each one its own buffer (the buffers of Bun hold up to 4 GiB)\n let position = 0\n let checksum = 0\n const read = (size: number, checked = true): Buffer => {\n const bytes = Buffer.allocUnsafe(size)\n let done = 0\n while (done < size) {\n const count = fs.readSync(\n descriptor,\n bytes,\n done,\n Math.min(size - done, IO_CHUNK),\n position + done,\n )\n if (count === 0) throw new Error(\"The snapshot is cut\")\n done += count\n }\n position += size\n if (checked) checksum = crc32(bytes, checksum)\n return bytes\n }\n const skipPadding = () => {\n if (position % 8) read(align(position) - position)\n }\n if (!read(8, false).equals(SNAPSHOT_MAGIC)) return undefined\n const expected = read(4, false).readUInt32LE(0)\n const length = read(4).readUInt32LE(0)\n const header = this.values.deserialize(read(length))\n if (\n header.format !== 3 ||\n header.logId !== this.logId ||\n header.logOffset > this.file.size\n )\n return undefined\n const end = Buffer.allocUnsafe(RECORD_HEADER)\n this.file.readInto(\n end,\n 0,\n RECORD_HEADER,\n header.logOffset - RECORD_HEADER,\n )\n if (!end.equals(COMMIT_RECORD)) return undefined\n const take = (size: number): Uint8Array => {\n skipPadding()\n return read(size)\n }\n const keydir = header.keydir.sizes.map(take)\n const trees = header.trees.map((tree: { sizes: number[] }) =>\n tree.sizes.map(take),\n )\n skipPadding()\n if (\n checksum !== expected ||\n position !== fs.fstatSync(descriptor).size\n )\n return undefined\n this.keydir = EmbeddedKeydir.import(header.keydir.state, keydir)\n header.trees.forEach(\n (tree: { name: string; state: number[] }, index: number) =>\n this.trees.set(\n tree.name,\n EmbeddedBTree.import(tree.state, trees[index]),\n ),\n )\n this.indexes.push(...header.indexes)\n for (const name of header.multikey) this.multikey.add(name)\n this.liveBytes = header.liveBytes\n this.generation = header.generation\n return header.logOffset\n } catch {\n this.keydir = new EmbeddedKeydir()\n this.trees.clear()\n this.indexes.length = 0\n this.multikey.clear()\n this.liveBytes = 0\n return undefined\n } finally {\n fs.closeSync(descriptor)\n }\n }\n\n /**\n * Whether whole operations follow a record whose CRC-32 does not match (its length read as it is).\n *\n * @param file\n * @param reader the reader stopped at the record\n */\n protected static isFollowedByCommit(\n file: EmbeddedFile,\n reader: EmbeddedRecordReader,\n ): boolean {\n const header = Buffer.allocUnsafe(RECORD_HEADER)\n if (\n file.readInto(header, 0, RECORD_HEADER, reader.position) <\n RECORD_HEADER\n )\n return false\n const following = new EmbeddedRecordReader(\n file,\n reader.position + RECORD_HEADER + header.readUInt32LE(0),\n )\n for (;;) {\n const record = following.next(true)\n if (typeof record === \"string\") return false\n if (record.type === RecordType.Commit) return true\n }\n }\n\n /**\n * Whether a document of a key is held.\n *\n * @param key\n */\n has(key: Uint8Array): boolean {\n return this.keydir.has(key)\n }\n\n /**\n * The document of a key, cached or read from the file (and cached). It is shared: it must not be changed.\n *\n * @param key\n */\n get(key: Buffer): EmbeddedDocument | undefined {\n const text = key.toString(\"latin1\")\n const cached = this.cache.get(text)\n if (cached) return cached\n const slot = this.keydir.find(key)\n if (slot < 0) return undefined\n const length = this.keydir.lengthAt(slot)\n const offset = this.keydir.offsetAt(slot)\n const record = Buffer.allocUnsafe(length)\n this.fileOf(this.keydir.fileAt(slot)).readInto(record, 0, length, offset)\n const payload = record.subarray(RECORD_HEADER)\n if (\n crc32(payload, crc32(record.subarray(8, 9))) !==\n record.readUInt32LE(4)\n )\n throw this.corrupted(offset)\n const document = this.values.deserialize(payload)\n this.cache.set(text, document, cachedSizeOf(length))\n return document\n }\n\n /**\n * The documents of the collection: the ones cached when they all are (as they are when it is called), else the\n * ones of its files read in their order as it is iterated (cached while the cache has room): a document written\n * meanwhile may be missed (updated or deleted before it is read, inserted) or, while the collection is compacted,\n * read twice. They are shared: they must not be changed.\n */\n *documents(): Generator<EmbeddedDocument> {\n if (this.cache.size === this.keydir.size) {\n yield* this.cache.documents()\n return\n }\n // During a compaction, the documents not copied yet are in the previous file\n for (const [file, generation] of this.previous\n ? [\n [this.previous, this.generation ^ 1] as const,\n [this.file, this.generation] as const,\n ]\n : [[this.file, this.generation] as const])\n yield* this.liveDocuments(file, generation)\n }\n\n /**\n * The documents of a file its keydir holds (cached while the cache has room).\n *\n * @param file\n * @param generation\n */\n protected *liveDocuments(\n file: EmbeddedFile,\n generation: number,\n ): Generator<EmbeddedDocument> {\n const reader = new EmbeddedRecordReader(file)\n for (;;) {\n const record = reader.next(true)\n if (record === \"end\") return\n if (typeof record === \"string\") throw this.corrupted(reader.position)\n if (record.type !== RecordType.Put) continue\n const key = this.values.idKeyOf(record.payload)\n const slot = this.keydir.find(key)\n if (\n slot < 0 ||\n this.keydir.fileAt(slot) !== generation ||\n this.keydir.offsetAt(slot) !== record.offset\n )\n continue\n const text = key.toString(\"latin1\")\n let document = this.cache.get(text)\n if (!document) {\n document = this.values.deserialize(record.payload)\n this.cache.offer(text, document, cachedSizeOf(record.length))\n }\n yield document\n }\n }\n\n /**\n * Writes changes of documents as one operation: all of them, or none when one of them has a duplicate key.\n *\n * @param changes\n */\n write(changes: EmbeddedChange[]): void {\n if (!changes.length) return\n const entries = this.indexChanges(changes)\n this.changed = true\n const records: Buffer[] = changes.map((change) =>\n change.next\n ? encodeRecord(\n RecordType.Put,\n change.data ?? this.values.serialize(change.next),\n )\n : encodeRecord(\n RecordType.Delete,\n this.values.serialize({ _id: change.previous!._id }),\n ),\n )\n let offset = this.file.append(\n Buffer.concat([\n ...records,\n encodeRecord(RecordType.Commit, Buffer.alloc(0)),\n ]),\n )\n changes.forEach((change, index) => {\n const text = change.key.toString(\"latin1\")\n if (change.next) {\n this.liveBytes +=\n records[index].length -\n this.keydir.set(\n change.key,\n offset,\n records[index].length,\n this.generation,\n )\n this.cache.set(\n text,\n change.next,\n cachedSizeOf(records[index].length),\n )\n } else {\n this.liveBytes -= this.keydir.delete(change.key)\n this.cache.delete(text)\n }\n offset += records[index].length\n })\n for (const { index, tree, removed, added, id, keys } of entries) {\n for (const key of removed) tree.delete(key, id)\n for (const key of added) tree.insert(key, id)\n if (keys > 1) this.multikey.add(index)\n }\n }\n\n /**\n * The keys of the _id of the documents of the entries of ranges of an index, in its order (or reversed): a\n * document is given once for each of its keys in the ranges.\n *\n * @param index\n * @param ranges\n * @param reverse\n */\n *idsIn(\n index: string,\n ranges: { lower?: EmbeddedBound; upper?: EmbeddedBound }[],\n reverse = false,\n ): Generator<Buffer> {\n const tree = this.trees.get(index)\n if (!tree) return\n for (const range of reverse ? [...ranges].reverse() : ranges)\n for (const [, id] of tree.range(range.lower, range.upper, reverse))\n yield id\n }\n\n /**\n * Adds an index, unless one of its name exists: built from the documents (read from the two files of a compaction\n * whose end it holds), in batches with the event loop yielded between them, while the writes of the collection wait\n * (building) and no compaction starts; it fails on a key of a document too large (EmbeddedKeyTooLongError), and a\n * unique one on the duplicate keys of the documents, the index not added. The queries use it once it is built.\n *\n * @param index\n */\n async createIndex(index: EmbeddedIndex): Promise<void> {\n while (this.building) await this.building\n if (this.indexes.some((existing) => existing.name === index.name))\n return\n let built!: () => void\n this.building = new Promise((resolve) => (built = resolve))\n try {\n // No compaction copying its documents meanwhile (a compaction copied waits for the build to end, and none\n // starts while it runs)\n while (this.compacting) await this.compacting\n const tree = new EmbeddedBTree()\n let multikey = false\n let read = 0\n for (const document of this.documents()) {\n const id = this.values.idKey(document._id)\n const keys = this.keysOf(index, document)\n if (keys.length > 1) multikey = true\n for (const key of keys) {\n if (!EmbeddedBTree.fits(key, id))\n throw new EmbeddedKeyTooLongError(\n this.name,\n index.name,\n key.length,\n this.keyValue(index, document),\n )\n if (index.unique && this.ownerOf(tree, key))\n throw new EmbeddedDuplicateKeyError(\n this.name,\n index.name,\n this.keyValue(index, document),\n )\n tree.insert(key, id)\n }\n if (++read % BUILD_BATCH === 0)\n await new Promise((resolve) => setImmediate(resolve))\n }\n this.trees.set(index.name, tree)\n if (multikey) this.multikey.add(index.name)\n this.changed = true\n this.file.append(\n Buffer.concat([\n encodeRecord(\n RecordType.CreateIndex,\n this.values.bson.BSON.serialize(index),\n ),\n encodeRecord(RecordType.Commit, Buffer.alloc(0)),\n ]),\n )\n this.indexes.push(index)\n } finally {\n this.building = undefined\n built()\n }\n }\n\n /**\n * Removes an index; whether it existed.\n *\n * @param name\n */\n dropIndex(name: string): boolean {\n const position = this.indexes.findIndex((index) => index.name === name)\n if (position < 0) return false\n this.changed = true\n this.file.append(\n Buffer.concat([\n encodeRecord(\n RecordType.DropIndex,\n this.values.bson.BSON.serialize({ name: name }),\n ),\n encodeRecord(RecordType.Commit, Buffer.alloc(0)),\n ]),\n )\n this.indexes.splice(position, 1)\n this.trees.delete(name)\n this.multikey.delete(name)\n return true\n }\n\n /**\n * Whether a scan of its file read in the last SCAN_TIMEOUT; else its scans are closed (their next read fails).\n *\n * @param now\n */\n isScanned(now = Date.now()): boolean {\n for (const scan of this.scans)\n if (now - scan.read < SCAN_TIMEOUT) return true\n for (const scan of this.scans) scan.closed = true\n this.scans.clear()\n return false\n }\n\n /**\n * Whether its file is worth compacting: larger than a size, and a ratio of the bytes of its live documents.\n *\n * @param minimumSize\n * @param ratio\n */\n isWorthCompacting(minimumSize: number, ratio: number): boolean {\n return (\n !this.previous &&\n this.file.size >= minimumSize &&\n this.file.size > this.liveBytes * ratio\n )\n }\n\n /**\n * Starts a compaction: a new file (its header record and the records of its indexes) is written from now on, the\n * live documents of the previous one copied to it then.\n *\n * @param next\n */\n beginCompaction(next: EmbeddedFile): void {\n const id = randomBytes(8).toString(\"hex\")\n next.append(\n Buffer.concat([\n encodeRecord(\n RecordType.Header,\n this.values.bson.BSON.serialize({\n name: this.name,\n format: 1,\n id: id,\n }),\n ),\n ...this.indexes.map((index) =>\n encodeRecord(\n RecordType.CreateIndex,\n this.values.bson.BSON.serialize(index),\n ),\n ),\n COMMIT_RECORD,\n ]),\n )\n this.previous = this.file\n this.file = next\n this.generation ^= 1\n this.logId = id\n this.changed = true\n }\n\n /**\n * Copies the documents of the previous file its keydir still holds there to the current one, a batch (one operation)\n * at a time, yielding between the batches (the writes made meanwhile are written to the current file).\n */\n *copyLiveDocuments(): Generator<void> {\n const previous = this.previous!\n const old = this.generation ^ 1\n const reader = new EmbeddedRecordReader(previous)\n let records: Buffer[] = []\n let keys: Buffer[] = []\n const flush = () => {\n if (!records.length) return\n let offset = this.file.append(\n Buffer.concat([...records, COMMIT_RECORD]),\n )\n records.forEach((record, index) => {\n this.keydir.set(keys[index], offset, record.length, this.generation)\n offset += record.length\n })\n records = []\n keys = []\n }\n for (;;) {\n const record = reader.next(true)\n if (record === \"end\") break\n if (typeof record === \"string\") throw this.corrupted(reader.position)\n if (record.type !== RecordType.Put) continue\n const key = this.values.idKeyOf(record.payload)\n const slot = this.keydir.find(key)\n if (\n slot < 0 ||\n this.keydir.fileAt(slot) !== old ||\n this.keydir.offsetAt(slot) !== record.offset\n )\n continue\n // Copied as it is: the same bytes, its live bytes unchanged. Its keydir slot checked above and set by\n // the flush in one synchronous span (the flush before the yield): a write made meanwhile is not\n // overwritten by its stale copy\n records.push(encodeRecord(RecordType.Put, record.payload))\n keys.push(key)\n if (records.length < 1000) continue\n flush()\n yield\n }\n flush()\n }\n\n /**\n * Ends a compaction: the previous file closed (its documents all copied).\n */\n endCompaction(): void {\n this.previous!.close()\n this.previous = undefined\n }\n\n /**\n * Applies the records of the file of a compaction cut by a crash (written after the ones of its file), then runs\n * the compaction to its end: its documents not copied yet copied.\n *\n * @param next\n * @param path the path of the file, for the errors\n */\n resumeCompaction(next: EmbeddedFile, path: string): void {\n const first = new EmbeddedRecordReader(next).next(true)\n if (typeof first === \"string\" || first.type !== RecordType.Header)\n throw new TypeORMError(\n `The file ${path} is not a file of mongo-embedded`,\n )\n this.previous = this.file\n this.file = next\n this.generation ^= 1\n this.logId = this.values.deserialize(first.payload).id\n const created: EmbeddedIndex[] = []\n const reader = new EmbeddedRecordReader(next, first.offset + first.length)\n let pending: PendingRecord[] = []\n let committed = first.offset + first.length\n for (;;) {\n const record = reader.next(true)\n if (record === \"end\" || record === \"torn\") break\n if (record === \"checksum\") {\n if (EmbeddedCollectionStore.isFollowedByCommit(next, reader))\n throw this.corrupted(reader.position)\n break\n }\n if (record.type === RecordType.Commit) {\n for (const done of pending) this.replay(done, created)\n pending = []\n committed = record.offset + record.length\n continue\n }\n const keyed =\n record.type === RecordType.Put ||\n record.type === RecordType.Delete\n pending.push({\n type: record.type,\n offset: record.offset,\n length: record.length,\n key: keyed ? this.values.idKeyOf(record.payload) : undefined,\n payload:\n record.type !== RecordType.Delete\n ? this.values.deserialize(record.payload)\n : undefined,\n })\n }\n if (committed < next.size) {\n next.truncate(committed)\n next.sync()\n }\n this.buildIndexes(created.filter((index) => this.indexes.includes(index)))\n for (const _ of this.copyLiveDocuments()) continue\n this.changed = true\n }\n\n /**\n * Closes its files (the database closed, or the collection dropped): a compaction running stops, their uses after\n * throw.\n */\n close(): void {\n this.closed = true\n this.cache.close()\n this.previous?.close()\n this.file.close()\n }\n\n /**\n * The file of a number of the slots of the keydir.\n *\n * @param generation\n */\n protected fileOf(generation: number): EmbeddedFile {\n return generation === this.generation ? this.file : this.previous!\n }\n\n /**\n * The error of a record of its file whose CRC-32 does not match.\n *\n * @param offset\n */\n protected corrupted(offset: number): TypeORMError {\n return new TypeORMError(\n `The file ${(this.file as { path?: string }).path ?? this.name} of mongo-embedded is corrupted at its offset ${offset}`,\n )\n }\n\n /**\n * Applies a record of an operation recovered.\n *\n * @param record\n */\n protected recover(record: PendingRecord): void {\n switch (record.type) {\n case RecordType.Put:\n this.liveBytes +=\n record.length -\n this.keydir.set(\n record.key!,\n record.offset,\n record.length,\n this.generation,\n )\n break\n case RecordType.Delete:\n this.liveBytes -= this.keydir.delete(record.key!)\n break\n case RecordType.CreateIndex:\n if (\n !this.indexes.some(\n (index) => index.name === record.payload!.name,\n )\n )\n this.indexes.push(record.payload as EmbeddedIndex)\n break\n case RecordType.DropIndex: {\n const position = this.indexes.findIndex(\n (index) => index.name === record.payload!.name,\n )\n if (position >= 0) this.indexes.splice(position, 1)\n break\n }\n }\n }\n\n /**\n * Applies a record written after the snapshot read: its document in the keydir and the indexes (the indexes created\n * are built once the records are applied).\n *\n * @param record\n * @param created the indexes created by the records\n */\n protected replay(record: PendingRecord, created: EmbeddedIndex[]): void {\n switch (record.type) {\n case RecordType.Put:\n case RecordType.Delete: {\n const previous = this.get(record.key!)\n const next =\n record.type === RecordType.Put ? record.payload : undefined\n const id = record.key!\n for (const index of this.indexes) {\n const tree = this.trees.get(index.name)\n if (!tree) continue\n const before = previous ? this.keysOf(index, previous) : []\n const after = next ? this.keysOf(index, next) : []\n for (const key of before) tree.delete(key, id)\n for (const key of after) tree.insert(key, id)\n if (after.length > 1) this.multikey.add(index.name)\n }\n this.cache.delete(id.toString(\"latin1\"))\n if (next)\n this.liveBytes +=\n record.length -\n this.keydir.set(\n id,\n record.offset,\n record.length,\n this.generation,\n )\n else this.liveBytes -= this.keydir.delete(id)\n break\n }\n case RecordType.CreateIndex:\n if (\n !this.indexes.some(\n (index) => index.name === record.payload!.name,\n )\n ) {\n const index = record.payload as EmbeddedIndex\n this.indexes.push(index)\n created.push(index)\n }\n break\n case RecordType.DropIndex: {\n const position = this.indexes.findIndex(\n (index) => index.name === record.payload!.name,\n )\n if (position >= 0) this.indexes.splice(position, 1)\n this.trees.delete(record.payload!.name)\n this.multikey.delete(record.payload!.name)\n break\n }\n }\n }\n\n /**\n * Builds indexes from the documents, read once; it fails on the duplicate keys of a unique one.\n *\n * @param indexes\n */\n protected buildIndexes(indexes: EmbeddedIndex[]): void {\n if (!indexes.length) return\n const trees = indexes.map(() => new EmbeddedBTree())\n for (const document of this.documents()) {\n const id = this.values.idKey(document._id)\n indexes.forEach((index, position) => {\n const keys = this.keysOf(index, document)\n if (keys.length > 1) this.multikey.add(index.name)\n for (const key of keys) {\n if (index.unique && this.ownerOf(trees[position], key))\n throw new EmbeddedDuplicateKeyError(\n this.name,\n index.name,\n this.keyValue(index, document),\n )\n trees[position].insert(key, id)\n }\n })\n }\n indexes.forEach((index, position) =>\n this.trees.set(index.name, trees[position]),\n )\n }\n\n /**\n * The changes of the entries of the indexes of a write, its unique keys checked (also between its changes).\n *\n * @param changes\n */\n protected indexChanges(changes: EmbeddedChange[]): {\n index: string\n tree: EmbeddedBTree\n removed: Buffer[]\n added: Buffer[]\n id: Buffer\n keys: number\n }[] {\n const entries: {\n index: string\n tree: EmbeddedBTree\n removed: Buffer[]\n added: Buffer[]\n id: Buffer\n keys: number\n }[] = []\n const inserted = new Set<string>()\n // The keys of the unique indexes written: their owners (the keys of their _id), null for the ones removed\n const pending = new Map<string, Map<string, string | null>>()\n for (const change of changes) {\n const owner = change.key.toString(\"latin1\")\n if (!change.previous && change.next) {\n if (this.keydir.has(change.key) || inserted.has(owner))\n throw new EmbeddedDuplicateKeyError(this.name, \"_id_\", {\n _id: change.next._id,\n })\n inserted.add(owner)\n }\n for (const index of this.indexes) {\n const tree = this.trees.get(index.name)!\n const before = change.previous\n ? this.keysOf(index, change.previous)\n : []\n const after = change.next ? this.keysOf(index, change.next) : []\n const kept = new Set(before.map((key) => key.toString(\"latin1\")))\n const now = new Set(after.map((key) => key.toString(\"latin1\")))\n const removed = before.filter(\n (key) => !now.has(key.toString(\"latin1\")),\n )\n const added = after.filter(\n (key) => !kept.has(key.toString(\"latin1\")),\n )\n // Checked before the write is written: an entry not fitting a tree would throw once it is\n for (const key of added)\n if (!EmbeddedBTree.fits(key, change.key))\n throw new EmbeddedKeyTooLongError(\n this.name,\n index.name,\n key.length,\n this.keyValue(index, change.next!),\n )\n if (index.unique) {\n let written = pending.get(index.name)\n if (!written) pending.set(index.name, (written = new Map()))\n for (const key of removed)\n written.set(key.toString(\"latin1\"), null)\n for (const key of added) {\n const text = key.toString(\"latin1\")\n const existing = written.has(text)\n ? written.get(text)\n : this.ownerOf(tree, key)?.toString(\"latin1\")\n if (\n existing !== undefined &&\n existing !== null &&\n existing !== owner\n )\n throw new EmbeddedDuplicateKeyError(\n this.name,\n index.name,\n this.keyValue(index, change.next!),\n )\n written.set(text, owner)\n }\n }\n entries.push({\n index: index.name,\n tree: tree,\n removed: removed,\n added: added,\n id: change.key,\n keys: after.length,\n })\n }\n }\n return entries\n }\n\n /**\n * The key of the _id of the document holding a key in an index, if any.\n *\n * @param tree\n * @param key\n */\n protected ownerOf(tree: EmbeddedBTree, key: Buffer): Buffer | undefined {\n for (const [, id] of tree.range(\n { key: key, inclusive: true },\n { key: key, inclusive: true },\n ))\n return id\n return undefined\n }\n\n /**\n * The keys of a document in an index.\n *\n * @param index\n * @param document\n */\n protected keysOf(index: EmbeddedIndex, document: EmbeddedDocument): Buffer[] {\n return this.encoding.keysOf(index.key, index.sparse, document)\n }\n\n /**\n * The fields of a document in an index, for the message of a duplicate key.\n *\n * @param index\n * @param document\n */\n protected keyValue(\n index: EmbeddedIndex,\n document: EmbeddedDocument,\n ): { [field: string]: any } {\n const value: { [field: string]: any } = {}\n for (const path of Object.keys(index.key))\n value[path] = this.values.valueAt(document, path) ?? null\n return value\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lakutata: the CRC-32 of zlib computed with a table, for the versions of Node.js without zlib.crc32 (before 22.2 and
|
|
3
|
+
* 20.15: Node.js 18 and 19 of NW.js and of the phones). It gives what zlib.crc32 gives.
|
|
4
|
+
*
|
|
5
|
+
* @param data The bytes.
|
|
6
|
+
* @param value The CRC-32 of the bytes before them, to continue it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function tableCrc32(data: Uint8Array, value?: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* lakutata: the CRC-32 of zlib of the bytes, continuing a value: zlib.crc32 where Node.js has it, else the table.
|
|
11
|
+
*
|
|
12
|
+
* @param data The bytes.
|
|
13
|
+
* @param value The CRC-32 of the bytes before them, to continue it.
|
|
14
|
+
*/
|
|
15
|
+
export declare const crc32: (data: Uint8Array, value?: number) => number;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.crc32 = void 0;
|
|
4
|
+
exports.tableCrc32 = tableCrc32;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const zlib = tslib_1.__importStar(require("zlib"));
|
|
7
|
+
/**
|
|
8
|
+
* lakutata: the table of the CRC-32 of zlib (ISO-HDLC, the reflected polynomial 0xedb88320), made at its first use.
|
|
9
|
+
*/
|
|
10
|
+
let table;
|
|
11
|
+
/**
|
|
12
|
+
* lakutata: the CRC-32 of zlib computed with a table, for the versions of Node.js without zlib.crc32 (before 22.2 and
|
|
13
|
+
* 20.15: Node.js 18 and 19 of NW.js and of the phones). It gives what zlib.crc32 gives.
|
|
14
|
+
*
|
|
15
|
+
* @param data The bytes.
|
|
16
|
+
* @param value The CRC-32 of the bytes before them, to continue it.
|
|
17
|
+
*/
|
|
18
|
+
function tableCrc32(data, value = 0) {
|
|
19
|
+
if (!table) {
|
|
20
|
+
table = new Uint32Array(256);
|
|
21
|
+
for (let n = 0; n < 256; n++) {
|
|
22
|
+
let c = n;
|
|
23
|
+
for (let k = 0; k < 8; k++)
|
|
24
|
+
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
25
|
+
table[n] = c >>> 0;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
let crc = (value ^ 0xffffffff) >>> 0;
|
|
29
|
+
for (let i = 0; i < data.length; i++)
|
|
30
|
+
crc = table[(crc ^ data[i]) & 0xff] ^ (crc >>> 8);
|
|
31
|
+
return (crc ^ 0xffffffff) >>> 0;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* lakutata: zlib.crc32 where Node.js has it, up to about 20 times faster than the table on large inputs.
|
|
35
|
+
*/
|
|
36
|
+
const native = zlib.crc32;
|
|
37
|
+
/**
|
|
38
|
+
* lakutata: the CRC-32 of zlib of the bytes, continuing a value: zlib.crc32 where Node.js has it, else the table.
|
|
39
|
+
*
|
|
40
|
+
* @param data The bytes.
|
|
41
|
+
* @param value The CRC-32 of the bytes before them, to continue it.
|
|
42
|
+
*/
|
|
43
|
+
exports.crc32 = typeof native === "function" ? native : tableCrc32;
|
|
44
|
+
//# sourceMappingURL=EmbeddedCrc32.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbeddedCrc32.js","sourceRoot":"","sources":["../../../../../vendor/typeorm/driver/mongo-embedded/EmbeddedCrc32.ts"],"names":[],"mappings":";;;AAcA,gCAYC;;AA1BD,mDAA4B;AAE5B;;GAEG;AACH,IAAI,KAA8B,CAAA;AAElC;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAgB,EAAE,QAAgB,CAAC;IAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,KAAK,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,CAAA;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,IAAI,CAAC,GAAG,CAAC,CAAA;YACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;YACxE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;IACL,CAAC;IACD,IAAI,GAAG,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;IACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,GAAG,GAAG,KAAK,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAA;IACvF,OAAO,CAAC,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,MAAM,GAAI,IAAiE,CAAC,KAAK,CAAA;AAEvF;;;;;GAKG;AACU,QAAA,KAAK,GACd,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAA","sourcesContent":["import * as zlib from \"zlib\"\n\n/**\n * lakutata: the table of the CRC-32 of zlib (ISO-HDLC, the reflected polynomial 0xedb88320), made at its first use.\n */\nlet table: Uint32Array | undefined\n\n/**\n * lakutata: the CRC-32 of zlib computed with a table, for the versions of Node.js without zlib.crc32 (before 22.2 and\n * 20.15: Node.js 18 and 19 of NW.js and of the phones). It gives what zlib.crc32 gives.\n *\n * @param data The bytes.\n * @param value The CRC-32 of the bytes before them, to continue it.\n */\nexport function tableCrc32(data: Uint8Array, value: number = 0): number {\n if (!table) {\n table = new Uint32Array(256)\n for (let n = 0; n < 256; n++) {\n let c = n\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1\n table[n] = c >>> 0\n }\n }\n let crc = (value ^ 0xffffffff) >>> 0\n for (let i = 0; i < data.length; i++) crc = table[(crc ^ data[i]) & 0xff] ^ (crc >>> 8)\n return (crc ^ 0xffffffff) >>> 0\n}\n\n/**\n * lakutata: zlib.crc32 where Node.js has it, up to about 20 times faster than the table on large inputs.\n */\nconst native = (zlib as { crc32?: (data: Uint8Array, value?: number) => number }).crc32\n\n/**\n * lakutata: the CRC-32 of zlib of the bytes, continuing a value: zlib.crc32 where Node.js has it, else the table.\n *\n * @param data The bytes.\n * @param value The CRC-32 of the bytes before them, to continue it.\n */\nexport const crc32: (data: Uint8Array, value?: number) => number =\n typeof native === \"function\" ? native : tableCrc32\n"]}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmbeddedRecordReader = exports.RecordType = exports.RECORD_HEADER = void 0;
|
|
4
4
|
exports.encodeRecord = encodeRecord;
|
|
5
|
-
const
|
|
6
|
-
const zlib = tslib_1.__importStar(require("zlib"));
|
|
5
|
+
const EmbeddedCrc32_1 = require("./EmbeddedCrc32");
|
|
7
6
|
/**
|
|
8
7
|
* lakutata: the size of the header of a record: the length of its payload (4 bytes), the CRC-32 of its type and
|
|
9
8
|
* payload (4 bytes), its type (1 byte).
|
|
@@ -37,7 +36,7 @@ exports.RecordType = {
|
|
|
37
36
|
* @param payload
|
|
38
37
|
*/
|
|
39
38
|
function checksumOf(type, payload) {
|
|
40
|
-
return
|
|
39
|
+
return (0, EmbeddedCrc32_1.crc32)(payload, (0, EmbeddedCrc32_1.crc32)(Buffer.of(type)));
|
|
41
40
|
}
|
|
42
41
|
/**
|
|
43
42
|
* lakutata: encodes a record.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedLog.js","sourceRoot":"","sources":["../../../../../vendor/typeorm/driver/mongo-embedded/EmbeddedLog.ts"],"names":[],"mappings":";;;AAiEA,oCAOC
|
|
1
|
+
{"version":3,"file":"EmbeddedLog.js","sourceRoot":"","sources":["../../../../../vendor/typeorm/driver/mongo-embedded/EmbeddedLog.ts"],"names":[],"mappings":";;;AAiEA,oCAOC;AAxED,mDAAuC;AAGvC;;;GAGG;AACU,QAAA,aAAa,GAAG,CAAC,CAAA;AAE9B;;;GAGG;AACU,QAAA,UAAU,GAAG;IACtB;;;OAGG;IACH,MAAM,EAAE,CAAC;IACT,wCAAwC;IACxC,GAAG,EAAE,CAAC;IACN,2CAA2C;IAC3C,MAAM,EAAE,CAAC;IACT,mDAAmD;IACnD,WAAW,EAAE,CAAC;IACd,yCAAyC;IACzC,SAAS,EAAE,CAAC;IACZ,+BAA+B;IAC/B,MAAM,EAAE,CAAC;CACH,CAAA;AAoBV;;;;;GAKG;AACH,SAAS,UAAU,CAAC,IAAY,EAAE,OAAmB;IACjD,OAAO,IAAA,qBAAK,EAAC,OAAO,EAAE,IAAA,qBAAK,EAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,OAAmB;IAC1D,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,qBAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACjE,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IACvC,MAAM,CAAC,aAAa,CAAC,UAAU,C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size of the header of a record: the length of its payload (4 bytes), the CRC-32 of its type and\n * payload (4 bytes), its type (1 byte).\n */\nexport const RECORD_HEADER = 9\n\n/**\n * lakutata: the types of the records of the file of a collection. An operation is its records followed by a commit\n * record; the records after the last commit record (an operation cut by a crash) are dropped when the file is opened.\n */\nexport const RecordType = {\n /**\n * The first record of a file: the name of its collection, the format of the file (1), and its id (which its\n * snapshot tells).\n */\n Header: 0,\n /** A document (BSON, its _id first). */\n Put: 1,\n /** The deletion of a document: its _id. */\n Delete: 2,\n /** The creation of an index: its specification. */\n CreateIndex: 3,\n /** The removal of an index: its name. */\n DropIndex: 4,\n /** The end of an operation. */\n Commit: 5,\n} as const\n\n/**\n * lakutata: a record read from a file. Its payload is a view of the buffer of the reader, valid until it reads the\n * next record.\n */\nexport interface EmbeddedRecord {\n type: number\n offset: number\n length: number\n payload: Buffer\n}\n\n/**\n * lakutata: why a record could not be read: the end of the file, a record past its end (cut by a crash), a record\n * whose CRC-32 does not match. The CRC-32 does not cover the length of a record: a length damaged in the middle of a\n * file reads as a record cut (past its end) or as a CRC-32 not matching (another record read).\n */\nexport type EmbeddedRecordEnd = \"end\" | \"torn\" | \"checksum\"\n\n/**\n * lakutata: the CRC-32 of the type and the payload of a record.\n *\n * @param type\n * @param payload\n */\nfunction checksumOf(type: number, payload: Uint8Array): number {\n return crc32(payload, crc32(Buffer.of(type)))\n}\n\n/**\n * lakutata: encodes a record.\n *\n * @param type\n * @param payload\n */\nexport function encodeRecord(type: number, payload: Uint8Array): Buffer {\n const record = Buffer.allocUnsafe(RECORD_HEADER + payload.length)\n record.writeUInt32LE(payload.length, 0)\n record.writeUInt32LE(checksumOf(type, payload), 4)\n record[8] = type\n record.set(payload, RECORD_HEADER)\n return record\n}\n\n/**\n * lakutata: reads the records of a file in its order, by blocks.\n */\nexport class EmbeddedRecordReader {\n protected block: Buffer\n\n protected blockStart = 0\n\n protected filled = 0\n\n /**\n * @param file\n * @param position the offset of the first record to read\n * @param end the offset the reading stops at (the size of the file when it is read, by default)\n * @param blockSize\n */\n constructor(\n protected readonly file: EmbeddedFile,\n public position = 0,\n protected readonly end = file.size,\n blockSize = 4 * 1024 * 1024,\n ) {\n this.block = Buffer.allocUnsafe(blockSize)\n }\n\n /**\n * The next record, or why there is none.\n *\n * @param verify whether its CRC-32 is checked\n */\n next(verify: boolean): EmbeddedRecord | EmbeddedRecordEnd {\n if (this.position >= this.end) return \"end\"\n if (!this.ensure(RECORD_HEADER)) return \"torn\"\n const length =\n RECORD_HEADER +\n this.block.readUInt32LE(this.position - this.blockStart)\n if (this.position + length > this.end || !this.ensure(length))\n return \"torn\"\n const start = this.position - this.blockStart\n const type = this.block[start + 8]\n const payload = this.block.subarray(\n start + RECORD_HEADER,\n start + length,\n )\n if (\n verify &&\n checksumOf(type, payload) !== this.block.readUInt32LE(start + 4)\n )\n return \"checksum\"\n const record = {\n type: type,\n offset: this.position,\n length: length,\n payload: payload,\n }\n this.position += length\n return record\n }\n\n /**\n * Makes the block hold the bytes from the position; whether the file has them.\n *\n * @param bytes\n */\n protected ensure(bytes: number): boolean {\n if (this.position + bytes <= this.blockStart + this.filled) return true\n if (bytes > this.block.length) this.block = Buffer.allocUnsafe(bytes)\n this.blockStart = this.position\n this.filled = this.file.readInto(\n this.block,\n 0,\n Math.min(this.block.length, this.end - this.position),\n this.position,\n )\n return this.filled >= bytes\n }\n}\n"]}
|
|
@@ -368,6 +368,10 @@ class EmbeddedWorkerClient {
|
|
|
368
368
|
};
|
|
369
369
|
const worker = new worker_threads_1.Worker(EmbeddedWorkerCode_1.embeddedWorkerCode, {
|
|
370
370
|
eval: true,
|
|
371
|
+
// lakutata: none of the options of the command line of the process, which the worker would inherit: with
|
|
372
|
+
// --input-type=module, its code (CommonJS) would run as an ES module; a list of its own refuses the
|
|
373
|
+
// options of V8 (--max-old-space-size) that the process may have
|
|
374
|
+
execArgv: [],
|
|
371
375
|
workerData: { [EmbeddedWorkerProtocol_1.WORKER_DATA_KEY]: data },
|
|
372
376
|
...(resourceLimits ? { resourceLimits: resourceLimits } : {}),
|
|
373
377
|
});
|