You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/04/26 18:04:56 UTC
[GitHub] [arrow] domoritz commented on a change in pull request #10151: ARROW-12528: [JS] Support typed arrays in Table.new
domoritz commented on a change in pull request #10151:
URL: https://github.com/apache/arrow/pull/10151#discussion_r620530082
##########
File path: js/src/util/args.ts
##########
@@ -21,11 +21,26 @@ import { Column } from '../column';
import { Vector } from '../vector';
import { DataType } from '../type';
import { Chunked } from '../vector/chunked';
+import { BigIntArray, TypedArray } from '../interfaces';
+import { FloatVector, IntVector } from '../vector/index';
type RecordBatchCtor = typeof import('../recordbatch').RecordBatch;
const isArray = Array.isArray;
+/** @ignore */
+export function isTypedArray(arr: any): arr is TypedArray | BigIntArray {
+ return ArrayBuffer.isView(arr) && 'BYTES_PER_ELEMENT' in arr;
+}
+
+/** @ignore */
+function vectorFromTypedArray(array: TypedArray): Vector {
+ if (array instanceof Float32Array || array instanceof Float64Array) {
+ return FloatVector.from(array);
+ }
+ return IntVector.from(array);
Review comment:
Use Vector.new with Data.new here.
--
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org