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W,GAAG,IAAI,CAAC;QACxB,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;CACJ;AAED,cAAc,CAAC,MAAM,WAAW,GAAG,CAA2B,KAA6B,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;AAC7G,cAAc,CAAC,MAAM,eAAe,GAAG,CAA2B,KAA6B,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC","file":"builder.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 { DataType } from '../../type';\nimport { Vector } from '../../vector';\nimport { VectorType as V } from '../../interfaces';\nimport { Builder, BuilderOptions } from '../../builder/index';\n\n/** @ignore */\nexport interface BuilderTransformOptions<T extends DataType = any, TNull = any> extends BuilderOptions<T, TNull> {\n queueingStrategy?: 'bytes' | 'count';\n dictionaryHashFunction?: (value: any) => string | number;\n readableStrategy?: { highWaterMark?: number, size?: any, type?: 'bytes'; };\n writableStrategy?: { highWaterMark?: number, size?: any, type?: 'bytes'; };\n valueToChildTypeId?: (builder: Builder<T, TNull>, value: any, offset: number) => number;\n}\n\n/** @ignore */\nexport function builderThroughDOMStream<T extends DataType = any, TNull = any>(options: BuilderTransformOptions<T, TNull>) {\n return new BuilderTransform(options);\n}\n\n/** @ignore */\nexport class BuilderTransform<T extends DataType = any, TNull = any> {\n\n public readable: ReadableStream<V<T>>;\n public writable: WritableStream<T['TValue'] | TNull>;\n public _controller: ReadableStreamDefaultController<V<T>> | null;\n\n private _numChunks = 0;\n private _finished = false;\n private _bufferedSize = 0;\n private _builder: Builder<T, TNull>;\n private _getSize: (builder: Builder<T, TNull>) => number;\n\n constructor(options: BuilderTransformOptions<T, TNull>) {\n\n // Access properties by string indexers to defeat closure compiler\n\n const {\n ['readableStrategy']: readableStrategy,\n ['writableStrategy']: writableStrategy,\n ['queueingStrategy']: queueingStrategy = 'count',\n ...builderOptions\n } = options;\n\n this._controller = null;\n this._builder = Builder.new<T, TNull>(builderOptions);\n this._getSize = queueingStrategy !== 'bytes' ? chunkLength : chunkByteLength;\n\n const { ['highWaterMark']: readableHighWaterMark = queueingStrategy === 'bytes' ? 2 ** 14 : 1000 } = { ...readableStrategy };\n const { ['highWaterMark']: writableHighWaterMark = queueingStrategy === 'bytes' ? 2 ** 14 : 1000 } = { ...writableStrategy };\n\n this['readable'] = new ReadableStream<V<T>>({\n ['cancel']: () => { this._builder.clear(); },\n ['pull']: (c) => { this._maybeFlush(this._builder, this._controller = c); },\n ['start']: (c) => { this._maybeFlush(this._builder, this._controller = c); },\n }, {\n 'highWaterMark': readableHighWaterMark,\n 'size': queueingStrategy !== 'bytes' ? chunkLength : chunkByteLength,\n });\n\n this['writable'] = new WritableStream({\n ['abort']: () => { this._builder.clear(); },\n ['write']: () => { this._maybeFlush(this._builder, this._controller); },\n ['close']: () => { this._maybeFlush(this._builder.finish(), this._controller); },\n }, {\n 'highWaterMark': writableHighWaterMark,\n 'size': (value: T['TValue'] | TNull) => this._writeValueAndReturnChunkSize(value),\n });\n }\n\n private _writeValueAndReturnChunkSize(value: T['TValue'] | TNull) {\n const bufferedSize = this._bufferedSize;\n this._bufferedSize = this._getSize(this._builder.append(value));\n return this._bufferedSize - bufferedSize;\n }\n\n private _maybeFlush(builder: Builder<T, TNull>, controller: ReadableStreamDefaultController<V<T>> | null) {\n if (controller === null) { return; }\n if (this._bufferedSize >= controller.desiredSize!) {\n ++this._numChunks && this._enqueue(controller, builder.toVector());\n }\n if (builder.finished) {\n if (builder.length > 0 || this._numChunks === 0) {\n ++this._numChunks && this._enqueue(controller, builder.toVector());\n }\n if (!this._finished && (this._finished = true)) {\n this._enqueue(controller, null);\n }\n }\n }\n\n private _enqueue(controller: ReadableStreamDefaultController<V<T>>, chunk: V<T> | null) {\n this._bufferedSize = 0;\n this._controller = null;\n chunk === null ? controller.close() : controller.enqueue(chunk);\n }\n}\n\n/** @ignore */ const chunkLength = <T extends DataType = any>(chunk: Vector<T> | Builder<T>) => chunk.length;\n/** @ignore */ const chunkByteLength = <T extends DataType = any>(chunk: Vector<T> | Builder<T>) => chunk.byteLength;\n"]} |