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CAAC,KAA4C,EAAE,IAAI,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE;QACtF,IAAI,IAAI,CAAC,WAAW,GAAG,CAAC,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SAC3D;QACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAO,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;IAChC,CAAC;IAES,aAAa,CAAC,OAAwB;QAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YAC7B,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,IAAI,CAAC,CAAC;gBAC/B,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;aAChC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","file":"map.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 { Field } from '../schema';\nimport { DataType, Map_, Struct } from '../type';\nimport { Builder, VariableWidthBuilder } from '../builder';\n\n/** @ignore */ type MapValue<K extends DataType = any, V extends DataType = any> = Map_<K, V>['TValue'];\n/** @ignore */ type MapValues<K extends DataType = any, V extends DataType = any> = Map<number, MapValue<K, V> | undefined>;\n/** @ignore */ type MapValueExt<K extends DataType = any, V extends DataType = any> = MapValue<K, V> | { [key: string]: V } | { [key: number]: V } ;\n\n/** @ignore */\nexport class MapBuilder<K extends DataType = any, V extends DataType = any, TNull = any> extends VariableWidthBuilder<Map_<K, V>, TNull> {\n\n protected _pending: MapValues<K, V> | undefined;\n public set(index: number, value: MapValueExt<K, V> | TNull) {\n return super.set(index, value as MapValue<K, V> | TNull);\n }\n\n public setValue(index: number, value: MapValueExt<K, V>) {\n value = value instanceof Map ? value : new Map(Object.entries(value));\n const pending = this._pending || (this._pending = new Map() as MapValues<K, V>);\n const current = pending.get(index);\n current && (this._pendingLength -= current.size);\n this._pendingLength += value.size;\n pending.set(index, value);\n }\n\n public addChild(child: Builder<Struct<{ key: K, value: V }>>, name = `${this.numChildren}`) {\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 Map_<K, V>(new Field(name, child.type, true), this.type.keysSorted);\n return this.numChildren - 1;\n }\n\n protected _flushPending(pending: MapValues<K, V>) {\n const offsets = this._offsets;\n const setValue = this._setValue;\n pending.forEach((value, index) => {\n if (value === undefined) {\n offsets.set(index, 0);\n } else {\n offsets.set(index, value.size);\n setValue(this, index, value);\n }\n });\n }\n}\n"]}