trxcllnt commented on code in PR #438:
URL: https://github.com/apache/arrow-js/pull/438#discussion_r3305182919


##########
src/visitor/vectorloader.ts:
##########
@@ -170,6 +170,24 @@ export class VectorLoader extends Visitor {
         return nullCount > 0 && this.readData(type, buffer) || new 
Uint8Array(0);
     }
     protected readOffsets<T extends DataType>(type: T, buffer?: BufferRegion) 
{ return this.readData(type, buffer); }
+    // Rebases int64 offsets to start at 0 so downstream `bigIntToNumber` 
narrowing
+    // always succeeds for spec-conforming wire input. Conforming producers may
+    // pre-shift offsets on sliced views, putting absolute values past 2^53; 
after
+    // rebasing, in-memory offsets are bounded by the child buffer's element 
count
+    // (which the JS runtime can allocate anyway). Genuinely too-large wire 
inputs
+    // fail honestly at child-buffer allocation rather than at offset 
narrowing.
+    protected readLargeOffsets<T extends DataType>(type: T, buffer?: 
BufferRegion): BigInt64Array {
+        const offsets: BigInt64Array = toBigInt64Array(this.readOffsets(type, 
buffer));
+        if (offsets.length === 0 || offsets[0] === BigInt(0)) {
+            return offsets;
+        }

Review Comment:
   We should also check if `offsets.at(-1) > Number.MAX_SAFE_INTEGER` and only 
rebase if it is.



-- 
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]

Reply via email to