@cobol-ts/cursor-loader-protobuf 0.0.0-stage → 0.0.16
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 +94 -2
- package/dist/index.d.ts +18 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/src/protobuf.accumulator.d.ts +24 -0
- package/dist/src/protobuf.accumulator.file.d.ts +24 -0
- package/dist/src/protobuf.accumulator.file.js +164 -0
- package/dist/src/protobuf.accumulator.file.js.map +1 -0
- package/dist/src/protobuf.accumulator.js +110 -0
- package/dist/src/protobuf.accumulator.js.map +1 -0
- package/dist/src/protobuf.buffered.spec.d.ts +1 -0
- package/dist/src/protobuf.buffered.spec.js +97 -0
- package/dist/src/protobuf.buffered.spec.js.map +1 -0
- package/dist/src/protobuf.cursor.integration.spec.d.ts +1 -0
- package/dist/src/protobuf.cursor.integration.spec.js +116 -0
- package/dist/src/protobuf.cursor.integration.spec.js.map +1 -0
- package/dist/src/protobuf.envelope.d.ts +6 -0
- package/dist/src/protobuf.envelope.js +48 -0
- package/dist/src/protobuf.envelope.js.map +1 -0
- package/dist/src/protobuf.file.node.d.ts +16 -0
- package/dist/src/protobuf.file.node.js +43 -0
- package/dist/src/protobuf.file.node.js.map +1 -0
- package/dist/src/protobuf.file.spec.d.ts +1 -0
- package/dist/src/protobuf.file.spec.js +162 -0
- package/dist/src/protobuf.file.spec.js.map +1 -0
- package/dist/src/protobuf.mixed.codec.d.ts +7 -0
- package/dist/src/protobuf.mixed.codec.js +105 -0
- package/dist/src/protobuf.mixed.codec.js.map +1 -0
- package/dist/src/protobuf.number.file.d.ts +17 -0
- package/dist/src/protobuf.number.file.js +107 -0
- package/dist/src/protobuf.number.file.js.map +1 -0
- package/dist/src/protobuf.number.projection.d.ts +25 -0
- package/dist/src/protobuf.number.projection.js +310 -0
- package/dist/src/protobuf.number.projection.js.map +1 -0
- package/dist/src/protobuf.number.projection.spec.d.ts +1 -0
- package/dist/src/protobuf.number.projection.spec.js +111 -0
- package/dist/src/protobuf.number.projection.spec.js.map +1 -0
- package/dist/src/protobuf.number.rolling.d.ts +21 -0
- package/dist/src/protobuf.number.rolling.js +162 -0
- package/dist/src/protobuf.number.rolling.js.map +1 -0
- package/dist/src/protobuf.parser.d.ts +35 -0
- package/dist/src/protobuf.parser.js +142 -0
- package/dist/src/protobuf.parser.js.map +1 -0
- package/dist/src/protobuf.projection.support.d.ts +14 -0
- package/dist/src/protobuf.projection.support.js +75 -0
- package/dist/src/protobuf.projection.support.js.map +1 -0
- package/dist/src/protobuf.rdw.d.ts +15 -0
- package/dist/src/protobuf.rdw.js +107 -0
- package/dist/src/protobuf.rdw.js.map +1 -0
- package/dist/src/protobuf.registration.d.ts +3 -0
- package/dist/src/protobuf.registration.js +8 -0
- package/dist/src/protobuf.registration.js.map +1 -0
- package/dist/src/protobuf.reuse.spec.d.ts +1 -0
- package/dist/src/protobuf.reuse.spec.js +117 -0
- package/dist/src/protobuf.reuse.spec.js.map +1 -0
- package/dist/src/protobuf.rolling.layout.d.ts +13 -0
- package/dist/src/protobuf.rolling.layout.js +69 -0
- package/dist/src/protobuf.rolling.layout.js.map +1 -0
- package/dist/src/protobuf.rolling.spec.d.ts +1 -0
- package/dist/src/protobuf.rolling.spec.js +174 -0
- package/dist/src/protobuf.rolling.spec.js.map +1 -0
- package/dist/src/protobuf.roundtrip.spec.d.ts +1 -0
- package/dist/src/protobuf.roundtrip.spec.js +195 -0
- package/dist/src/protobuf.roundtrip.spec.js.map +1 -0
- package/dist/src/protobuf.safe-integer.d.ts +10 -0
- package/dist/src/protobuf.safe-integer.js +88 -0
- package/dist/src/protobuf.safe-integer.js.map +1 -0
- package/dist/src/protobuf.scalar.codec.d.ts +17 -0
- package/dist/src/protobuf.scalar.codec.js +276 -0
- package/dist/src/protobuf.scalar.codec.js.map +1 -0
- package/dist/src/protobuf.schema.d.ts +17 -0
- package/dist/src/protobuf.schema.first.parser.d.ts +10 -0
- package/dist/src/protobuf.schema.first.parser.js +23 -0
- package/dist/src/protobuf.schema.first.parser.js.map +1 -0
- package/dist/src/protobuf.schema.js +91 -0
- package/dist/src/protobuf.schema.js.map +1 -0
- package/package.json +68 -3
package/README.md
CHANGED
|
@@ -1,3 +1,95 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cobol-ts/cursor-loader-protobuf
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The fourth COBOL-TS physical format is a sorted, self-describing Protobuf accumulator file. It uses the same four-byte variable-record RDW convention as the COBOL reader: a big-endian 16-bit total record length (including the RDW), then two zero control bytes. Each message payload follows immediately. The maximum entire record is 65,535 bytes.
|
|
4
|
+
|
|
5
|
+
## Quick orientation
|
|
6
|
+
|
|
7
|
+
**Responsibility.** Read and write schema-first Protobuf accumulator files and supply field accessors, framing and pooled message adapters.
|
|
8
|
+
|
|
9
|
+
**Boundary.** Wire format, schema and message reuse are separate from the CEL graph that produces values.
|
|
10
|
+
|
|
11
|
+
**Public modules.** [protobuf.parser.ts](./src/protobuf.parser.ts), [protobuf.registration.ts](./src/protobuf.registration.ts), [protobuf.file.node.ts](./src/protobuf.file.node.ts), [protobuf.projection.support.ts](./src/protobuf.projection.support.ts), [protobuf.schema.ts](./src/protobuf.schema.ts) (and 9 more exports in [`index.ts`](index.ts)).
|
|
12
|
+
|
|
13
|
+
**Tests.** [protobuf.buffered.spec.ts](src/protobuf.buffered.spec.ts), [protobuf.cursor.integration.spec.ts](src/protobuf.cursor.integration.spec.ts), [protobuf.file.spec.ts](src/protobuf.file.spec.ts) (+3 more)
|
|
14
|
+
|
|
15
|
+
**Related packages.** [@cobol-ts/cursor-loader-source](../cursor-loader-source/README.md) · [@cobol-ts/cursor-composition](../cursor-composition/README.md).
|
|
16
|
+
|
|
17
|
+
## Format
|
|
18
|
+
|
|
19
|
+
Record 0 contains a fixed-schema `SchemaEnvelope` with version `1`, the serialized `google.protobuf.FileDescriptorSet`, and the fully qualified accumulator message name. All remaining records are Protobuf messages of that type. The schema record is not a customer record. An empty file is invalid; a schema-only file is valid. This version has one schema per file and does not interpret schema changes in the middle.
|
|
20
|
+
|
|
21
|
+
## Typical use
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import {create} from '@bufbuild/protobuf'
|
|
25
|
+
import {normalise} from '@cobol-ts/dependency_node'
|
|
26
|
+
import {valueOrThrow} from '@cobol-ts/errors'
|
|
27
|
+
import {
|
|
28
|
+
accumulatorSchemaFromGraph,
|
|
29
|
+
readAccumulatorFile,
|
|
30
|
+
writeAccumulatorFile
|
|
31
|
+
} from '@cobol-ts/cursor-loader-protobuf'
|
|
32
|
+
|
|
33
|
+
const canonical = valueOrThrow(normalise(authoringGraph))
|
|
34
|
+
const schema = accumulatorSchemaFromGraph(canonical)
|
|
35
|
+
const rows = [
|
|
36
|
+
create(schema.message, {customerId:1001n, totalCustomers:1n}),
|
|
37
|
+
create(schema.message, {customerId:1002n, totalCustomers:2n})
|
|
38
|
+
]
|
|
39
|
+
await writeAccumulatorFile('old.pb',schema,rows)
|
|
40
|
+
|
|
41
|
+
for await (const acc of readAccumulatorFile('old.pb')) {
|
|
42
|
+
try {
|
|
43
|
+
// acc.data contains the decoded message; updates use acc.set().
|
|
44
|
+
const data = acc.data as typeof acc.data & {totalCustomers: bigint}
|
|
45
|
+
data.totalCustomers += 1n // Access to the bound, decoded message
|
|
46
|
+
} finally {
|
|
47
|
+
acc.close()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Graph metadata selects storage scalars: `int` → `int64`, `uint` → `uint64`, `double` → `double`, `bool` → `bool`, `string` → `string`. Numeric nodes without `celResultType` fail schema preparation, because `number` does not distinguish integer from double. A `customerId` int64 key is added at field number 1. All canonical graph nodes become accumulator fields. Although the generated descriptor uses optional proto3 scalar fields, experiment-phase data files follow a complete-field contract: every value is serialized, including defaults. Field-presence tracking is not used in this phase. To evolve schemas compatibly, pass persistent field numbers into `accumulatorSchemaFromGraph`; otherwise numbering reflects canonical node order and is not promised stable across experiments.
|
|
53
|
+
|
|
54
|
+
The reader discovers the schema from the first RDW; no generated experiment-specific TypeScript is necessary. The public `Accumulator` wrapper is pooled; `close()` returns it to the pool. The schema-first path decodes into the same mutable message retained by the pooled wrapper; no new message is created per accumulator record. Attempts to access a closed accumulator or close it twice throw. Advancing the cursor does not implicitly close a lease: multiple accumulators can remain live concurrently. Closing the iterator cleans up outstanding leases, including on early termination.
|
|
55
|
+
|
|
56
|
+
`writeAccumulatorFile` requires strictly ascending bigint `customerId` keys. The caller is responsible for writing to a temporary output path and publishing only after successful completion. The schema-first reader uses `openRecordCursor()` and the Protobuf parser’s `prepare()` step to consume the first RDW as its descriptor envelope. It then reads subsequent data records using the same pooled physical-record and byte-buffer machinery as the COBOL cursor; there is no second RDW reader for data records. Its pooled accumulator owns and releases the underlying physical-record lease. The older explicit-schema projection and scan functions remain available. Performance comparisons remain follow-on work.
|
|
57
|
+
|
|
58
|
+
## Tests
|
|
59
|
+
|
|
60
|
+
`protobuf.roundtrip.spec.ts` exercises a real canonical graph, a three-customer write → read → update → write → read cycle, a second experiment schema, bigint fidelity, `errors` as a legitimate message field, lease reuse and malformed framing. Run the repository's Jest/Laoban test suite with `@bufbuild/protobuf` installed to verify dynamic descriptor APIs.
|
|
61
|
+
|
|
62
|
+
`protobuf.cursor.integration.spec.ts` performs the full three-record schema-first write → shared physical cursor read with fragmented buffers → pooled accumulator update → write → shared physical cursor reload sequence, and verifies simultaneous outstanding leases. Both data reading and `readAccumulatorFileSchema()` use the shared `openRecordCursor()` preparation path; no independent RDW reader is used for either.
|
|
63
|
+
|
|
64
|
+
## Fixed-shape, pooled accumulator messages
|
|
65
|
+
|
|
66
|
+
The schema-first accumulator reader keeps the same mutable Protobuf message inside each pooled
|
|
67
|
+
accumulator wrapper. When the wrapper is reacquired, a schema-prepared scalar wire decoder
|
|
68
|
+
writes directly into that message; neither `fromBinary()` nor a new message is used for data
|
|
69
|
+
records. The first schema envelope is still decoded once with Protobuf-ES.
|
|
70
|
+
|
|
71
|
+
The writer emits **every field**, including zero/false/empty-string values. This is stricter
|
|
72
|
+
than ordinary Protobuf serialization, which may omit defaults. The reader rejects incomplete
|
|
73
|
+
records instead of silently retaining values from a previous customer. No separate reset pass,
|
|
74
|
+
field-presence policy or schema switching is performed. The initial codec supports scalar
|
|
75
|
+
`int64`, `uint64`, `double`, `bool` and `string` fields only.
|
|
76
|
+
|
|
77
|
+
The wrapper and the message may both be reused after `close()`. As with other pooled cursors,
|
|
78
|
+
references must not be used after closing. Multiple active leases remain independent.
|
|
79
|
+
|
|
80
|
+
The scalar decoder assumes the file conforms to the writer's complete-field contract; it
|
|
81
|
+
intentionally rejects unknown or repeated tags. This is a purpose-specific experiment format,
|
|
82
|
+
not a general-purpose Protobuf parser. The generic `readProtobufFile()` path remains available
|
|
83
|
+
for normal Protobuf messages.
|
|
84
|
+
|
|
85
|
+
## Reusable byte buffers (batch hot path)
|
|
86
|
+
|
|
87
|
+
The schema-first reader retains one scratch byte buffer per cursor for RDW payloads fragmented across physical buffers. Its capacity grows only when needed (bounded by the configured maximum record size); contiguous payloads continue to use a view of the underlying physical buffer. The scratch is safe to reuse because `decodeInto()` consumes it synchronously before the cursor advances. The general-purpose explicit-schema Protobuf reader retains its original independent-message ownership semantics.
|
|
88
|
+
|
|
89
|
+
`writeAccumulatorFile()` uses `createBufferedRdwWriter()` with a reusable 1 MiB buffer. The scalar codec computes each record’s encoded size, writes directly after four reserved RDW bytes, and emits the length header in place. Many complete records are flushed together. No per-record JavaScript `number[]`, encoded-payload `Uint8Array`, or separately framed `Uint8Array` is created; occasional buffer flushes perform file writes, while the schema envelope is encoded once. The `encode()` and `rdwFrame()` convenience APIs still allocate when called explicitly, but are **not** used in the batch writer.
|
|
90
|
+
|
|
91
|
+
The synchronous `appendEncoded()` returns `false` when a flush is required. Its caller awaits `flush()` and retries; the normal append path creates no Promise. Tests in `protobuf.buffered.spec.ts` exercise offsets, exact encoding and decoding, default-value overwrite, Unicode, multiple flushes and short writes.
|
|
92
|
+
|
|
93
|
+
## Rolling-window accumulator values
|
|
94
|
+
|
|
95
|
+
A canonical rolling-window value is encoded as a nested Protobuf message, with `count`, `excluded`, `hasExpired`, and `values` (exactly `size + 1` physical scalar slots). The length and unrestricted periodicity string are embedded in the generated descriptor name; storage compatibility does not rely on a global enum. Native Protobuf messages expose the nested wire representation; the number-backed graph projection exposes a reusable `RingBuffer<T>`. Both readers accept schema-first files produced by either writer. The existing scalar-only Protobuf hot path and its wire bytes remain unchanged. The mixed-value adapter currently uses standard `fromBinary`/`toBinary` and must be benchmarked before being treated as allocation-free.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './src/protobuf.parser';
|
|
2
|
+
export * from './src/protobuf.registration';
|
|
3
|
+
export * from './src/protobuf.file.node';
|
|
4
|
+
export * from './src/protobuf.projection.support';
|
|
5
|
+
export * from './src/protobuf.schema';
|
|
6
|
+
export * from './src/protobuf.envelope';
|
|
7
|
+
export * from './src/protobuf.rdw';
|
|
8
|
+
export * from './src/protobuf.accumulator';
|
|
9
|
+
export * from './src/protobuf.accumulator.file';
|
|
10
|
+
export * from './src/protobuf.schema.first.parser';
|
|
11
|
+
export * from './src/protobuf.scalar.codec';
|
|
12
|
+
export * from "./src/protobuf.safe-integer";
|
|
13
|
+
export * from "./src/protobuf.number.projection";
|
|
14
|
+
export * from "./src/protobuf.number.file";
|
|
15
|
+
export * from "./src/protobuf.safe-integer";
|
|
16
|
+
export * from "./src/protobuf.number.projection";
|
|
17
|
+
export * from "./src/protobuf.number.file";
|
|
18
|
+
export * from "./src/protobuf.rolling.layout";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./src/protobuf.parser"), exports);
|
|
18
|
+
__exportStar(require("./src/protobuf.registration"), exports);
|
|
19
|
+
__exportStar(require("./src/protobuf.file.node"), exports);
|
|
20
|
+
__exportStar(require("./src/protobuf.projection.support"), exports);
|
|
21
|
+
__exportStar(require("./src/protobuf.schema"), exports);
|
|
22
|
+
__exportStar(require("./src/protobuf.envelope"), exports);
|
|
23
|
+
__exportStar(require("./src/protobuf.rdw"), exports);
|
|
24
|
+
__exportStar(require("./src/protobuf.accumulator"), exports);
|
|
25
|
+
__exportStar(require("./src/protobuf.accumulator.file"), exports);
|
|
26
|
+
__exportStar(require("./src/protobuf.schema.first.parser"), exports);
|
|
27
|
+
__exportStar(require("./src/protobuf.scalar.codec"), exports);
|
|
28
|
+
__exportStar(require("./src/protobuf.safe-integer"), exports);
|
|
29
|
+
__exportStar(require("./src/protobuf.number.projection"), exports);
|
|
30
|
+
__exportStar(require("./src/protobuf.number.file"), exports);
|
|
31
|
+
__exportStar(require("./src/protobuf.safe-integer"), exports);
|
|
32
|
+
__exportStar(require("./src/protobuf.number.projection"), exports);
|
|
33
|
+
__exportStar(require("./src/protobuf.number.file"), exports);
|
|
34
|
+
__exportStar(require("./src/protobuf.rolling.layout"), exports);
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,8DAA4C;AAC5C,2DAAyC;AACzC,oEAAkD;AAClD,wDAAsC;AACtC,0DAAwC;AACxC,qDAAmC;AACnC,6DAA2C;AAC3C,kEAAgD;AAEhD,qEAAmD;AAEnD,8DAA4C;AAE5C,8DAA4C;AAC5C,mEAAiD;AACjD,6DAA2C;AAE3C,8DAA4C;AAC5C,mEAAiD;AACjD,6DAA2C;AAE3C,gEAA8C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Message } from '@bufbuild/protobuf';
|
|
2
|
+
export interface Accumulator<T extends Message = Message> {
|
|
3
|
+
readonly data: T;
|
|
4
|
+
readonly representation: T;
|
|
5
|
+
readonly result: T;
|
|
6
|
+
readonly closed: boolean;
|
|
7
|
+
set<K extends keyof T>(name: K, value: T[K]): boolean;
|
|
8
|
+
close(): void;
|
|
9
|
+
}
|
|
10
|
+
interface Closeable {
|
|
11
|
+
close(): void;
|
|
12
|
+
}
|
|
13
|
+
/** One pool per cursor. The wrapper owns its parent physical-record lease. */
|
|
14
|
+
export declare function createAccumulatorPool<T extends Message>(): {
|
|
15
|
+
acquire: (data: T, parent?: Closeable) => Accumulator<T>;
|
|
16
|
+
};
|
|
17
|
+
/** Shares the same message objects between persisted rows and new entities. */
|
|
18
|
+
export interface MessageAccumulatorPool<T extends Message = Message> {
|
|
19
|
+
readonly messageTypeName: string;
|
|
20
|
+
acquire(bytes: Uint8Array, parent?: Closeable): Accumulator<T>;
|
|
21
|
+
acquireEmpty(customerId: bigint): Accumulator<T>;
|
|
22
|
+
}
|
|
23
|
+
export declare function createMessageAccumulatorPool<T extends Message>(schema: import('@bufbuild/protobuf').DescMessage, codec: import('./protobuf.scalar.codec').ScalarAccumulatorCodec<T>): MessageAccumulatorPool<T>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Message } from '@bufbuild/protobuf';
|
|
2
|
+
import { type MessageAccumulatorPool, type Accumulator } from './protobuf.accumulator';
|
|
3
|
+
import { type CallbackLeaseCursor } from '@cobol-ts/cursor-file';
|
|
4
|
+
import type { AccumulatorSchema } from './protobuf.schema';
|
|
5
|
+
export interface AccumulatorFileRecord<T extends Message = Message> extends Accumulator<T> {
|
|
6
|
+
}
|
|
7
|
+
export interface AccumulatorCursorOptions<T extends Message = Message> {
|
|
8
|
+
readonly bufferSize?: number;
|
|
9
|
+
readonly maxRecordBytes?: number;
|
|
10
|
+
readonly pool?: MessageAccumulatorPool<T>;
|
|
11
|
+
readonly expectedSchema?: AccumulatorSchema;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Schema and data records pass through one physical cursor and shared buffers.
|
|
15
|
+
* Every returned accumulator owns the corresponding physical-record lease.
|
|
16
|
+
*/
|
|
17
|
+
export declare function readAccumulatorFile<T extends Message = Message>(filename: string, options?: AccumulatorCursorOptions<T>): AsyncGenerator<AccumulatorFileRecord<T>, void, void>;
|
|
18
|
+
/** Resumable protobuf cursor retaining the pool and schema-check semantics. */
|
|
19
|
+
export declare function openAccumulatorFileCursor<T extends Message = Message>(filename: string, options?: AccumulatorCursorOptions<T>): Promise<CallbackLeaseCursor<AccumulatorFileRecord<T>>>;
|
|
20
|
+
/** Read the descriptor using the same cursor prepare() phase, without iteration. */
|
|
21
|
+
export declare function readAccumulatorFileSchema(filename: string, options?: AccumulatorCursorOptions): Promise<AccumulatorSchema>;
|
|
22
|
+
/** The writer emits one schema record followed by homogeneous RDW messages. */
|
|
23
|
+
export declare function writeAccumulatorFile(filename: string, schema: AccumulatorSchema, records: Iterable<Message> | AsyncIterable<Message>): Promise<void>;
|
|
24
|
+
export declare function emptyAccumulator(schema: AccumulatorSchema): Message;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readAccumulatorFile = readAccumulatorFile;
|
|
4
|
+
exports.openAccumulatorFileCursor = openAccumulatorFileCursor;
|
|
5
|
+
exports.readAccumulatorFileSchema = readAccumulatorFileSchema;
|
|
6
|
+
exports.writeAccumulatorFile = writeAccumulatorFile;
|
|
7
|
+
exports.emptyAccumulator = emptyAccumulator;
|
|
8
|
+
const promises_1 = require("node:fs/promises");
|
|
9
|
+
const protobuf_1 = require("@bufbuild/protobuf");
|
|
10
|
+
const wkt_1 = require("@bufbuild/protobuf/wkt");
|
|
11
|
+
const protobuf_accumulator_1 = require("./protobuf.accumulator");
|
|
12
|
+
const protobuf_scalar_codec_1 = require("./protobuf.scalar.codec");
|
|
13
|
+
const cursor_record_1 = require("@cobol-ts/cursor-record");
|
|
14
|
+
const cursor_file_1 = require("@cobol-ts/cursor-file");
|
|
15
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
16
|
+
const protobuf_schema_first_parser_1 = require("./protobuf.schema.first.parser");
|
|
17
|
+
const protobuf_parser_1 = require("./protobuf.parser");
|
|
18
|
+
const protobuf_envelope_1 = require("./protobuf.envelope");
|
|
19
|
+
const protobuf_rdw_1 = require("./protobuf.rdw");
|
|
20
|
+
/** Create the same prepared physical cursor for data iteration or schema inspection. */
|
|
21
|
+
function openAccumulatorCursor(filename, file, options) {
|
|
22
|
+
return (0, cursor_record_1.openRecordCursor)(protobuf_schema_first_parser_1.schemaFirstProtobufParser, { maxRecordBytes: options.maxRecordBytes }, (0, cursor_record_1.createDefaultPhysicalRecordConfig)({
|
|
23
|
+
source: filename,
|
|
24
|
+
file,
|
|
25
|
+
bufferSize: options.bufferSize ?? 65536,
|
|
26
|
+
fillFileBuffer: cursor_file_1.fillNodeFileBuffer,
|
|
27
|
+
createRecordState: protobuf_parser_1.createProtobufRecordState
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Schema and data records pass through one physical cursor and shared buffers.
|
|
32
|
+
* Every returned accumulator owns the corresponding physical-record lease.
|
|
33
|
+
*/
|
|
34
|
+
async function* readAccumulatorFile(filename, options = {}) {
|
|
35
|
+
const file = await (0, promises_1.open)(filename, 'r');
|
|
36
|
+
let opened;
|
|
37
|
+
try {
|
|
38
|
+
opened = await openAccumulatorCursor(filename, file, options);
|
|
39
|
+
const schema = opened.details.accumulatorSchema;
|
|
40
|
+
if (options.pool !== undefined) {
|
|
41
|
+
if (options.expectedSchema === undefined)
|
|
42
|
+
throw new Error('External accumulator pool requires an expected schema');
|
|
43
|
+
const expected = options.expectedSchema;
|
|
44
|
+
const a = (0, protobuf_1.toBinary)(wkt_1.FileDescriptorSetSchema, expected.descriptorSet);
|
|
45
|
+
const b = (0, protobuf_1.toBinary)(wkt_1.FileDescriptorSetSchema, schema.descriptorSet);
|
|
46
|
+
if (expected.messageFullName !== schema.messageFullName || a.length !== b.length || a.some((byte, i) => byte !== b[i]))
|
|
47
|
+
throw new Error('Accumulator input schema does not match the prepared pool');
|
|
48
|
+
}
|
|
49
|
+
const pool = options.pool ?? (0, protobuf_accumulator_1.createMessageAccumulatorPool)(schema.message, (0, protobuf_scalar_codec_1.createScalarAccumulatorCodec)(schema));
|
|
50
|
+
for await (const record of opened.recordCursor) {
|
|
51
|
+
if ((0, errors_1.isErrors)(record.result)) {
|
|
52
|
+
record.physicalRecord.close();
|
|
53
|
+
throw new errors_1.ErrorsException(record.result.errors, record.result.reference);
|
|
54
|
+
}
|
|
55
|
+
const bytes = record.result.data;
|
|
56
|
+
let lease;
|
|
57
|
+
try {
|
|
58
|
+
lease = pool.acquire(bytes, record.physicalRecord);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
record.physicalRecord.close();
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
// Ownership transfers to the consumer. Outstanding leases must remain
|
|
65
|
+
// valid even when the iterator reaches EOF or is cancelled.
|
|
66
|
+
yield lease;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
opened?.close();
|
|
71
|
+
await file.close();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Resumable protobuf cursor retaining the pool and schema-check semantics. */
|
|
75
|
+
async function openAccumulatorFileCursor(filename, options = {}) {
|
|
76
|
+
const file = await (0, promises_1.open)(filename, 'r');
|
|
77
|
+
let opened;
|
|
78
|
+
try {
|
|
79
|
+
opened = await openAccumulatorCursor(filename, file, options);
|
|
80
|
+
const schema = opened.details.accumulatorSchema;
|
|
81
|
+
if (options.pool !== undefined) {
|
|
82
|
+
if (options.expectedSchema === undefined)
|
|
83
|
+
throw new Error('External accumulator pool requires an expected schema');
|
|
84
|
+
const expected = options.expectedSchema;
|
|
85
|
+
const a = (0, protobuf_1.toBinary)(wkt_1.FileDescriptorSetSchema, expected.descriptorSet);
|
|
86
|
+
const b = (0, protobuf_1.toBinary)(wkt_1.FileDescriptorSetSchema, schema.descriptorSet);
|
|
87
|
+
if (expected.messageFullName !== schema.messageFullName || a.length !== b.length || a.some((byte, i) => byte !== b[i]))
|
|
88
|
+
throw new Error('Accumulator input schema does not match the prepared pool');
|
|
89
|
+
}
|
|
90
|
+
const pool = options.pool ?? (0, protobuf_accumulator_1.createMessageAccumulatorPool)(schema.message, (0, protobuf_scalar_codec_1.createScalarAccumulatorCodec)(schema));
|
|
91
|
+
const cursor = opened;
|
|
92
|
+
let pending;
|
|
93
|
+
const receive = (result, physical) => {
|
|
94
|
+
if ((0, errors_1.isErrors)(result))
|
|
95
|
+
throw new errors_1.ErrorsException(result.errors, result.reference);
|
|
96
|
+
pending = pool.acquire(result.data, physical);
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
take() {
|
|
100
|
+
pending = undefined;
|
|
101
|
+
const result = cursor.takeRecord(receive);
|
|
102
|
+
if (result instanceof Promise)
|
|
103
|
+
return result.then(hasRow => hasRow ? pending : undefined);
|
|
104
|
+
return result ? pending : undefined;
|
|
105
|
+
},
|
|
106
|
+
async close() { try {
|
|
107
|
+
cursor.close();
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
await file.close();
|
|
111
|
+
} }
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
opened?.close();
|
|
116
|
+
await file.close();
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** Read the descriptor using the same cursor prepare() phase, without iteration. */
|
|
121
|
+
async function readAccumulatorFileSchema(filename, options = {}) {
|
|
122
|
+
const file = await (0, promises_1.open)(filename, 'r');
|
|
123
|
+
let opened;
|
|
124
|
+
try {
|
|
125
|
+
opened = await openAccumulatorCursor(filename, file, options);
|
|
126
|
+
return opened.details.accumulatorSchema;
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
opened?.close();
|
|
130
|
+
await file.close();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** The writer emits one schema record followed by homogeneous RDW messages. */
|
|
134
|
+
async function writeAccumulatorFile(filename, schema, records) {
|
|
135
|
+
const file = await (0, promises_1.open)(filename, 'w');
|
|
136
|
+
const codec = (0, protobuf_scalar_codec_1.createScalarAccumulatorCodec)(schema);
|
|
137
|
+
const writer = (0, protobuf_rdw_1.createBufferedRdwWriter)(file);
|
|
138
|
+
try {
|
|
139
|
+
if (!writer.appendRecord((0, protobuf_envelope_1.encodeSchemaEnvelope)(schema)))
|
|
140
|
+
throw new Error('Accumulator schema does not fit the output buffer');
|
|
141
|
+
let previous;
|
|
142
|
+
for await (const record of records) {
|
|
143
|
+
const key = record.customerId;
|
|
144
|
+
if (typeof key !== 'bigint')
|
|
145
|
+
throw new Error('Accumulator customerId must be an int64 bigint');
|
|
146
|
+
if (previous !== undefined && key <= previous)
|
|
147
|
+
throw new Error('Accumulator records must be strictly sorted by customerId');
|
|
148
|
+
previous = key;
|
|
149
|
+
if (!writer.appendEncoded(record, codec)) {
|
|
150
|
+
await writer.flush();
|
|
151
|
+
if (!writer.appendEncoded(record, codec))
|
|
152
|
+
throw new Error('Accumulator record does not fit the output buffer');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
await writer.flush();
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
await file.close();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function emptyAccumulator(schema) {
|
|
162
|
+
return (0, protobuf_1.create)(schema.message);
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=protobuf.accumulator.file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protobuf.accumulator.file.js","sourceRoot":"","sources":["../../src/protobuf.accumulator.file.ts"],"names":[],"mappings":";;AA0CA,kDAmCC;AAGD,8DAiCC;AAGD,8DAaC;AAGD,oDAyBC;AAED,4CAEC;AAjKD,+CAAsD;AACtD,iDAAgE;AAChE,gDAA+D;AAC/D,iEAAiH;AACjH,mEAAqE;AACrE,2DAA2F;AAC3F,uDAAkF;AAClF,6CAA0D;AAC1D,iFAAyE;AACzE,uDAA4D;AAC5D,2DAA8E;AAC9E,iDAAuD;AAYvD,wFAAwF;AACxF,SAAS,qBAAqB,CAAC,QAAe,EAAC,IAAe,EAAC,OAAoE;IAC/H,OAAO,IAAA,gCAAgB,EACnB,wDAAyB,EACzB,EAAC,cAAc,EAAC,OAAO,CAAC,cAAc,EAAC,EACvC,IAAA,iDAAiC,EAAC;QAC9B,MAAM,EAAC,QAAQ;QACf,IAAI;QACJ,UAAU,EAAC,OAAO,CAAC,UAAU,IAAE,KAAK;QACpC,cAAc,EAAC,gCAAkB;QACjC,iBAAiB,EAAC,2CAAyB;KAC9C,CAAC,CACL,CAAC;AACN,CAAC;AAED;;;GAGG;AACI,KAAK,SAAS,CAAC,CAAC,mBAAmB,CACtC,QAAe,EACf,UAAoC,EAAE;IAEtC,MAAM,IAAI,GAAC,MAAM,IAAA,eAAI,EAAC,QAAQ,EAAC,GAAG,CAAC,CAAC;IACpC,IAAI,MA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AI,KAAK,EAAC,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAChC,MAAM,GAAG,GAAE,MAA2C,CAAC,UAAU,CAAC;YAClE,IAAG,OAAO,GAAG,KAAG,QAAQ;gBAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;YAC5F,IAAG,QAAQ,KAAG,SAAS,IAAI,GAAG,IAAE,QAAQ;gBAAE,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;YACvH,QAAQ,GAAC,GAAG,CAAC;YACb,IAAG,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAC,KAAK,CAAC,EAAE,CAAC;gBACrC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;gBACrB,IAAG,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,EAAC,KAAK,CAAC;oBAClC,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;YAC7E,CAAC;QACL,CAAC;QACD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;YAAS,CAAC;QAAA,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IAAA,CAAC;AACnC,CAAC;AAED,SAAgB,gBAAgB,CAAC,MAAwB;IACrD,OAAO,IAAA,iBAAM,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAccumulatorPool = createAccumulatorPool;
|
|
4
|
+
exports.createMessageAccumulatorPool = createMessageAccumulatorPool;
|
|
5
|
+
const protobuf_1 = require("@bufbuild/protobuf");
|
|
6
|
+
/** One pool per cursor. The wrapper owns its parent physical-record lease. */
|
|
7
|
+
function createAccumulatorPool() {
|
|
8
|
+
const available = [];
|
|
9
|
+
function acquire(data, parent) {
|
|
10
|
+
const item = available.pop() ?? {
|
|
11
|
+
current: undefined,
|
|
12
|
+
parent: undefined,
|
|
13
|
+
active: false,
|
|
14
|
+
get closed() { return !this.active; },
|
|
15
|
+
get representation() { return this.data; },
|
|
16
|
+
get result() { return this.data; },
|
|
17
|
+
get data() {
|
|
18
|
+
if (!this.active || this.current === undefined)
|
|
19
|
+
throw new Error('Accumulator is closed');
|
|
20
|
+
return this.current;
|
|
21
|
+
},
|
|
22
|
+
set(name, value) {
|
|
23
|
+
this.data[name] = value;
|
|
24
|
+
return true; // Materiality remains the existing always-true policy.
|
|
25
|
+
},
|
|
26
|
+
close() {
|
|
27
|
+
if (!this.active)
|
|
28
|
+
throw new Error('Accumulator already closed');
|
|
29
|
+
this.active = false;
|
|
30
|
+
this.current = undefined;
|
|
31
|
+
const parent = this.parent;
|
|
32
|
+
this.parent = undefined;
|
|
33
|
+
try {
|
|
34
|
+
parent?.close();
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
available.push(this);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
item.current = data;
|
|
42
|
+
item.parent = parent;
|
|
43
|
+
item.active = true;
|
|
44
|
+
return item;
|
|
45
|
+
}
|
|
46
|
+
return { acquire };
|
|
47
|
+
}
|
|
48
|
+
function createMessageAccumulatorPool(schema, codec) {
|
|
49
|
+
const available = [];
|
|
50
|
+
function take() {
|
|
51
|
+
return available.pop() ?? {
|
|
52
|
+
current: (0, protobuf_1.create)(schema),
|
|
53
|
+
parent: undefined,
|
|
54
|
+
active: false,
|
|
55
|
+
get closed() { return !this.active; },
|
|
56
|
+
get representation() { return this.data; },
|
|
57
|
+
get result() { return this.data; },
|
|
58
|
+
get data() {
|
|
59
|
+
if (!this.active)
|
|
60
|
+
throw new Error('Accumulator is closed');
|
|
61
|
+
return this.current;
|
|
62
|
+
},
|
|
63
|
+
set(name, value) {
|
|
64
|
+
this.data[name] = value;
|
|
65
|
+
return true;
|
|
66
|
+
},
|
|
67
|
+
close() {
|
|
68
|
+
if (!this.active)
|
|
69
|
+
throw new Error('Accumulator already closed');
|
|
70
|
+
this.active = false;
|
|
71
|
+
const parent = this.parent;
|
|
72
|
+
this.parent = undefined;
|
|
73
|
+
try {
|
|
74
|
+
parent?.close();
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
available.push(this);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function acquire(bytes, parent) {
|
|
83
|
+
const item = take();
|
|
84
|
+
try {
|
|
85
|
+
codec.decodeInto(bytes, item.current);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
available.push(item);
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
item.parent = parent;
|
|
92
|
+
item.active = true;
|
|
93
|
+
return item;
|
|
94
|
+
}
|
|
95
|
+
function acquireEmpty(customerId) {
|
|
96
|
+
const item = take();
|
|
97
|
+
try {
|
|
98
|
+
codec.initialize(item.current, customerId);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
available.push(item);
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
item.parent = undefined;
|
|
105
|
+
item.active = true;
|
|
106
|
+
return item;
|
|
107
|
+
}
|
|
108
|
+
return { messageTypeName: schema.typeName, acquire, acquireEmpty };
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=protobuf.accumulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protobuf.accumulator.js","sourceRoot":"","sources":["../../src/protobuf.accumulator.ts"],"names":[],"mappings":";;AAmBA,sDAiCC;AASD,oEAkDC;AA/GD,iDAAuD;AAkBvD,8EAA8E;AAC9E,SAAgB,qBAAqB;IACjC,MAAM,SAAS,GAAwB,EAAE,CAAC;IAC1C,SAAS,OAAO,CAAC,IAAM,EAAC,MAAiB;QACrC,MAAM,IAAI,GAAC,SAAS,CAAC,GAAG,EAAE,IAAE;YACxB,OAAO,EAAC,SAAS;YACjB,MAAM,EAAC,SAA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AC,IAAI,EAAE,CAAC;QAClB,IAAG,CAAC;YAAA,KAAK,CAAC,UAAU,CAAC,KAAK,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAAA,CAAC;QAC1C,OAAM,KAAK,EAAC,CAAC;YAAA,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAAA,MAAM,KAAK,CAAC;QAAA,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAC,MAAM,CAAC;QAAA,IAAI,CAAC,MAAM,GAAC,IAAI,CAAC;QACpC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,SAAS,YAAY,CAAC,UAAiB;QACnC,MAAM,IAAI,GAAC,IAAI,EAAE,CAAC;QAClB,IAAG,CAAC;YAAA,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAC,UAAU,CAAC,CAAC;QAAA,CAAC;QAC/C,OAAM,KAAK,EAAC,CAAC;YAAA,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAAA,MAAM,KAAK,CAAC;QAAA,CAAC;QAC/C,IAAI,CAAC,MAAM,GAAC,SAAS,CAAC;QAAA,IAAI,CAAC,MAAM,GAAC,IAAI,CAAC;QACvC,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,EAAC,eAAe,EAAC,MAAM,CAAC,QAAQ,EAAC,OAAO,EAAC,YAAY,EAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const protobuf_1 = require("@bufbuild/protobuf");
|
|
4
|
+
const dependency_node_1 = require("@cobol-ts/dependency_node");
|
|
5
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
6
|
+
const protobuf_schema_1 = require("./protobuf.schema");
|
|
7
|
+
const protobuf_scalar_codec_1 = require("./protobuf.scalar.codec");
|
|
8
|
+
const protobuf_rdw_1 = require("./protobuf.rdw");
|
|
9
|
+
const authoring = {
|
|
10
|
+
counter: { type: 'cel', cel: 'prev.counter + 1', metadata: { type: 'number', celResultType: 'int' } },
|
|
11
|
+
ratio: { type: 'cel', cel: '1.5', metadata: { type: 'number', celResultType: 'double' } },
|
|
12
|
+
enabled: { type: 'cel', cel: 'true', metadata: { type: 'boolean', celResultType: 'bool' } },
|
|
13
|
+
label: { type: 'cel', cel: '"hi"', metadata: { type: 'string', celResultType: 'string' } }
|
|
14
|
+
};
|
|
15
|
+
function fixture() {
|
|
16
|
+
const schema = (0, protobuf_schema_1.accumulatorSchemaFromGraph)((0, errors_1.valueOrThrow)((0, dependency_node_1.normalise)(authoring)));
|
|
17
|
+
return { schema, codec: (0, protobuf_scalar_codec_1.createScalarAccumulatorCodec)(schema) };
|
|
18
|
+
}
|
|
19
|
+
describe('buffered scalar accumulator serialization', () => {
|
|
20
|
+
test('encodes into an existing buffer at an offset and overwrites defaults exactly', () => {
|
|
21
|
+
const { schema, codec } = fixture();
|
|
22
|
+
const first = (0, protobuf_1.create)(schema.message, { customerId: 5n, counter: 9007199254740993n, ratio: -2.75, enabled: true, label: 'A😀é' });
|
|
23
|
+
const second = (0, protobuf_1.create)(schema.message, { customerId: 6n, counter: 0n, ratio: 0, enabled: false, label: '' });
|
|
24
|
+
const out = new Uint8Array(1024).fill(0xaa);
|
|
25
|
+
const length = codec.encodedLength(first);
|
|
26
|
+
expect(codec.encodeInto(first, out, 4)).toEqual(length);
|
|
27
|
+
expect(out.slice(4, 4 + length)).toEqual(codec.encode(first));
|
|
28
|
+
expect(out[3]).toEqual(0xaa);
|
|
29
|
+
expect(out[4 + length]).toEqual(0xaa);
|
|
30
|
+
const reusable = (0, protobuf_1.create)(schema.message);
|
|
31
|
+
codec.decodeInto(out.subarray(4, 4 + length), reusable);
|
|
32
|
+
expect({ customerId: reusable.customerId, counter: reusable.counter,
|
|
33
|
+
ratio: reusable.ratio, enabled: reusable.enabled, label: reusable.label })
|
|
34
|
+
.toEqual({ customerId: 5n, counter: 9007199254740993n, ratio: -2.75, enabled: true, label: 'A😀é' });
|
|
35
|
+
const secondLength = codec.encodeInto(second, out, 4);
|
|
36
|
+
codec.decodeInto(out.subarray(4, 4 + secondLength), reusable);
|
|
37
|
+
expect({ customerId: reusable.customerId, counter: reusable.counter,
|
|
38
|
+
ratio: reusable.ratio, enabled: reusable.enabled, label: reusable.label })
|
|
39
|
+
.toEqual({ customerId: 6n, counter: 0n, ratio: 0, enabled: false, label: '' });
|
|
40
|
+
});
|
|
41
|
+
test('handles malformed surrogate pairs like standard UTF-8 and checks capacity before writing', () => {
|
|
42
|
+
const { schema, codec } = fixture();
|
|
43
|
+
const record = (0, protobuf_1.create)(schema.message, { customerId: 9n, label: '\ud800A\udc00' });
|
|
44
|
+
const expected = codec.encode(record);
|
|
45
|
+
const output = new Uint8Array(expected.length);
|
|
46
|
+
expect(codec.encodeInto(record, output, 0)).toEqual(expected.length);
|
|
47
|
+
expect(output).toEqual(expected);
|
|
48
|
+
const decoded = (0, protobuf_1.create)(schema.message);
|
|
49
|
+
codec.decodeInto(output, decoded);
|
|
50
|
+
expect(decoded.label).toEqual('\ufffdA\ufffd');
|
|
51
|
+
expect(() => codec.encodeInto(record, new Uint8Array(expected.length - 1), 0))
|
|
52
|
+
.toThrow(`Accumulator output buffer too small: need ${expected.length} bytes`);
|
|
53
|
+
});
|
|
54
|
+
test('batches complete RDW records into a reusable writer buffer and handles partial writes', async () => {
|
|
55
|
+
const { schema, codec } = fixture();
|
|
56
|
+
const chunks = [];
|
|
57
|
+
const fake = {
|
|
58
|
+
async write(buffer, offset, length) {
|
|
59
|
+
const written = Math.min(length, 4096);
|
|
60
|
+
chunks.push(buffer.slice(offset, offset + written));
|
|
61
|
+
return { bytesWritten: written };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const writer = (0, protobuf_rdw_1.createBufferedRdwWriter)(fake, 65535);
|
|
65
|
+
const rows = Array.from({ length: 220 }, (_, i) => (0, protobuf_1.create)(schema.message, {
|
|
66
|
+
customerId: BigInt(i + 1), counter: BigInt(i), ratio: i / 2, enabled: i % 2 === 0, label: 'X'.repeat(300)
|
|
67
|
+
}));
|
|
68
|
+
for (const row of rows) {
|
|
69
|
+
if (!writer.appendEncoded(row, codec)) {
|
|
70
|
+
await writer.flush();
|
|
71
|
+
expect(writer.appendEncoded(row, codec)).toEqual(true);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
await writer.flush();
|
|
75
|
+
const bytes = new Uint8Array(chunks.reduce((n, c) => n + c.length, 0));
|
|
76
|
+
let position = 0;
|
|
77
|
+
for (const chunk of chunks) {
|
|
78
|
+
bytes.set(chunk, position);
|
|
79
|
+
position += chunk.length;
|
|
80
|
+
}
|
|
81
|
+
let offset = 0;
|
|
82
|
+
const actual = [];
|
|
83
|
+
const reusable = (0, protobuf_1.create)(schema.message);
|
|
84
|
+
while (offset < bytes.length) {
|
|
85
|
+
const size = bytes[offset] * 256 + bytes[offset + 1];
|
|
86
|
+
expect([bytes[offset + 2], bytes[offset + 3]]).toEqual([0, 0]);
|
|
87
|
+
codec.decodeInto(bytes.subarray(offset + 4, offset + size), reusable);
|
|
88
|
+
actual.push({ customerId: reusable.customerId, counter: reusable.counter,
|
|
89
|
+
ratio: reusable.ratio, enabled: reusable.enabled, label: reusable.label });
|
|
90
|
+
offset += size;
|
|
91
|
+
}
|
|
92
|
+
expect(offset).toEqual(bytes.length);
|
|
93
|
+
expect(actual).toEqual(rows.map(row => ({ customerId: row.customerId, counter: row.counter,
|
|
94
|
+
ratio: row.ratio, enabled: row.enabled, label: row.label })));
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=protobuf.buffered.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protobuf.buffered.spec.js","sourceRoot":"","sources":["../../src/protobuf.buffered.spec.ts"],"names":[],"mappings":";;AACA,iDAA0C;AAC1C,+DAAoD;AAC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