[
https://issues.apache.org/jira/browse/ARROW-1652?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16235775#comment-16235775
]
ASF GitHub Bot commented on ARROW-1652:
---------------------------------------
TheNeuralBit commented on a change in pull request #1273: ARROW-1652: [JS]
housekeeping, vector cleanup
URL: https://github.com/apache/arrow/pull/1273#discussion_r148540215
##########
File path: js/src/types/table/row.ts
##########
@@ -0,0 +1,56 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import { Vector, Struct } from '../types';
+import { VirtualVector } from '../vector/virtual';
+
+export class Row<TKey extends string | number> extends Vector {
+ readonly row: number;
+ readonly table: Struct<TKey>;
+ [Symbol.toStringTag]() { return 'Row'; }
+ constructor(table: Struct<TKey>, row: number) {
+ super();
+ this.row = row;
+ this.table = table;
+ }
+ get length() { return this.table.length; }
+ get<T = any>(key: TKey) {
+ const col = this.table.col(key as TKey);
+ return col ? col.get(this.row) as T : null;
+ }
Review comment:
@trxcllnt actually what I'm getting at here is something like the following:
```
let row = table.get(row_index);
let a = row.get('column_a'), b = row.get('column_b');
```
Each `get` call would result in a batch lookup in both the `column_a` and
`column_b` VirtualVectors even if the batch structure for both vectors is the
same. I'm just suggesting there could be a sub-class of `Row` that handles that
case. It could do the batch lookup once for the first call to `get` and re-use
it as a batch hint on subsequent calls.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> [JS] Separate Vector into BatchVector and CompositeVector
> ---------------------------------------------------------
>
> Key: ARROW-1652
> URL: https://issues.apache.org/jira/browse/ARROW-1652
> Project: Apache Arrow
> Issue Type: Improvement
> Components: JavaScript
> Reporter: Brian Hulette
> Assignee: Paul Taylor
> Priority: Major
> Labels: Performance, pull-request-available
>
> CompositeVector should have a {{batch(..)}} function that returns a
> BatchVector
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)