trackoor opened a new issue, #531:
URL: https://github.com/apache/arrow-js/issues/531

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   The doc comment on `Vector.indexOf` says `offset` is "the index at which to 
begin the search".
   
   ```js
   // npm i [email protected]
   import * as A from 'apache-arrow';
   
   const n = A.vectorFromArray([5, 7, 5, 7, 5], new A.Int32);
   console.log(n.indexOf(7, 2), n.includes(7, 4), n.indexOf(7, 99));
   
   const c = A.vectorFromArray([5, 7], new A.Int32)
     .concat(A.vectorFromArray([5, 7, 5], new A.Int32)); // two chunks
   console.log(c.indexOf(5, 3), c.indexOf(7, 2), c.indexOf(7, 99));
   ```
   
   Actual:
   ```
   1 true 1
   2 1 null
   ```
   Expected (same as `[5, 7, 5, 7, 5].indexOf(...)`):
   ```
   3 false -1
   4 3 -1
   ```
   
   Two separate causes:
   
   1. Single chunk: the constructor installs `this.indexOf = (index) => 
indexOf(unchunkedData, index)` (`src/vector.ts`), which drops the second 
argument.
   2. Chunked: `wrapChunkedIndexOf` in `src/util/chunk.ts` starts `total` at 0 
even when the search begins in a later chunk, so the returned index is relative 
to that chunk; and when `offset` is past the end, `binarySearch` returns `null` 
instead of -1.
   
   Version: [email protected] (Node.js v26.13.0, Linux x64), also on main 
f7398fa.
   
   Credit: https://ucsbplse.github.io/
   


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