Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/src/Arrow.externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ FlatListData.prototype.valueOffsets;

var DictionaryData = function() {};
/** @type {?} */
DictionaryData.prototype.indicies;
DictionaryData.prototype.indices;
/** @type {?} */
DictionaryData.prototype.dictionary;

Expand Down
22 changes: 11 additions & 11 deletions js/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,28 +148,28 @@ export class FlatListData<T extends FlatListType> extends FlatData<T> {

export class DictionaryData<T extends DataType> extends BaseData<Dictionary<T>> {
protected _dictionary: Vector<T>;
protected _indicies: Data<Int<any>>;
public get indicies() { return this._indicies; }
protected _indices: Data<Int<any>>;
public get indices() { return this._indices; }
public get dictionary() { return this._dictionary; }
constructor(type: Dictionary<T>, dictionary: Vector<T>, indicies: Data<Int<any>>) {
super(type, indicies.length, (indicies as any)._nullCount);
this._indicies = indicies;
constructor(type: Dictionary<T>, dictionary: Vector<T>, indices: Data<Int<any>>) {
super(type, indices.length, (indices as any)._nullCount);
this._indices = indices;
this._dictionary = dictionary;
this.length = this._indicies.length;
this.length = this._indices.length;
}
public get nullCount() { return this._indicies.nullCount; }
public get nullBitmap() { return this._indicies.nullBitmap; }
public get nullCount() { return this._indices.nullCount; }
public get nullBitmap() { return this._indices.nullBitmap; }
public clone<R extends Dictionary<T>>(type: R, length = this.length, offset = this.offset) {
const data = this._dictionary.data.clone(type.dictionary as any);
return new DictionaryData<R>(
this.type as any,
this._dictionary.clone(data) as any,
this._indicies.slice(offset - this.offset, length)
this._indices.slice(offset - this.offset, length)
) as any;
}
protected sliceInternal(clone: this, _offset: number, _length: number) {
clone.length = clone._indicies.length;
clone._nullCount = (clone._indicies as any)._nullCount;
clone.length = clone._indices.length;
clone._nullCount = (clone._indices as any)._nullCount;
return clone;
}
}
Expand Down
2 changes: 1 addition & 1 deletion js/src/ipc/reader/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export abstract class TypeDataLoader extends TypeVisitor {
public visitFixedSizeList (type: FixedSizeList) { return this.visitFixedSizeListType(type); }
public visitMap (type: Map_) { return this.visitNestedType(type); }
public visitDictionary (type: Dictionary) {
return new DictionaryData(type, this.dictionaries.get(type.id)!, this.visit(type.indicies));
return new DictionaryData(type, this.dictionaries.get(type.id)!, this.visit(type.indices));
}
protected getFieldMetadata() { return this.nodes.next().value; }
protected getBufferMetadata() { return this.buffers.next().value; }
Expand Down
4 changes: 2 additions & 2 deletions js/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class Table implements DataFrame {
const batch = batches[batchIndex];
// rebind the countBy Col
count_by.bind(batch);
const keys = (count_by.vector as DictionaryVector).indicies;
const keys = (count_by.vector as DictionaryVector).indices;
// yield all indices
for (let index = -1, numRows = batch.length; ++index < numRows;) {
let key = keys.get(index);
Expand Down Expand Up @@ -258,7 +258,7 @@ class FilteredDataFrame implements DataFrame {
const predicate = this.predicate.bind(batch);
// rebind the countBy Col
count_by.bind(batch);
const keys = (count_by.vector as DictionaryVector).indicies;
const keys = (count_by.vector as DictionaryVector).indices;
// yield all indices
for (let index = -1, numRows = batch.length; ++index < numRows;) {
let key = keys.get(index);
Expand Down
12 changes: 6 additions & 6 deletions js/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ export class Field<T extends DataType = DataType> {
public toString() { return `${this.name}: ${this.type}`; }
public get typeId(): T['TType'] { return this.type.TType; }
public get [Symbol.toStringTag](): string { return 'Field'; }
public get indicies(): T | Int<any> {
return DataType.isDictionary(this.type) ? this.type.indicies : this.type;
public get indices(): T | Int<any> {
return DataType.isDictionary(this.type) ? this.type.indices : this.type;
}
}

Expand Down Expand Up @@ -443,17 +443,17 @@ export interface Dictionary<T extends DataType = any> extends DataType<Type.Dict
export class Dictionary<T extends DataType> extends DataType<Type.Dictionary> {
public readonly id: number;
public readonly dictionary: T;
public readonly indicies: Int<any>;
public readonly indices: Int<any>;
public readonly isOrdered: boolean;
constructor(dictionary: T, indicies: Int<any>, id?: Long | number | null, isOrdered?: boolean | null) {
constructor(dictionary: T, indices: Int<any>, id?: Long | number | null, isOrdered?: boolean | null) {
super(Type.Dictionary);
this.indicies = indicies;
this.indices = indices;
this.dictionary = dictionary;
this.isOrdered = isOrdered || false;
this.id = id == null ? DictionaryBatch.getId() : typeof id === 'number' ? id : id.low;
}
public get ArrayType() { return this.dictionary.ArrayType; }
public toString() { return `Dictionary<${this.indicies}, ${this.dictionary}>`; }
public toString() { return `Dictionary<${this.indices}, ${this.dictionary}>`; }
protected static [Symbol.toStringTag] = ((proto: Dictionary) => {
return proto[Symbol.toStringTag] = 'Dictionary';
})(Dictionary.prototype);
Expand Down
12 changes: 6 additions & 6 deletions js/src/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,29 +394,29 @@ export class UnionVector<T extends (SparseUnion | DenseUnion) = any> extends Nes

export class DictionaryVector<T extends DataType = DataType> extends Vector<Dictionary<T>> {
// @ts-ignore
public readonly indicies: Vector<Int>;
public readonly indices: Vector<Int>;
// @ts-ignore
public readonly dictionary: Vector<T>;
constructor(data: Data<Dictionary<T>>, view: View<Dictionary<T>> = new DictionaryView<T>(data.dictionary, new IntVector(data.indicies))) {
constructor(data: Data<Dictionary<T>>, view: View<Dictionary<T>> = new DictionaryView<T>(data.dictionary, new IntVector(data.indices))) {
super(data as Data<any>, view);
if (data instanceof DictionaryData && view instanceof DictionaryView) {
this.indicies = view.indicies;
this.indices = view.indices;
this.dictionary = data.dictionary;
} else if (data instanceof ChunkedData && view instanceof ChunkedView) {
const chunks = view.chunkVectors as DictionaryVector<T>[];
// Assume the last chunk's dictionary data is the most up-to-date,
// including data from DictionaryBatches that were marked as deltas
this.dictionary = chunks[chunks.length - 1].dictionary;
this.indicies = chunks.reduce<Vector<Int> | null>(
this.indices = chunks.reduce<Vector<Int> | null>(
(idxs: Vector<Int> | null, dict: DictionaryVector<T>) =>
!idxs ? dict.indicies! : idxs.concat(dict.indicies!),
!idxs ? dict.indices! : idxs.concat(dict.indices!),
null
)!;
} else {
throw new TypeError(`Unrecognized DictionaryVector view`);
}
}
public getKey(index: number) { return this.indicies.get(index); }
public getKey(index: number) { return this.indices.get(index); }
public getValue(key: number) { return this.dictionary.get(key); }
public reverseLookup(value: T) { return this.dictionary.indexOf(value); }
}
Expand Down
24 changes: 12 additions & 12 deletions js/src/vector/dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,39 @@ import { View, Vector } from '../vector';
import { IterableArrayLike, DataType, Dictionary, Int } from '../type';

export class DictionaryView<T extends DataType> implements View<T> {
public indicies: Vector<Int>;
public indices: Vector<Int>;
public dictionary: Vector<T>;
constructor(dictionary: Vector<T>, indicies: Vector<Int>) {
this.indicies = indicies;
constructor(dictionary: Vector<T>, indices: Vector<Int>) {
this.indices = indices;
this.dictionary = dictionary;
}
public clone(data: Data<Dictionary<T>>): this {
return new DictionaryView(data.dictionary, this.indicies.clone(data.indicies)) as this;
return new DictionaryView(data.dictionary, this.indices.clone(data.indices)) as this;
}
public isValid(index: number): boolean {
return this.indicies.isValid(index);
return this.indices.isValid(index);
}
public get(index: number): T['TValue'] {
return this.dictionary.get(this.indicies.get(index));
return this.dictionary.get(this.indices.get(index));
}
public set(index: number, value: T['TValue']): void {
this.dictionary.set(this.indicies.get(index), value);
this.dictionary.set(this.indices.get(index), value);
}
public toArray(): IterableArrayLike<T['TValue']> {
return [...this];
}
public *[Symbol.iterator](): IterableIterator<T['TValue']> {
const values = this.dictionary, indicies = this.indicies;
for (let index = -1, n = indicies.length; ++index < n;) {
yield values.get(indicies.get(index));
const values = this.dictionary, indices = this.indices;
for (let index = -1, n = indices.length; ++index < n;) {
yield values.get(indices.get(index));
}
}
public indexOf(search: T['TValue']) {
// First find the dictionary key for the desired value...
const key = this.dictionary.indexOf(search);
if (key === -1) { return key; }

// ... then find the first occurence of that key in indicies
return this.indicies.indexOf(key!);
// ... then find the first occurence of that key in indices
return this.indices.indexOf(key!);
}
}