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AK,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IACS,aAAa,CAAC,OAA6C;QACjE,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,KAAK,GAAG,CAAC,EAAE,KAA6B,CAAC;QAC7C,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE;YAC5B,IAAI,KAAK,KAAK,SAAS,EAAE;gBACrB,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;aACzB;iBAAM;gBACH,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBACjC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;aAC1C;SACJ;IACL,CAAC;CACJ","file":"list.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 { Run } from './run';\nimport { Field } from '../schema';\nimport { DataType, List } from '../type';\nimport { OffsetsBufferBuilder } from './buffer';\nimport { Builder, BuilderOptions, VariableWidthBuilder } from '../builder';\n\n/** @ignore */\nexport class ListBuilder<T extends DataType = any, TNull = any> extends VariableWidthBuilder<List<T>, TNull> {\n    protected _run = new Run<T, TNull>();\n    protected _offsets: OffsetsBufferBuilder;\n    constructor(opts: BuilderOptions<List<T>, TNull>) {\n        super(opts);\n        this._offsets = new OffsetsBufferBuilder();\n    }\n    public addChild(child: Builder<T>, name = '0') {\n        if (this.numChildren > 0) {\n            throw new Error('ListBuilder can only have one child.');\n        }\n        this.children[this.numChildren] = child;\n        this.type = new List(new Field(name, child.type, true));\n        return this.numChildren - 1;\n    }\n    public clear() {\n        this._run.clear();\n        return super.clear();\n    }\n    protected _flushPending(pending: Map<number, T['TValue'] | undefined>) {\n        const run = this._run;\n        const offsets = this._offsets;\n        const setValue = this._setValue;\n        let index = 0, value: Uint8Array | undefined;\n        for ([index, value] of pending) {\n            if (value === undefined) {\n                offsets.set(index, 0);\n            } else {\n                offsets.set(index, value.length);\n                setValue(this, index, run.bind(value));\n            }\n        }\n    }\n}\n"]}