chaokunyang commented on code in PR #3994:
URL: https://github.com/apache/fory/pull/3994#discussion_r3889912699
##########
javascript/test/array.test.ts:
##########
@@ -323,6 +323,18 @@ describe("array", () => {
);
expect(containsBytes(bfloat16Bytes, [0x80, 0x3f, 0x00, 0xc0])).toBe(true);
});
+
+ test("should large any-typed list work", () => {
+ // The dynamic element write path must reserve writer capacity per item.
+ // Without it, single-byte writes past the buffer end were silent no-ops
+ // while the cursor advanced, so dump() returned uninitialized tail bytes.
+ const fory = new Fory({ compatible: false });
+ const { serialize, deserialize } = fory.register(Type.list(Type.any()));
+ const arr = new Array(150000).fill(1);
Review Comment:
[P2] Exercise the mixed and declared collection paths
Because every element is `1`, `writeElementsHeader` sets `isSame = true`, so
this test exercises only the aggregate reserve. The per-item mixed-type
reserves and the `writeDeclared` reserve can still be removed without this test
failing. Please add a list larger than the initial writer buffer with mixed
element types; if `writeDeclared` is part of this fix, cover the unknown-Struct
declared-list reserialization path as well.
##########
javascript/test/map.test.ts:
##########
@@ -213,4 +213,22 @@ describe("map", () => {
expect(serializer.deserialize(valid)).toEqual(value);
}
});
+
+ test("should large declared map work", () => {
+ // The generated map write must reserve writer capacity for its entries.
+ // Without it, unchecked DataView writes past the buffer end threw a
+ // RangeError once the map body outgrew the initial buffer.
+ const fory = new Fory({ compatible: false });
+ const { serialize, deserialize } = fory.register(
+ Type.struct(
+ { namespace: "example", typeName: "BigMap" },
+ { m: Type.map(Type.int32({ encoding: "fixed" }), Type.int32({
encoding: "fixed" })) },
Review Comment:
[P2] Cover MapAnySerializer capacity growth
This declared `int32` map goes through `writeSpecificType`, so it does not
execute the new reserve in `MapAnySerializer.write`. Please add a
`Type.map(Type.any(), Type.any())` case large enough to exceed the initial
writer buffer, so removing that reserve makes the regression test fail.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]