Skip to content

Commit aa89a50

Browse files
committed
PR feedback 2
1 parent 6371c4a commit aa89a50

File tree

15 files changed

+237
-508
lines changed

15 files changed

+237
-508
lines changed

packages/dds/tree/src/feature-libraries/chunked-forest/codec/codecs.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from "../../../codec/index.js";
1515
import {
1616
CursorLocationType,
17+
type ITreeCursorSynchronous,
1718
type SchemaAndPolicy,
1819
type TreeChunk,
1920
} from "../../../core/index.js";
@@ -34,32 +35,36 @@ export const ChunkReferenceId = Type.Number({ multipleOf: 1, minimum: 0 });
3435
export type ChunkReferenceId = Static<typeof ChunkReferenceId>;
3536

3637
/**
37-
* Properties for encoding a chunk that supports incremental encoding.
38-
* Fields that support incremental encoding will encode their chunks separately by calling `encodeIncrementalChunk`.
38+
* Properties for incremental encoding.
39+
* Fields that support incremental encoding will encode their chunks separately by calling `encodeIncrementalField`.
3940
* This supports features like incremental summarization where the summary from these fields can be re-used if
4041
* unchanged between summaries.
4142
* Note that each of these chunks that are incrementally encoded is fully self-describing (contain its own shapes
4243
* list and identifier table) and does not rely on context from its parent.
4344
*/
4445
export interface IncrementalEncoder {
4546
/**
46-
* Called to encode an incremental chunk which are encoded separately from the main buffer.
47-
* @param chunk - The chunk to encode.
48-
* @param chunkEncoder - A function that encodes the chunk's contents.
49-
* @returns The reference ID of the encoded chunk. This is used to retrieve the encoded chunk later.
47+
* Called to encode an incremental field at the cursor. The chunks for this field are encoded separately
48+
* from the main buffer.
49+
* @param cursor - The cursor pointing to the field to encode.
50+
* @param chunkEncoder - A function that encodes the contents of the passed chunk in the field.
51+
* @returns The reference IDs of the encoded chunks in the field. This is used to retrieve the encoded
52+
* chunks later.
5053
*/
51-
encodeIncrementalChunk(
52-
chunk: TreeChunk,
53-
chunkEncoder: () => EncodedFieldBatch,
54-
): ChunkReferenceId;
54+
encodeIncrementalField(
55+
cursor: ITreeCursorSynchronous,
56+
chunkEncoder: (chunk: TreeChunk) => EncodedFieldBatch,
57+
): ChunkReferenceId[];
5558
}
5659

5760
/**
58-
* Properties for decoding a chunk that supports incremental encoding. See {@link IncrementalEncoder} for more details.
61+
* Properties for incremental decoding.
62+
* Fields that had their chunks incrementally encoded will retrieve these chunks by calling
63+
* `getEncodedIncrementalChunk`. See {@link IncrementalEncoder} for more details.
5964
*/
6065
export interface IncrementalDecoder {
6166
/**
62-
* Called to get the encoded contents of an incremental chunk with the given reference ID.
67+
* Called to get the encoded contents of an chunk in an incremental field with the given reference ID.
6368
* @param referenceId - The reference ID of the chunk to retrieve.
6469
* @returns The encoded contents of the chunk.
6570
*/
@@ -73,7 +78,7 @@ export interface FieldBatchEncodingContext {
7378
readonly originatorId: SessionId;
7479
readonly schema?: SchemaAndPolicy;
7580
/**
76-
* An encoder / decoder for encoding and decoding of incremental chunks. This will be defined if
81+
* An encoder / decoder for encoding and decoding of incremental fields. This will be defined if
7782
* incremental encoding is supported and enabled.
7883
*/
7984
readonly incrementalEncoderDecoder?: IncrementalEncoderDecoder;

0 commit comments

Comments
 (0)