This is an automated email from the ASF dual-hosted git repository.

kylebarron pushed a commit to branch kyle/slice-value-offsets
in repository https://gitbox.apache.org/repos/asf/arrow-js.git

commit c1954631bab9a2df7f3dbf4a0d9b725ca631ce75
Author: Kyle Barron <[email protected]>
AuthorDate: Tue Sep 22 10:04:45 2026 -0400

    fix: slice value offsets according to spec
---
 src/data.ts | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/data.ts b/src/data.ts
index b13efdb..1101e25 100644
--- a/src/data.ts
+++ b/src/data.ts
@@ -168,6 +168,16 @@ export class Data<T extends DataType = DataType> {
             this.variadicBuffers = variadicBuffers;
         }
         this.variadicBuffers ??= [];
+
+        // Slice offsets to the correct length defined by the spec. Often the
+        // backing buffer of `valueOffsets` is longer than the spec requires,
+        // either due to IPC padding or builder over-allocation.
+        if (this.valueOffsets) {
+            const numValueOffsets = DataType.isUnion(type) ? this.length : 
this.length + 1;
+            if (this.valueOffsets.length > numValueOffsets) {
+                this.valueOffsets = this.valueOffsets.subarray(0, 
numValueOffsets);
+            }
+        }
     }
 
     public getValid(index: number): boolean {

Reply via email to