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


##########
src/visitor/get.ts:
##########
@@ -149,10 +154,39 @@ const getFixedSizeBinary = <T extends FixedSizeBinary>({ 
stride, values }: Data<
 /** @ignore */
 const getBinary = <T extends Binary | LargeBinary>({ values, valueOffsets }: 
Data<T>, index: number): T['TValue'] => getVariableWidthBytes(values, 
valueOffsets, index);
 /** @ignore */
+const getBinaryViewValue = <T extends BinaryView>(data: Data<T>, index: 
number): T['TValue'] => {
+    const values = data.values as Uint8Array;
+    if (!values) {
+        throw new Error('BinaryView data is missing view buffer');
+    }
+    const start = (data.offset + index) * BINARY_VIEW_SIZE;
+    const baseOffset = values.byteOffset + start;
+    const view = new DataView(values.buffer, baseOffset, BINARY_VIEW_SIZE);
+    const size = view.getInt32(0, true);
+    if (size <= 0) {
+        return new Uint8Array(0) as T['TValue'];
+    }
+    if (size <= BINARY_VIEW_INLINE_CAPACITY) {
+        return new Uint8Array(values.buffer, baseOffset + 4, size) as 
T['TValue'];

Review Comment:
   ```suggestion
           return new data.type.ArrayType(values.buffer, baseOffset + 4, size);
   ```



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