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"dataframe.js","sourcesContent":["// Licensed to the Apache Software Foundation (ASF) under one\n// or more contributor license agreements. See the NOTICE file\n// distributed with this work for additional information\n// regarding copyright ownership. The ASF licenses this file\n// to you under the Apache License, Version 2.0 (the\n// \"License\"); you may not use this file except in compliance\n// with the License. You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing,\n// software distributed under the License is distributed on an\n// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n// KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations\n// under the License.\n\nimport { Table } from '../table';\nimport { Vector } from '../vector';\nimport { IntVector } from '../vector/int';\nimport { Field, Schema } from '../schema';\nimport { Predicate, Col } from './predicate';\nimport { RecordBatch } from '../recordbatch';\nimport { VectorType as V } from '../interfaces';\nimport { DataType, Int, Struct, Dictionary } from '../type';\n\n/** @ignore */\nexport type BindFunc = (batch: RecordBatch) => void;\n/** @ignore */\nexport type NextFunc = (idx: number, batch: RecordBatch) => void;\n\nTable.prototype.countBy = function(this: Table, name: Col | string) { return new DataFrame(this.chunks).countBy(name); };\nTable.prototype.scan = function(this: Table, next: NextFunc, bind?: BindFunc) { return new DataFrame(this.chunks).scan(next, bind); };\nTable.prototype.scanReverse = function(this: Table, next: NextFunc, bind?: BindFunc) { return new DataFrame(this.chunks).scanReverse(next, bind); };\nTable.prototype.filter = function(this: Table, predicate: Predicate): FilteredDataFrame { return new DataFrame(this.chunks).filter(predicate); };\n\nexport class DataFrame extends Table {\n public filter(predicate: Predicate): FilteredDataFrame {\n return new FilteredDataFrame(this.chunks, predicate);\n }\n public scan(next: NextFunc, bind?: BindFunc) {\n const batches = this.chunks, numBatches = batches.length;\n for (let batchIndex = -1; ++batchIndex < numBatches;) {\n // load batches\n const batch = batches[batchIndex];\n if (bind) { bind(batch); }\n // yield all indices\n for (let index = -1, numRows = batch.length; ++index < numRows;) {\n next(index, batch);\n }\n }\n }\n public scanReverse(next: NextFunc, bind?: BindFunc) {\n const batches = this.chunks, numBatches = batches.length;\n for (let batchIndex = numBatches; --batchIndex >= 0;) {\n // load batches\n const batch = batches[batchIndex];\n if (bind) { bind(batch); }\n // yield all indices\n for (let index = batch.length; --index >= 0;) {\n next(index, batch);\n }\n }\n }\n public countBy(name: Col | string) {\n const batches = this.chunks, numBatches = batches.length;\n const count_by = typeof name === 'string' ? new Col(name) : name as Col;\n // Assume that all dictionary batches are deltas, which means that the\n // last record batch has the most complete dictionary\n count_by.bind(batches[numBatches - 1]);\n const vector = count_by.vector as V;\n if (!DataType.isDictionary(vector.type)) {\n throw new Error('countBy currently only supports dictionary-encoded columns');\n }\n\n const countByteLength = Math.ceil(Math.log(vector.length) / Math.log(256));\n const CountsArrayType = countByteLength == 4 ? Uint32Array :\n countByteLength >= 2 ? Uint16Array : Uint8Array;\n\n const counts = new CountsArrayType(vector.dictionary.length);\n for (let batchIndex = -1; ++batchIndex < numBatches;) {\n // load batches\n const batch = batches[batchIndex];\n // rebind the countBy Col\n count_by.bind(batch);\n const keys = (count_by.vector as V).indices;\n // yield all indices\n for (let index = -1, numRows = batch.length; ++index < numRows;) {\n let key = keys.get(index);\n if (key !== null) { counts[key]++; }\n }\n }\n return new CountByResult(vector.dictionary, IntVector.from(counts));\n }\n}\n\n/** @ignore */\nexport class CountByResult extends Table<{ values: T, counts: TCount }> {\n constructor(values: Vector, counts: V) {\n type R = { values: T, counts: TCount };\n const schema = new Schema([\n new Field('values', values.type),\n new Field('counts', counts.type)\n ]);\n super(new RecordBatch(schema, counts.length, [values, counts]));\n }\n public toJSON(): Object {\n const values = this.getColumnAt(0)!;\n const counts = this.getColumnAt(1)!;\n const result = {} as { [k: string]: number | null };\n for (let i = -1; ++i < this.length;) {\n result[values.get(i)] = counts.get(i);\n }\n return result;\n }\n}\n\n/** @ignore */\nexport class FilteredDataFrame extends DataFrame {\n private _predicate: Predicate;\n constructor (batches: RecordBatch[], predicate: Predicate) {\n super(batches);\n this._predicate = predicate;\n }\n public scan(next: NextFunc, bind?: BindFunc) {\n // inlined version of this:\n // this.parent.scan((idx, columns) => {\n // if (this.predicate(idx, columns)) next(idx, columns);\n // });\n const batches = this._chunks;\n const numBatches = batches.length;\n for (let batchIndex = -1; ++batchIndex < numBatches;) {\n // load batches\n const batch = batches[batchIndex];\n const predicate = this._predicate.bind(batch);\n let isBound = false;\n // yield all indices\n for (let index = -1, numRows = batch.length; ++index < numRows;) {\n if (predicate(index, batch)) {\n // bind batches lazily - if predicate doesn't match anything\n // in the batch we don't need to call bind on the batch\n if (bind && !isBound) {\n bind(batch);\n isBound = true;\n }\n next(index, batch);\n }\n }\n }\n }\n public scanReverse(next: NextFunc, bind?: BindFunc) {\n const batches = this._chunks;\n const numBatches = batches.length;\n for (let batchIndex = numBatches; --batchIndex >= 0;) {\n // load batches\n const batch = batches[batchIndex];\n const predicate = this._predicate.bind(batch);\n let isBound = false;\n // yield all indices\n for (let index = batch.length; --index >= 0;) {\n if (predicate(index, batch)) {\n // bind batches lazily - if predicate doesn't match anything\n // in the batch we don't need to call bind on the batch\n if (bind && !isBound) {\n bind(batch);\n isBound = true;\n }\n next(index, batch);\n }\n }\n }\n }\n public count(): number {\n // inlined version of this:\n // let sum = 0;\n // this.parent.scan((idx, columns) => {\n // if (this.predicate(idx, columns)) ++sum;\n // });\n // return sum;\n let sum = 0;\n const batches = this._chunks;\n const numBatches = batches.length;\n for (let batchIndex = -1; ++batchIndex < numBatches;) {\n // load batches\n const batch = batches[batchIndex];\n const predicate = this._predicate.bind(batch);\n // yield all indices\n for (let index = -1, numRows = batch.length; ++index < numRows;) {\n if (predicate(index, batch)) { ++sum; }\n }\n }\n return sum;\n }\n public *[Symbol.iterator](): IterableIterator['TValue']> {\n // inlined version of this:\n // this.parent.scan((idx, columns) => {\n // if (this.predicate(idx, columns)) next(idx, columns);\n // });\n const batches = this._chunks;\n const numBatches = batches.length;\n for (let batchIndex = -1; ++batchIndex < numBatches;) {\n // load batches\n const batch = batches[batchIndex];\n // TODO: bind batches lazily\n // If predicate doesn't match anything in the batch we don't need\n // to bind the callback\n const predicate = this._predicate.bind(batch);\n // yield all indices\n for (let index = -1, numRows = batch.length; ++index < numRows;) {\n if (predicate(index, batch)) { yield batch.get(index) as any; }\n }\n }\n }\n public filter(predicate: Predicate): FilteredDataFrame {\n return new FilteredDataFrame(\n this._chunks,\n this._predicate.and(predicate)\n );\n }\n public countBy(name: Col | string) {\n const batches = this._chunks, numBatches = batches.length;\n const count_by = typeof name === 'string' ? new Col(name) : name as Col;\n // Assume that all dictionary batches are deltas, which means that the\n // last record batch has the most complete dictionary\n count_by.bind(batches[numBatches - 1]);\n const vector = count_by.vector as V;\n if (!DataType.isDictionary(vector.type)) {\n throw new Error('countBy currently only supports dictionary-encoded columns');\n }\n\n const countByteLength = Math.ceil(Math.log(vector.length) / Math.log(256));\n const CountsArrayType = countByteLength == 4 ? Uint32Array :\n countByteLength >= 2 ? Uint16Array : Uint8Array;\n\n const counts = new CountsArrayType(vector.dictionary.length);\n\n for (let batchIndex = -1; ++batchIndex < numBatches;) {\n // load batches\n const batch = batches[batchIndex];\n const predicate = this._predicate.bind(batch);\n // rebind the countBy Col\n count_by.bind(batch);\n const keys = (count_by.vector as V).indices;\n // yield all indices\n for (let index = -1, numRows = batch.length; ++index < numRows;) {\n let key = keys.get(index);\n if (key !== null && predicate(index, batch)) { counts[key]++; }\n }\n }\n return new CountByResult(vector.dictionary, IntVector.from(counts));\n }\n}\n"]}