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C;IACrC,MAAM,IAAI,GAAG,IAAI,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrD,IAAI,IAAI,IAAI,iBAAiB,EAAE;QAC3B,IAAI,wBAAwB,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;YACxE,OAAO,IAAI,0BAA0B,CAAC,IAAI,8BAA8B,CAAI,IAAI,CAAC,CAAC,CAAC;SACtF;KACJ;IACD,OAAO,IAAI,4BAA4B,CAAC,IAAI,gCAAgC,CAAI,IAAI,CAAC,CAAC,CAAC;AAC3F,CAAC","file":"reader.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 { Vector } from '../vector';\nimport { DataType } from '../type';\nimport { MessageHeader } from '../enum';\nimport { Footer } from './metadata/file';\nimport { Schema, Field } from '../schema';\nimport streamAdapters from '../io/adapters';\nimport { Message } from './metadata/message';\nimport * as metadata from './metadata/message';\nimport { ArrayBufferViewInput } from '../util/buffer';\nimport { ByteStream, AsyncByteStream } from '../io/stream';\nimport { RandomAccessFile, AsyncRandomAccessFile } from '../io/file';\nimport { VectorLoader, JSONVectorLoader } from '../visitor/vectorloader';\nimport { RecordBatch, _InternalEmptyPlaceholderRecordBatch } from '../recordbatch';\nimport {\n FileHandle,\n ArrowJSONLike,\n ITERATOR_DONE,\n ReadableInterop,\n} from '../io/interfaces';\nimport {\n MessageReader, AsyncMessageReader, JSONMessageReader,\n checkForMagicArrowString, magicLength, magicAndPadding, magicX2AndPadding\n} from './message';\nimport {\n isPromise,\n isIterable, isAsyncIterable,\n isIteratorResult, isArrowJSON,\n isFileHandle, isFetchResponse,\n isReadableDOMStream, isReadableNodeStream\n} from '../util/compat';\n\n/** @ignore */ export type FromArg0 = ArrowJSONLike;\n/** @ignore */ export type FromArg1 = PromiseLike;\n/** @ignore */ export type FromArg2 = Iterable | ArrayBufferViewInput;\n/** @ignore */ export type FromArg3 = PromiseLike | ArrayBufferViewInput>;\n/** @ignore */ export type FromArg4 = Response | NodeJS.ReadableStream | ReadableStream | AsyncIterable;\n/** @ignore */ export type FromArg5 = FileHandle | PromiseLike | PromiseLike;\n/** @ignore */ export type FromArgs = FromArg0 | FromArg1 | FromArg2 | FromArg3 | FromArg4 | FromArg5;\n\n/** @ignore */ type OpenOptions = { autoDestroy?: boolean; };\n/** @ignore */ type RecordBatchReaders = RecordBatchFileReader | RecordBatchStreamReader;\n/** @ignore */ type AsyncRecordBatchReaders = AsyncRecordBatchFileReader | AsyncRecordBatchStreamReader;\n/** @ignore */ type RecordBatchFileReaders = RecordBatchFileReader | AsyncRecordBatchFileReader;\n/** @ignore */ type RecordBatchStreamReaders = RecordBatchStreamReader | AsyncRecordBatchStreamReader;\n\nexport class RecordBatchReader extends ReadableInterop> {\n\n protected _impl: RecordBatchReaderImpls;\n protected constructor(impl: RecordBatchReaderImpls) {\n super();\n this._impl = impl;\n }\n\n public get closed() { return this._impl.closed; }\n public get schema() { return this._impl.schema; }\n public get autoDestroy() { return this._impl.autoDestroy; }\n public get dictionaries() { return this._impl.dictionaries; }\n public get numDictionaries() { return this._impl.numDictionaries; }\n public get numRecordBatches() { return this._impl.numRecordBatches; }\n public get footer() { return this._impl.isFile() ? this._impl.footer : null; }\n\n public isSync(): this is RecordBatchReaders { return this._impl.isSync(); }\n public isAsync(): this is AsyncRecordBatchReaders { return this._impl.isAsync(); }\n public isFile(): this is RecordBatchFileReaders { return this._impl.isFile(); }\n public isStream(): this is RecordBatchStreamReaders { return this._impl.isStream(); }\n\n public next() {\n return this._impl.next();\n }\n public throw(value?: any) {\n return this._impl.throw(value);\n }\n public return(value?: any) {\n return this._impl.return(value);\n }\n public cancel() {\n return this._impl.cancel();\n }\n public reset(schema?: Schema | null): this {\n this._impl.reset(schema);\n this._DOMStream = undefined;\n this._nodeStream = undefined;\n return this;\n }\n public open(options?: OpenOptions) {\n const opening = this._impl.open(options);\n return isPromise(opening) ? opening.then(() => this) : this;\n }\n public readRecordBatch(index: number): RecordBatch | null | Promise | null> {\n return this._impl.isFile() ? this._impl.readRecordBatch(index) : null;\n }\n public [Symbol.iterator](): IterableIterator> {\n return (>> this._impl)[Symbol.iterator]();\n }\n public [Symbol.asyncIterator](): AsyncIterableIterator> {\n return (>> this._impl)[Symbol.asyncIterator]();\n }\n public toDOMStream() {\n return streamAdapters.toDOMStream>(\n (this.isSync()\n ? { [Symbol.iterator]: () => this } as Iterable>\n : { [Symbol.asyncIterator]: () => this } as AsyncIterable>));\n }\n public toNodeStream() {\n return streamAdapters.toNodeStream>(\n (this.isSync()\n ? { [Symbol.iterator]: () => this } as Iterable>\n : { [Symbol.asyncIterator]: () => this } as AsyncIterable>),\n { objectMode: true });\n }\n\n /** @nocollapse */\n // @ts-ignore\n public static throughNode(options?: import('stream').DuplexOptions & { autoDestroy: boolean }): import('stream').Duplex {\n throw new Error(`\"throughNode\" not available in this environment`);\n }\n /** @nocollapse */\n public static throughDOM(\n // @ts-ignore\n writableStrategy?: ByteLengthQueuingStrategy,\n // @ts-ignore\n readableStrategy?: { autoDestroy: boolean }\n ): { writable: WritableStream, readable: ReadableStream> } {\n throw new Error(`\"throughDOM\" not available in this environment`);\n }\n\n public static from(source: T): T;\n public static from(source: FromArg0): RecordBatchStreamReader;\n public static from(source: FromArg1): Promise>;\n public static from(source: FromArg2): RecordBatchFileReader | RecordBatchStreamReader;\n public static from(source: FromArg3): Promise | RecordBatchStreamReader>;\n public static from(source: FromArg4): Promise | AsyncRecordBatchReaders>;\n public static from(source: FromArg5): Promise | AsyncRecordBatchStreamReader>;\n /** @nocollapse */\n public static from(source: any) {\n if (source instanceof RecordBatchReader) {\n return source;\n } else if (isArrowJSON(source)) {\n return fromArrowJSON(source);\n } else if (isFileHandle(source)) {\n return fromFileHandle(source);\n } else if (isPromise(source)) {\n return (async () => await RecordBatchReader.from(await source))();\n } else if (isFetchResponse(source) || isReadableDOMStream(source) || isReadableNodeStream(source) || isAsyncIterable(source)) {\n return fromAsyncByteStream(new AsyncByteStream(source));\n }\n return fromByteStream(new ByteStream(source));\n }\n\n public static readAll(source: T): T extends RecordBatchReaders ? IterableIterator : AsyncIterableIterator;\n public static readAll(source: FromArg0): IterableIterator>;\n public static readAll(source: FromArg1): AsyncIterableIterator>;\n public static readAll(source: FromArg2): IterableIterator | RecordBatchStreamReader>;\n public static readAll(source: FromArg3): AsyncIterableIterator | RecordBatchStreamReader>;\n public static readAll(source: FromArg4): AsyncIterableIterator | AsyncRecordBatchReaders>;\n public static readAll(source: FromArg5): AsyncIterableIterator | AsyncRecordBatchStreamReader>;\n /** @nocollapse */\n public static readAll(source: any) {\n if (source instanceof RecordBatchReader) {\n return source.isSync() ? readAllSync(source) : readAllAsync(source as AsyncRecordBatchReaders);\n } else if (isArrowJSON(source) || ArrayBuffer.isView(source) || isIterable(source) || isIteratorResult(source)) {\n return readAllSync(source) as IterableIterator>;\n }\n return readAllAsync(source) as AsyncIterableIterator | AsyncRecordBatchReaders>;\n }\n}\n\n//\n// Since TS is a structural type system, we define the following subclass stubs\n// so that concrete types exist to associate with with the interfaces below.\n//\n// The implementation for each RecordBatchReader is hidden away in the set of\n// `RecordBatchReaderImpl` classes in the second half of this file. This allows\n// us to export a single RecordBatchReader class, and swap out the impl based\n// on the io primitives or underlying arrow (JSON, file, or stream) at runtime.\n//\n// Async/await makes our job a bit harder, since it forces everything to be\n// either fully sync or fully async. This is why the logic for the reader impls\n// has been duplicated into both sync and async variants. Since the RBR\n// delegates to its impl, an RBR with an AsyncRecordBatchFileReaderImpl for\n// example will return async/await-friendly Promises, but one with a (sync)\n// RecordBatchStreamReaderImpl will always return values. Nothing should be\n// different about their logic, aside from the async handling. This is also why\n// this code looks highly structured, as it should be nearly identical and easy\n// to follow.\n//\n\n/** @ignore */\nexport class RecordBatchStreamReader extends RecordBatchReader {\n constructor(protected _impl: RecordBatchStreamReaderImpl) { super (_impl); }\n public [Symbol.iterator]() { return (this._impl as IterableIterator>)[Symbol.iterator](); }\n public async *[Symbol.asyncIterator](): AsyncIterableIterator> { yield* this[Symbol.iterator](); }\n}\n/** @ignore */\nexport class AsyncRecordBatchStreamReader extends RecordBatchReader {\n constructor(protected _impl: AsyncRecordBatchStreamReaderImpl) { super (_impl); }\n public [Symbol.iterator](): IterableIterator> { throw new Error(`AsyncRecordBatchStreamReader is not Iterable`); }\n public [Symbol.asyncIterator]() { return (this._impl as AsyncIterableIterator>)[Symbol.asyncIterator](); }\n}\n/** @ignore */\nexport class RecordBatchFileReader extends RecordBatchStreamReader {\n constructor(protected _impl: RecordBatchFileReaderImpl) { super (_impl); }\n}\n/** @ignore */\nexport class AsyncRecordBatchFileReader extends AsyncRecordBatchStreamReader {\n constructor(protected _impl: AsyncRecordBatchFileReaderImpl) { super (_impl); }\n}\n\n//\n// Now override the return types for each sync/async RecordBatchReader variant\n//\n\n/** @ignore */\nexport interface RecordBatchStreamReader extends RecordBatchReader {\n open(options?: OpenOptions | undefined): this;\n cancel(): void;\n throw(value?: any): IteratorResult;\n return(value?: any): IteratorResult;\n next(value?: any): IteratorResult>;\n}\n\n/** @ignore */\nexport interface AsyncRecordBatchStreamReader extends RecordBatchReader {\n open(options?: OpenOptions | undefined): Promise;\n cancel(): Promise;\n throw(value?: any): Promise>;\n return(value?: any): Promise>;\n next(value?: any): Promise>>;\n}\n\n/** @ignore */\nexport interface RecordBatchFileReader extends RecordBatchStreamReader {\n footer: Footer;\n readRecordBatch(index: number): RecordBatch | null;\n}\n\n/** @ignore */\nexport interface AsyncRecordBatchFileReader extends AsyncRecordBatchStreamReader {\n footer: Footer;\n readRecordBatch(index: number): Promise | null>;\n}\n\n/** @ignore */\ntype RecordBatchReaderImpls =\n RecordBatchJSONReaderImpl |\n RecordBatchFileReaderImpl |\n RecordBatchStreamReaderImpl |\n AsyncRecordBatchFileReaderImpl |\n AsyncRecordBatchStreamReaderImpl;\n\n/** @ignore */\ninterface RecordBatchReaderImpl {\n\n closed: boolean;\n schema: Schema;\n autoDestroy: boolean;\n dictionaries: Map;\n\n isFile(): this is RecordBatchFileReaders;\n isStream(): this is RecordBatchStreamReaders;\n isSync(): this is RecordBatchReaders;\n isAsync(): this is AsyncRecordBatchReaders;\n\n reset(schema?: Schema | null): this;\n}\n\n/** @ignore */\ninterface RecordBatchStreamReaderImpl extends RecordBatchReaderImpl {\n\n open(options?: OpenOptions): this;\n cancel(): void;\n\n throw(value?: any): IteratorResult;\n return(value?: any): IteratorResult;\n next(value?: any): IteratorResult>;\n\n [Symbol.iterator](): IterableIterator>;\n}\n\n/** @ignore */\ninterface AsyncRecordBatchStreamReaderImpl extends RecordBatchReaderImpl {\n\n open(options?: OpenOptions): Promise;\n cancel(): Promise;\n\n throw(value?: any): Promise>;\n return(value?: any): Promise>;\n next(value?: any): Promise>>;\n\n [Symbol.asyncIterator](): AsyncIterableIterator>;\n}\n\n/** @ignore */\ninterface RecordBatchFileReaderImpl extends RecordBatchStreamReaderImpl {\n readRecordBatch(index: number): RecordBatch | null;\n}\n\n/** @ignore */\ninterface AsyncRecordBatchFileReaderImpl extends AsyncRecordBatchStreamReaderImpl {\n readRecordBatch(index: number): Promise | null>;\n}\n\n/** @ignore */\nabstract class RecordBatchReaderImpl implements RecordBatchReaderImpl {\n\n // @ts-ignore\n public schema: Schema;\n public closed = false;\n public autoDestroy = true;\n public dictionaries: Map;\n\n protected _dictionaryIndex = 0;\n protected _recordBatchIndex = 0;\n public get numDictionaries() { return this._dictionaryIndex; }\n public get numRecordBatches() { return this._recordBatchIndex; }\n\n constructor(dictionaries = new Map()) {\n this.dictionaries = dictionaries;\n }\n\n public isSync(): this is RecordBatchReaders { return false; }\n public isAsync(): this is AsyncRecordBatchReaders { return false; }\n public isFile(): this is RecordBatchFileReaders { return false; }\n public isStream(): this is RecordBatchStreamReaders { return false; }\n\n public reset(schema?: Schema | null) {\n this._dictionaryIndex = 0;\n this._recordBatchIndex = 0;\n this.schema = schema;\n this.dictionaries = new Map();\n return this;\n }\n\n protected _loadRecordBatch(header: metadata.RecordBatch, body: any) {\n return new RecordBatch(this.schema, header.length, this._loadVectors(header, body, this.schema.fields));\n }\n protected _loadDictionaryBatch(header: metadata.DictionaryBatch, body: any) {\n const { id, isDelta, data } = header;\n const { dictionaries, schema } = this;\n const dictionary = dictionaries.get(id);\n if (isDelta || !dictionary) {\n const type = schema.dictionaries.get(id)!;\n return (dictionary && isDelta ? dictionary.concat(\n Vector.new(this._loadVectors(data, body, [type])[0])) :\n Vector.new(this._loadVectors(data, body, [type])[0])) as Vector;\n }\n return dictionary;\n }\n protected _loadVectors(header: metadata.RecordBatch, body: any, types: (Field | DataType)[]) {\n return new VectorLoader(body, header.nodes, header.buffers, this.dictionaries).visitMany(types);\n }\n}\n\n/** @ignore */\nclass RecordBatchStreamReaderImpl extends RecordBatchReaderImpl implements IterableIterator> {\n\n protected _reader: MessageReader;\n protected _handle: ByteStream | ArrowJSONLike;\n\n constructor(source: ByteStream | ArrowJSONLike, dictionaries?: Map) {\n super(dictionaries);\n this._reader = !isArrowJSON(source)\n ? new MessageReader(this._handle = source)\n : new JSONMessageReader(this._handle = source);\n }\n\n public isSync(): this is RecordBatchReaders { return true; }\n public isStream(): this is RecordBatchStreamReaders { return true; }\n public [Symbol.iterator](): IterableIterator> {\n return this as IterableIterator>;\n }\n public cancel() {\n if (!this.closed && (this.closed = true)) {\n this.reset()._reader.return();\n this._reader = null;\n this.dictionaries = null;\n }\n }\n public open(options?: OpenOptions) {\n if (!this.closed) {\n this.autoDestroy = shouldAutoDestroy(this, options);\n if (!(this.schema || (this.schema = this._reader.readSchema()!))) {\n this.cancel();\n }\n }\n return this;\n }\n public throw(value?: any): IteratorResult {\n if (!this.closed && this.autoDestroy && (this.closed = true)) {\n return this.reset()._reader.throw(value);\n }\n return ITERATOR_DONE;\n }\n public return(value?: any): IteratorResult {\n if (!this.closed && this.autoDestroy && (this.closed = true)) {\n return this.reset()._reader.return(value);\n }\n return ITERATOR_DONE;\n }\n public next(): IteratorResult> {\n if (this.closed) { return ITERATOR_DONE; }\n let message: Message | null, { _reader: reader } = this;\n while (message = this._readNextMessageAndValidate()) {\n if (message.isSchema()) {\n this.reset(message.header());\n } else if (message.isRecordBatch()) {\n this._recordBatchIndex++;\n const header = message.header();\n const buffer = reader.readMessageBody(message.bodyLength);\n const recordBatch = this._loadRecordBatch(header, buffer);\n return { done: false, value: recordBatch };\n } else if (message.isDictionaryBatch()) {\n this._dictionaryIndex++;\n const header = message.header();\n const buffer = reader.readMessageBody(message.bodyLength);\n const vector = this._loadDictionaryBatch(header, buffer);\n this.dictionaries.set(header.id, vector);\n }\n }\n if (this.schema && this._recordBatchIndex === 0) {\n this._recordBatchIndex++;\n return { done: false, value: new _InternalEmptyPlaceholderRecordBatch(this.schema) };\n }\n return this.return();\n }\n protected _readNextMessageAndValidate(type?: T | null) {\n return this._reader.readMessage(type);\n }\n}\n\n/** @ignore */\nclass AsyncRecordBatchStreamReaderImpl extends RecordBatchReaderImpl implements AsyncIterableIterator> {\n\n protected _handle: AsyncByteStream;\n protected _reader: AsyncMessageReader;\n\n constructor(source: AsyncByteStream, dictionaries?: Map) {\n super(dictionaries);\n this._reader = new AsyncMessageReader(this._handle = source);\n }\n public isAsync(): this is AsyncRecordBatchReaders { return true; }\n public isStream(): this is RecordBatchStreamReaders { return true; }\n public [Symbol.asyncIterator](): AsyncIterableIterator> {\n return this as AsyncIterableIterator>;\n }\n public async cancel() {\n if (!this.closed && (this.closed = true)) {\n await this.reset()._reader.return();\n this._reader = null;\n this.dictionaries = null;\n }\n }\n public async open(options?: OpenOptions) {\n if (!this.closed) {\n this.autoDestroy = shouldAutoDestroy(this, options);\n if (!(this.schema || (this.schema = (await this._reader.readSchema())!))) {\n await this.cancel();\n }\n }\n return this;\n }\n public async throw(value?: any): Promise> {\n if (!this.closed && this.autoDestroy && (this.closed = true)) {\n return await this.reset()._reader.throw(value);\n }\n return ITERATOR_DONE;\n }\n public async return(value?: any): Promise> {\n if (!this.closed && this.autoDestroy && (this.closed = true)) {\n return await this.reset()._reader.return(value);\n }\n return ITERATOR_DONE;\n }\n public async next() {\n if (this.closed) { return ITERATOR_DONE; }\n let message: Message | null, { _reader: reader } = this;\n while (message = await this._readNextMessageAndValidate()) {\n if (message.isSchema()) {\n await this.reset(message.header());\n } else if (message.isRecordBatch()) {\n this._recordBatchIndex++;\n const header = message.header();\n const buffer = await reader.readMessageBody(message.bodyLength);\n const recordBatch = this._loadRecordBatch(header, buffer);\n return { done: false, value: recordBatch };\n } else if (message.isDictionaryBatch()) {\n this._dictionaryIndex++;\n const header = message.header();\n const buffer = await reader.readMessageBody(message.bodyLength);\n const vector = this._loadDictionaryBatch(header, buffer);\n this.dictionaries.set(header.id, vector);\n }\n }\n if (this.schema && this._recordBatchIndex === 0) {\n this._recordBatchIndex++;\n return { done: false, value: new _InternalEmptyPlaceholderRecordBatch(this.schema) };\n }\n return await this.return();\n }\n protected async _readNextMessageAndValidate(type?: T | null) {\n return await this._reader.readMessage(type);\n }\n}\n\n/** @ignore */\nclass RecordBatchFileReaderImpl extends RecordBatchStreamReaderImpl {\n\n // @ts-ignore\n protected _footer?: Footer;\n // @ts-ignore\n protected _handle: RandomAccessFile;\n public get footer() { return this._footer!; }\n public get numDictionaries() { return this._footer ? this._footer.numDictionaries : 0; }\n public get numRecordBatches() { return this._footer ? this._footer.numRecordBatches : 0; }\n\n constructor(source: RandomAccessFile | ArrayBufferViewInput, dictionaries?: Map) {\n super(source instanceof RandomAccessFile ? source : new RandomAccessFile(source), dictionaries);\n }\n public isSync(): this is RecordBatchReaders { return true; }\n public isFile(): this is RecordBatchFileReaders { return true; }\n public open(options?: OpenOptions) {\n if (!this.closed && !this._footer) {\n this.schema = (this._footer = this._readFooter()).schema;\n for (const block of this._footer.dictionaryBatches()) {\n block && this._readDictionaryBatch(this._dictionaryIndex++);\n }\n }\n return super.open(options);\n }\n public readRecordBatch(index: number) {\n if (this.closed) { return null; }\n if (!this._footer) { this.open(); }\n const block = this._footer && this._footer.getRecordBatch(index);\n if (block && this._handle.seek(block.offset)) {\n const message = this._reader.readMessage(MessageHeader.RecordBatch);\n if (message && message.isRecordBatch()) {\n const header = message.header();\n const buffer = this._reader.readMessageBody(message.bodyLength);\n const recordBatch = this._loadRecordBatch(header, buffer);\n return recordBatch;\n }\n }\n return null;\n }\n protected _readDictionaryBatch(index: number) {\n const block = this._footer && this._footer.getDictionaryBatch(index);\n if (block && this._handle.seek(block.offset)) {\n const message = this._reader.readMessage(MessageHeader.DictionaryBatch);\n if (message && message.isDictionaryBatch()) {\n const header = message.header();\n const buffer = this._reader.readMessageBody(message.bodyLength);\n const vector = this._loadDictionaryBatch(header, buffer);\n this.dictionaries.set(header.id, vector);\n }\n }\n }\n protected _readFooter() {\n const { _handle } = this;\n const offset = _handle.size - magicAndPadding;\n const length = _handle.readInt32(offset);\n const buffer = _handle.readAt(offset - length, length);\n return Footer.decode(buffer);\n }\n protected _readNextMessageAndValidate(type?: T | null): Message | null {\n if (!this._footer) { this.open(); }\n if (this._footer && this._recordBatchIndex < this.numRecordBatches) {\n const block = this._footer && this._footer.getRecordBatch(this._recordBatchIndex);\n if (block && this._handle.seek(block.offset)) {\n return this._reader.readMessage(type);\n }\n }\n return null;\n }\n}\n\n/** @ignore */\nclass AsyncRecordBatchFileReaderImpl extends AsyncRecordBatchStreamReaderImpl\n implements AsyncRecordBatchFileReaderImpl {\n\n protected _footer?: Footer;\n // @ts-ignore\n protected _handle: AsyncRandomAccessFile;\n public get footer() { return this._footer!; }\n public get numDictionaries() { return this._footer ? this._footer.numDictionaries : 0; }\n public get numRecordBatches() { return this._footer ? this._footer.numRecordBatches : 0; }\n\n constructor(source: FileHandle, byteLength?: number, dictionaries?: Map);\n constructor(source: FileHandle | AsyncRandomAccessFile, dictionaries?: Map);\n constructor(source: FileHandle | AsyncRandomAccessFile, ...rest: any[]) {\n const byteLength = typeof rest[0] !== 'number' ? rest.shift() : undefined;\n const dictionaries = rest[0] instanceof Map ? > rest.shift() : undefined;\n super(source instanceof AsyncRandomAccessFile ? source : new AsyncRandomAccessFile(source, byteLength), dictionaries);\n }\n public isFile(): this is RecordBatchFileReaders { return true; }\n public isAsync(): this is AsyncRecordBatchReaders { return true; }\n public async open(options?: OpenOptions) {\n if (!this.closed && !this._footer) {\n this.schema = (this._footer = await this._readFooter()).schema;\n for (const block of this._footer.dictionaryBatches()) {\n block && await this._readDictionaryBatch(this._dictionaryIndex++);\n }\n }\n return await super.open(options);\n }\n public async readRecordBatch(index: number) {\n if (this.closed) { return null; }\n if (!this._footer) { await this.open(); }\n const block = this._footer && this._footer.getRecordBatch(index);\n if (block && (await this._handle.seek(block.offset))) {\n const message = await this._reader.readMessage(MessageHeader.RecordBatch);\n if (message && message.isRecordBatch()) {\n const header = message.header();\n const buffer = await this._reader.readMessageBody(message.bodyLength);\n const recordBatch = this._loadRecordBatch(header, buffer);\n return recordBatch;\n }\n }\n return null;\n }\n protected async _readDictionaryBatch(index: number) {\n const block = this._footer && this._footer.getDictionaryBatch(index);\n if (block && (await this._handle.seek(block.offset))) {\n const message = await this._reader.readMessage(MessageHeader.DictionaryBatch);\n if (message && message.isDictionaryBatch()) {\n const header = message.header();\n const buffer = await this._reader.readMessageBody(message.bodyLength);\n const vector = this._loadDictionaryBatch(header, buffer);\n this.dictionaries.set(header.id, vector);\n }\n }\n }\n protected async _readFooter() {\n const { _handle } = this;\n _handle._pending && await _handle._pending;\n const offset = _handle.size - magicAndPadding;\n const length = await _handle.readInt32(offset);\n const buffer = await _handle.readAt(offset - length, length);\n return Footer.decode(buffer);\n }\n protected async _readNextMessageAndValidate(type?: T | null): Promise | null> {\n if (!this._footer) { await this.open(); }\n if (this._footer && this._recordBatchIndex < this.numRecordBatches) {\n const block = this._footer.getRecordBatch(this._recordBatchIndex);\n if (block && await this._handle.seek(block.offset)) {\n return await this._reader.readMessage(type);\n }\n }\n return null;\n }\n}\n\n/** @ignore */\nclass RecordBatchJSONReaderImpl extends RecordBatchStreamReaderImpl {\n constructor(source: ArrowJSONLike, dictionaries?: Map) {\n super(source, dictionaries);\n }\n protected _loadVectors(header: metadata.RecordBatch, body: any, types: (Field | DataType)[]) {\n return new JSONVectorLoader(body, header.nodes, header.buffers, this.dictionaries).visitMany(types);\n }\n}\n\n//\n// Define some helper functions and static implementations down here. There's\n// a bit of branching in the static methods that can lead to the same routines\n// being executed, so we've broken those out here for readability.\n//\n\n/** @ignore */\nfunction shouldAutoDestroy(self: { autoDestroy: boolean }, options?: OpenOptions) {\n return options && (typeof options['autoDestroy'] === 'boolean') ? options['autoDestroy'] : self['autoDestroy'];\n}\n\n/** @ignore */\nfunction* readAllSync(source: RecordBatchReaders | FromArg0 | FromArg2) {\n const reader = RecordBatchReader.from( source) as RecordBatchReaders;\n try {\n if (!reader.open({ autoDestroy: false }).closed) {\n do { yield reader; } while (!(reader.reset().open()).closed);\n }\n } finally { reader.cancel(); }\n}\n\n/** @ignore */\nasync function* readAllAsync(source: AsyncRecordBatchReaders | FromArg1 | FromArg3 | FromArg4 | FromArg5) {\n const reader = await RecordBatchReader.from( source) as RecordBatchReader;\n try {\n if (!(await reader.open({ autoDestroy: false })).closed) {\n do { yield reader; } while (!(await reader.reset().open()).closed);\n }\n } finally { await reader.cancel(); }\n}\n\n/** @ignore */\nfunction fromArrowJSON(source: ArrowJSONLike) {\n return new RecordBatchStreamReader(new RecordBatchJSONReaderImpl(source));\n}\n\n/** @ignore */\nfunction fromByteStream(source: ByteStream) {\n const bytes = source.peek((magicLength + 7) & ~7);\n return bytes && bytes.byteLength >= 4 ? !checkForMagicArrowString(bytes)\n ? new RecordBatchStreamReader(new RecordBatchStreamReaderImpl(source))\n : new RecordBatchFileReader(new RecordBatchFileReaderImpl(source.read()))\n : new RecordBatchStreamReader(new RecordBatchStreamReaderImpl(function*(): any {}()));\n}\n\n/** @ignore */\nasync function fromAsyncByteStream(source: AsyncByteStream) {\n const bytes = await source.peek((magicLength + 7) & ~7);\n return bytes && bytes.byteLength >= 4 ? !checkForMagicArrowString(bytes)\n ? new AsyncRecordBatchStreamReader(new AsyncRecordBatchStreamReaderImpl(source))\n : new RecordBatchFileReader(new RecordBatchFileReaderImpl(await source.read()))\n : new AsyncRecordBatchStreamReader(new AsyncRecordBatchStreamReaderImpl(async function*(): any {}()));\n}\n\n/** @ignore */\nasync function fromFileHandle(source: FileHandle) {\n const { size } = await source.stat();\n const file = new AsyncRandomAccessFile(source, size);\n if (size >= magicX2AndPadding) {\n if (checkForMagicArrowString(await file.readAt(0, (magicLength + 7) & ~7))) {\n return new AsyncRecordBatchFileReader(new AsyncRecordBatchFileReaderImpl(file));\n }\n }\n return new AsyncRecordBatchStreamReader(new AsyncRecordBatchStreamReaderImpl(file));\n}\n"]}