[
https://issues.apache.org/jira/browse/ARROW-1652?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16235801#comment-16235801
]
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_r148545546
##########
File path: js/src/types/table/table.ts
##########
@@ -0,0 +1,63 @@
+// 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 { Row } from './row';
+import { toString } from './toString';
+import { VirtualVector } from '../vector/virtual';
+import { Vector, Column, Struct } from '../types';
+
+export interface TableVector {
+ toString(): string;
+ toString(index: boolean): string;
+ toString(options: { index: boolean }): string;
+}
+
+export class TableVector extends Vector<TableRow> implements Struct<string> {
+ readonly length: number;
+ readonly columns: Column[];
+ constructor(argv: { columns: Column[] }) {
+ super();
+ this.columns = argv.columns || [];
+ if (!this.length) {
+ this.length = Math.max(...this.columns.map((col) => col.length)) |
0;
+ }
+ }
+ get(index: number): TableRow {
+ return new TableRow(this, index);
+ }
+ col(name: string) {
+ return this.columns.find((col) => col.name === name) || null;
+ }
Review comment:
> @TheNeuralBit yeah, I'm open to ideas here. Perhaps the best approach here
is to do away with the distinction between table/struct, and make get() and
key() take column indexes, and col() take a column name. Also fwiw when a Row's
this.table is a StructVector, the table.col(key) call accesses the columns
Array by index, which (if I understand correctly) sounds like what you're
looking for here?
Yeah that is what I'm getting at here - it would be great if there was a way
for `Row` to access columns by index (as well as by name).
And actually now that I think about it, `StructVector` should have column
names for its children, since they're specified [as a list of Fields in the
Schema](https://github.com/apache/arrow/blob/master/format/Schema.fbs#L286). So
your suggestion to remove the distinction completely makes a lot of sense.
I'd be fine with leaving this PR as-is and opening another ticket for that
task.
----------------------------------------------------------------
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)