@ducklings/workers 1.4.3-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/constants.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/util/arrays.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/util/objects.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/data-types.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/util/numbers.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/util/strings.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/util/read.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/util/struct.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/batch.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/column.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/table.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/batch-type.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/decode/block.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/decode/record-batch.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/decode/dictionary-batch.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/decode/data-type.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/decode/metadata.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/decode/schema.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/decode/message.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/decode/decode-ipc.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/decode/table-from-ipc.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/encode/builder.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/encode/record-batch.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/encode/dictionary-batch.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/encode/metadata.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/encode/data-type.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/encode/schema.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/encode/footer.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/encode/message.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/encode/sink.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/encode/encode-ipc.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/encode/table-to-ipc.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/buffer.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/batch.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/validity.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/dictionary.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/infer-type.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/binary.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/bool.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/decimal.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/fixed-size-binary.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/fixed-size-list.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/interval.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/list.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/struct.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/map.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/run-end-encoded.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/union.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/utf8.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builders/values.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/builder.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/column-from-values.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/column-from-array.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/table-from-columns.js","../../../node_modules/.pnpm/@uwdata+flechette@2.2.6/node_modules/@uwdata/flechette/src/build/table-from-arrays.js","../src/index.ts"],"names":["MAGIC","EOS","Version","Endianness","MessageHeader","Type","Precision","DateUnit","TimeUnit","IntervalUnit","UnionMode","uint8Array","uint16Array","uint32Array","uint64Array","int8Array","int16Array","int32Array","int64Array","float32Array","float64Array","isArrayBufferLike","data","intArrayType","bitWidth","signed","i","TypedArray","isTypedArray","value","isArray","isInt64ArrayType","bisect","offsets","index","a","b","mid","align64","length","bpe","align","array","alignedLength","resize","newLength","offset","newArray","grow","shift","isDate","isIterable","check","test","message","checkOneOf","set","keyFor","object","key","val","invalidDataType","typeId","field","name","type","nullable","metadata","isField","isDataType","asField","defaultName","defaultNullable","basicType","dictionary","indexType","ordered","id","int32","nullType","int","int8","int16","int64","uint8","uint16","uint32","uint64","float","precision","float32","float64","binary","utf8","bool","decimal","scale","date","unit","dateDay","time","timestamp","timezone","interval","list","child","struct","children","union","mode","typeIds","typeIdForValue","v","m","fixedSizeBinary","stride","fixedSizeList","mapType","keysSorted","duration","largeBinary","largeUtf8","largeList","runEndEncoded","runsField","valuesField","listView","largeListView","f64","buf","i64","u32","i32","u8","identity","toBigInt","toOffset","toDateDay","toTimestamp","toMonthDayNanoBytes","d","n","toNumber","divide","num","div","toDecimal32","toDecimal","asUint64","fromDecimal64","fromDecimal128","x","fromDecimal256","toFloat16","sign","expo","sigf","textDecoder","textEncoder","decodeUtf8","encodeUtf8","str","keyString","objectKey","s","k","SIZEOF_INT","SIZEOF_SHORT","decodeBit","bitmap","readObject","pos","readInt32","vtable","size","readInt16","read","fallback","off","readOffset","readBoolean","readInt8","readUint8","readUint16","readUint32","readInt64","readString","readVector","extract","base","_","RowIndex","proxyFactory","names","batches","RowObject","structObject","proto","batch","objectFactory","obj","isDirectBatch","DirectBatch","Batch","nullCount","validity","values","sizes","start","end","options","NumberBatch","ArrayBatch","NullBatch","Int64Batch","Float16Batch","BoolBatch","Decimal32NumberBatch","DecimalBatch","DecimalNumberBatch","DecimalBigIntBatch","DateBatch","DateDayBatch","DateDayMillisecondBatch","TimestampSecondBatch","TimestampMillisecondBatch","TimestampMicrosecondBatch","TimestampNanosecondBatch","IntervalDayTimeBatch","IntervalMonthDayNanoBatch","offset32","offset64","BinaryBatch","LargeBinaryBatch","Utf8Batch","LargeUtf8Batch","ListBatch","LargeListBatch","ListViewBatch","LargeListViewBatch","FixedBatch","FixedBinaryBatch","FixedListBatch","pairs","keys","vals","entries","MapEntryBatch","MapBatch","SparseUnionBatch","typeMap","DenseUnionBatch","StructBatch","factory","StructProxyBatch","RunEndEncodedBatch","runs","DictionaryBatch","ViewBatch","BinaryViewBatch","Utf8ViewBatch","columnBuilder","Column","batchedIterator","copy","ArrayType","copyArray","extractArray","iter","next","j","Table","_Table","schema","useProxy","f","gen","c","indices","as","fields","renameField","all","cols","getFactory","numRows","output","row","batchType","useBigInt","useDate","useDecimalInt","useMap","wrap","BaseClass","WrapperClass","decodeBlock","decodeBlocks","decodeRecordBatch","version","get","decodeDictionaryBatch","decodeDataType","decodeMetadata","decodeSchema","decodeSchemaFields","fieldsOffset","decodeField","typeOffset","dict","decodeDictionary","decodeFieldChildren","fieldOffset","decodeInt","invalidMessageMetadata","expected","actual","invalidMessageBodyLength","invalidMessageType","decodeMessage","metadataLength","head","bodyLength","content","decoder","body","decodeIPC","source","isArrowFileFormat","decodeIPCFile","decodeIPCStream","stream","records","dictionaries","dicts","recs","tableFromIPC","createTable","dictionaryMap","context","contextGenerator","dictionaryTypes","visitSchemaFields","isDelta","visit","ctx","visitor","visitField","nodes","regions","variadic","nodeIndex","bufferIndex","variadicIndex","node","buffer","BatchType","writeInt32","INIT_SIZE","Builder","sink","prep","numFields","addFields","objectBuilder","items","itemSize","alignment","writeItem","rootOffset","bytes","pad","byteCount","builder","additionalBytes","space","minalign","bufSize","used","alignSize","startOffset","slot","defaultValue","vtableOffset","standardFields","len","existingTable","vtables","vt1","outer_loop","vt2","encodeRecordBatch","nodeVector","regionVector","region","variadicVector","count","encodeDictionaryBatch","dictionaryBatch","dataOffset","encodeMetadata","encodeDataType","encodeDictionary","encodeInt","encodeFloat","encodeDecimal","encodeDate","encodeTime","encodeTimestamp","encodeInterval","encodeDuration","encodeFixedSize","encodeMap","encodeUnion","timezoneOffset","typeIdsOffset","isLittleEndian","encodeSchema","fieldOffsets","encodeField","fieldsVectorOffset","metadataOffset","dictionaryOffset","childOffsets","childrenVectorOffset","nameOffset","writeFooter","dictBlocks","recordBlocks","recsOffset","encodeBlock","dictsOffset","schemaOffset","writeMessage","headerType","headerOffset","blocks","prefixSize","messageSize","alignedSize","Sink","MemorySink","bufs","sum","STREAM","FILE","encodeIPC","format","file","writeBuffers","buffers","tableToIPC","table","columns","checkBatchLengths","idMap","assembleDictionaryBatches","assembleRecordBatches","assembleSchema","assembleContext","byteLength","dictMap","dictionaryColumn","assembleRecordBatch","col","visitDictionaries","visitDictType","visitFields","parentType","batchIndex","column","arrayType","Buffer","Bitmap","BatchBuilder","ValidityBuilder","isValid","dictionaryContext","dictionaryValues","valueType","DictionaryBuilder","inferType","profile","profiler","boolCount","numberCount","intCount","bigintCount","dateCount","dayCount","stringCount","arrayCount","structCount","min","max","minLength","maxLength","minBigInt","maxBigInt","arrayProfile","structProfiles","valid","intType","bigintType","unionType","BinaryBuilder","BoolBuilder","DecimalBuilder","FixedSizeBinaryBuilder","FixedSizeListBuilder","IntervalDayTimeBuilder","IntervalMonthDayNanoBuilder","AbstractListBuilder","offsetType","ListBuilder","AbstractStructBuilder","StructBuilder","setters","MapBuilder","MapStructBuilder","keyValuePair","NO_VALUE","RunEndEncodedBuilder","AbstractUnionBuilder","lookup","SparseUnionBuilder","DenseUnionBuilder","Utf8Builder","DirectBuilder","Int64Builder","TransformBuilder","transform","builderContext","columnFromValues","callback","maxBatchRows","opt","nullBatches","limit","numBatches","rem","columnFromArray","columnFromTypedArray","typeForTypedArray","add","idx","tableFromColumns","tableFromArrays","types","DuckDBType","AccessMode","DuckDBError","_DuckDBError","code","query","stripSqlComments","sql","result","DANGEROUS_PATTERNS","checkSql","strippedSql","sanitizeSql","module","initPromise","getModule","init","DuckDBModule","imports","receiveInstance","instance","versionPtr","readColumnData","mod","dataPtr","nullmaskPtr","rowCount","duckdbType","hasNullmask","low","high","bigValue","days","micros","millis","PreparedStatement","stmtPtr","_connPtr","valLow","valHigh","ptr","tsLow","tsHigh","resultPtr","errorPtr","errorMsg","columnCount","namePtr","columnData","colIdx","rowIdx","strPtr","rows","rowsChanged","stmtPtrPtr","DataChunk","chunkPtr","columnIndex","vectorPtr","validityPtr","columnType","r","isRowNull","strBase","chunkPtrPtr","StreamingResult","chunk","allRows","colName","chunkData","DuckDB","_DuckDB","config","finalConfig","configPtrPtr","configPtr","setConfig","dbPtrPtr","errorPtrPtr","connPtrPtr","connPtr","configPtrPtrForDestroy","Connection","error","boolPtr","tableData","fn"],"mappings":";AACO,IAAMA,EAAAA,CAAQ,UAAA,CAAW,EAAA,CAAG,EAAA,CAAI,EAAA,CAAI,EAAA,CAAI,EAAA,CAAI,EAAA,CAAI,EAAE,CAAA,CAG5CC,EAAAA,CAAM,UAAA,CAAW,GAAG,GAAA,CAAK,GAAA,CAAK,GAAA,CAAK,GAAA,CAAK,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAC,CAAA,CAKlDC,CAAAA,CAAgC,CAE3C,EAAA,CAAI,CAAA,CAMJ,EAAA,CAAI,CAAA,CAUJ,EAAA,CAAI,CACN,CAAA,CAKaC,EAAAA,CAAmC,CAC9C,MAAA,CAAQ,CAEV,CAAA,CAKaC,CAAAA,CAAsC,CACjD,IAAA,CAAM,CAAA,CAIN,OAAQ,CAAA,CASR,eAAA,CAAiB,CAAA,CAMjB,WAAA,CAAa,CAAA,CAQb,MAAA,CAAQ,CAAA,CAQR,YAAA,CAAc,CAChB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CAAA,CAC7ClE,CAAAA,CAAO,KAAA,CAAM,mBAAA,CAAqB,IAAA,CAAM,CAAC,QAAQ,CAAA,CAAG,CAACkE,CAAU,CAAC,EAClE,CAAA,OAAE,CACAlE,CAAAA,CAAO,MAAMkE,CAAU,EACzB,CAEA,IAAA,CAAK,MAAA,CAAS,IAAA,CACd,IAAA,CAAK,OAAA,CAAU,EACjB,CACF","file":"index.js","sourcesContent":["/** Magic bytes 'ARROW1' indicating the Arrow 'file' format. */\nexport const MAGIC = Uint8Array.of(65, 82, 82, 79, 87, 49);\n\n/** Bytes for an 'end of stream' message. */\nexport const EOS = Uint8Array.of(255, 255, 255, 255, 0, 0, 0, 0);\n\n/**\n * Apache Arrow version.\n */\nexport const Version = /** @type {const} */ ({\n /** 0.1.0 (October 2016). */\n V1: 0,\n /** 0.2.0 (February 2017). Non-backwards compatible with V1. */\n V2: 1,\n /** 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2. */\n V3: 2,\n /** >= 0.8.0 (December 2017). Non-backwards compatible with V3. */\n V4: 3,\n /**\n * >= 1.0.0 (July 2020). Backwards compatible with V4 (V5 readers can read V4\n * metadata and IPC messages). Implementations are recommended to provide a\n * V4 compatibility mode with V5 format changes disabled.\n *\n * Incompatible changes between V4 and V5:\n * - Union buffer layout has changed.\n * In V5, Unions don't have a validity bitmap buffer.\n */\n V5: 4\n});\n\n/**\n * Endianness of Arrow-encoded data.\n */\nexport const Endianness = /** @type {const} */ ({\n Little: 0,\n Big: 1\n});\n\n/**\n * Message header type codes.\n */\nexport const MessageHeader = /** @type {const} */ ({\n NONE: 0,\n /**\n * A Schema describes the columns in a record batch.\n */\n Schema: 1,\n /**\n * For sending dictionary encoding information. Any Field can be\n * dictionary-encoded, but in this case none of its children may be\n * dictionary-encoded.\n * There is one vector / column per dictionary, but that vector / column\n * may be spread across multiple dictionary batches by using the isDelta\n * flag.\n */\n DictionaryBatch: 2,\n /**\n * A data header describing the shared memory layout of a \"record\" or \"row\"\n * batch. Some systems call this a \"row batch\" internally and others a \"record\n * batch\".\n */\n RecordBatch: 3,\n /**\n * EXPERIMENTAL: Metadata for n-dimensional arrays, aka \"tensors\" or\n * \"ndarrays\". Arrow implementations in general are not required to implement\n * this type.\n *\n * Not currently supported by Flechette.\n */\n Tensor: 4,\n /**\n * EXPERIMENTAL: Metadata for n-dimensional sparse arrays, aka \"sparse\n * tensors\". Arrow implementations in general are not required to implement\n * this type.\n *\n * Not currently supported by Flechette.\n */\n SparseTensor: 5\n});\n\n/**\n * Field data type ids.\n * Only non-negative values ever occur in IPC flatbuffer binary data.\n */\nexport const Type = /** @type {const} */ ({\n /**\n * Dictionary types compress data by using a set of integer indices to\n * lookup potentially repeated vales in a separate dictionary of values.\n *\n * This type entry is provided for API convenience, it does not occur\n * in actual Arrow IPC binary data.\n */\n Dictionary: -1,\n /** No data type. Included for flatbuffer compatibility. */\n NONE: 0,\n /** Null values only. */\n Null: 1,\n /** Integers, either signed or unsigned, with 8, 16, 32, or 64 bit widths. */\n Int: 2,\n /** Floating point numbers with 16, 32, or 64 bit precision. */\n Float: 3,\n /** Opaque binary data. */\n Binary: 4,\n /** Unicode with UTF-8 encoding. */\n Utf8: 5,\n /** Booleans represented as 8 bit bytes. */\n Bool: 6,\n /**\n * Exact decimal value represented as an integer value in two's complement.\n * Currently only 128-bit (16-byte) and 256-bit (32-byte) integers are used.\n * The representation uses the endianness indicated in the schema.\n */\n Decimal: 7,\n /**\n * Date is either a 32-bit or 64-bit signed integer type representing an\n * elapsed time since UNIX epoch (1970-01-01), stored in either of two units:\n * - Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no\n * leap seconds), where the values are evenly divisible by 86400000\n * - Days (32 bits) since the UNIX epoch\n */\n Date: 8,\n /**\n * Time is either a 32-bit or 64-bit signed integer type representing an\n * elapsed time since midnight, stored in either of four units: seconds,\n * milliseconds, microseconds or nanoseconds.\n *\n * The integer `bitWidth` depends on the `unit` and must be one of the following:\n * - SECOND and MILLISECOND: 32 bits\n * - MICROSECOND and NANOSECOND: 64 bits\n *\n * The allowed values are between 0 (inclusive) and 86400 (=24*60*60) seconds\n * (exclusive), adjusted for the time unit (for example, up to 86400000\n * exclusive for the MILLISECOND unit).\n * This definition doesn't allow for leap seconds. Time values from\n * measurements with leap seconds will need to be corrected when ingesting\n * into Arrow (for example by replacing the value 86400 with 86399).\n */\n Time: 9,\n /**\n * Timestamp is a 64-bit signed integer representing an elapsed time since a\n * fixed epoch, stored in either of four units: seconds, milliseconds,\n * microseconds or nanoseconds, and is optionally annotated with a timezone.\n *\n * Timestamp values do not include any leap seconds (in other words, all\n * days are considered 86400 seconds long).\n *\n * The timezone is an optional string for the name of a timezone, one of:\n *\n * - As used in the Olson timezone database (the \"tz database\" or\n * \"tzdata\"), such as \"America/New_York\".\n * - An absolute timezone offset of the form \"+XX:XX\" or \"-XX:XX\",\n * such as \"+07:30\".\n *\n * Whether a timezone string is present indicates different semantics about\n * the data.\n */\n Timestamp: 10,\n /**\n * A \"calendar\" interval which models types that don't necessarily\n * have a precise duration without the context of a base timestamp (e.g.\n * days can differ in length during day light savings time transitions).\n * All integers in the units below are stored in the endianness indicated\n * by the schema.\n *\n * - YEAR_MONTH - Indicates the number of elapsed whole months, stored as\n * 4-byte signed integers.\n * - DAY_TIME - Indicates the number of elapsed days and milliseconds (no\n * leap seconds), stored as 2 contiguous 32-bit signed integers (8-bytes\n * in total). Support of this IntervalUnit is not required for full arrow\n * compatibility.\n * - MONTH_DAY_NANO - A triple of the number of elapsed months, days, and\n * nanoseconds. The values are stored contiguously in 16-byte blocks.\n * Months and days are encoded as 32-bit signed integers and nanoseconds\n * is encoded as a 64-bit signed integer. Nanoseconds does not allow for\n * leap seconds. Each field is independent (e.g. there is no constraint\n * that nanoseconds have the same sign as days or that the quantity of\n * nanoseconds represents less than a day's worth of time).\n */\n Interval: 11,\n /**\n * List (vector) data supporting variably-sized lists.\n * A list has a single child data type for list entries.\n */\n List: 12,\n /**\n * A struct consisting of multiple named child data types.\n */\n Struct: 13,\n /**\n * A union is a complex type with parallel child data types. By default ids\n * in the type vector refer to the offsets in the children. Optionally\n * typeIds provides an indirection between the child offset and the type id.\n * For each child `typeIds[offset]` is the id used in the type vector.\n */\n Union: 14,\n /**\n * Binary data where each entry has the same fixed size.\n */\n FixedSizeBinary: 15,\n /**\n * List (vector) data where every list has the same fixed size.\n * A list has a single child data type for list entries.\n */\n FixedSizeList: 16,\n /**\n * A Map is a logical nested type that is represented as\n * List<entries: Struct<key: K, value: V>>\n *\n * In this layout, the keys and values are each respectively contiguous. We do\n * not constrain the key and value types, so the application is responsible\n * for ensuring that the keys are hashable and unique. Whether the keys are sorted\n * may be set in the metadata for this field.\n *\n * In a field with Map type, the field has a child Struct field, which then\n * has two children: key type and the second the value type. The names of the\n * child fields may be respectively \"entries\", \"key\", and \"value\", but this is\n * not enforced.\n *\n * Map\n * ```text\n * - child[0] entries: Struct\n * - child[0] key: K\n * - child[1] value: V\n * ```\n * Neither the \"entries\" field nor the \"key\" field may be nullable.\n *\n * The metadata is structured so that Arrow systems without special handling\n * for Map can make Map an alias for List. The \"layout\" attribute for the Map\n * field must have the same contents as a List.\n */\n Map: 17,\n /**\n * An absolute length of time unrelated to any calendar artifacts. For the\n * purposes of Arrow implementations, adding this value to a Timestamp\n * (\"t1\") naively (i.e. simply summing the two numbers) is acceptable even\n * though in some cases the resulting Timestamp (t2) would not account for\n * leap-seconds during the elapsed time between \"t1\" and \"t2\". Similarly,\n * representing the difference between two Unix timestamp is acceptable, but\n * would yield a value that is possibly a few seconds off from the true\n * elapsed time.\n *\n * The resolution defaults to millisecond, but can be any of the other\n * supported TimeUnit values as with Timestamp and Time types. This type is\n * always represented as an 8-byte integer.\n */\n Duration: 18,\n /**\n * Same as Binary, but with 64-bit offsets, allowing representation of\n * extremely large data values.\n */\n LargeBinary: 19,\n /**\n * Same as Utf8, but with 64-bit offsets, allowing representation of\n * extremely large data values.\n */\n LargeUtf8: 20,\n /**\n * Same as List, but with 64-bit offsets, allowing representation of\n * extremely large data values.\n */\n LargeList: 21,\n /**\n * Contains two child arrays, run_ends and values. The run_ends child array\n * must be a 16/32/64-bit integer array which encodes the indices at which\n * the run with the value in each corresponding index in the values child\n * array ends. Like list/struct types, the value array can be of any type.\n */\n RunEndEncoded: 22,\n /**\n * Logically the same as Binary, but the internal representation uses a view\n * struct that contains the string length and either the string's entire data\n * inline (for small strings) or an inlined prefix, an index of another buffer,\n * and an offset pointing to a slice in that buffer (for non-small strings).\n *\n * Since it uses a variable number of data buffers, each Field with this type\n * must have a corresponding entry in `variadicBufferCounts`.\n */\n BinaryView: 23,\n /**\n * Logically the same as Utf8, but the internal representation uses a view\n * struct that contains the string length and either the string's entire data\n * inline (for small strings) or an inlined prefix, an index of another buffer,\n * and an offset pointing to a slice in that buffer (for non-small strings).\n *\n * Since it uses a variable number of data buffers, each Field with this type\n * must have a corresponding entry in `variadicBufferCounts`.\n */\n Utf8View: 24,\n /**\n * Represents the same logical types that List can, but contains offsets and\n * sizes allowing for writes in any order and sharing of child values among\n * list values.\n */\n ListView: 25,\n /**\n * Same as ListView, but with 64-bit offsets and sizes, allowing to represent\n * extremely large data values.\n */\n LargeListView: 26\n});\n\n/**\n * Floating point number precision.\n */\nexport const Precision = /** @type {const} */ ({\n /** 16-bit floating point number. */\n HALF: 0,\n /** 32-bit floating point number. */\n SINGLE: 1,\n /** 64-bit floating point number. */\n DOUBLE: 2\n});\n\n/**\n * Date units.\n */\nexport const DateUnit = /** @type {const} */ ({\n /* Days (as 32 bit int) since the UNIX epoch. */\n DAY: 0,\n /**\n * Milliseconds (as 64 bit int) indicating UNIX time elapsed since the epoch\n * (no leap seconds), with values evenly divisible by 86400000.\n */\n MILLISECOND: 1\n});\n\n/**\n * Time units.\n */\nexport const TimeUnit = /** @type {const} */ ({\n /** Seconds. */\n SECOND: 0,\n /** Milliseconds. */\n MILLISECOND: 1,\n /** Microseconds. */\n MICROSECOND: 2,\n /** Nanoseconds. */\n NANOSECOND: 3\n});\n\n/**\n * Date/time interval units.\n */\nexport const IntervalUnit = /** @type {const} */ ({\n /**\n * Indicates the number of elapsed whole months, stored as 4-byte signed\n * integers.\n */\n YEAR_MONTH: 0,\n /**\n * Indicates the number of elapsed days and milliseconds (no leap seconds),\n * stored as 2 contiguous 32-bit signed integers (8-bytes in total). Support\n * of this IntervalUnit is not required for full arrow compatibility.\n */\n DAY_TIME: 1,\n /**\n * A triple of the number of elapsed months, days, and nanoseconds.\n * The values are stored contiguously in 16-byte blocks. Months and days are\n * encoded as 32-bit signed integers and nanoseconds is encoded as a 64-bit\n * signed integer. Nanoseconds does not allow for leap seconds. Each field is\n * independent (e.g. there is no constraint that nanoseconds have the same\n * sign as days or that the quantity of nanoseconds represents less than a\n * day's worth of time).\n */\n MONTH_DAY_NANO: 2\n});\n\n/**\n * Union type modes.\n */\nexport const UnionMode = /** @type {const} */ ({\n /** Sparse union layout with full arrays for each sub-type. */\n Sparse: 0,\n /** Dense union layout with offsets into value arrays. */\n Dense: 1\n});\n","/**\n * @import { Int64ArrayConstructor, IntArrayConstructor, IntegerArray, TypedArray } from '../types.js'\n */\nexport const uint8Array = Uint8Array;\nexport const uint16Array = Uint16Array;\nexport const uint32Array = Uint32Array;\nexport const uint64Array = BigUint64Array;\nexport const int8Array = Int8Array;\nexport const int16Array = Int16Array;\nexport const int32Array = Int32Array;\nexport const int64Array = BigInt64Array;\nexport const float32Array = Float32Array;\nexport const float64Array = Float64Array;\n\n/**\n * Check if an input value is an ArrayBuffer or SharedArrayBuffer.\n * @param {unknown} data\n * @returns {data is ArrayBufferLike}\n */\nexport function isArrayBufferLike(data) {\n return data instanceof ArrayBuffer || (\n typeof SharedArrayBuffer !== 'undefined' &&\n data instanceof SharedArrayBuffer\n );\n}\n\n/**\n * Return the appropriate typed array constructor for the given\n * integer type metadata.\n * @param {number} bitWidth The integer size in bits.\n * @param {boolean} signed Flag indicating if the integer is signed.\n * @returns {IntArrayConstructor}\n */\nexport function intArrayType(bitWidth, signed) {\n const i = Math.log2(bitWidth) - 3;\n return (\n signed\n ? [int8Array, int16Array, int32Array, int64Array]\n : [uint8Array, uint16Array, uint32Array, uint64Array]\n )[i];\n}\n\n/** Shared prototype for typed arrays. */\nconst TypedArray = Object.getPrototypeOf(Int8Array);\n\n/**\n * Check if a value is a typed array.\n * @param {*} value The value to check.\n * @returns {value is TypedArray}\n * True if value is a typed array, false otherwise.\n */\nexport function isTypedArray(value) {\n return value instanceof TypedArray;\n}\n\n/**\n * Check if a value is either a standard array or typed array.\n * @param {*} value The value to check.\n * @returns {value is (Array | TypedArray)}\n * True if value is an array, false otherwise.\n */\nexport function isArray(value) {\n return Array.isArray(value) || isTypedArray(value);\n}\n\n/**\n * Check if a value is an array type (constructor) for 64-bit integers,\n * one of BigInt64Array or BigUint64Array.\n * @param {*} value The value to check.\n * @returns {value is Int64ArrayConstructor}\n * True if value is a 64-bit array type, false otherwise.\n */\nexport function isInt64ArrayType(value) {\n return value === int64Array || value === uint64Array;\n}\n\n/**\n * Determine the correct index into an offset array for a given\n * full column row index. Assumes offset indices can be manipulated\n * as 32-bit signed integers.\n * @param {IntegerArray} offsets The offsets array.\n * @param {number} index The full column row index.\n */\nexport function bisect(offsets, index) {\n let a = 0;\n let b = offsets.length;\n if (b <= 2147483648) { // 2 ** 31\n // fast version, use unsigned bit shift\n // array length fits within 32-bit signed integer\n do {\n const mid = (a + b) >>> 1;\n if (offsets[mid] <= index) a = mid + 1;\n else b = mid;\n } while (a < b);\n } else {\n // slow version, use division and truncate\n // array length exceeds 32-bit signed integer\n do {\n const mid = Math.trunc((a + b) / 2);\n if (offsets[mid] <= index) a = mid + 1;\n else b = mid;\n } while (a < b);\n }\n return a;\n}\n\n/**\n * Compute a 64-bit aligned buffer size.\n * @param {number} length The starting size.\n * @param {number} bpe Bytes per element.\n * @returns {number} The aligned size.\n */\nfunction align64(length, bpe = 1) {\n return (((length * bpe) + 7) & ~7) / bpe;\n}\n\n/**\n * Return a 64-bit aligned version of the array.\n * @template {TypedArray} T\n * @param {T} array The array.\n * @param {number} length The current array length.\n * @returns {T} The aligned array.\n */\nexport function align(array, length = array.length) {\n const alignedLength = align64(length, array.BYTES_PER_ELEMENT);\n return array.length > alignedLength ? /** @type {T} */ (array.subarray(0, alignedLength))\n : array.length < alignedLength ? resize(array, alignedLength)\n : array;\n}\n\n/**\n * Resize a typed array to exactly the specified length.\n * @template {TypedArray} T\n * @param {T} array The array.\n * @param {number} newLength The new length.\n * @param {number} [offset] The offset at which to copy the old array.\n * @returns {T} The resized array.\n */\nexport function resize(array, newLength, offset = 0) {\n // @ts-ignore\n const newArray = new array.constructor(newLength);\n newArray.set(array, offset);\n return newArray;\n}\n\n/**\n * Grow a typed array to accommdate a minimum index. The array size is\n * doubled until it exceeds the minimum index.\n * @template {TypedArray} T\n * @param {T} array The array.\n * @param {number} index The minimum index.\n * @param {boolean} [shift] Flag to shift copied bytes to back of array.\n * @returns {T} The resized array.\n */\nexport function grow(array, index, shift) {\n while (array.length <= index) {\n array = resize(array, array.length << 1, shift ? array.length : 0);\n }\n return array;\n}\n","/**\n * Check if a value is a Date instance\n * @param {*} value The value to check.\n * @returns {value is Date} True if value is a Date, false otherwise.\n */\nexport function isDate(value) {\n return value instanceof Date;\n}\n\n/**\n * Check if a value is iterable.\n * @param {*} value The value to check.\n * @returns {value is Iterable} True if value is iterable, false otherwise.\n */\nexport function isIterable(value) {\n return typeof value[Symbol.iterator] === 'function';\n}\n\n/**\n * Return the input value if it passes a test.\n * Otherwise throw an error using the given message generator.\n * @template T\n * @param {T} value The value to check.\n * @param {(value: T) => boolean} test The test function.\n * @param {(value: *) => string} message Message generator.\n * @returns {T} The input value.\n * @throws if the value does not pass the test\n */\nexport function check(value, test, message) {\n if (test(value)) return value;\n throw new Error(message(value));\n}\n\n/**\n * Return the input value if it exists in the provided set.\n * Otherwise throw an error using the given message generator.\n * @template T\n * @param {T} value The value to check.\n * @param {T[] | Record<string,T>} set The set of valid values.\n * @param {(value: *) => string} [message] Message generator.\n * @returns {T} The input value.\n * @throws if the value is not included in the set\n */\nexport function checkOneOf(value, set, message) {\n set = Array.isArray(set) ? set : Object.values(set);\n return check(\n value,\n (value) => set.includes(value),\n message ?? (() => `${value} must be one of ${set}`)\n );\n}\n\n/**\n * Return the first object key that pairs with the given value.\n * @param {Record<string,any>} object The object to search.\n * @param {any} value The value to lookup.\n * @returns {string} The first matching key, or '<Unknown>' if not found.\n */\nexport function keyFor(object, value) {\n for (const [key, val] of Object.entries(object)) {\n if (val === value) return key;\n }\n return '<Unknown>';\n}\n","/**\n * @import { BinaryType, BinaryViewType, BoolType, DataType, DateType, DateUnit_, DecimalType, DictionaryType, DurationType, Field, FixedSizeBinaryType, FixedSizeListType, FloatType, IntBitWidth, IntervalType, IntervalUnit_, IntType, LargeBinaryType, LargeListType, LargeListViewType, LargeUtf8Type, ListType, ListViewType, MapType, NullType, Precision_, RunEndEncodedType, StructType, TimestampType, TimeType, TimeUnit_, UnionMode_, UnionType, Utf8Type, Utf8ViewType } from './types.js'\n */\nimport { DateUnit, IntervalUnit, Precision, TimeUnit, Type, UnionMode } from './constants.js';\nimport { intArrayType, float32Array, float64Array, int32Array, int64Array, uint16Array, uint64Array } from './util/arrays.js';\nimport { check, checkOneOf, keyFor } from './util/objects.js';\n\n/**\n * @typedef {Field | DataType} FieldInput\n */\n\nexport const invalidDataType = (typeId) =>\n `Unsupported data type: \"${keyFor(Type, typeId)}\" (id ${typeId})`;\n\n/**\n * Return a new field instance for use in a schema or type definition. A field\n * represents a field name, data type, and additional metadata. Fields are used\n * to represent child types within nested types like List, Struct, and Union.\n * @param {string} name The field name.\n * @param {DataType} type The field data type.\n * @param {boolean} [nullable=true] Flag indicating if the field is nullable\n * (default `true`).\n * @param {Map<string,string>|null} [metadata=null] Custom field metadata\n * annotations (default `null`).\n * @returns {Field} The field instance.\n */\nexport const field = (name, type, nullable = true, metadata = null) => ({\n name,\n type,\n nullable,\n metadata\n});\n\n/**\n * Checks if a value is a field instance.\n * @param {any} value\n * @returns {value is Field}\n */\nfunction isField(value) {\n return Object.hasOwn(value, 'name') && isDataType(value.type)\n}\n\n/**\n * Checks if a value is a data type instance.\n * @param {any} value\n * @returns {value is DataType}\n */\nfunction isDataType(value) {\n return typeof value?.typeId === 'number';\n}\n\n/**\n * Return a field instance from a field or data type input.\n * @param {FieldInput} value\n * The value to map to a field.\n * @param {string} [defaultName] The default field name.\n * @param {boolean} [defaultNullable=true] The default nullable value.\n * @returns {Field} The field instance.\n */\nfunction asField(value, defaultName = '', defaultNullable = true) {\n return isField(value)\n ? value\n : field(\n defaultName,\n check(value, isDataType, () => `Data type expected.`),\n defaultNullable\n );\n}\n\n/////\n\n/**\n * Return a basic type with only a type id.\n * @template {typeof Type[keyof typeof Type]} T\n * @param {T} typeId The type id.\n */\nconst basicType = (typeId) => ({ typeId });\n\n/**\n * Return a Dictionary data type instance. A dictionary type consists of a\n * dictionary of values (which may be of any type) and corresponding integer\n * indices that reference those values. If values are repeated, a dictionary\n * encoding can provide substantial space savings. In the IPC format,\n * dictionary indices reside alongside other columns in a record batch, while\n * dictionary values are written to special dictionary batches, linked by a\n * unique dictionary *id*.\n * @param {DataType} type The data type of dictionary\n * values.\n * @param {IntType} [indexType] The data type of\n * dictionary indices. Must be an integer type (default `int32`).\n * @param {boolean} [ordered=false] Indicates if dictionary values are\n * ordered (default `false`).\n * @param {number} [id=-1] The dictionary id. The default value (-1) indicates\n * the dictionary applies to a single column only. Provide an explicit id in\n * order to reuse a dictionary across columns when building, in which case\n * different dictionaries *must* have different unique ids. All dictionary\n * ids are later resolved (possibly to new values) upon IPC encoding.\n * @returns {DictionaryType}\n */\nexport const dictionary = (type, indexType, ordered = false, id = -1) => ({\n typeId: Type.Dictionary,\n id,\n dictionary: type,\n indices: indexType || int32(),\n ordered\n});\n\n/**\n * Return a Null data type instance. Null data requires no storage and all\n * extracted values are `null`.\n * @returns {NullType} The null data type.\n */\nexport const nullType = () => basicType(Type.Null);\n\n/**\n * Return an Int data type instance.\n * @param {IntBitWidth} [bitWidth=32] The integer bit width.\n * One of `8`, `16`, `32` (default), or `64`.\n * @param {boolean} [signed=true] Flag for signed or unsigned integers\n * (default `true`).\n * @returns {IntType} The integer data type.\n */\nexport const int = (bitWidth = 32, signed = true) => ({\n typeId: Type.Int,\n bitWidth: checkOneOf(bitWidth, [8, 16, 32, 64]),\n signed,\n values: intArrayType(bitWidth, signed)\n});\n/**\n * Return an Int data type instance for 8 bit signed integers.\n * @returns {IntType} The integer data type.\n */\nexport const int8 = () => int(8);\n/**\n * Return an Int data type instance for 16 bit signed integers.\n * @returns {IntType} The integer data type.\n */\nexport const int16 = () => int(16);\n/**\n * Return an Int data type instance for 32 bit signed integers.\n * @returns {IntType} The integer data type.\n */\nexport const int32 = () => int(32);\n/**\n * Return an Int data type instance for 64 bit signed integers.\n * @returns {IntType} The integer data type.\n */\nexport const int64 = () => int(64);\n/**\n * Return an Int data type instance for 8 bit unsigned integers.\n * @returns {IntType} The integer data type.\n */\nexport const uint8 = () => int(8, false);\n/**\n * Return an Int data type instance for 16 bit unsigned integers.\n * @returns {IntType} The integer data type.\n */\nexport const uint16 = () => int(16, false);\n/**\n * Return an Int data type instance for 32 bit unsigned integers.\n * @returns {IntType} The integer data type.\n */\nexport const uint32 = () => int(32, false);\n/**\n * Return an Int data type instance for 64 bit unsigned integers.\n * @returns {IntType} The integer data type.\n */\nexport const uint64 = () => int(64, false);\n\n/**\n * Return a Float data type instance for floating point numbers.\n * @param {Precision_} [precision=2] The floating point\n * precision. One of `Precision.HALF` (16-bit), `Precision.SINGLE` (32-bit)\n * or `Precision.DOUBLE` (64-bit, default).\n * @returns {FloatType} The floating point data type.\n */\nexport const float = (precision = 2) => ({\n typeId: Type.Float,\n precision: checkOneOf(precision, Precision),\n values: [uint16Array, float32Array, float64Array][precision]\n});\n/**\n * Return a Float data type instance for half-precision (16 bit) numbers.\n * @returns {FloatType} The floating point data type.\n */\nexport const float16 = () => float(Precision.HALF);\n/**\n * Return a Float data type instance for single-precision (32 bit) numbers.\n * @returns {FloatType} The floating point data type.\n */\nexport const float32 = () => float(Precision.SINGLE);\n/**\n * Return a Float data type instance for double-precision (64 bit) numbers.\n * @returns {FloatType} The floating point data type.\n */\nexport const float64 = () => float(Precision.DOUBLE);\n\n/**\n * Return a Binary data type instance for variably-sized opaque binary data\n * with 32-bit offsets.\n * @returns {BinaryType} The binary data type.\n */\nexport const binary = () => ({\n typeId: Type.Binary,\n offsets: int32Array\n});\n\n/**\n * Return a Utf8 data type instance for Unicode string data.\n * [UTF-8](https://en.wikipedia.org/wiki/UTF-8) code points are stored as\n * binary data.\n * @returns {Utf8Type} The utf8 data type.\n */\nexport const utf8 = () => ({\n typeId: Type.Utf8,\n offsets: int32Array\n});\n\n/**\n * Return a Bool data type instance. Bool values are stored compactly in\n * bitmaps with eight values per byte.\n * @returns {BoolType} The bool data type.\n */\nexport const bool = () => basicType(Type.Bool);\n\n/**\n * Return a Decimal data type instance. Decimal values are represented as 32,\n * 64, 128, or 256 bit integers in two's complement. Decimals are fixed point\n * numbers with a set *precision* (total number of decimal digits) and *scale*\n * (number of fractional digits). For example, the number `35.42` can be\n * represented as `3542` with *precision* ≥ 4 and *scale* = 2.\n * @param {number} precision The decimal precision: the total number of\n * decimal digits that can be represented.\n * @param {number} scale The number of fractional digits, beyond the\n * decimal point.\n * @param {32 | 64 | 128 | 256} [bitWidth] The decimal bit width.\n * One of 32, 64, 128 (default), or 256.\n * @returns {DecimalType} The decimal data type.\n */\nexport const decimal = (precision, scale, bitWidth = 128) => ({\n typeId: Type.Decimal,\n precision,\n scale,\n bitWidth: checkOneOf(bitWidth, [32, 64, 128, 256]),\n values: bitWidth === 32 ? int32Array : uint64Array\n});\n/**\n * Return an Decimal data type instance with a bit width of 32.\n * @param {number} precision The decimal precision: the total number of\n * decimal digits that can be represented.\n * @param {number} scale The number of fractional digits, beyond the\n * decimal point.\n * @returns {DecimalType} The decimal data type.\n */\nexport const decimal32 = (precision, scale) => decimal(precision, scale, 32);\n/**\n * Return an Decimal data type instance with a bit width of 64.\n * @param {number} precision The decimal precision: the total number of\n * decimal digits that can be represented.\n * @param {number} scale The number of fractional digits, beyond the\n * decimal point.\n * @returns {DecimalType} The decimal data type.\n */\nexport const decimal64 = (precision, scale) => decimal(precision, scale, 64);\n/**\n * Return an Decimal data type instance with a bit width of 128.\n * @param {number} precision The decimal precision: the total number of\n * decimal digits that can be represented.\n * @param {number} scale The number of fractional digits, beyond the\n * decimal point.\n * @returns {DecimalType} The decimal data type.\n */\nexport const decimal128 = (precision, scale) => decimal(precision, scale, 128);\n/**\n * Return an Decimal data type instance with a bit width of 256.\n * @param {number} precision The decimal precision: the total number of\n * decimal digits that can be represented.\n * @param {number} scale The number of fractional digits, beyond the\n * decimal point.\n * @returns {DecimalType} The decimal data type.\n */\nexport const decimal256 = (precision, scale) => decimal(precision, scale, 256);\n\n/**\n * Return a Date data type instance. Date values are 32-bit or 64-bit signed\n * integers representing elapsed time since the UNIX epoch (Jan 1, 1970 UTC),\n * either in units of days (32 bits) or milliseconds (64 bits, with values\n * evenly divisible by 86400000).\n * @param {DateUnit_} unit The date unit.\n * One of `DateUnit.DAY` or `DateUnit.MILLISECOND`.\n * @returns {DateType} The date data type.\n */\nexport const date = (unit) => ({\n typeId: Type.Date,\n unit: checkOneOf(unit, DateUnit),\n values: unit === DateUnit.DAY ? int32Array : int64Array\n});\n/**\n * Return a Date data type instance with units of days.\n * @returns {DateType} The date data type.\n */\nexport const dateDay = () => date(DateUnit.DAY);\n/**\n * Return a Date data type instance with units of milliseconds.\n * @returns {DateType} The date data type.\n */\nexport const dateMillisecond = () => date(DateUnit.MILLISECOND);\n\n/**\n * Return a Time data type instance, stored in one of four *unit*s: seconds,\n * milliseconds, microseconds or nanoseconds. The integer *bitWidth* is\n * inferred from the *unit* and is 32 bits for seconds and milliseconds or\n * 64 bits for microseconds and nanoseconds. The allowed values are between 0\n * (inclusive) and 86400 (=24*60*60) seconds (exclusive), adjusted for the\n * time unit (for example, up to 86400000 exclusive for the\n * `DateUnit.MILLISECOND` unit.\n *\n * This definition doesn't allow for leap seconds. Time values from\n * measurements with leap seconds will need to be corrected when ingesting\n * into Arrow (for example by replacing the value 86400 with 86399).\n * @param {TimeUnit_} unit The time unit.\n * One of `TimeUnit.SECOND`, `TimeUnit.MILLISECOND` (default),\n * `TimeUnit.MICROSECOND`, or `TimeUnit.NANOSECOND`.\n * @returns {TimeType} The time data type.\n */\nexport const time = (unit = TimeUnit.MILLISECOND) => {\n unit = checkOneOf(unit, TimeUnit);\n const bitWidth = unit === TimeUnit.SECOND || unit === TimeUnit.MILLISECOND ? 32 : 64;\n return {\n typeId: Type.Time,\n unit,\n bitWidth,\n values: bitWidth === 32 ? int32Array : int64Array\n };\n};\n/**\n * Return a Time data type instance, represented as seconds.\n * @returns {TimeType} The time data type.\n */\nexport const timeSecond = () => time(TimeUnit.SECOND);\n/**\n * Return a Time data type instance, represented as milliseconds.\n * @returns {TimeType} The time data type.\n */\nexport const timeMillisecond = () => time(TimeUnit.MILLISECOND);\n/**\n * Return a Time data type instance, represented as microseconds.\n * @returns {TimeType} The time data type.\n */\nexport const timeMicrosecond = () => time(TimeUnit.MICROSECOND);\n/**\n * Return a Time data type instance, represented as nanoseconds.\n * @returns {TimeType} The time data type.\n */\nexport const timeNanosecond = () => time(TimeUnit.NANOSECOND);\n\n/**\n * Return a Timestamp data type instance. Timestamp values are 64-bit signed\n * integers representing an elapsed time since a fixed epoch, stored in either\n * of four units: seconds, milliseconds, microseconds or nanoseconds, and are\n * optionally annotated with a timezone. Timestamp values do not include any\n * leap seconds (in other words, all days are considered 86400 seconds long).\n * @param {TimeUnit_} [unit] The time unit.\n * One of `TimeUnit.SECOND`, `TimeUnit.MILLISECOND` (default),\n * `TimeUnit.MICROSECOND`, or `TimeUnit.NANOSECOND`.\n * @param {string|null} [timezone=null] An optional string for the name of a\n * timezone. If provided, the value should either be a string as used in the\n * Olson timezone database (the \"tz database\" or \"tzdata\"), such as\n * \"America/New_York\", or an absolute timezone offset of the form \"+XX:XX\" or\n * \"-XX:XX\", such as \"+07:30\".Whether a timezone string is present indicates\n * different semantics about the data.\n * @returns {TimestampType} The time data type.\n */\nexport const timestamp = (unit = TimeUnit.MILLISECOND, timezone = null) => ({\n typeId: Type.Timestamp,\n unit: checkOneOf(unit, TimeUnit),\n timezone,\n values: int64Array\n});\n\n/**\n * Return an Interval type instance. Values represent calendar intervals stored\n * as integers for each date part. The supported *unit*s are year/moth,\n * day/time, and month/day/nanosecond intervals.\n *\n * `IntervalUnit.YEAR_MONTH` indicates the number of elapsed whole months,\n * stored as 32-bit signed integers.\n *\n * `IntervalUnit.DAY_TIME` indicates the number of elapsed days and\n * milliseconds (no leap seconds), stored as 2 contiguous 32-bit signed\n * integers (8-bytes in total).\n *\n * `IntervalUnit.MONTH_DAY_NANO` is a triple of the number of elapsed months,\n * days, and nanoseconds. The values are stored contiguously in 16-byte blocks.\n * Months and days are encoded as 32-bit signed integers and nanoseconds is\n * encoded as a 64-bit signed integer. Nanoseconds does not allow for leap\n * seconds. Each field is independent (e.g. there is no constraint that\n * nanoseconds have the same sign as days or that the quantity of nanoseconds\n * represents less than a day's worth of time).\n * @param {IntervalUnit_} unit The interval unit.\n * One of `IntervalUnit.YEAR_MONTH`, `IntervalUnit.DAY_TIME`, or\n * `IntervalUnit.MONTH_DAY_NANO` (default).\n * @returns {IntervalType} The interval data type.\n */\nexport const interval = (unit = IntervalUnit.MONTH_DAY_NANO) => ({\n typeId: Type.Interval,\n unit: checkOneOf(unit, IntervalUnit),\n values: unit === IntervalUnit.MONTH_DAY_NANO ? undefined : int32Array\n});\n\n/**\n * Return a List data type instance, representing variably-sized lists\n * (arrays) with 32-bit offsets. A list has a single child data type for\n * list entries. Lists are represented using integer offsets that indicate\n * list extents within a single child array containing all list values.\n * @param {FieldInput} child The child (list item) field or data type.\n * @returns {ListType} The list data type.\n */\nexport const list = (child) => ({\n typeId: Type.List,\n children: [ asField(child) ],\n offsets: int32Array\n});\n\n/**\n * Return a Struct data type instance. A struct consists of multiple named\n * child data types. Struct values are stored as parallel child batches, one\n * per child type, and extracted to standard JavaScript objects.\n * @param {Field[] | Record<string, DataType>} children\n * An array of property fields, or an object mapping property names to data\n * types. If an object, the instantiated fields are assumed to be nullable\n * and have no metadata.\n * @returns {StructType} The struct data type.\n */\nexport const struct = (children) => ({\n typeId: Type.Struct,\n children: Array.isArray(children) && isField(children[0])\n ? /** @type {Field[]} */ (children)\n : Object.entries(children).map(([name, type]) => field(name, type))\n});\n\n/**\n * Return a Union type instance. A union is a complex type with parallel\n * *children* data types. Union values are stored in either a sparse\n * (`UnionMode.Sparse`) or dense (`UnionMode.Dense`) layout *mode*. In a\n * sparse layout, child types are stored in parallel arrays with the same\n * lengths, resulting in many unused, empty values. In a dense layout, child\n * types have variable lengths and an offsets array is used to index the\n * appropriate value.\n *\n * By default, ids in the type vector refer to the index in the children\n * array. Optionally, *typeIds* provide an indirection between the child\n * index and the type id. For each child, `typeIds[index]` is the id used\n * in the type vector. The *typeIdForValue* argument provides a lookup\n * function for mapping input data to the proper child type id, and is\n * required if using builder methods.\n * @param {UnionMode_} mode The union mode.\n * One of `UnionMode.Sparse` or `UnionMode.Dense`.\n * @param {FieldInput[]} children The children fields or data types.\n * Types are mapped to nullable fields with no metadata.\n * @param {number[]} [typeIds] Children type ids, in the same order as the\n * children types. Type ids provide a level of indirection over children\n * types. If not provided, the children indices are used as the type ids.\n * @param {(value: any, index: number) => number} [typeIdForValue]\n * A function that takes an arbitrary value and a row index and returns a\n * correponding union type id. Required by builder methods.\n * @returns {UnionType} The union data type.\n */\nexport const union = (mode, children, typeIds, typeIdForValue) => {\n typeIds ??= children.map((v, i) => i);\n return {\n typeId: Type.Union,\n mode: checkOneOf(mode, UnionMode),\n typeIds,\n typeMap: typeIds.reduce((m, id, i) => ((m[id] = i), m), {}),\n children: children.map((v, i) => asField(v, `_${i}`)),\n typeIdForValue,\n offsets: int32Array,\n };\n};\n\n/**\n * Create a FixedSizeBinary data type instance for opaque binary data where\n * each entry has the same fixed size.\n * @param {number} stride The fixed size in bytes.\n * @returns {FixedSizeBinaryType} The fixed size binary data type.\n */\nexport const fixedSizeBinary = (stride) => ({\n typeId: Type.FixedSizeBinary,\n stride\n});\n\n/**\n * Return a FixedSizeList type instance for list (array) data where every list\n * has the same fixed size. A list has a single child data type for list\n * entries. Fixed size lists are represented as a single child array containing\n * all list values, indexed using the known stride.\n * @param {FieldInput} child The list item data type.\n * @param {number} stride The fixed list size.\n * @returns {FixedSizeListType} The fixed size list data type.\n */\nexport const fixedSizeList = (child, stride) => ({\n typeId: Type.FixedSizeList,\n stride,\n children: [ asField(child) ]\n});\n\n/**\n * Internal method to create a Map type instance.\n * @param {boolean} keysSorted Flag indicating if the map keys are sorted.\n * @param {Field} child The child fields.\n * @returns {MapType} The map data type.\n */\nexport const mapType = (keysSorted, child) => ({\n typeId: Type.Map,\n keysSorted,\n children: [child],\n offsets: int32Array\n});\n\n/**\n * Return a Map data type instance representing collections of key-value pairs.\n * A Map is a logical nested type that is represented as a list of key-value\n * structs. The key and value types are not constrained, so the application is\n * responsible for ensuring that the keys are hashable and unique, and that\n * keys are properly sorted if *keysSorted* is `true`.\n * @param {FieldInput} keyField The map key field or data type.\n * @param {FieldInput} valueField The map value field or data type.\n * @param {boolean} [keysSorted=false] Flag indicating if the map keys are\n * sorted (default `false`).\n * @returns {MapType} The map data type.\n */\nexport const map = (keyField, valueField, keysSorted = false) => mapType(\n keysSorted,\n field(\n 'entries',\n struct([ asField(keyField, 'key', false), asField(valueField, 'value') ]),\n false\n )\n);\n\n/**\n * Return a Duration data type instance. Durations represent an absolute length\n * of time unrelated to any calendar artifacts. The resolution defaults to\n * millisecond, but can be any of the other `TimeUnit` values. This type is\n * always represented as a 64-bit integer.\n * @param {TimeUnit_} unit\n * @returns {DurationType} The duration data type.\n */\nexport const duration = (unit = TimeUnit.MILLISECOND) => ({\n typeId: Type.Duration,\n unit: checkOneOf(unit, TimeUnit),\n values: int64Array\n});\n\n/**\n * Return a LargeBinary data type instance for variably-sized opaque binary\n * data with 64-bit offsets, allowing representation of extremely large data\n * values.\n * @returns {LargeBinaryType} The large binary data type.\n */\nexport const largeBinary = () => ({\n typeId: Type.LargeBinary,\n offsets: int64Array\n});\n\n/**\n * Return a LargeUtf8 data type instance for Unicode string data of variable\n * length with 64-bit offsets, allowing representation of extremely large data\n * values. [UTF-8](https://en.wikipedia.org/wiki/UTF-8) code points are stored\n * as binary data.\n * @returns {LargeUtf8Type} The large utf8 data type.\n */\nexport const largeUtf8 = () => ({\n typeId: Type.LargeUtf8,\n offsets: int64Array\n});\n\n/**\n * Return a LargeList data type instance, representing variably-sized lists\n * (arrays) with 64-bit offsets, allowing representation of extremely large\n * data values. A list has a single child data type for list entries. Lists\n * are represented using integer offsets that indicate list extents within a\n * single child array containing all list values.\n * @param {FieldInput} child The child (list item) field or data type.\n * @returns {LargeListType} The large list data type.\n */\nexport const largeList = (child) => ({\n typeId: Type.LargeList,\n children: [ asField(child) ],\n offsets: int64Array\n});\n\n/**\n * Return a RunEndEncoded data type instance, which compresses data by\n * representing consecutive repeated values as a run. This data type uses two\n * child arrays, `run_ends` and `values`. The `run_ends` child array must be\n * a 16, 32, or 64 bit integer array which encodes the indices at which the\n * run with the value in each corresponding index in the values child array\n * ends. Like list and struct types, the `values` array can be of any type.\n * @param {FieldInput} runsField The run-ends field or data type.\n * @param {FieldInput} valuesField The values field or data type.\n * @returns {RunEndEncodedType} The large list data type.\n */\nexport const runEndEncoded = (runsField, valuesField) => ({\n typeId: Type.RunEndEncoded,\n children: [\n check(\n asField(runsField, 'run_ends'),\n (field) => field.type.typeId === Type.Int,\n () => 'Run-ends must have an integer type.'\n ),\n asField(valuesField, 'values')\n ]\n});\n\n/**\n * Return a BinaryView data type instance. BinaryView data is logically the\n * same as the Binary type, but the internal representation uses a view struct\n * that contains the string length and either the string's entire data inline\n * (for small strings) or an inlined prefix, an index of another buffer, and an\n * offset pointing to a slice in that buffer (for non-small strings).\n *\n * Flechette can encode and decode BinaryView data; however, Flechette does\n * not currently support building BinaryView columns from JavaScript values.\n * @returns {BinaryViewType} The binary view data type.\n */\nexport const binaryView = () => /** @type {BinaryViewType} */\n (basicType(Type.BinaryView));\n\n/**\n * Return a Utf8View data type instance. Utf8View data is logically the same as\n * the Utf8 type, but the internal representation uses a view struct that\n * contains the string length and either the string's entire data inline (for\n * small strings) or an inlined prefix, an index of another buffer, and an\n * offset pointing to a slice in that buffer (for non-small strings).\n *\n * Flechette can encode and decode Utf8View data; however, Flechette does\n * not currently support building Utf8View columns from JavaScript values.\n * @returns {Utf8ViewType} The utf8 view data type.\n */\nexport const utf8View = () => /** @type {Utf8ViewType} */\n (basicType(Type.Utf8View));\n\n/**\n * Return a ListView data type instance, representing variably-sized lists\n * (arrays) with 32-bit offsets. ListView data represents the same logical\n * types that List can, but contains both offsets and sizes allowing for\n * writes in any order and sharing of child values among list values.\n *\n * Flechette can encode and decode ListView data; however, Flechette does not\n * currently support building ListView columns from JavaScript values.\n * @param {FieldInput} child The child (list item) field or data type.\n * @returns {ListViewType} The list view data type.\n */\nexport const listView = (child) => ({\n typeId: Type.ListView,\n children: [ asField(child, 'value') ],\n offsets: int32Array\n});\n\n/**\n * Return a LargeListView data type instance, representing variably-sized lists\n * (arrays) with 64-bit offsets, allowing representation of extremely large\n * data values. LargeListView data represents the same logical types that\n * LargeList can, but contains both offsets and sizes allowing for writes\n * in any order and sharing of child values among list values.\n *\n * Flechette can encode and decode LargeListView data; however, Flechette does\n * not currently support building LargeListView columns from JavaScript values.\n * @param {FieldInput} child The child (list item) field or data type.\n * @returns {LargeListViewType} The large list view data type.\n */\nexport const largeListView = (child) => ({\n typeId: Type.LargeListView,\n children: [ asField(child, 'value') ],\n offsets: int64Array\n});\n","/**\n * @import { TimeUnit_, TypedArray } from '../types.js';\n */\nimport { float64Array, int32Array, int64Array, isInt64ArrayType, uint32Array, uint8Array } from './arrays.js';\nimport { TimeUnit } from '../constants.js';\n\n// typed arrays over a shared buffer to aid binary conversion\nconst f64 = new float64Array(2);\nconst buf = f64.buffer;\nconst i64 = new int64Array(buf);\nconst u32 = new uint32Array(buf);\nconst i32 = new int32Array(buf);\nconst u8 = new uint8Array(buf);\n\n/**\n * Return a value unchanged.\n * @template T\n * @param {T} value The value.\n * @returns {T} The value.\n */\nexport function identity(value) {\n return value;\n}\n\n/**\n * Return a value coerced to a BigInt.\n * @param {*} value The value.\n * @returns {bigint} The BigInt value.\n */\nexport function toBigInt(value) {\n return BigInt(value);\n}\n\n/**\n * Return an offset conversion method for the given data type.\n * @param {{ offsets: TypedArray}} type The array type.\n */\nexport function toOffset(type) {\n return isInt64ArrayType(type) ? toBigInt : identity;\n}\n\n/**\n * Return the number of days from a millisecond timestamp.\n * @param {number} value The millisecond timestamp.\n * @returns {number} The number of days.\n */\nexport function toDateDay(value) {\n return (value / 864e5) | 0;\n}\n\n/**\n * Return a timestamp conversion method for the given time unit.\n * @param {TimeUnit_} unit The time unit.\n * @returns {(value: number) => bigint} The conversion method.\n */\nexport function toTimestamp(unit) {\n return unit === TimeUnit.SECOND ? value => toBigInt(value / 1e3)\n : unit === TimeUnit.MILLISECOND ? toBigInt\n : unit === TimeUnit.MICROSECOND ? value => toBigInt(value * 1e3)\n : value => toBigInt(value * 1e6);\n}\n\n/**\n * Write month/day/nanosecond interval to a byte buffer.\n * @param {Array | Float64Array} interval The interval data.\n * @returns {Uint8Array} A byte buffer with the interval data.\n * The returned buffer is reused across calls, and so should be\n * copied to a target buffer immediately.\n */\nexport function toMonthDayNanoBytes([m, d, n]) {\n i32[0] = m;\n i32[1] = d;\n i64[1] = toBigInt(n);\n return u8;\n}\n\n/**\n * Coerce a bigint value to a number. Throws an error if the bigint value\n * lies outside the range of what a number can precisely represent.\n * @param {bigint} value The value to check and possibly convert.\n * @returns {number} The converted number value.\n */\nexport function toNumber(value) {\n if (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER) {\n throw Error(`BigInt exceeds integer number representation: ${value}`);\n }\n return Number(value);\n}\n\n/**\n * Divide one BigInt value by another, and return the result as a number.\n * The division may involve unsafe integers and a loss of precision.\n * @param {bigint} num The numerator.\n * @param {bigint} div The divisor.\n * @returns {number} The result of the division as a floating point number.\n */\nexport function divide(num, div) {\n return Number(num / div) + Number(num % div) / Number(div);\n}\n\n/**\n * Return a 32-bit decimal conversion method for the given decimal scale.\n * @param {number} scale The scale mapping fractional digits to integers.\n * @returns {(value: number|bigint) => number} A conversion method that maps\n * floating point numbers to 32-bit decimals.\n */\nexport function toDecimal32(scale) {\n return (value) => typeof value === 'bigint'\n ? Number(value)\n : Math.trunc(value * scale);\n}\n\n/**\n * Convert a floating point number or bigint to decimal bytes.\n * @param {number|bigint} value The number to encode. If a bigint, we assume\n * it already represents the decimal in integer form with the correct scale.\n * Otherwise, we assume a float that requires scaled integer conversion.\n * @param {BigUint64Array} buf The uint64 array to write to.\n * @param {number} offset The starting index offset into the array.\n * @param {number} stride The stride of an encoded decimal, in 64-bit steps.\n * @param {number} scale The scale mapping fractional digits to integers.\n */\nexport function toDecimal(value, buf, offset, stride, scale) {\n const v = typeof value === 'bigint'\n ? value\n : toBigInt(Math.trunc(value * scale));\n // assignment into uint64array performs needed truncation for us\n buf[offset] = v;\n if (stride > 1) {\n buf[offset + 1] = (v >> 64n);\n if (stride > 2) {\n buf[offset + 2] = (v >> 128n);\n buf[offset + 3] = (v >> 192n);\n }\n }\n}\n\n// helper method to extract uint64 values from bigints\nconst asUint64 = v => BigInt.asUintN(64, v);\n\n/**\n * Convert a 64-bit decimal value to a bigint.\n * @param {BigUint64Array} buf The uint64 array containing the decimal bytes.\n * @param {number} offset The starting index offset into the array.\n * @returns {bigint} The converted decimal as a bigint, such that all\n * fractional digits are scaled up to integers (for example, 1.12 -> 112).\n */\nexport function fromDecimal64(buf, offset) {\n return BigInt.asIntN(64, buf[offset]);\n}\n\n/**\n * Convert a 128-bit decimal value to a bigint.\n * @param {BigUint64Array} buf The uint64 array containing the decimal bytes.\n * @param {number} offset The starting index offset into the array.\n * @returns {bigint} The converted decimal as a bigint, such that all\n * fractional digits are scaled up to integers (for example, 1.12 -> 112).\n */\nexport function fromDecimal128(buf, offset) {\n const i = offset << 1;\n let x;\n if (BigInt.asIntN(64, buf[i + 1]) < 0) {\n x = asUint64(~buf[i]) | (asUint64(~buf[i + 1]) << 64n);\n x = -(x + 1n);\n } else {\n x = buf[i] | (buf[i + 1] << 64n);\n }\n return x;\n}\n\n/**\n * Convert a 256-bit decimal value to a bigint.\n * @param {BigUint64Array} buf The uint64 array containing the decimal bytes.\n * @param {number} offset The starting index offset into the array.\n * @returns {bigint} The converted decimal as a bigint, such that all\n * fractional digits are scaled up to integers (for example, 1.12 -> 112).\n */\nexport function fromDecimal256(buf, offset) {\n const i = offset << 2;\n let x;\n if (BigInt.asIntN(64, buf[i + 3]) < 0) {\n x = asUint64(~buf[i])\n | (asUint64(~buf[i + 1]) << 64n)\n | (asUint64(~buf[i + 2]) << 128n)\n | (asUint64(~buf[i + 3]) << 192n);\n x = -(x + 1n);\n } else {\n x = buf[i]\n | (buf[i + 1] << 64n)\n | (buf[i + 2] << 128n)\n | (buf[i + 3] << 192n);\n }\n return x;\n}\n\n/**\n * Convert a 16-bit float from integer bytes to a number.\n * Adapted from https://github.com/apache/arrow/blob/main/js/src/util/math.ts\n * @param {number} value The float as a 16-bit integer.\n * @returns {number} The converted 64-bit floating point number.\n */\nexport function fromFloat16(value) {\n const expo = (value & 0x7C00) >> 10;\n const sigf = (value & 0x03FF) / 1024;\n const sign = (-1) ** ((value & 0x8000) >> 15);\n switch (expo) {\n case 0x1F: return sign * (sigf ? Number.NaN : 1 / 0);\n case 0x00: return sign * (sigf ? 6.103515625e-5 * sigf : 0);\n }\n return sign * (2 ** (expo - 15)) * (1 + sigf);\n}\n\n/**\n * Convert a number to a 16-bit float as integer bytes..\n * Inspired by numpy's `npy_double_to_half`:\n * https://github.com/numpy/numpy/blob/5a5987291dc95376bb098be8d8e5391e89e77a2c/numpy/core/src/npymath/halffloat.c#L43\n * Adapted from https://github.com/apache/arrow/blob/main/js/src/util/math.ts\n * @param {number} value The 64-bit floating point number to convert.\n * @returns {number} The converted 16-bit integer.\n */\nexport function toFloat16(value) {\n if (value !== value) return 0x7E00; // NaN\n f64[0] = value;\n\n // Magic numbers:\n // 0x80000000 = 10000000 00000000 00000000 00000000 -- masks the 32nd bit\n // 0x7ff00000 = 01111111 11110000 00000000 00000000 -- masks the 21st-31st bits\n // 0x000fffff = 00000000 00001111 11111111 11111111 -- masks the 1st-20th bit\n const sign = (u32[1] & 0x80000000) >> 16 & 0xFFFF;\n let expo = (u32[1] & 0x7FF00000), sigf = 0x0000;\n\n if (expo >= 0x40F00000) {\n //\n // If exponent overflowed, the float16 is either NaN or Infinity.\n // Rules to propagate the sign bit: mantissa > 0 ? NaN : +/-Infinity\n //\n // Magic numbers:\n // 0x40F00000 = 01000000 11110000 00000000 00000000 -- 6-bit exponent overflow\n // 0x7C000000 = 01111100 00000000 00000000 00000000 -- masks the 27th-31st bits\n //\n // returns:\n // qNaN, aka 32256 decimal, 0x7E00 hex, or 01111110 00000000 binary\n // sNaN, aka 32000 decimal, 0x7D00 hex, or 01111101 00000000 binary\n // +inf, aka 31744 decimal, 0x7C00 hex, or 01111100 00000000 binary\n // -inf, aka 64512 decimal, 0xFC00 hex, or 11111100 00000000 binary\n //\n // If mantissa is greater than 23 bits, set to +Infinity like numpy\n if (u32[0] > 0) {\n expo = 0x7C00;\n } else {\n expo = (expo & 0x7C000000) >> 16;\n sigf = (u32[1] & 0x000FFFFF) >> 10;\n }\n } else if (expo <= 0x3F000000) {\n //\n // If exponent underflowed, the float is either signed zero or subnormal.\n //\n // Magic numbers:\n // 0x3F000000 = 00111111 00000000 00000000 00000000 -- 6-bit exponent underflow\n //\n sigf = 0x100000 + (u32[1] & 0x000FFFFF);\n sigf = 0x100000 + (sigf << ((expo >> 20) - 998)) >> 21;\n expo = 0;\n } else {\n //\n // No overflow or underflow, rebase the exponent and round the mantissa\n // Magic numbers:\n // 0x200 = 00000010 00000000 -- masks off the 10th bit\n //\n // Ensure the first mantissa bit (the 10th one) is 1 and round\n expo = (expo - 0x3F000000) >> 10;\n sigf = ((u32[1] & 0x000FFFFF) + 0x200) >> 10;\n }\n return sign | expo | sigf & 0xFFFF;\n}\n","import { isArray } from './arrays.js';\nimport { isDate } from './objects.js';\n\nconst textDecoder = new TextDecoder('utf-8');\nconst textEncoder = new TextEncoder();\n\n/**\n * Return a UTF-8 string decoded from a byte buffer.\n * @param {Uint8Array} buf The byte buffer.\n * @returns {string} The decoded string.\n */\nexport function decodeUtf8(buf) {\n return textDecoder.decode(buf);\n}\n\n/**\n * Return a byte buffer encoded from a UTF-8 string.\n * @param {string } str The string to encode.\n * @returns {Uint8Array} The encoded byte buffer.\n */\nexport function encodeUtf8(str) {\n return textEncoder.encode(str);\n}\n\n/**\n * Return a string-coercible key value that uniquely identifies a value.\n * @param {*} value The input value.\n * @returns {string} The key string.\n */\nexport function keyString(value) {\n const val = typeof value !== 'object' || !value ? (value ?? null)\n : isDate(value) ? +value\n // @ts-ignore\n : isArray(value) ? `[${value.map(keyString)}]`\n : objectKey(value);\n return `${val}`;\n}\n\nfunction objectKey(value) {\n let s = '';\n let i = -1;\n for (const k in value) {\n if (++i > 0) s += ',';\n s += `\"${k}\":${keyString(value[k])}`;\n }\n return `{${s}}`;\n}\n","import { toNumber } from './numbers.js';\nimport { decodeUtf8 } from './strings.js';\n\n/** The size in bytes of a 32-bit integer. */\nexport const SIZEOF_INT = 4;\n\n/** The size in bytes of a 16-bit integer. */\nexport const SIZEOF_SHORT = 2;\n\n/**\n * Return a boolean for a single bit in a bitmap.\n * @param {Uint8Array} bitmap The bitmap.\n * @param {number} index The bit index to read.\n * @returns {boolean} The boolean bitmap value.\n */\nexport function decodeBit(bitmap, index) {\n return (bitmap[index >> 3] & 1 << (index % 8)) !== 0;\n}\n\n/**\n * Lookup helper for flatbuffer object (table) entries.\n * @param {Uint8Array} buf The byte buffer.\n * @param {number} index The base index of the object.\n */\nexport function readObject(buf, index) {\n const pos = index + readInt32(buf, index);\n const vtable = pos - readInt32(buf, pos);\n const size = readInt16(buf, vtable);\n /**\n * Retrieve a value from a flatbuffer table layout.\n * @template T\n * @param {number} index The table entry index.\n * @param {(buf: Uint8Array, offset: number) => T} read Read function to invoke.\n * @param {T} [fallback=null] The default fallback value.\n * @returns {T}\n */\n return (index, read, fallback = null) => {\n if (index < size) {\n const off = readInt16(buf, vtable + index);\n if (off) return read(buf, pos + off);\n }\n return fallback;\n };\n}\n\n/**\n * Return a buffer offset value.\n * @param {Uint8Array} buf\n * @param {number} offset\n * @returns {number}\n */\nexport function readOffset(buf, offset) {\n return offset;\n}\n\n/**\n * Return a boolean value.\n * @param {Uint8Array} buf\n * @param {number} offset\n * @returns {boolean}\n */\nexport function readBoolean(buf, offset) {\n return !!readInt8(buf, offset);\n}\n\n/**\n * Return a signed 8-bit integer value.\n * @param {Uint8Array} buf\n * @param {number} offset\n * @returns {number}\n */\nexport function readInt8(buf, offset) {\n return readUint8(buf, offset) << 24 >> 24;\n}\n\n/**\n * Return an unsigned 8-bit integer value.\n * @param {Uint8Array} buf\n * @param {number} offset\n * @returns {number}\n */\nexport function readUint8(buf, offset) {\n return buf[offset];\n}\n\n/**\n * Return a signed 16-bit integer value.\n * @param {Uint8Array} buf\n * @param {number} offset\n * @returns {number}\n */\nexport function readInt16(buf, offset) {\n return readUint16(buf, offset) << 16 >> 16;\n}\n\n/**\n * Return an unsigned 16-bit integer value.\n * @param {Uint8Array} buf\n * @param {number} offset\n * @returns {number}\n */\nexport function readUint16(buf, offset) {\n return buf[offset] | buf[offset + 1] << 8;\n}\n\n/**\n * Return a signed 32-bit integer value.\n * @param {Uint8Array} buf\n * @param {number} offset\n * @returns {number}\n */\nexport function readInt32(buf, offset) {\n return buf[offset]\n | buf[offset + 1] << 8\n | buf[offset + 2] << 16\n | buf[offset + 3] << 24;\n}\n\n/**\n * Return an unsigned 32-bit integer value.\n * @param {Uint8Array} buf\n * @param {number} offset\n * @returns {number}\n */\nexport function readUint32(buf, offset) {\n return readInt32(buf, offset) >>> 0;\n}\n\n/**\n * Return a signed 64-bit integer value coerced to a JS number.\n * Throws an error if the value exceeds what a JS number can represent.\n * @param {Uint8Array} buf\n * @param {number} offset\n * @returns {number}\n */\nexport function readInt64(buf, offset) {\n return toNumber(BigInt.asIntN(\n 64,\n BigInt(readUint32(buf, offset)) +\n (BigInt(readUint32(buf, offset + SIZEOF_INT)) << 32n)\n ));\n}\n\n/**\n * Create a JavaScript string from UTF-8 data stored inside the FlatBuffer.\n * This allocates a new string and converts to wide chars upon each access.\n * @param {Uint8Array} buf The byte buffer.\n * @param {number} index The index of the string entry.\n * @returns {string} The decoded string.\n */\nexport function readString(buf, index) {\n let offset = index + readInt32(buf, index); // get the string offset\n const length = readInt32(buf, offset); // get the string length\n offset += SIZEOF_INT; // skip length value\n return decodeUtf8(buf.subarray(offset, offset + length));\n}\n\n/**\n * Extract a flatbuffer vector to an array.\n * @template T\n * @param {Uint8Array} buf The byte buffer.\n * @param {number} offset The offset location of the vector.\n * @param {number} stride The stride between vector entries.\n * @param {(buf: Uint8Array, pos: number) => T} extract Vector entry extraction function.\n * @returns {T[]} The extracted vector entries.\n */\nexport function readVector(buf, offset, stride, extract) {\n if (!offset) return [];\n\n // get base position by adding offset delta\n const base = offset + readInt32(buf, offset);\n\n // read vector size, extract entries\n return Array.from(\n { length: readInt32(buf, base) },\n (_, i) => extract(buf, base + SIZEOF_INT + i * stride)\n );\n}\n","/**\n * @import { Batch } from '../batch.js';\n */\n\n/**\n * Symbol for the row index value of a struct object proxy.\n */\nexport const RowIndex = Symbol('rowIndex');\n\n/**\n * Returns a row proxy object factory. The resulting method takes a\n * batch-level row index as input and returns an object that proxies\n * access to underlying batches.\n * @param {string[]} names The column (property) names\n * @param {Batch[]} batches The value batches.\n * @returns {(index: number) => Record<string, any>}\n */\nexport function proxyFactory(names, batches) {\n class RowObject {\n /**\n * Create a new proxy row object representing a struct or table row.\n * @param {number} index The record batch row index.\n */\n constructor(index) {\n this[RowIndex] = index;\n }\n\n /**\n * Return a JSON-compatible object representation.\n */\n toJSON() {\n return structObject(names, batches, this[RowIndex]);\n }\n };\n\n // prototype for row proxy objects\n const proto = RowObject.prototype;\n\n for (let i = 0; i < names.length; ++i) {\n // skip duplicated column names\n if (Object.hasOwn(proto, names[i])) continue;\n\n // add a getter method for the current batch\n const batch = batches[i];\n Object.defineProperty(proto, names[i], {\n get() { return batch.at(this[RowIndex]); },\n enumerable: true\n });\n }\n\n return index => new RowObject(index);\n}\n\n/**\n * Returns a row object factory. The resulting method takes a\n * batch-level row index as input and returns an object whose property\n * values have been extracted from the batches.\n * @param {string[]} names The column (property) names\n * @param {Batch[]} batches The value batches.\n * @returns {(index: number) => Record<string, any>}\n */\nexport function objectFactory(names, batches) {\n return index => structObject(names, batches, index);\n}\n\n/**\n * Return a vanilla object representing a struct (row object) type.\n * @param {string[]} names The column (property) names\n * @param {Batch[]} batches The value batches.\n * @param {number} index The record batch row index.\n * @returns {Record<string, any>}\n */\nexport function structObject(names, batches, index) {\n const obj = {};\n for (let i = 0; i < names.length; ++i) {\n obj[names[i]] = batches[i].at(index);\n }\n return obj;\n}\n","/**\n * @import { Column } from './column.js'\n * @import { DataType, DecimalType, IntegerArray, OffsetArray, TypedArray, TypedArrayConstructor, ValueArray } from './types.js'\n */\nimport { bisect, float64Array } from './util/arrays.js';\nimport { divide, fromDecimal128, fromDecimal256, fromDecimal64, toNumber } from './util/numbers.js';\nimport { decodeBit, readInt32, readInt64 } from './util/read.js';\nimport { decodeUtf8 } from './util/strings.js';\nimport { objectFactory, proxyFactory } from './util/struct.js';\n\n/**\n * Check if the input is a batch that supports direct access to\n * binary data in the form of typed arrays.\n * @param {Batch<any>?} batch The data batch to check.\n * @returns {boolean} True if a direct batch, false otherwise.\n */\nexport function isDirectBatch(batch) {\n return batch instanceof DirectBatch;\n}\n\n/**\n * Column values from a single record batch.\n * A column may contain multiple batches.\n * @template T\n */\nexport class Batch {\n /**\n * The array type to use when extracting data from the batch.\n * A null value indicates that the array type should match\n * the type of the batch's values array.\n * @type {ArrayConstructor | TypedArrayConstructor | null}\n */\n static ArrayType = null;\n\n /**\n * Create a new column batch.\n * @param {object} options\n * @param {number} options.length The length of the batch\n * @param {number} options.nullCount The null value count\n * @param {DataType} options.type The data type.\n * @param {Uint8Array} [options.validity] Validity bitmap buffer\n * @param {TypedArray} [options.values] Values buffer\n * @param {OffsetArray} [options.offsets] Offsets buffer\n * @param {OffsetArray} [options.sizes] Sizes buffer\n * @param {Batch[]} [options.children] Children batches\n */\n constructor({\n length,\n nullCount,\n type,\n validity,\n values,\n offsets,\n sizes,\n children\n }) {\n this.length = length;\n this.nullCount = nullCount;\n this.type = type;\n this.validity = validity;\n this.values = values;\n this.offsets = offsets;\n this.sizes = sizes;\n this.children = children;\n\n // optimize access if this batch has no null values\n // some types (like union) may have null values in\n // child batches, but no top-level validity buffer\n if (!nullCount || !this.validity) {\n /** @type {(index: number) => T | null} */\n this.at = index => this.value(index);\n }\n }\n\n /**\n * Provide an informative object string tag.\n */\n get [Symbol.toStringTag]() {\n return 'Batch';\n }\n\n /**\n * Return the value at the given index.\n * @param {number} index The value index.\n * @returns {T | null} The value.\n */\n at(index) {\n return this.isValid(index) ? this.value(index) : null;\n }\n\n /**\n * Check if a value at the given index is valid (non-null).\n * @param {number} index The value index.\n * @returns {boolean} True if valid, false otherwise.\n */\n isValid(index) {\n return decodeBit(this.validity, index);\n }\n\n /**\n * Return the value at the given index. This method does not check the\n * validity bitmap and is intended primarily for internal use. In most\n * cases, callers should use the `at()` method instead.\n * @param {number} index The value index\n * @returns {T} The value, ignoring the validity bitmap.\n */\n value(index) {\n return /** @type {T} */ (this.values[index]);\n }\n\n /**\n * Extract an array of values within the given index range. Unlike\n * Array.slice, all arguments are required and may not be negative indices.\n * @param {number} start The starting index, inclusive\n * @param {number} end The ending index, exclusive\n * @returns {ValueArray<T?>} The slice of values\n */\n slice(start, end) {\n const n = end - start;\n const values = Array(n);\n for (let i = 0; i < n; ++i) {\n values[i] = this.at(start + i);\n }\n return values;\n }\n\n /**\n * Return an iterator over the values in this batch.\n * @returns {Iterator<T?>}\n */\n *[Symbol.iterator]() {\n for (let i = 0; i < this.length; ++i) {\n yield this.at(i);\n }\n }\n}\n\n/**\n * A batch whose value buffer can be used directly, without transformation.\n * @template T\n * @extends {Batch<T>}\n */\nexport class DirectBatch extends Batch {\n /**\n * Create a new column batch with direct value array access.\n * @param {object} options\n * @param {number} options.length The length of the batch\n * @param {number} options.nullCount The null value count\n * @param {DataType} options.type The data type.\n * @param {Uint8Array} [options.validity] Validity bitmap buffer\n * @param {TypedArray} options.values Values buffer\n */\n constructor(options) {\n super(options);\n // underlying buffers may be padded, exceeding the logical batch length\n // we trim the values array so we can safely access it directly\n const { length, values } = this;\n this.values = values.subarray(0, length);\n }\n\n /**\n * Extract an array of values within the given index range. Unlike\n * Array.slice, all arguments are required and may not be negative indices.\n * When feasible, a zero-copy subarray of a typed array is returned.\n * @param {number} start The starting index, inclusive\n * @param {number} end The ending index, exclusive\n * @returns {ValueArray<T?>} The slice of values\n */\n slice(start, end) {\n // @ts-ignore\n return this.nullCount\n ? super.slice(start, end)\n : this.values.subarray(start, end);\n }\n\n /**\n * Return an iterator over the values in this batch.\n * @returns {Iterator<T?>}\n */\n [Symbol.iterator]() {\n return this.nullCount\n ? super[Symbol.iterator]()\n : /** @type {Iterator<T?>} */ (this.values[Symbol.iterator]());\n }\n}\n\n/**\n * A batch whose values are transformed to 64-bit numbers.\n * @extends {Batch<number>}\n */\nexport class NumberBatch extends Batch {\n static ArrayType = float64Array;\n}\n\n/**\n * A batch whose values should be returned in a standard array.\n * @template T\n * @extends {Batch<T>}\n */\nexport class ArrayBatch extends Batch {\n static ArrayType = Array;\n}\n\n/**\n * A batch of null values only.\n * @extends {ArrayBatch<null>}\n */\nexport class NullBatch extends ArrayBatch {\n /**\n * @param {number} index The value index\n * @returns {null}\n */\n value(index) { // eslint-disable-line no-unused-vars\n return null;\n }\n}\n\n/**\n * A batch that coerces BigInt values to 64-bit numbers.\n * @extends {NumberBatch}\n */\nexport class Int64Batch extends NumberBatch {\n /**\n * @param {number} index The value index\n */\n value(index) {\n return toNumber(/** @type {bigint} */ (this.values[index]));\n }\n}\n\n/**\n * A batch of 16-bit floating point numbers, accessed as unsigned\n * 16-bit ints and transformed to 64-bit numbers.\n */\nexport class Float16Batch extends NumberBatch {\n /**\n * @param {number} index The value index\n */\n value(index) {\n const v = /** @type {number} */ (this.values[index]);\n const expo = (v & 0x7C00) >> 10;\n const sigf = (v & 0x03FF) / 1024;\n const sign = (-1) ** ((v & 0x8000) >> 15);\n switch (expo) {\n case 0x1F: return sign * (sigf ? Number.NaN : 1 / 0);\n case 0x00: return sign * (sigf ? 6.103515625e-5 * sigf : 0);\n }\n return sign * (2 ** (expo - 15)) * (1 + sigf);\n }\n}\n\n/**\n * A batch of boolean values stored as a bitmap.\n * @extends {ArrayBatch<boolean>}\n */\nexport class BoolBatch extends ArrayBatch {\n /**\n * @param {number} index The value index\n */\n value(index) {\n return decodeBit(/** @type {Uint8Array} */ (this.values), index);\n }\n}\n\n/**\n * A batch of 32-bit decimal numbers, returned as converted 64-bit floating\n * point numbers. Number coercion may be lossy if the decimal precision can\n * not be represented in a 64-bit floating point format.\n * @extends {NumberBatch}\n */\nexport class Decimal32NumberBatch extends NumberBatch {\n constructor(options) {\n super(options);\n const { scale } = /** @type {DecimalType} */ (this.type);\n this.scale = 10 ** scale;\n }\n /**\n * @param {number} index The value index\n */\n value(index) {\n return /** @type {number} */(this.values[index]) / this.scale;\n }\n}\n\n/**\n * An abstract class for a batch of 64-, 128- or 256-bit decimal numbers,\n * accessed in strided BigUint64Arrays.\n * @template T\n * @extends {Batch<T>}\n */\nexport class DecimalBatch extends Batch {\n constructor(options) {\n super(options);\n const { bitWidth, scale } = /** @type {DecimalType} */ (this.type);\n this.decimal = bitWidth === 64 ? fromDecimal64\n : bitWidth === 128 ? fromDecimal128\n : fromDecimal256;\n this.scale = 10n ** BigInt(scale);\n }\n}\n\n/**\n * A batch of 64-, 128- or 256-bit decimal numbers, returned as converted\n * 64-bit floating point numbers. Number coercion may be lossy if the decimal\n * precision can not be represented in a 64-bit floating point format.\n * @extends {DecimalBatch<number>}\n */\nexport class DecimalNumberBatch extends DecimalBatch {\n static ArrayType = float64Array;\n /**\n * @param {number} index The value index\n */\n value(index) {\n return divide(\n this.decimal(/** @type {BigUint64Array} */ (this.values), index),\n this.scale\n );\n }\n}\n\n/**\n * A batch of 64-, 128- or 256-bit decimal numbers, returned as scaled\n * bigint values, such that all fractional digits have been shifted\n * to integer places by the decimal type scale factor.\n * @extends {DecimalBatch<bigint>}\n */\nexport class DecimalBigIntBatch extends DecimalBatch {\n static ArrayType = Array;\n /**\n * @param {number} index The value index\n */\n value(index) {\n return this.decimal(/** @type {BigUint64Array} */ (this.values), index);\n }\n}\n\n/**\n * A batch of date or timestamp values that are coerced to UNIX epoch timestamps\n * and returned as JS Date objects. This batch wraps a source batch that provides\n * timestamp values.\n * @extends {ArrayBatch<Date>}\n */\nexport class DateBatch extends ArrayBatch {\n /**\n * Create a new date batch.\n * @param {Batch<number>} batch A batch of timestamp values.\n */\n constructor(batch) {\n super(batch);\n this.source = batch;\n }\n\n /**\n * @param {number} index The value index\n */\n value(index) {\n return new Date(this.source.value(index));\n }\n}\n\n/**\n * A batch of dates as day counts, coerced to timestamp numbers.\n */\nexport class DateDayBatch extends NumberBatch {\n /**\n * @param {number} index The value index\n * @returns {number}\n */\n value(index) {\n // epoch days to milliseconds\n return 86400000 * /** @type {number} */ (this.values[index]);\n }\n}\n\n/**\n * A batch of dates as millisecond timestamps, coerced to numbers.\n */\nexport const DateDayMillisecondBatch = Int64Batch;\n\n/**\n * A batch of timestaps in seconds, coerced to millisecond numbers.\n */\nexport class TimestampSecondBatch extends Int64Batch {\n /**\n * @param {number} index The value index\n */\n value(index) {\n return super.value(index) * 1e3; // seconds to milliseconds\n }\n}\n\n/**\n * A batch of timestaps in milliseconds, coerced to numbers.\n */\nexport const TimestampMillisecondBatch = Int64Batch;\n\n/**\n * A batch of timestaps in microseconds, coerced to millisecond numbers.\n */\nexport class TimestampMicrosecondBatch extends Int64Batch {\n /**\n * @param {number} index The value index\n */\n value(index) {\n // microseconds to milliseconds\n return divide(/** @type {bigint} */ (this.values[index]), 1000n);\n }\n}\n\n/**\n * A batch of timestaps in nanoseconds, coerced to millisecond numbers.\n */\nexport class TimestampNanosecondBatch extends Int64Batch {\n /**\n * @param {number} index The value index\n */\n value(index) {\n // nanoseconds to milliseconds\n return divide(/** @type {bigint} */ (this.values[index]), 1000000n);\n }\n}\n\n/**\n * A batch of day/time intervals, returned as two-element 32-bit int arrays.\n * @extends {ArrayBatch<Int32Array>}\n */\nexport class IntervalDayTimeBatch extends ArrayBatch {\n /**\n * @param {number} index The value index\n * @returns {Int32Array}\n */\n value(index) {\n const values = /** @type {Int32Array} */ (this.values);\n return values.subarray(index << 1, (index + 1) << 1);\n }\n}\n\n/**\n * A batch of month/day/nanosecond intervals, returned as three-element arrays.\n * @extends {ArrayBatch<Float64Array>}\n */\nexport class IntervalMonthDayNanoBatch extends ArrayBatch {\n /**\n * @param {number} index The value index\n */\n value(index) {\n const values = /** @type {Uint8Array} */ (this.values);\n const base = index << 4;\n return Float64Array.of(\n readInt32(values, base),\n readInt32(values, base + 4),\n readInt64(values, base + 8)\n );\n }\n}\n\nconst offset32 = ({values, offsets}, index) => values.subarray(offsets[index], offsets[index + 1]);\nconst offset64 = ({values, offsets}, index) => values.subarray(toNumber(offsets[index]), toNumber(offsets[index + 1]));\n\n/**\n * A batch of binary blobs with variable offsets, returned as byte buffers of\n * unsigned 8-bit integers. The offsets are 32-bit ints.\n * @extends {ArrayBatch<Uint8Array>}\n */\nexport class BinaryBatch extends ArrayBatch {\n /**\n * @param {number} index\n * @returns {Uint8Array}\n */\n value(index) {\n return offset32(this, index);\n }\n}\n\n/**\n * A batch of binary blobs with variable offsets, returned as byte buffers of\n * unsigned 8-bit integers. The offsets are 64-bit ints. Value extraction will\n * fail if an offset exceeds `Number.MAX_SAFE_INTEGER`.\n * @extends {ArrayBatch<Uint8Array>}\n */\nexport class LargeBinaryBatch extends ArrayBatch {\n /**\n * @param {number} index\n * @returns {Uint8Array}\n */\n value(index) {\n return offset64(this, index);\n }\n}\n\n/**\n * A batch of UTF-8 strings with variable offsets. The offsets are 32-bit ints.\n * @extends {ArrayBatch<string>}\n */\nexport class Utf8Batch extends ArrayBatch {\n /**\n * @param {number} index\n */\n value(index) {\n return decodeUtf8(offset32(this, index));\n }\n}\n\n/**\n * A batch of UTF-8 strings with variable offsets. The offsets are 64-bit ints.\n * Value extraction will fail if an offset exceeds `Number.MAX_SAFE_INTEGER`.\n * @extends {ArrayBatch<string>}\n */\nexport class LargeUtf8Batch extends ArrayBatch {\n /**\n * @param {number} index\n */\n value(index) {\n return decodeUtf8(offset64(this, index));\n }\n}\n\n/**\n * A batch of list (array) values of variable length. The list offsets are\n * 32-bit ints.\n * @template V\n * @extends {ArrayBatch<ValueArray<V>>}\n */\nexport class ListBatch extends ArrayBatch {\n /**\n * @param {number} index\n * @returns {ValueArray<V>}\n */\n value(index) {\n const offsets = /** @type {Int32Array} */ (this.offsets);\n return this.children[0].slice(offsets[index], offsets[index + 1]);\n }\n}\n\n/**\n * A batch of list (array) values of variable length. The list offsets are\n * 64-bit ints. Value extraction will fail if an offset exceeds\n * `Number.MAX_SAFE_INTEGER`.\n * @template V\n * @extends {ArrayBatch<ValueArray<V>>}\n */\nexport class LargeListBatch extends ArrayBatch {\n /**\n * @param {number} index\n * @returns {ValueArray<V>}\n */\n value(index) {\n const offsets = /** @type {BigInt64Array} */ (this.offsets);\n return this.children[0].slice(toNumber(offsets[index]), toNumber(offsets[index + 1]));\n }\n}\n\n/**\n * A batch of list (array) values of variable length. The list offsets and\n * sizes are 32-bit ints.\n * @template V\n * @extends {ArrayBatch<ValueArray<V>>}\n */\nexport class ListViewBatch extends ArrayBatch {\n /**\n * @param {number} index\n * @returns {ValueArray<V>}\n */\n value(index) {\n const a = /** @type {number} */ (this.offsets[index]);\n const b = a + /** @type {number} */ (this.sizes[index]);\n return this.children[0].slice(a, b);\n }\n}\n\n/**\n * A batch of list (array) values of variable length. The list offsets and\n * sizes are 64-bit ints. Value extraction will fail if an offset or size\n * exceeds `Number.MAX_SAFE_INTEGER`.\n * @template V\n * @extends {ArrayBatch<ValueArray<V>>}\n */\nexport class LargeListViewBatch extends ArrayBatch {\n /**\n * @param {number} index\n * @returns {ValueArray<V>}\n */\n value(index) {\n const a = /** @type {bigint} */ (this.offsets[index]);\n const b = a + /** @type {bigint} */ (this.sizes[index]);\n return this.children[0].slice(toNumber(a), toNumber(b));\n }\n}\n\n/**\n * A batch with a fixed stride.\n * @template T\n * @extends {ArrayBatch<T>}\n */\nclass FixedBatch extends ArrayBatch {\n constructor(options) {\n super(options);\n /** @type {number} */\n // @ts-ignore\n this.stride = this.type.stride;\n }\n}\n\n/**\n * A batch of binary blobs of fixed size, returned as byte buffers of unsigned\n * 8-bit integers.\n * @extends {FixedBatch<Uint8Array>}\n */\nexport class FixedBinaryBatch extends FixedBatch {\n /**\n * @param {number} index\n * @returns {Uint8Array}\n */\n value(index) {\n const { stride, values } = this;\n return /** @type {Uint8Array} */ (values)\n .subarray(index * stride, (index + 1) * stride);\n }\n}\n\n/**\n * A batch of list (array) values of fixed length.\n * @template V\n * @extends {FixedBatch<ValueArray<V>>}\n */\nexport class FixedListBatch extends FixedBatch {\n /**\n * @param {number} index\n * @returns {ValueArray<V>}\n */\n value(index) {\n const { children, stride } = this;\n return children[0].slice(index * stride, (index + 1) * stride);\n }\n}\n\n/**\n * Extract Map key-value pairs from parallel child batches.\n */\nfunction pairs({ children, offsets }, index) {\n const [ keys, vals ] = children[0].children;\n const start = offsets[index];\n const end = offsets[index + 1];\n const entries = [];\n for (let i = start; i < end; ++i) {\n entries.push([keys.at(i), vals.at(i)]);\n }\n return entries;\n}\n\n/**\n * A batch of map (key, value) values. The map is represented as a list of\n * key-value structs.\n * @template K, V\n * @extends {ArrayBatch<[K, V][]>}\n */\nexport class MapEntryBatch extends ArrayBatch {\n /**\n * Return the value at the given index.\n * @param {number} index The value index.\n * @returns {[K, V][]} The map entries as an array of [key, value] arrays.\n */\n value(index) {\n return /** @type {[K, V][]} */ (pairs(this, index));\n }\n}\n\n/**\n * A batch of map (key, value) values. The map is represented as a list of\n * key-value structs.\n * @template K, V\n * @extends {ArrayBatch<Map<K, V>>}\n */\nexport class MapBatch extends ArrayBatch {\n /**\n * Return the value at the given index.\n * @param {number} index The value index.\n * @returns {Map<K, V>} The map value.\n */\n value(index) {\n return new Map(/** @type {[K, V][]} */ (pairs(this, index)));\n }\n}\n\n/**\n * A batch of union-type values with a sparse layout, enabling direct\n * lookup from the child value batches.\n * @template T\n * @extends {ArrayBatch<T>}\n */\nexport class SparseUnionBatch extends ArrayBatch {\n /**\n * Create a new column batch.\n * @param {object} options\n * @param {number} options.length The length of the batch\n * @param {number} options.nullCount The null value count\n * @param {DataType} options.type The data type.\n * @param {Uint8Array} [options.validity] Validity bitmap buffer\n * @param {Int32Array} [options.offsets] Offsets buffer\n * @param {Batch[]} options.children Children batches\n * @param {Int8Array} options.typeIds Union type ids buffer\n * @param {Record<string, number>} options.map A typeId to children index map\n */\n constructor({ typeIds, ...options }) {\n super(options);\n /** @type {Int8Array} */\n this.typeIds = typeIds;\n /** @type {Record<string, number>} */\n // @ts-ignore\n this.typeMap = this.type.typeMap;\n }\n\n /**\n * @param {number} index The value index.\n */\n value(index, offset = index) {\n const { typeIds, children, typeMap } = this;\n return children[typeMap[typeIds[index]]].at(offset);\n }\n}\n\n/**\n * A batch of union-type values with a dense layout, reqiring offset\n * lookups from the child value batches.\n * @template T\n * @extends {SparseUnionBatch<T>}\n */\nexport class DenseUnionBatch extends SparseUnionBatch {\n /**\n * @param {number} index The value index.\n */\n value(index) {\n return super.value(index, /** @type {number} */ (this.offsets[index]));\n }\n}\n\n/**\n * A batch of struct values, containing a set of named properties.\n * Struct property values are extracted and returned as JS objects.\n * @extends {ArrayBatch<Record<string, any>>}\n */\nexport class StructBatch extends ArrayBatch {\n constructor(options, factory = objectFactory) {\n super(options);\n /** @type {string[]} */\n // @ts-ignore\n this.names = this.type.children.map(child => child.name);\n this.factory = factory(this.names, this.children);\n }\n\n /**\n * @param {number} index The value index.\n * @returns {Record<string, any>}\n */\n value(index) {\n return this.factory(index);\n }\n}\n\n/**\n * A batch of struct values, containing a set of named properties.\n * Structs are returned as proxy objects that extract data directly\n * from underlying Arrow batches.\n * @extends {StructBatch}\n */\nexport class StructProxyBatch extends StructBatch {\n constructor(options) {\n super(options, proxyFactory);\n }\n}\n\n/**\n * A batch of run-end-encoded values.\n * @template T\n * @extends {ArrayBatch<T>}\n */\nexport class RunEndEncodedBatch extends ArrayBatch {\n /**\n * @param {number} index The value index.\n */\n value(index) {\n const [ { values: runs }, vals ] = this.children;\n return vals.at(\n bisect(/** @type {IntegerArray} */(runs), index)\n );\n }\n}\n\n/**\n * A batch of dictionary-encoded values.\n * @template T\n * @extends {ArrayBatch<T>}\n */\nexport class DictionaryBatch extends ArrayBatch {\n /**\n * Register the backing dictionary. Dictionaries are added\n * after batch creation as the complete dictionary may not\n * be finished across multiple record batches.\n * @param {Column<T>} dictionary\n * The dictionary of column values.\n */\n setDictionary(dictionary) {\n this.dictionary = dictionary;\n this.cache = dictionary.cache();\n return this;\n }\n\n /**\n * @param {number} index The value index.\n */\n value(index) {\n return this.cache[this.key(index)];\n }\n\n /**\n * @param {number} index The value index.\n * @returns {number} The dictionary key\n */\n key(index) {\n return /** @type {number} */ (this.values[index]);\n }\n}\n\n/**\n * @template T\n * @extends {ArrayBatch<T>}\n */\nclass ViewBatch extends ArrayBatch {\n /**\n * Create a new view batch.\n * @param {object} options Batch options.\n * @param {number} options.length The length of the batch\n * @param {number} options.nullCount The null value count\n * @param {DataType} options.type The data type.\n * @param {Uint8Array} [options.validity] Validity bitmap buffer\n * @param {Uint8Array} options.values Values buffer\n * @param {Uint8Array[]} options.data View data buffers\n */\n constructor({ data, ...options }) {\n super(options);\n this.data = data;\n }\n\n /**\n * Get the binary data at the provided index.\n * @param {number} index The value index.\n * @returns {Uint8Array}\n */\n view(index) {\n const { values, data } = this;\n const offset = index << 4; // each entry is 16 bytes\n let start = offset + 4;\n let buf = /** @type {Uint8Array} */ (values);\n const length = readInt32(buf, offset);\n if (length > 12) {\n // longer strings are in a data buffer\n start = readInt32(buf, offset + 12);\n buf = data[readInt32(buf, offset + 8)];\n }\n return buf.subarray(start, start + length);\n }\n}\n\n/**\n * A batch of binary blobs from variable data buffers, returned as byte\n * buffers of unsigned 8-bit integers.\n * @extends {ViewBatch<Uint8Array>}\n */\nexport class BinaryViewBatch extends ViewBatch {\n /**\n * @param {number} index The value index.\n */\n value(index) {\n return this.view(index);\n }\n}\n\n/**\n * A batch of UTF-8 strings from variable data buffers.\n * @extends {ViewBatch<string>}\n */\nexport class Utf8ViewBatch extends ViewBatch {\n /**\n * @param {number} index The value index.\n */\n value(index) {\n return decodeUtf8(this.view(index));\n }\n}\n","/**\n * @import { Batch } from './batch.js'\n * @import { DataType, ValueArray } from './types.js'\n */\nimport { bisect } from './util/arrays.js';\nimport { isDirectBatch } from './batch.js';\n\n/**\n * Build up a column from batches.\n */\nexport function columnBuilder(type) {\n let data = [];\n return {\n add(batch) { data.push(batch); return this; },\n clear: () => data = [],\n done: () => new Column(data, type)\n };\n}\n\n/**\n * A data column. A column provides a view over one or more value batches,\n * each drawn from an Arrow record batch. This class supports random access\n * to column values by integer index; however, extracting arrays using\n * `toArray()` or iterating over values (`for (const value of column) {...}`)\n * provide more efficient ways for bulk access or scanning.\n * @template T\n */\nexport class Column {\n /**\n * Create a new column instance.\n * @param {Batch<T>[]} data The value batches.\n * @param {DataType} [type] The column data type.\n * If not specified, the type is extracted from the batches.\n */\n constructor(data, type = data[0]?.type) {\n /**\n * The column data type.\n * @type {DataType}\n * @readonly\n */\n this.type = type;\n /**\n * The column length.\n * @type {number}\n * @readonly\n */\n this.length = data.reduce((m, c) => m + c.length, 0);\n /**\n * The count of null values in the column.\n * @type {number}\n * @readonly\n */\n this.nullCount = data.reduce((m, c) => m + c.nullCount, 0);\n /**\n * An array of column data batches.\n * @type {readonly Batch<T>[]}\n * @readonly\n */\n this.data = data;\n\n const n = data.length;\n const offsets = new Int32Array(n + 1);\n if (n === 1) {\n const [ batch ] = data;\n offsets[1] = batch.length;\n // optimize access to single batch\n this.at = index => batch.at(index);\n } else {\n for (let i = 0, s = 0; i < n; ++i) {\n offsets[i + 1] = (s += data[i].length);\n }\n }\n\n /**\n * Index offsets for data batches.\n * Used to map a column row index to a batch-specific index.\n * @type {Int32Array}\n * @readonly\n */\n this.offsets = offsets;\n }\n\n /**\n * Provide an informative object string tag.\n */\n get [Symbol.toStringTag]() {\n return 'Column';\n }\n\n /**\n * Return an iterator over the values in this column.\n * @returns {Iterator<T?>}\n */\n [Symbol.iterator]() {\n const data = this.data;\n return data.length === 1\n ? data[0][Symbol.iterator]()\n : batchedIterator(data);\n }\n\n /**\n * Return the column value at the given index. If a column has multiple\n * batches, this method performs binary search over the batch lengths to\n * determine the batch from which to retrieve the value. The search makes\n * lookup less efficient than a standard array access. If making a full\n * scan of a column, consider extracting arrays via `toArray()` or using an\n * iterator (`for (const value of column) {...}`).\n * @param {number} index The row index.\n * @returns {T | null} The value.\n */\n at(index) {\n // NOTE: if there is only one batch, this method is replaced with an\n // optimized version in the Column constructor.\n const { data, offsets } = this;\n const i = bisect(offsets, index) - 1;\n return data[i]?.at(index - offsets[i]); // undefined if out of range\n }\n\n /**\n * Return the column value at the given index. This method is the same as\n * `at()` and is provided for better compatibility with Apache Arrow JS.\n * @param {number} index The row index.\n * @returns {T | null} The value.\n */\n get(index) {\n return this.at(index);\n }\n\n /**\n * Extract column values into a single array instance. When possible,\n * a zero-copy subarray of the input Arrow data is returned.\n * @returns {ValueArray<T?>}\n */\n toArray() {\n const { length, nullCount, data } = this;\n const copy = !nullCount && isDirectBatch(data[0]);\n const n = data.length;\n\n if (copy && n === 1) {\n // use batch array directly\n // @ts-ignore\n return data[0].values;\n }\n\n // determine output array type\n const ArrayType = !n || nullCount > 0 ? Array\n // @ts-ignore\n : (data[0].constructor.ArrayType ?? data[0].values.constructor);\n\n const array = new ArrayType(length);\n return copy ? copyArray(array, data) : extractArray(array, data);\n }\n\n /**\n * Return an array of cached column values.\n * Used internally to accelerate dictionary types.\n */\n cache() {\n return this._cache ?? (this._cache = this.toArray());\n }\n}\n\nfunction *batchedIterator(data) {\n for (let i = 0; i < data.length; ++i) {\n const iter = data[i][Symbol.iterator]();\n for (let next = iter.next(); !next.done; next = iter.next()) {\n yield next.value;\n }\n }\n}\n\nfunction copyArray(array, data) {\n for (let i = 0, offset = 0; i < data.length; ++i) {\n const { values } = data[i];\n array.set(values, offset);\n offset += values.length;\n }\n return array;\n}\n\nfunction extractArray(array, data) {\n let index = -1;\n for (let i = 0; i < data.length; ++i) {\n const batch = data[i];\n for (let j = 0; j < batch.length; ++j) {\n array[++index] = batch.at(j);\n }\n }\n return array;\n}\n","/**\n * @import { Column } from './column.js'\n * @import { Schema, StructFactory, TypeMap, ValueArray } from './types.js'\n */\nimport { bisect } from './util/arrays.js';\nimport { objectFactory, proxyFactory } from './util/struct.js';\n\n/**\n * A table consists of a collection of named columns (or 'children').\n * To work with table data directly in JavaScript, use `toColumns()`\n * to extract an object that maps column names to extracted value arrays,\n * or `toArray()` to extract an array of row objects. For random access\n * by row index, use `getChild()` to access data for a specific column.\n * @template {TypeMap} [T=TypeMap]\n */\nexport class Table {\n /**\n * Create a new table with the given schema and columns (children).\n * @param {Schema} schema The table schema.\n * @param {Column[]} children The table columns.\n * @param {boolean} [useProxy=false] Flag indicating if row proxy\n * objects should be used to represent table rows (default `false`).\n */\n constructor(schema, children, useProxy = false) {\n const names = schema.fields.map(f => f.name);\n\n /**\n * @type {Schema}\n * @readonly\n */\n this.schema = schema;\n /**\n * @type {(keyof T)[]}\n * @readonly\n */\n this.names = names;\n /**\n * @type {Column[]}\n * @readonly\n */\n this.children = children;\n /**\n * @type {StructFactory}\n * @readonly\n */\n this.factory = useProxy ? proxyFactory : objectFactory;\n\n // lazily created row object generators\n const gen = [];\n\n /**\n * Returns a row object generator for the given batch index.\n * @private\n * @readonly\n * @param {number} b The batch index.\n * @returns {(index: number) => { [P in keyof T]: T[P] }}\n */\n this.getFactory = b => gen[b]\n ?? (gen[b] = this.factory(names, children.map(c => c.data[b])));\n }\n\n /**\n * Provide an informative object string tag.\n */\n get [Symbol.toStringTag]() {\n return 'Table';\n }\n\n /**\n * The number of columns in this table.\n * @return {number} The number of columns.\n */\n get numCols() {\n return this.names.length;\n }\n\n /**\n * The number of rows in this table.\n * @return {number} The number of rows.\n */\n get numRows() {\n return this.children[0]?.length ?? 0;\n }\n\n /**\n * Return the child column at the given index position.\n * @template {T[keyof T]} R\n * @param {number} index The column index.\n * @returns {Column<R>}\n */\n getChildAt(index) {\n return this.children[index];\n }\n\n /**\n * Return the first child column with the given name.\n * @template {keyof T} P\n * @param {P} name The column name.\n * @returns {Column<T[P]>}\n */\n getChild(name) {\n const i = this.names.findIndex(x => x === name);\n return i > -1 ? this.children[i] : undefined;\n }\n\n /**\n * Construct a new table containing only columns at the specified indices.\n * The order of columns in the new table matches the order of input indices.\n * @template {T[keyof T]} V\n * @param {number[]} indices The indices of columns to keep.\n * @param {string[]} [as] Optional new names for selected columns.\n * @returns {Table<{ [key: string]: V }>} A new table with selected columns.\n */\n selectAt(indices, as = []) {\n const { children, factory, schema } = this;\n const { fields } = schema;\n return new Table(\n {\n ...schema,\n fields: indices.map((i, j) => renameField(fields[i], as[j]))\n },\n indices.map(i => children[i]),\n factory === proxyFactory\n );\n }\n\n /**\n * Construct a new table containing only columns with the specified names.\n * If columns have duplicate names, the first (with lowest index) is used.\n * The order of columns in the new table matches the order of input names.\n * @template {keyof T} K\n * @param {K[]} names Names of columns to keep.\n * @param {string[]} [as] Optional new names for selected columns.\n * @returns A new table with columns matching the specified names.\n */\n select(names, as) {\n const all = /** @type {K[]} */(this.names);\n const indices = names.map(name => all.indexOf(name));\n return this.selectAt(indices, as);\n }\n\n /**\n * Return an object mapping column names to extracted value arrays.\n * @returns {{ [P in keyof T]: ValueArray<T[P]> }}\n */\n toColumns() {\n const { children, names } = this;\n /** @type {{ [P in keyof T]: ValueArray<T[P]> }} */\n // @ts-expect-error assign to empty object\n const cols = {};\n names.forEach((name, i) => cols[name] = children[i]?.toArray() ?? [] );\n return cols;\n }\n\n /**\n * Return an array of objects representing the rows of this table.\n * @returns {{ [P in keyof T]: T[P] }[]}\n */\n toArray() {\n const { children, getFactory, numRows } = this;\n const data = children[0]?.data ?? [];\n const output = Array(numRows);\n for (let b = 0, row = -1; b < data.length; ++b) {\n const f = getFactory(b);\n for (let i = 0; i < data[b].length; ++i) {\n output[++row] = f(i);\n }\n }\n return output;\n }\n\n /**\n * Return an iterator over objects representing the rows of this table.\n * @returns {Generator<{ [P in keyof T]: T[P] }, any, any>}\n */\n *[Symbol.iterator]() {\n const { children, getFactory } = this;\n const data = children[0]?.data ?? [];\n for (let b = 0; b < data.length; ++b) {\n const f = getFactory(b);\n for (let i = 0; i < data[b].length; ++i) {\n yield f(i);\n }\n }\n }\n\n /**\n * Return a row object for the given index.\n * @param {number} index The row index.\n * @returns {{ [P in keyof T]: T[P] }} The row object.\n */\n at(index) {\n const { children, getFactory, numRows } = this;\n if (index < 0 || index >= numRows) return null;\n const [{ offsets }] = children;\n const b = bisect(offsets, index) - 1;\n return getFactory(b)(index - offsets[b]);\n }\n\n /**\n * Return a row object for the given index. This method is the same as\n * `at()` and is provided for better compatibility with Apache Arrow JS.\n * @param {number} index The row index.\n * @returns {{ [P in keyof T]: T[P] }} The row object.\n */\n get(index) {\n return this.at(index);\n }\n}\n\nfunction renameField(field, name) {\n return (name != null && name !== field.name)\n ? { ...field, name }\n : field;\n}\n","/**\n * @import { DataType, ExtractionOptions } from './types.js';\n */\nimport { BinaryBatch, BinaryViewBatch, BoolBatch, DateBatch, DateDayBatch, DateDayMillisecondBatch, Decimal32NumberBatch, DecimalBigIntBatch, DecimalNumberBatch, DenseUnionBatch, DictionaryBatch, DirectBatch, FixedBinaryBatch, FixedListBatch, Float16Batch, Int64Batch, IntervalDayTimeBatch, IntervalMonthDayNanoBatch, LargeBinaryBatch, LargeListBatch, LargeListViewBatch, LargeUtf8Batch, ListBatch, ListViewBatch, MapBatch, MapEntryBatch, NullBatch, RunEndEncodedBatch, SparseUnionBatch, StructBatch, StructProxyBatch, TimestampMicrosecondBatch, TimestampMillisecondBatch, TimestampNanosecondBatch, TimestampSecondBatch, Utf8Batch, Utf8ViewBatch } from './batch.js';\nimport { DateUnit, IntervalUnit, TimeUnit, Type } from './constants.js';\nimport { invalidDataType } from './data-types.js';\n\n/**\n * Return a batch constructor for the given data type and extraction options.\n * @param {DataType} type The data type.\n * @param {ExtractionOptions} options The extraction options.\n */\nexport function batchType(type, options = {}) {\n const { typeId, bitWidth, mode, precision, unit } = /** @type {any} */(type);\n const { useBigInt, useDate, useDecimalInt, useMap, useProxy } = options;\n\n switch (typeId) {\n case Type.Null: return NullBatch;\n case Type.Bool: return BoolBatch;\n case Type.Int:\n case Type.Time:\n case Type.Duration:\n return useBigInt || bitWidth < 64 ? DirectBatch : Int64Batch;\n case Type.Float:\n return precision ? DirectBatch : Float16Batch;\n case Type.Date:\n return wrap(\n unit === DateUnit.DAY ? DateDayBatch : DateDayMillisecondBatch,\n useDate && DateBatch\n );\n case Type.Timestamp:\n return wrap(\n unit === TimeUnit.SECOND ? TimestampSecondBatch\n : unit === TimeUnit.MILLISECOND ? TimestampMillisecondBatch\n : unit === TimeUnit.MICROSECOND ? TimestampMicrosecondBatch\n : TimestampNanosecondBatch,\n useDate && DateBatch\n );\n case Type.Decimal:\n return bitWidth === 32\n ? (useDecimalInt ? DirectBatch : Decimal32NumberBatch)\n : (useDecimalInt ? DecimalBigIntBatch : DecimalNumberBatch);\n case Type.Interval:\n return unit === IntervalUnit.DAY_TIME ? IntervalDayTimeBatch\n : unit === IntervalUnit.YEAR_MONTH ? DirectBatch\n : IntervalMonthDayNanoBatch;\n case Type.FixedSizeBinary: return FixedBinaryBatch;\n case Type.Utf8: return Utf8Batch;\n case Type.LargeUtf8: return LargeUtf8Batch;\n case Type.Binary: return BinaryBatch;\n case Type.LargeBinary: return LargeBinaryBatch;\n case Type.BinaryView: return BinaryViewBatch;\n case Type.Utf8View: return Utf8ViewBatch;\n case Type.List: return ListBatch;\n case Type.LargeList: return LargeListBatch;\n case Type.Map: return useMap ? MapBatch : MapEntryBatch;\n case Type.ListView: return ListViewBatch;\n case Type.LargeListView: return LargeListViewBatch;\n case Type.FixedSizeList: return FixedListBatch;\n case Type.Struct: return useProxy ? StructProxyBatch : StructBatch;\n case Type.RunEndEncoded: return RunEndEncodedBatch;\n case Type.Dictionary: return DictionaryBatch;\n case Type.Union: return mode ? DenseUnionBatch : SparseUnionBatch;\n }\n throw new Error(invalidDataType(typeId));\n}\n\nfunction wrap(BaseClass, WrapperClass) {\n return WrapperClass\n ? class WrapBatch extends WrapperClass {\n constructor(options) {\n super(new BaseClass(options));\n }\n }\n : BaseClass;\n}\n","import { readInt32, readInt64, readVector } from '../util/read.js';\n\n/**\n * Decode a block that points to messages within an Arrow 'file' format.\n * @param {Uint8Array} buf A byte buffer of binary Arrow IPC data\n * @param {number} index The starting index in the byte buffer\n * @returns The file block.\n */\nexport function decodeBlock(buf, index) {\n // 0: offset\n // 8: metadataLength\n // 16: bodyLength\n return {\n offset: readInt64(buf, index),\n metadataLength: readInt32(buf, index + 8),\n bodyLength: readInt64(buf, index + 16)\n }\n}\n\n/**\n * Decode a vector of blocks.\n * @param {Uint8Array} buf\n * @param {number} index\n * @returns An array of file blocks.\n */\nexport function decodeBlocks(buf, index) {\n return readVector(buf, index, 24, decodeBlock);\n}\n","/**\n * @import { RecordBatch, Version_ } from '../types.js'\n */\nimport { Version } from '../constants.js';\nimport { readInt64, readObject, readOffset, readVector } from '../util/read.js';\n\n/**\n * Decode a record batch.\n * @param {Uint8Array} buf A byte buffer of binary Arrow IPC data\n * @param {number} index The starting index in the byte buffer\n * @param {Version_} version Arrow version value\n * @returns {RecordBatch} The record batch\n */\nexport function decodeRecordBatch(buf, index, version) {\n // 4: length\n // 6: nodes\n // 8: buffers\n // 10: compression (not supported)\n // 12: variadicBuffers (buffer counts for view-typed fields)\n const get = readObject(buf, index);\n if (get(10, readOffset, 0)) {\n throw new Error('Record batch compression not implemented');\n }\n\n // If an Arrow buffer was written before version 4,\n // advance 8 bytes to skip the now-removed page_id field\n const offset = version < Version.V4 ? 8 : 0;\n\n return {\n length: get(4, readInt64, 0),\n nodes: readVector(buf, get(6, readOffset), 16, (buf, pos) => ({\n length: readInt64(buf, pos),\n nullCount: readInt64(buf, pos + 8)\n })),\n regions: readVector(buf, get(8, readOffset), 16 + offset, (buf, pos) => ({\n offset: readInt64(buf, pos + offset),\n length: readInt64(buf, pos + offset + 8)\n })),\n variadic: readVector(buf, get(12, readOffset), 8, readInt64)\n };\n}\n","/**\n * @import { DictionaryBatch, Version_ } from '../types.js'\n */\nimport { readBoolean, readInt64, readObject } from '../util/read.js';\nimport { decodeRecordBatch } from './record-batch.js';\n\n/**\n * Decode a dictionary batch.\n * @param {Uint8Array} buf A byte buffer of binary Arrow IPC data\n * @param {number} index The starting index in the byte buffer\n * @param {Version_} version Arrow version value\n * @returns {DictionaryBatch} The dictionary batch\n */\nexport function decodeDictionaryBatch(buf, index, version) {\n // 4: id\n // 6: data\n // 8: isDelta\n const get = readObject(buf, index);\n return {\n id: get(4, readInt64, 0),\n data: get(6, (buf, off) => decodeRecordBatch(buf, off, version)),\n /**\n * If isDelta is true the values in the dictionary are to be appended to a\n * dictionary with the indicated id. If isDelta is false this dictionary\n * should replace the existing dictionary.\n */\n isDelta: get(8, readBoolean, false)\n };\n}\n","/**\n * @import { DataType, Field } from '../types.js'\n */\nimport { DateUnit, IntervalUnit, Precision, TimeUnit, Type, UnionMode } from '../constants.js';\nimport { binary, date, decimal, duration, fixedSizeBinary, fixedSizeList, float, int, interval, invalidDataType, largeBinary, largeList, largeListView, largeUtf8, list, listView, mapType, runEndEncoded, struct, time, timestamp, union, utf8 } from '../data-types.js';\nimport { checkOneOf } from '../util/objects.js';\nimport { readBoolean, readInt16, readInt32, readObject, readOffset, readString, readVector } from '../util/read.js';\n\n/**\n * Decode a data type definition for a field.\n * @param {Uint8Array} buf A byte buffer of binary Arrow IPC data.\n * @param {number} index The starting index in the byte buffer.\n * @param {number} typeId The data type id.\n * @param {Field[]} [children] A list of parsed child fields.\n * @returns {DataType} The data type.\n */\nexport function decodeDataType(buf, index, typeId, children) {\n checkOneOf(typeId, Type, invalidDataType);\n const get = readObject(buf, index);\n\n switch (typeId) {\n // types without flatbuffer objects\n case Type.Binary: return binary();\n case Type.Utf8: return utf8();\n case Type.LargeBinary: return largeBinary();\n case Type.LargeUtf8: return largeUtf8();\n case Type.List: return list(children[0]);\n case Type.ListView: return listView(children[0]);\n case Type.LargeList: return largeList(children[0]);\n case Type.LargeListView: return largeListView(children[0]);\n case Type.Struct: return struct(children);\n case Type.RunEndEncoded: return runEndEncoded(children[0], children[1]);\n\n // types with flatbuffer objects\n case Type.Int: return int(\n // @ts-ignore\n get(4, readInt32, 0), // bitwidth\n get(6, readBoolean, false) // signed\n );\n case Type.Float: return float(\n // @ts-ignore\n get(4, readInt16, Precision.HALF) // precision\n );\n case Type.Decimal: return decimal(\n get(4, readInt32, 0), // precision\n get(6, readInt32, 0), // scale\n // @ts-ignore\n get(8, readInt32, 128) // bitwidth\n );\n case Type.Date: return date(\n // @ts-ignore\n get(4, readInt16, DateUnit.MILLISECOND) // unit\n );\n case Type.Time: return time(\n // @ts-ignore\n get(4, readInt16, TimeUnit.MILLISECOND) // unit\n );\n case Type.Timestamp: return timestamp(\n // @ts-ignore\n get(4, readInt16, TimeUnit.SECOND), // unit\n get(6, readString) // timezone\n );\n case Type.Interval: return interval(\n // @ts-ignore\n get(4, readInt16, IntervalUnit.YEAR_MONTH) // unit\n );\n case Type.Duration: return duration(\n // @ts-ignore\n get(4, readInt16, TimeUnit.MILLISECOND) // unit\n );\n\n case Type.FixedSizeBinary: return fixedSizeBinary(\n get(4, readInt32, 0) // stride\n );\n case Type.FixedSizeList: return fixedSizeList(\n children[0],\n get(4, readInt32, 0), // stride\n );\n case Type.Map: return mapType(\n get(4, readBoolean, false), // keysSorted\n children[0]\n );\n\n case Type.Union: return union(\n // @ts-ignore\n get(4, readInt16, UnionMode.Sparse), // mode\n children,\n readVector(buf, get(6, readOffset), 4, readInt32) // type ids\n );\n }\n // case Type.NONE:\n // case Type.Null:\n // case Type.Bool:\n // case Type.BinaryView:\n // case Type.Utf8View:\n // @ts-ignore\n return { typeId };\n}\n","/**\n * @import { Metadata } from '../types.js'\n */\nimport { readObject, readString, readVector } from '../util/read.js';\n\n/**\n * Decode custom metadata consisting of key-value string pairs.\n * @param {Uint8Array} buf A byte buffer of binary Arrow IPC data\n * @param {number} index The starting index in the byte buffer\n * @returns {Metadata | null} The custom metadata map\n */\nexport function decodeMetadata(buf, index) {\n const entries = readVector(buf, index, 4, (buf, pos) => {\n const get = readObject(buf, pos);\n return /** @type {[string, string]} */ ([\n get(4, readString), // 4: key (string)\n get(6, readString) // 6: key (string)\n ]);\n });\n return entries.length ? new Map(entries) : null;\n}\n","/**\n * @import { DictionaryType, Endianness_, Field, IntType, Schema, Version_ } from '../types.js'\n */\nimport { Type } from '../constants.js';\nimport { dictionary, int32 } from '../data-types.js';\nimport { readBoolean, readInt16, readInt64, readObject, readOffset, readString, readUint8, readVector } from '../util/read.js';\nimport { decodeDataType } from './data-type.js';\nimport { decodeMetadata } from './metadata.js';\n\n/**\n * Decode a table schema describing the fields and their data types.\n * @param {Uint8Array} buf A byte buffer of binary Arrow IPC data\n * @param {number} index The starting index in the byte buffer\n * @param {Version_} version Arrow version value\n * @returns {Schema} The schema\n */\nexport function decodeSchema(buf, index, version) {\n // 4: endianness (int16)\n // 6: fields (vector)\n // 8: metadata (vector)\n // 10: features (int64[])\n const get = readObject(buf, index);\n return {\n version,\n endianness: /** @type {Endianness_} */ (get(4, readInt16, 0)),\n fields: get(6, decodeSchemaFields, []),\n metadata: get(8, decodeMetadata)\n };\n}\n\n/**\n * @returns {Field[] | null}\n */\nfunction decodeSchemaFields(buf, fieldsOffset) {\n return readVector(buf, fieldsOffset, 4, decodeField);\n}\n\n/**\n * @returns {Field}\n */\nfunction decodeField(buf, index) {\n // 4: name (string)\n // 6: nullable (bool)\n // 8: type id (uint8)\n // 10: type (union)\n // 12: dictionary (table)\n // 14: children (vector)\n // 16: metadata (vector)\n const get = readObject(buf, index);\n const typeId = get(8, readUint8, Type.NONE);\n const typeOffset = get(10, readOffset, 0);\n const dict = get(12, decodeDictionary);\n const children = get(14, (buf, off) => decodeFieldChildren(buf, off));\n\n let type = decodeDataType(buf, typeOffset, typeId, children);\n if (dict) {\n dict.dictionary = type;\n type = dict;\n }\n\n return {\n name: get(4, readString),\n type,\n nullable: get(6, readBoolean, false),\n metadata: get(16, decodeMetadata)\n };\n}\n\n/**\n * @returns {Field[] | null}\n */\nfunction decodeFieldChildren(buf, fieldOffset) {\n const children = readVector(buf, fieldOffset, 4, decodeField);\n return children.length ? children : null;\n}\n\n/**\n * @param {Uint8Array} buf\n * @param {number} index\n * @returns {DictionaryType}\n */\nfunction decodeDictionary(buf, index) {\n if (!index) return null;\n // 4: id (int64)\n // 6: indexType (Int type)\n // 8: isOrdered (boolean)\n // 10: kind (int16) currently only dense array is supported\n const get = readObject(buf, index);\n return dictionary(\n null, // data type will be populated by caller\n get(6, decodeInt, int32()), // index type\n get(8, readBoolean, false), // ordered\n get(4, readInt64, 0), // id\n );\n}\n\n/**\n * Decode an integer data type.\n * @param {Uint8Array} buf A byte buffer of binary Arrow IPC data.\n * @param {number} index The starting index in the byte buffer.\n * @returns {IntType}\n */\nfunction decodeInt(buf, index) {\n return /** @type {IntType} */ (\n decodeDataType(buf, index, Type.Int)\n );\n}\n","/**\n * @import { Message, MessageHeader_, Version_ } from '../types.js'\n */\nimport { MessageHeader, Version } from '../constants.js';\nimport { keyFor } from '../util/objects.js';\nimport { SIZEOF_INT, readInt16, readInt32, readInt64, readObject, readOffset, readUint8 } from '../util/read.js';\nimport { decodeDictionaryBatch } from './dictionary-batch.js';\nimport { decodeRecordBatch } from './record-batch.js';\nimport { decodeSchema } from './schema.js';\n\nconst invalidMessageMetadata = (expected, actual) =>\n `Expected to read ${expected} metadata bytes, but only read ${actual}.`;\n\nconst invalidMessageBodyLength = (expected, actual) =>\n `Expected to read ${expected} bytes for message body, but only read ${actual}.`;\n\nconst invalidMessageType = (type) =>\n `Unsupported message type: ${type} (${keyFor(MessageHeader, type)})`;\n\n/**\n * A \"message\" contains a block of Apache Arrow data, such as a schema,\n * record batch, or dictionary batch. This message decodes a single\n * message, returning its associated metadata and content.\n * @param {Uint8Array} buf A byte buffer of binary Arrow IPC data\n * @param {number} index The starting index in the byte buffer\n * @returns {Message} The decoded message.\n */\nexport function decodeMessage(buf, index) {\n // get message start\n let metadataLength = readInt32(buf, index) || 0;\n index += SIZEOF_INT;\n\n // ARROW-6313: If the first 4 bytes are continuation indicator (-1), read\n // the next 4 for the 32-bit metadata length. Otherwise, assume this is a\n // pre-v0.15 message, where the first 4 bytes are the metadata length.\n if (metadataLength === -1) {\n metadataLength = readInt32(buf, index) || 0;\n index += SIZEOF_INT;\n }\n if (metadataLength === 0) return null;\n\n const head = buf.subarray(index, index += metadataLength);\n if (head.byteLength < metadataLength) {\n throw new Error(invalidMessageMetadata(metadataLength, head.byteLength));\n }\n\n // decode message metadata\n // 4: version\n // 6: headerType\n // 8: headerIndex\n // 10: bodyLength\n const get = readObject(head, 0);\n const version = /** @type {Version_} */\n (get(4, readInt16, Version.V1));\n const type = /** @type {MessageHeader_} */\n (get(6, readUint8, MessageHeader.NONE));\n const offset = get(8, readOffset, 0);\n const bodyLength = get(10, readInt64, 0);\n let content;\n\n if (offset) {\n // decode message header\n const decoder = type === MessageHeader.Schema ? decodeSchema\n : type === MessageHeader.DictionaryBatch ? decodeDictionaryBatch\n : type === MessageHeader.RecordBatch ? decodeRecordBatch\n : null;\n if (!decoder) throw new Error(invalidMessageType(type));\n content = decoder(head, offset, version);\n\n // extract message body\n if (bodyLength > 0) {\n const body = buf.subarray(index, index += bodyLength);\n if (body.byteLength < bodyLength) {\n throw new Error(invalidMessageBodyLength(bodyLength, body.byteLength));\n }\n // @ts-ignore\n content.body = body;\n } else if (type !== MessageHeader.Schema) {\n // table-from-ipc.js buffer accessor requires body to exist, even for empty batches\n // @ts-ignore\n content.body = new Uint8Array(0);\n }\n }\n\n return { version, type, index, content };\n}\n","/**\n * @import { ArrowData, Version_ } from '../types.js'\n */\nimport { MAGIC, MessageHeader, Version } from '../constants.js';\nimport { isArrayBufferLike } from '../util/arrays.js';\nimport { readInt16, readInt32, readObject } from '../util/read.js';\nimport { decodeBlocks } from './block.js';\nimport { decodeMessage } from './message.js';\nimport { decodeMetadata } from './metadata.js';\nimport { decodeSchema } from './schema.js';\n\n/**\n * Decode [Apache Arrow IPC data][1] and return parsed schema, record batch,\n * and dictionary batch definitions. The input binary data may be either\n * an `ArrayBuffer` or `Uint8Array`. For Arrow data in the IPC 'stream' format,\n * an array of `Uint8Array` instances is also supported.\n *\n * This method stops short of generating views over field buffers. Use the\n * `createData()` method on the result to enable column data access.\n *\n * [1]: https://arrow.apache.org/docs/format/Columnar.html#serialization-and-interprocess-communication-ipc\n * @param {ArrayBufferLike | Uint8Array | Uint8Array[]} data\n * The source byte buffer, or an array of buffers. If an array, each byte\n * array may contain one or more self-contained messages. Messages may NOT\n * span multiple byte arrays.\n * @returns {import('../types.js').ArrowData}\n */\nexport function decodeIPC(data) {\n const source = isArrayBufferLike(data) ? new Uint8Array(data) : data;\n return source instanceof Uint8Array && isArrowFileFormat(source)\n ? decodeIPCFile(source)\n : decodeIPCStream(source);\n}\n\n/**\n * @param {Uint8Array} buf\n * @returns {boolean}\n */\nfunction isArrowFileFormat(buf) {\n if (!buf || buf.length < 4) return false;\n for (let i = 0; i < 6; ++i) {\n if (MAGIC[i] !== buf[i]) return false;\n }\n return true;\n}\n\n/**\n * Decode data in the [Arrow IPC 'stream' format][1].\n *\n * [1]: https://arrow.apache.org/docs/format/Columnar.html#ipc-streaming-format\n * @param {Uint8Array | Uint8Array[]} data The source byte buffer, or an\n * array of buffers. If an array, each byte array may contain one or more\n * self-contained messages. Messages may NOT span multiple byte arrays.\n * @returns {ArrowData}\n */\nexport function decodeIPCStream(data) {\n const stream = [data].flat();\n\n let schema;\n const records = [];\n const dictionaries = [];\n\n // consume each message in the stream\n for (const buf of stream) {\n if (!(buf instanceof Uint8Array)) {\n throw new Error(`IPC data batch was not a Uint8Array.`);\n }\n let offset = 0;\n\n // decode all messages in current buffer\n while (true) {\n const m = decodeMessage(buf, offset);\n if (m === null) break; // end of messages\n offset = m.index;\n if (!m.content) continue;\n switch (m.type) {\n case MessageHeader.Schema:\n // ignore repeated schema messages\n if (!schema) schema = m.content;\n break;\n case MessageHeader.RecordBatch:\n records.push(m.content);\n break;\n case MessageHeader.DictionaryBatch:\n dictionaries.push(m.content);\n break;\n }\n }\n }\n\n return /** @type {ArrowData} */ (\n { schema, dictionaries, records, metadata: null }\n );\n}\n\n/**\n * Decode data in the [Arrow IPC 'file' format][1].\n *\n * [1]: https://arrow.apache.org/docs/format/Columnar.html#ipc-file-format\n * @param {Uint8Array} data The source byte buffer.\n * @returns {ArrowData}\n */\nexport function decodeIPCFile(data) {\n // find footer location\n const offset = data.byteLength - (MAGIC.length + 4);\n const length = readInt32(data, offset);\n\n // decode file footer\n // 4: version\n // 6: schema\n // 8: dictionaries (vector)\n // 10: batches (vector)\n // 12: metadata\n const get = readObject(data, offset - length);\n const version = /** @type {Version_} */\n (get(4, readInt16, Version.V1));\n const dicts = get(8, decodeBlocks, []);\n const recs = get(10, decodeBlocks, []);\n\n return /** @type {ArrowData} */ ({\n schema: get(6, (buf, index) => decodeSchema(buf, index, version)),\n dictionaries: dicts.map(({ offset }) => decodeMessage(data, offset).content),\n records: recs.map(({ offset }) => decodeMessage(data, offset).content),\n metadata: get(12, decodeMetadata)\n });\n}\n","/**\n * @import { ArrowData, ExtractionOptions, Field, RecordBatch, Schema } from '../types.js'\n */\nimport { batchType } from '../batch-type.js';\nimport { columnBuilder } from '../column.js';\nimport { Type, UnionMode, Version } from '../constants.js';\nimport { invalidDataType } from '../data-types.js';\nimport { Table } from '../table.js';\nimport { int8Array } from '../util/arrays.js';\nimport { decodeIPC } from './decode-ipc.js';\n\n/**\n * Decode [Apache Arrow IPC data][1] and return a new Table. The input binary\n * data may be either an `ArrayBuffer` or `Uint8Array`. For Arrow data in the\n * [IPC 'stream' format][2], an array of `Uint8Array` values is also supported.\n *\n * [1]: https://arrow.apache.org/docs/format/Columnar.html#serialization-and-interprocess-communication-ipc\n * [2]: https://arrow.apache.org/docs/format/Columnar.html#ipc-streaming-format\n * @param {ArrayBufferLike | Uint8Array | Uint8Array[]} data\n * The source byte buffer, or an array of buffers. If an array, each byte\n * array may contain one or more self-contained messages. Messages may NOT\n * span multiple byte arrays.\n * @param {ExtractionOptions} [options]\n * Options for controlling how values are transformed when extracted\n * from an Arrow binary representation.\n * @returns {Table} A Table instance.\n */\nexport function tableFromIPC(data, options) {\n return createTable(decodeIPC(data), options);\n}\n\n/**\n * Create a table from parsed IPC data.\n * @param {ArrowData} data\n * The IPC data, as returned by parseIPC.\n * @param {ExtractionOptions} [options]\n * Options for controlling how values are transformed when extracted\n * from am Arrow binary representation.\n * @returns {Table} A Table instance.\n */\nexport function createTable(data, options = {}) {\n const { schema = { fields: [] }, dictionaries, records } = data;\n const { version, fields } = schema;\n const dictionaryMap = new Map;\n const context = contextGenerator(options, version, dictionaryMap);\n\n // build dictionary type map\n const dictionaryTypes = new Map;\n visitSchemaFields(schema, field => {\n const type = field.type;\n if (type.typeId === Type.Dictionary) {\n dictionaryTypes.set(type.id, type.dictionary);\n }\n });\n\n // decode dictionaries, build dictionary column map\n const dicts = new Map;\n for (const dict of dictionaries) {\n const { id, data, isDelta, body } = dict;\n const type = dictionaryTypes.get(id);\n const batch = visit(type, context({ ...data, body }));\n if (!dicts.has(id)) {\n if (isDelta) {\n throw new Error('Delta update can not be first dictionary batch.');\n }\n dicts.set(id, columnBuilder(type).add(batch));\n } else {\n const dict = dicts.get(id);\n if (!isDelta) dict.clear();\n dict.add(batch);\n }\n }\n dicts.forEach((value, key) => dictionaryMap.set(key, value.done()));\n\n // decode column fields\n const cols = fields.map(f => columnBuilder(f.type));\n for (const batch of records) {\n const ctx = context(batch);\n fields.forEach((f, i) => cols[i].add(visit(f.type, ctx)));\n }\n\n return new Table(schema, cols.map(c => c.done()), options.useProxy);\n}\n\n/**\n * Visit all fields within a schema.\n * @param {Schema} schema\n * @param {(field: Field) => void} visitor\n */\nfunction visitSchemaFields(schema, visitor) {\n schema.fields.forEach(function visitField(field) {\n visitor(field);\n // @ts-ignore\n field.type.dictionary?.children?.forEach(visitField);\n // @ts-ignore\n field.type.children?.forEach(visitField);\n });\n}\n\n/**\n * Context object generator for field visitation and buffer definition.\n */\nfunction contextGenerator(options, version, dictionaryMap) {\n const base = {\n version,\n options,\n dictionary: id => dictionaryMap.get(id),\n };\n\n /**\n * Return a context generator.\n * @param {RecordBatch} batch\n */\n return batch => {\n const { length, nodes, regions, variadic, body } = batch;\n let nodeIndex = -1;\n let bufferIndex = -1;\n let variadicIndex = -1;\n return {\n ...base,\n length,\n node: () => nodes[++nodeIndex],\n buffer: (ArrayType) => {\n const { length, offset } = regions[++bufferIndex];\n return ArrayType\n ? new ArrayType(body.buffer, body.byteOffset + offset, length / ArrayType.BYTES_PER_ELEMENT)\n : body.subarray(offset, offset + length)\n },\n variadic: () => variadic[++variadicIndex],\n visit(children) { return children.map(f => visit(f.type, this)); }\n };\n };\n}\n\n/**\n * Visit a field, instantiating views of buffer regions.\n */\nfunction visit(type, ctx) {\n const { typeId } = type;\n const { options, node, buffer, variadic, version } = ctx;\n const BatchType = batchType(type, options);\n\n // extract the next { length, nullCount } field node - ALL fields have field nodes\n const base = { ...node(), type };\n\n if (typeId === Type.Null) {\n // null fields have field nodes but no data buffers\n return new BatchType({ ...base, nullCount: base.length });\n }\n\n switch (typeId) {\n // validity and data value buffers\n case Type.Bool:\n case Type.Int:\n case Type.Time:\n case Type.Duration:\n case Type.Float:\n case Type.Decimal:\n case Type.Date:\n case Type.Timestamp:\n case Type.Interval:\n case Type.FixedSizeBinary:\n return new BatchType({\n ...base,\n validity: buffer(),\n values: buffer(type.values)\n });\n\n // validity, offset, and value buffers\n case Type.Utf8:\n case Type.LargeUtf8:\n case Type.Binary:\n case Type.LargeBinary:\n return new BatchType({\n ...base,\n validity: buffer(),\n offsets: buffer(type.offsets),\n values: buffer()\n });\n\n // views with variadic buffers\n case Type.BinaryView:\n case Type.Utf8View:\n return new BatchType({\n ...base,\n validity: buffer(),\n values: buffer(), // views buffer\n data: Array.from({ length: variadic() }, () => buffer()) // data buffers\n });\n\n // validity, offset, and list child\n case Type.List:\n case Type.LargeList:\n case Type.Map:\n return new BatchType({\n ...base,\n validity: buffer(),\n offsets: buffer(type.offsets),\n children: ctx.visit(type.children)\n });\n\n // validity, offset, size, and list child\n case Type.ListView:\n case Type.LargeListView:\n return new BatchType({\n ...base,\n validity: buffer(),\n offsets: buffer(type.offsets),\n sizes: buffer(type.offsets),\n children: ctx.visit(type.children)\n });\n\n // validity and children\n case Type.FixedSizeList:\n case Type.Struct:\n return new BatchType({\n ...base,\n validity: buffer(),\n children: ctx.visit(type.children)\n });\n\n // children only\n case Type.RunEndEncoded:\n return new BatchType({\n ...base,\n children: ctx.visit(type.children)\n });\n\n // dictionary\n case Type.Dictionary: {\n const { id, indices } = type;\n return new BatchType({\n ...base,\n validity: buffer(),\n values: buffer(indices.values),\n }).setDictionary(ctx.dictionary(id));\n }\n\n // union\n case Type.Union: {\n if (version < Version.V5) {\n buffer(); // skip unused null bitmap\n }\n return new BatchType({\n ...base,\n typeIds: buffer(int8Array),\n offsets: type.mode === UnionMode.Sparse ? null : buffer(type.offsets),\n children: ctx.visit(type.children)\n });\n }\n\n // unsupported type\n default:\n throw new Error(invalidDataType(typeId));\n }\n}\n","/**\n * @import { Sink } from './sink.js';\n */\nimport { grow } from '../util/arrays.js';\nimport { SIZEOF_INT, SIZEOF_SHORT, readInt16 } from '../util/read.js';\nimport { encodeUtf8 } from '../util/strings.js';\n\nexport function writeInt32(buf, index, value) {\n buf[index] = value;\n buf[index + 1] = value >> 8;\n buf[index + 2] = value >> 16;\n buf[index + 3] = value >> 24;\n}\n\nconst INIT_SIZE = 1024;\n\n/** Flatbuffer binary builder. */\nexport class Builder {\n /**\n * Create a new builder instance.\n * @param {Sink} sink The byte consumer.\n */\n constructor(sink) {\n /**\n * Sink that consumes built byte buffers;\n * @type {Sink}\n */\n this.sink = sink;\n /**\n * Minimum alignment encountered so far.\n * @type {number}\n */\n this.minalign = 1;\n /**\n * Current byte buffer.\n * @type {Uint8Array}\n */\n this.buf = new Uint8Array(INIT_SIZE);\n /**\n * Remaining space in the current buffer.\n * @type {number}\n */\n this.space = INIT_SIZE;\n /**\n * List of offsets of all vtables. Used to find and\n * reuse tables upon duplicated table field schemas.\n * @type {number[]}\n */\n this.vtables = [];\n /**\n * Total bytes written to sink thus far.\n */\n this.outputBytes = 0;\n }\n\n /**\n * Returns the flatbuffer offset, relative to the end of the current buffer.\n * @returns {number} Offset relative to the end of the buffer.\n */\n offset() {\n return this.buf.length - this.space;\n }\n\n /**\n * Write a flatbuffer int8 value at the current buffer position\n * and advance the internal cursor.\n * @param {number} value\n */\n writeInt8(value) {\n this.buf[this.space -= 1] = value;\n }\n\n /**\n * Write a flatbuffer int16 value at the current buffer position\n * and advance the internal cursor.\n * @param {number} value\n */\n writeInt16(value) {\n this.buf[this.space -= 2] = value;\n this.buf[this.space + 1] = value >> 8;\n }\n\n /**\n * Write a flatbuffer int32 value at the current buffer position\n * and advance the internal cursor.\n * @param {number} value\n */\n writeInt32(value) {\n writeInt32(this.buf, this.space -= 4, value);\n }\n\n /**\n * Write a flatbuffer int64 value at the current buffer position\n * and advance the internal cursor.\n * @param {number} value\n */\n writeInt64(value) {\n const v = BigInt(value);\n this.writeInt32(Number(BigInt.asIntN(32, v >> BigInt(32))));\n this.writeInt32(Number(BigInt.asIntN(32, v)));\n }\n\n /**\n * Add a flatbuffer int8 value, properly aligned,\n * @param value The int8 value to add the buffer.\n */\n addInt8(value) {\n prep(this, 1, 0);\n this.writeInt8(value);\n }\n\n /**\n * Add a flatbuffer int16 value, properly aligned,\n * @param value The int16 value to add the buffer.\n */\n addInt16(value) {\n prep(this, 2, 0);\n this.writeInt16(value);\n }\n\n /**\n * Add a flatbuffer int32 value, properly aligned,\n * @param value The int32 value to add the buffer.\n */\n addInt32(value) {\n prep(this, 4, 0);\n this.writeInt32(value);\n }\n\n /**\n * Add a flatbuffer int64 values, properly aligned.\n * @param value The int64 value to add the buffer.\n */\n addInt64(value) {\n prep(this, 8, 0);\n this.writeInt64(value);\n }\n\n /**\n * Add a flatbuffer offset, relative to where it will be written.\n * @param {number} offset The offset to add.\n */\n addOffset(offset) {\n prep(this, SIZEOF_INT, 0); // Ensure alignment is already done.\n this.writeInt32(this.offset() - offset + SIZEOF_INT);\n }\n\n /**\n * Add a flatbuffer object (vtable).\n * @param {number} numFields The maximum number of fields\n * this object may include.\n * @param {(tableBuilder: ReturnType<objectBuilder>) => void} [addFields]\n * A callback function that writes all fields using an object builder.\n * @returns {number} The object offset.\n */\n addObject(numFields, addFields) {\n const b = objectBuilder(this, numFields);\n addFields?.(b);\n return b.finish();\n }\n\n /**\n * Add a flatbuffer vector (list).\n * @template T\n * @param {T[]} items An array of items to write.\n * @param {number} itemSize The size in bytes of a serialized item.\n * @param {number} alignment The desired byte alignment value.\n * @param {(builder: this, item: T) => void} writeItem A callback\n * function that writes a vector item to this builder.\n * @returns {number} The vector offset.\n */\n addVector(items, itemSize, alignment, writeItem) {\n const n = items?.length;\n if (!n) return 0;\n prep(this, SIZEOF_INT, itemSize * n);\n prep(this, alignment, itemSize * n); // Just in case alignment > int.\n for (let i = n; --i >= 0;) {\n writeItem(this, items[i]);\n }\n this.writeInt32(n);\n return this.offset();\n }\n\n /**\n * Convenience method for writing a vector of byte buffer offsets.\n * @param {number[]} offsets\n * @returns {number} The vector offset.\n */\n addOffsetVector(offsets) {\n return this.addVector(offsets, 4, 4, (b, off) => b.addOffset(off));\n }\n\n /**\n * Add a flatbuffer UTF-8 string.\n * @param {string} s The string to encode.\n * @return {number} The string offset.\n */\n addString(s) {\n if (s == null) return 0;\n const utf8 = encodeUtf8(s);\n const n = utf8.length;\n this.addInt8(0); // string null terminator\n prep(this, SIZEOF_INT, n);\n this.buf.set(utf8, this.space -= n);\n this.writeInt32(n);\n return this.offset();\n }\n\n /**\n * Finish the current flatbuffer by adding a root offset.\n * @param {number} rootOffset The root offset.\n */\n finish(rootOffset) {\n prep(this, this.minalign, SIZEOF_INT);\n this.addOffset(rootOffset);\n }\n\n /**\n * Flush the current flatbuffer byte buffer content to the sink,\n * and reset the flatbuffer builder state.\n */\n flush() {\n const { buf, sink } = this;\n const bytes = buf.subarray(this.space, buf.length);\n sink.write(bytes);\n this.outputBytes += bytes.byteLength;\n this.minalign = 1;\n this.vtables = [];\n this.buf = new Uint8Array(INIT_SIZE);\n this.space = INIT_SIZE;\n }\n\n /**\n * Add a byte buffer directly to the builder sink. This method bypasses\n * any unflushed flatbuffer state and leaves it unchanged, writing the\n * buffer to the sink *before* the flatbuffer.\n * The buffer will be padded for 64-bit (8-byte) alignment as needed.\n * @param {Uint8Array} buffer The buffer to add.\n * @returns {number} The total byte count of the buffer and padding.\n */\n addBuffer(buffer) {\n const size = buffer.byteLength;\n if (!size) return 0;\n this.sink.write(buffer);\n this.outputBytes += size;\n const pad = ((size + 7) & ~7) - size;\n this.addPadding(pad);\n return size + pad;\n }\n\n /**\n * Write padding bytes directly to the builder sink. This method bypasses\n * any unflushed flatbuffer state and leaves it unchanged, writing the\n * padding bytes to the sink *before* the flatbuffer.\n * @param {number} byteCount The number of padding bytes.\n */\n addPadding(byteCount) {\n if (byteCount > 0) {\n this.sink.write(new Uint8Array(byteCount));\n this.outputBytes += byteCount;\n }\n }\n}\n\n/**\n * Prepare to write an element of `size` after `additionalBytes` have been\n * written, e.g. if we write a string, we need to align such the int length\n * field is aligned to 4 bytes, and the string data follows it directly. If all\n * we need to do is alignment, `additionalBytes` will be 0.\n * @param {Builder} builder The builder to prep.\n * @param {number} size The size of the new element to write.\n * @param {number} additionalBytes Additional padding size.\n */\nexport function prep(builder, size, additionalBytes) {\n let { buf, space, minalign } = builder;\n\n // track the biggest thing we've ever aligned to\n if (size > minalign) {\n builder.minalign = size;\n }\n\n // find alignment needed so that `size` aligns after `additionalBytes`\n const bufSize = buf.length;\n const used = bufSize - space + additionalBytes;\n const alignSize = (~used + 1) & (size - 1);\n\n // reallocate the buffer if needed\n buf = grow(buf, used + alignSize + size - 1, true);\n space += buf.length - bufSize;\n\n // add padding\n for (let i = 0; i < alignSize; ++i) {\n buf[--space] = 0;\n }\n\n // update builder state\n builder.buf = buf;\n builder.space = space;\n}\n\n/**\n * Returns a builder object for flatbuffer objects (vtables).\n * @param {Builder} builder The underlying flatbuffer builder.\n * @param {number} numFields The expected number of fields, not\n * including the standard size fields.\n */\nfunction objectBuilder(builder, numFields) {\n /** @type {number[]} */\n const vtable = Array(numFields).fill(0);\n const startOffset = builder.offset();\n\n function slot(index) {\n vtable[index] = builder.offset();\n }\n\n return {\n /**\n * Add an int8-valued table field.\n * @param {number} index\n * @param {number} value\n * @param {number} defaultValue\n */\n addInt8(index, value, defaultValue) {\n if (value != defaultValue) {\n builder.addInt8(value);\n slot(index);\n }\n },\n\n /**\n * Add an int16-valued table field.\n * @param {number} index\n * @param {number} value\n * @param {number} defaultValue\n */\n addInt16(index, value, defaultValue) {\n if (value != defaultValue) {\n builder.addInt16(value);\n slot(index);\n }\n },\n\n /**\n * Add an int32-valued table field.\n * @param {number} index\n * @param {number} value\n * @param {number} defaultValue\n */\n addInt32(index, value, defaultValue) {\n if (value != defaultValue) {\n builder.addInt32(value);\n slot(index);\n }\n },\n\n /**\n * Add an int64-valued table field.\n * @param {number} index\n * @param {number} value\n * @param {number} defaultValue\n */\n addInt64(index, value, defaultValue) {\n if (value != defaultValue) {\n builder.addInt64(value);\n slot(index);\n }\n },\n\n /**\n * Add a buffer offset-valued table field.\n * @param {number} index\n * @param {number} value\n * @param {number} defaultValue\n */\n addOffset(index, value, defaultValue) {\n if (value != defaultValue) {\n builder.addOffset(value);\n slot(index);\n }\n },\n\n /**\n * Write the vtable to the buffer and return the table offset.\n * @returns {number} The buffer offset to the vtable.\n */\n finish() {\n // add offset entry, will overwrite later with actual offset\n builder.addInt32(0);\n const vtableOffset = builder.offset();\n\n // trim zero-valued fields (indicating default value)\n let i = numFields;\n while (--i >= 0 && vtable[i] === 0) {} // eslint-disable-line no-empty\n const size = i + 1;\n\n // Write out the current vtable.\n for (; i >= 0; --i) {\n // Offset relative to the start of the table.\n builder.addInt16(vtable[i] ? (vtableOffset - vtable[i]) : 0);\n }\n\n const standardFields = 2; // size fields\n builder.addInt16(vtableOffset - startOffset);\n const len = (size + standardFields) * SIZEOF_SHORT;\n builder.addInt16(len);\n\n // Search for an existing vtable that matches the current one.\n let existingTable = 0;\n const { buf, vtables, space: vt1 } = builder;\n outer_loop:\n for (i = 0; i < vtables.length; ++i) {\n const vt2 = buf.length - vtables[i];\n if (len == readInt16(buf, vt2)) {\n for (let j = SIZEOF_SHORT; j < len; j += SIZEOF_SHORT) {\n if (readInt16(buf, vt1 + j) != readInt16(buf, vt2 + j)) {\n continue outer_loop;\n }\n }\n existingTable = vtables[i];\n break;\n }\n }\n\n if (existingTable) {\n // Found a match: remove the current vtable.\n // Point table to existing vtable.\n builder.space = buf.length - vtableOffset;\n writeInt32(buf, builder.space, existingTable - vtableOffset);\n } else {\n // No match: add the location of the current vtable to the vtables list.\n // Point table to current vtable.\n const off = builder.offset();\n vtables.push(off);\n writeInt32(buf, buf.length - vtableOffset, off - vtableOffset);\n }\n\n return vtableOffset;\n }\n }\n}\n","/**\n * @import { RecordBatch } from '../types.js';\n * @import { Builder } from './builder.js';\n */\n\n/**\n * @param {Builder} builder\n * @param {RecordBatch} batch\n * @returns {number}\n */\nexport function encodeRecordBatch(builder, batch) {\n const { nodes, regions, variadic } = batch;\n const nodeVector = builder.addVector(nodes, 16, 8,\n (builder, node) => {\n builder.writeInt64(node.nullCount);\n builder.writeInt64(node.length);\n return builder.offset();\n }\n );\n const regionVector = builder.addVector(regions, 16, 8,\n (builder, region) => {\n builder.writeInt64(region.length);\n builder.writeInt64(region.offset);\n return builder.offset();\n }\n );\n const variadicVector = builder.addVector(variadic, 8, 8,\n (builder, count) => builder.addInt64(count)\n );\n return builder.addObject(5, b => {\n b.addInt64(0, nodes[0].length, 0);\n b.addOffset(1, nodeVector, 0);\n b.addOffset(2, regionVector, 0);\n // NOT SUPPORTED: 3, compression offset\n b.addOffset(4, variadicVector, 0);\n });\n}\n","/**\n * @import { DictionaryBatch } from '../types.js';\n * @import { Builder } from './builder.js';\n */\nimport { encodeRecordBatch } from './record-batch.js';\n\n/**\n * @param {Builder} builder\n * @param {DictionaryBatch} dictionaryBatch\n * @returns {number}\n */\nexport function encodeDictionaryBatch(builder, dictionaryBatch) {\n const dataOffset = encodeRecordBatch(builder, dictionaryBatch.data);\n return builder.addObject(3, b => {\n b.addInt64(0, dictionaryBatch.id, 0);\n b.addOffset(1, dataOffset, 0);\n b.addInt8(2, +dictionaryBatch.isDelta, 0);\n });\n}\n","/**\n * @import { Builder } from './builder.js';\n */\n\n/**\n * @param {Builder} builder\n * @param {Map<string, string>} metadata\n * @returns {number}\n */\nexport function encodeMetadata(builder, metadata) {\n return metadata?.size > 0\n ? builder.addOffsetVector(Array.from(metadata, ([k, v]) => {\n const key = builder.addString(`${k}`);\n const val = builder.addString(`${v}`);\n return builder.addObject(2, b => {\n b.addOffset(0, key, 0);\n b.addOffset(1, val, 0);\n });\n }))\n : 0;\n}\n","/**\n * @import { DataType } from '../types.js';\n * @import { Builder } from './builder.js';\n */\nimport { DateUnit, IntervalUnit, Precision, TimeUnit, Type, UnionMode } from '../constants.js';\nimport { invalidDataType } from '../data-types.js';\nimport { checkOneOf } from '../util/objects.js';\n\n/**\n * Encode a data type into a flatbuffer.\n * @param {Builder} builder\n * @param {DataType} type\n * @returns {number} The offset at which the data type is written.\n */\nexport function encodeDataType(builder, type) {\n const typeId = checkOneOf(type.typeId, Type, invalidDataType);\n\n switch (typeId) {\n case Type.Dictionary:\n return encodeDictionary(builder, type);\n case Type.Int:\n return encodeInt(builder, type);\n case Type.Float:\n return encodeFloat(builder, type);\n case Type.Decimal:\n return encodeDecimal(builder, type);\n case Type.Date:\n return encodeDate(builder, type);\n case Type.Time:\n return encodeTime(builder, type);\n case Type.Timestamp:\n return encodeTimestamp(builder, type);\n case Type.Interval:\n return encodeInterval(builder, type);\n case Type.Duration:\n return encodeDuration(builder, type);\n case Type.FixedSizeBinary:\n case Type.FixedSizeList:\n return encodeFixedSize(builder, type);\n case Type.Map:\n return encodeMap(builder, type);\n case Type.Union:\n return encodeUnion(builder, type);\n }\n // case Type.Null:\n // case Type.Binary:\n // case Type.LargeBinary:\n // case Type.BinaryView:\n // case Type.Bool:\n // case Type.Utf8:\n // case Type.Utf8View:\n // case Type.LargeUtf8:\n // case Type.List:\n // case Type.ListView:\n // case Type.LargeList:\n // case Type.LargeListView:\n // case Type.RunEndEncoded:\n // case Type.Struct:\n return builder.addObject(0);\n}\n\nfunction encodeDate(builder, type) {\n return builder.addObject(1, b => {\n b.addInt16(0, type.unit, DateUnit.MILLISECOND);\n });\n}\n\nfunction encodeDecimal(builder, type) {\n return builder.addObject(3, b => {\n b.addInt32(0, type.precision, 0);\n b.addInt32(1, type.scale, 0);\n b.addInt32(2, type.bitWidth, 128);\n });\n}\n\nfunction encodeDuration(builder, type) {\n return builder.addObject(1, b => {\n b.addInt16(0, type.unit, TimeUnit.MILLISECOND);\n });\n}\n\nfunction encodeFixedSize(builder, type) {\n return builder.addObject(1, b => {\n b.addInt32(0, type.stride, 0);\n });\n}\n\nfunction encodeFloat(builder, type) {\n return builder.addObject(1, b => {\n b.addInt16(0, type.precision, Precision.HALF);\n });\n}\n\nfunction encodeInt(builder, type) {\n return builder.addObject(2, b => {\n b.addInt32(0, type.bitWidth, 0);\n b.addInt8(1, +type.signed, 0);\n });\n}\n\nfunction encodeInterval(builder, type) {\n return builder.addObject(1, b => {\n b.addInt16(0, type.unit, IntervalUnit.YEAR_MONTH);\n });\n}\n\nfunction encodeMap(builder, type) {\n return builder.addObject(1, b => {\n b.addInt8(0, +type.keysSorted, 0);\n });\n}\n\nfunction encodeTime(builder, type) {\n return builder.addObject(2, b => {\n b.addInt16(0, type.unit, TimeUnit.MILLISECOND);\n b.addInt32(1, type.bitWidth, 32);\n });\n}\n\nfunction encodeTimestamp(builder, type) {\n const timezoneOffset = builder.addString(type.timezone);\n return builder.addObject(2, b => {\n b.addInt16(0, type.unit, TimeUnit.SECOND);\n b.addOffset(1, timezoneOffset, 0);\n });\n}\n\nfunction encodeUnion(builder, type) {\n const typeIdsOffset = builder.addVector(\n type.typeIds, 4, 4,\n (builder, value) => builder.addInt32(value)\n );\n return builder.addObject(2, b => {\n b.addInt16(0, type.mode, UnionMode.Sparse);\n b.addOffset(1, typeIdsOffset, 0);\n });\n}\n\nfunction encodeDictionary(builder, type) {\n // The Arrow spec uses signed 32-bit integers as the default index type.\n // However, multiple 3rd party tools fail on a null (default) index type,\n // so we always encode the index data type explicitly here.\n return builder.addObject(4, b => {\n b.addInt64(0, type.id, 0);\n b.addOffset(1, encodeDataType(builder, type.indices), 0);\n b.addInt8(2, +type.ordered, 0);\n // NOT SUPPORTED: 3, dictionaryKind (defaults to dense array)\n });\n}\n","/**\n * @import { DictionaryType, Field, Schema } from '../types.js';\n * @import { Builder } from './builder.js';\n */\nimport { Type } from '../constants.js';\nimport { encodeDataType } from './data-type.js';\nimport { encodeMetadata } from './metadata.js';\n\nconst isLittleEndian = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;\n\n/**\n * @param {Builder} builder\n * @param {Schema} schema\n * @returns {number}\n */\nexport function encodeSchema(builder, schema) {\n const { fields, metadata } = schema;\n const fieldOffsets = fields.map(f => encodeField(builder, f));\n const fieldsVectorOffset = builder.addOffsetVector(fieldOffsets);\n const metadataOffset = encodeMetadata(builder, metadata);\n return builder.addObject(4, b => {\n b.addInt16(0, +(!isLittleEndian), 0);\n b.addOffset(1, fieldsVectorOffset, 0);\n b.addOffset(2, metadataOffset, 0);\n // NOT SUPPORTED: 3, features\n });\n}\n\n/**\n * @param {Builder} builder\n * @param {Field} field\n * @returns {number}\n */\nfunction encodeField(builder, field) {\n const { name, nullable, type, metadata } = field;\n let { typeId } = type;\n\n // encode field data type\n let typeOffset = 0;\n let dictionaryOffset = 0;\n if (typeId !== Type.Dictionary) {\n typeOffset = encodeDataType(builder, type);\n } else {\n const dict = /** @type {DictionaryType} */ (type).dictionary;\n typeId = dict.typeId;\n dictionaryOffset = encodeDataType(builder, type);\n typeOffset = encodeDataType(builder, dict);\n }\n\n // encode children, metadata, name, and field object\n // @ts-ignore\n const childOffsets = (type.children || []).map(f => encodeField(builder, f));\n const childrenVectorOffset = builder.addOffsetVector(childOffsets);\n const metadataOffset = encodeMetadata(builder, metadata);\n const nameOffset = builder.addString(name);\n return builder.addObject(7, b => {\n b.addOffset(0, nameOffset, 0);\n b.addInt8(1, +nullable, +false);\n b.addInt8(2, typeId, Type.NONE);\n b.addOffset(3, typeOffset, 0);\n b.addOffset(4, dictionaryOffset, 0);\n b.addOffset(5, childrenVectorOffset, 0);\n b.addOffset(6, metadataOffset, 0);\n });\n}\n","/**\n * @import { Block, Schema } from '../types.js';\n * @import { Builder } from './builder.js';\n */\nimport { MAGIC, Version } from '../constants.js';\nimport { encodeMetadata } from './metadata.js';\nimport { encodeSchema } from './schema.js';\n\n/**\n * Write a file footer.\n * @param {Builder} builder The binary builder.\n * @param {Schema} schema The table schema.\n * @param {Block[]} dictBlocks Dictionary batch file blocks.\n * @param {Block[]} recordBlocks Record batch file blocks.\n * @param {Map<string,string> | null} metadata File-level metadata.\n */\nexport function writeFooter(builder, schema, dictBlocks, recordBlocks, metadata) {\n // encode footer flatbuffer\n const metadataOffset = encodeMetadata(builder, metadata);\n const recsOffset = builder.addVector(recordBlocks, 24, 8, encodeBlock);\n const dictsOffset = builder.addVector(dictBlocks, 24, 8, encodeBlock);\n const schemaOffset = encodeSchema(builder, schema);\n builder.finish(\n builder.addObject(5, b => {\n b.addInt16(0, Version.V5, Version.V1);\n b.addOffset(1, schemaOffset, 0);\n b.addOffset(2, dictsOffset, 0);\n b.addOffset(3, recsOffset, 0);\n b.addOffset(4, metadataOffset, 0);\n })\n );\n const size = builder.offset();\n\n // add eos with continuation indicator\n builder.addInt32(0);\n builder.addInt32(-1);\n\n // write builder contents\n builder.flush();\n\n // write file tail\n builder.sink.write(new Uint8Array(Int32Array.of(size).buffer));\n builder.sink.write(MAGIC);\n}\n\n/**\n * Encode a file pointer block.\n * @param {Builder} builder\n * @param {Block} block\n * @returns {number} the current block offset\n */\nfunction encodeBlock(builder, { offset, metadataLength, bodyLength }) {\n builder.writeInt64(bodyLength);\n builder.writeInt32(0);\n builder.writeInt32(metadataLength);\n builder.writeInt64(offset);\n return builder.offset();\n}\n","/**\n * @import { Block, MessageHeader_ } from '../types.js';\n * @import { Builder } from './builder.js';\n */\nimport { MessageHeader, Version } from '../constants.js';\n\n/**\n * Write an IPC message to the builder sink.\n * @param {Builder} builder\n * @param {MessageHeader_} headerType\n * @param {number} headerOffset\n * @param {number} bodyLength\n * @param {Block[]} [blocks]\n */\nexport function writeMessage(builder, headerType, headerOffset, bodyLength, blocks) {\n builder.finish(\n builder.addObject(5, b => {\n b.addInt16(0, Version.V5, Version.V1);\n b.addInt8(1, headerType, MessageHeader.NONE);\n b.addOffset(2, headerOffset, 0);\n b.addInt64(3, bodyLength, 0);\n // NOT SUPPORTED: 4, message-level metadata\n })\n );\n\n const prefixSize = 8; // continuation indicator + message size\n const messageSize = builder.offset();\n const alignedSize = (messageSize + prefixSize + 7) & ~7;\n\n // track blocks for file footer\n blocks?.push({\n offset: builder.outputBytes,\n metadataLength: alignedSize,\n bodyLength\n });\n\n // write size prefix (including padding)\n builder.addInt32(alignedSize - prefixSize);\n\n // write the stream continuation indicator\n builder.addInt32(-1);\n\n // flush the builder content\n builder.flush();\n\n // add alignment padding as needed\n builder.addPadding(alignedSize - messageSize - prefixSize);\n}\n","export class Sink {\n /**\n * Write bytes to this sink.\n * @param {Uint8Array} bytes The byte buffer to write.\n */\n write(bytes) { // eslint-disable-line no-unused-vars\n }\n\n /**\n * Write padding bytes (zeroes) to this sink.\n * @param {number} byteCount The number of padding bytes.\n */\n pad(byteCount) {\n this.write(new Uint8Array(byteCount));\n }\n\n /**\n * @returns {Uint8Array | null}\n */\n finish() {\n return null;\n }\n}\n\nexport class MemorySink extends Sink {\n /**\n * A sink that collects bytes in memory.\n */\n constructor() {\n super();\n this.buffers = [];\n }\n\n /**\n * Write bytes\n * @param {Uint8Array} bytes\n */\n write(bytes) {\n this.buffers.push(bytes);\n }\n\n /**\n * @returns {Uint8Array}\n */\n finish() {\n const bufs = this.buffers;\n const size = bufs.reduce((sum, b) => sum + b.byteLength, 0);\n const buf = new Uint8Array(size);\n for (let i = 0, off = 0; i < bufs.length; ++i) {\n buf.set(bufs[i], off);\n off += bufs[i].byteLength;\n }\n return buf;\n }\n}\n","/**\n * @import { Sink } from './sink.js';\n */\nimport { EOS, MAGIC, MessageHeader } from '../constants.js';\nimport { Builder } from './builder.js';\nimport { encodeDictionaryBatch } from './dictionary-batch.js';\nimport { writeFooter } from './footer.js';\nimport { encodeRecordBatch } from './record-batch.js';\nimport { encodeSchema } from './schema.js';\nimport { writeMessage } from './message.js';\nimport { MemorySink } from './sink.js';\n\nconst STREAM = 'stream';\nconst FILE = 'file';\n\n/**\n * Encode assembled data into Arrow IPC binary format.\n * @param {any} data Assembled table data.\n * @param {object} options Encoding options.\n * @param {Sink} [options.sink] IPC byte consumer.\n * @param {'stream' | 'file'} [options.format] Arrow stream or file format.\n * @returns {Sink} The sink that was passed in.\n */\nexport function encodeIPC(data, { sink, format = STREAM } = {}) {\n if (format !== STREAM && format !== FILE) {\n throw new Error(`Unrecognized Arrow IPC format: ${format}`);\n }\n const { schema, dictionaries = [], records = [], metadata } = data;\n const builder = new Builder(sink || new MemorySink());\n const file = format === FILE;\n const dictBlocks = [];\n const recordBlocks = [];\n\n if (file) {\n builder.addBuffer(MAGIC);\n }\n\n // both stream and file start with the schema\n if (schema) {\n writeMessage(\n builder,\n MessageHeader.Schema,\n encodeSchema(builder, schema),\n 0\n );\n }\n\n // write dictionary messages\n for (const dict of dictionaries) {\n const { data } = dict;\n writeMessage(\n builder,\n MessageHeader.DictionaryBatch,\n encodeDictionaryBatch(builder, dict),\n data.byteLength,\n dictBlocks\n );\n writeBuffers(builder, data.buffers);\n }\n\n // write record batch messages\n for (const batch of records) {\n writeMessage(\n builder,\n MessageHeader.RecordBatch,\n encodeRecordBatch(builder, batch),\n batch.byteLength,\n recordBlocks\n );\n writeBuffers(builder, batch.buffers);\n }\n\n // both stream and file include end-of-stream message\n builder.addBuffer(EOS);\n\n if (file) {\n writeFooter(builder, schema, dictBlocks, recordBlocks, metadata);\n }\n\n return builder.sink;\n}\n\n/**\n * Write byte buffers to the builder sink.\n * Buffers are aligned to 64 bits (8 bytes) as needed.\n * @param {Builder} builder\n * @param {Uint8Array[]} buffers\n */\nfunction writeBuffers(builder, buffers) {\n for (let i = 0; i < buffers.length; ++i) {\n builder.addBuffer(buffers[i]); // handles alignment for us\n }\n}\n","/**\n * @import { Batch, DictionaryBatch } from '../batch.js'\n * @import { Column } from '../column.js'\n * @import { Table } from '../table.js'\n * @import { DataType, RecordBatch, Schema, TypedArray } from '../types.js'\n * @import { Sink } from './sink.js';\n */\nimport { Type, UnionMode } from '../constants.js';\nimport { invalidDataType } from '../data-types.js';\nimport { encodeIPC } from './encode-ipc.js';\n\n/**\n * Encode an Arrow table into Arrow IPC binary format.\n * @param {Table} table The Arrow table to encode.\n * @param {object} options Encoding options.\n * @param {Sink} [options.sink] IPC byte consumer.\n * @param {'stream' | 'file'} [options.format] Arrow stream or file format.\n * @returns {Uint8Array | null} The generated bytes (for an in-memory sink)\n * or null (if using a sink that writes bytes elsewhere).\n */\nexport function tableToIPC(table, options) {\n // accept a format string option for Arrow-JS compatibility\n if (typeof options === 'string') {\n options = { format: options };\n }\n\n const columns = table.children;\n checkBatchLengths(columns);\n\n const { dictionaries, idMap } = assembleDictionaryBatches(columns);\n const records = assembleRecordBatches(columns);\n const schema = assembleSchema(table.schema, idMap);\n const data = { schema, dictionaries, records };\n return encodeIPC(data, options).finish();\n}\n\nfunction checkBatchLengths(columns) {\n const n = columns[0]?.data.map(d => d.length);\n columns.forEach(({ data }) => {\n if (data.length !== n.length || data.some((b, i) => b.length !== n[i])) {\n throw new Error('Columns have inconsistent batch sizes.');\n }\n });\n}\n\n/**\n * Create a new assembly context.\n */\nfunction assembleContext() {\n let byteLength = 0;\n const nodes = [];\n const regions = [];\n const buffers = [];\n const variadic = [];\n return {\n /**\n * @param {number} length\n * @param {number} nullCount\n */\n node(length, nullCount) {\n nodes.push({ length, nullCount });\n },\n /**\n * @param {TypedArray} b\n */\n buffer(b) {\n const size = b.byteLength;\n const length = ((size + 7) & ~7);\n regions.push({ offset: byteLength, length });\n byteLength += length;\n buffers.push(new Uint8Array(b.buffer, b.byteOffset, size));\n },\n /**\n * @param {number} length\n */\n variadic(length) {\n variadic.push(length);\n },\n /**\n * @param {DataType} type\n * @param {Batch} batch\n */\n children(type, batch) {\n // @ts-ignore\n type.children.forEach((field, index) => {\n visit(field.type, batch.children[index], this);\n });\n },\n /**\n * @returns {RecordBatch}\n */\n done() {\n return { byteLength, nodes, regions, variadic, buffers };\n }\n };\n}\n\n/**\n * Assemble dictionary batches and their unique ids.\n * @param {Column[]} columns The table columns.\n * @returns {{\n * dictionaries: DictionaryBatch[],\n * idMap: Map<DataType, number>\n * }}\n * The assembled dictionary batches and a map from dictionary column\n * instances to dictionary ids.\n */\nfunction assembleDictionaryBatches(columns) {\n const dictionaries = [];\n const dictMap = new Map;\n const idMap = new Map;\n let id = -1;\n\n // track dictionaries, key by dictionary column, assign ids\n const visitor = dictionaryColumn => {\n if (!dictMap.has(dictionaryColumn)) {\n dictMap.set(dictionaryColumn, ++id);\n for (let i = 0; i < dictionaryColumn.data.length; ++i) {\n dictionaries.push({\n id,\n isDelta: i > 0,\n data: assembleRecordBatch([dictionaryColumn], i)\n });\n }\n idMap.set(dictionaryColumn.type, id);\n } else {\n idMap.set(dictionaryColumn.type, dictMap.get(dictionaryColumn));\n }\n };\n\n // recurse through column batches to find dictionaries\n // it is sufficient to visit the first batch only,\n // as all batches have the same dictionary column\n columns.forEach(col => visitDictionaries(col.data[0], visitor));\n\n return { dictionaries, idMap };\n}\n\n/**\n * Traverse column batches to visit dictionary columns.\n * @param {Batch} batch\n * @param {(column: Column) => void} visitor\n */\nfunction visitDictionaries(batch, visitor) {\n if (batch?.type.typeId === Type.Dictionary) {\n // @ts-ignore - batch has type DictionaryBatch\n const dictionary = batch.dictionary;\n visitor(dictionary);\n visitDictionaries(dictionary.data[0], visitor);\n }\n batch?.children?.forEach(child => visitDictionaries(child, visitor));\n}\n\n/**\n * Assemble a schema with resolved dictionary ids.\n * @param {Schema} schema The schema.\n * @param {Map<DataType, number>} idMap A map\n * from dictionary value types to dictionary ids.\n * @returns {Schema} A new schema with resolved\n * dictionary ids. If there are no dictionaries, the input schema is\n * returned unchanged.\n */\nfunction assembleSchema(schema, idMap) {\n // early exit if no dictionaries\n if (!idMap.size) return schema;\n\n const visit = type => {\n if (type.typeId === Type.Dictionary) {\n type.id = idMap.get(type.dictionary); // lookup and set id\n visitDictType(type);\n }\n if (type.children) {\n (type.children = type.children.slice()).forEach(visitFields);\n }\n };\n\n // visit a field in a field array\n const visitFields = (field, index, array) => {\n const type = { ...field.type };\n array[index] = { ...field, type };\n visit(type);\n };\n\n // visit a dictionary values type\n const visitDictType = (parentType) => {\n const type = { ...parentType.dictionary };\n parentType.dictionary = type;\n visit(type);\n };\n\n schema = { ...schema, fields: schema.fields.slice() };\n schema.fields.forEach(visitFields);\n return schema;\n}\n\n/**\n * Assemble record batches with marshalled buffers.\n * @param {Column[]} columns The table columns.\n * @returns {RecordBatch[]} The assembled record batches.\n */\nfunction assembleRecordBatches(columns) {\n return (columns[0]?.data || [])\n .map((_, index) => assembleRecordBatch(columns, index));\n}\n\n/**\n * Assemble a record batch with marshalled buffers.\n * @param {Column[]} columns The table columns.\n * @param {number} batchIndex The batch index.\n * @returns {RecordBatch} The assembled record batch.\n */\nfunction assembleRecordBatch(columns, batchIndex = 0) {\n const ctx = assembleContext();\n columns.forEach(column => {\n visit(column.type, column.data[batchIndex], ctx);\n });\n return ctx.done();\n}\n\n/**\n * Visit a column batch, assembling buffer data.\n * @param {DataType} type The data type.\n * @param {Batch} batch The column batch.\n * @param {ReturnType<assembleContext>} ctx The assembly context.\n */\nfunction visit(type, batch, ctx) {\n const { typeId } = type;\n\n // record field node info - ALL fields need field nodes, including nulls\n ctx.node(batch.length, batch.nullCount);\n\n // null fields have field nodes but no data buffers\n if (typeId === Type.Null) return;\n\n switch (typeId) {\n // validity and value buffers\n // backing dictionaries handled elsewhere\n case Type.Bool:\n case Type.Int:\n case Type.Time:\n case Type.Duration:\n case Type.Float:\n case Type.Date:\n case Type.Timestamp:\n case Type.Decimal:\n case Type.Interval:\n case Type.FixedSizeBinary:\n case Type.Dictionary: // dict key values\n ctx.buffer(batch.validity);\n ctx.buffer(batch.values);\n return;\n\n // validity, offset, and value buffers\n case Type.Utf8:\n case Type.LargeUtf8:\n case Type.Binary:\n case Type.LargeBinary:\n ctx.buffer(batch.validity);\n ctx.buffer(batch.offsets);\n ctx.buffer(batch.values);\n return;\n\n // views with variadic buffers\n case Type.BinaryView:\n case Type.Utf8View:\n ctx.buffer(batch.validity);\n ctx.buffer(batch.values);\n // @ts-ignore\n ctx.variadic(batch.data.length);\n // @ts-ignore\n batch.data.forEach(b => ctx.buffer(b));\n return;\n\n // validity, offset, and list child\n case Type.List:\n case Type.LargeList:\n case Type.Map:\n ctx.buffer(batch.validity);\n ctx.buffer(batch.offsets);\n ctx.children(type, batch);\n return;\n\n // validity, offset, size, and list child\n case Type.ListView:\n case Type.LargeListView:\n ctx.buffer(batch.validity);\n ctx.buffer(batch.offsets);\n ctx.buffer(batch.sizes);\n ctx.children(type, batch);\n return;\n\n // validity and children\n case Type.FixedSizeList:\n case Type.Struct:\n ctx.buffer(batch.validity);\n ctx.children(type, batch);\n return;\n\n // children only\n case Type.RunEndEncoded:\n ctx.children(type, batch);\n return;\n\n // union\n case Type.Union: {\n // @ts-ignore\n ctx.buffer(batch.typeIds);\n if (type.mode === UnionMode.Dense) {\n ctx.buffer(batch.offsets);\n }\n ctx.children(type, batch);\n return;\n }\n\n // unsupported type\n default:\n throw new Error(invalidDataType(typeId));\n }\n}\n","/**\n * @import { TypedArray, TypedArrayConstructor } from '../types.js'\n */\nimport { align, grow, uint8Array } from '../util/arrays.js';\n\n/**\n * Create a new resizable buffer instance.\n * @param {TypedArrayConstructor} [arrayType]\n * The array type.\n * @returns {Buffer} The buffer.\n */\nexport function buffer(arrayType) {\n return new Buffer(arrayType);\n}\n\n/**\n * Resizable byte buffer.\n */\nexport class Buffer {\n /**\n * Create a new resizable buffer instance.\n * @param {TypedArrayConstructor} arrayType\n */\n constructor(arrayType = uint8Array) {\n this.buf = new arrayType(512);\n }\n /**\n * Return the underlying data as a 64-bit aligned array of minimum size.\n * @param {number} size The desired minimum array size.\n * @returns {TypedArray} The 64-bit aligned array.\n */\n array(size) {\n return align(this.buf, size);\n }\n /**\n * Prepare for writes to the given index, resizing as necessary.\n * @param {number} index The array index to prepare to write to.\n */\n prep(index) {\n if (index >= this.buf.length) {\n this.buf = grow(this.buf, index);\n }\n }\n /**\n * Return the value at the given index.\n * @param {number} index The array index.\n */\n get(index) {\n return this.buf[index];\n }\n /**\n * Set a value at the given index.\n * @param {number | bigint} value The value to set.\n * @param {number} index The index to write to.\n */\n set(value, index) {\n this.prep(index);\n this.buf[index] = value;\n }\n /**\n * Write a byte array at the given index. The method should be called\n * only when the underlying buffer is of type Uint8Array.\n * @param {Uint8Array} bytes The byte array.\n * @param {number} index The starting index to write to.\n */\n write(bytes, index) {\n this.prep(index + bytes.length);\n /** @type {Uint8Array} */ (this.buf).set(bytes, index);\n }\n}\n\n/**\n * Create a new resizable bitmap instance.\n * @returns {Bitmap} The bitmap buffer.\n */\nexport function bitmap() {\n return new Bitmap();\n}\n\n/**\n * Resizable bitmap buffer.\n */\nexport class Bitmap extends Buffer {\n /**\n * Set a bit to true at the given bitmap index.\n * @param {number} index The index to write to.\n */\n set(index) {\n const i = index >> 3;\n this.prep(i);\n /** @type {Uint8Array} */ (this.buf)[i] |= (1 << (index % 8));\n }\n}\n","/**\n * @import { Batch } from '../../batch.js'\n */\n\n/**\n * Abstract class for building a column data batch.\n */\nexport class BatchBuilder {\n constructor(type, ctx) {\n this.type = type;\n this.ctx = ctx;\n this.batchClass = ctx.batchType(type);\n }\n\n /**\n * Initialize the builder state.\n * @returns {this} This builder.\n */\n init() {\n this.index = -1;\n return this;\n }\n\n /**\n * Write a value to the builder.\n * @param {*} value\n * @param {number} index\n * @returns {boolean | void}\n */\n set(value, index) {\n this.index = index;\n return false;\n }\n\n /**\n * Returns a batch constructor options object.\n * Used internally to marshal batch data.\n * @returns {Record<string, any>}\n */\n done() {\n return null;\n }\n\n /**\n * Returns a completed batch and reinitializes the builder state.\n * @returns {Batch}\n */\n batch() {\n const b = new this.batchClass(this.done());\n this.init();\n return b;\n }\n}\n","import { uint8Array } from '../../util/arrays.js';\nimport { bitmap } from '../buffer.js';\nimport { BatchBuilder } from './batch.js';\n\n/**\n * Builder for validity bitmaps within batches.\n */\nexport class ValidityBuilder extends BatchBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n }\n\n init() {\n this.nullCount = 0;\n this.validity = bitmap();\n return super.init();\n }\n\n /**\n * @param {*} value\n * @param {number} index\n * @returns {boolean | void}\n */\n set(value, index) {\n this.index = index;\n const isValid = value != null;\n if (isValid) {\n this.validity.set(index);\n } else {\n this.nullCount++;\n }\n return isValid;\n }\n\n done() {\n const { index, nullCount, type, validity } = this;\n return {\n length: index + 1,\n nullCount,\n type,\n validity: nullCount\n ? validity.array((index >> 3) + 1)\n : new uint8Array(0)\n };\n }\n}\n","/**\n * @import { builderContext } from '../builder.js'\n * @import { DictionaryType, ExtractionOptions } from '../../types.js'\n */\nimport { Column } from '../../column.js';\nimport { keyString } from '../../util/strings.js';\nimport { batchType } from '../../batch-type.js';\nimport { buffer } from '../buffer.js';\nimport { ValidityBuilder } from './validity.js';\n\n/**\n * Create a context object for managing dictionary builders.\n */\nexport function dictionaryContext() {\n const idMap = new Map;\n const dicts = new Set;\n return {\n /**\n * Get a dictionary values builder for the given dictionary type.\n * @param {DictionaryType} type\n * The dictionary type.\n * @param {*} ctx The builder context.\n * @returns {ReturnType<dictionaryValues>}\n */\n get(type, ctx) {\n // if a dictionary has a non-negative id, assume it was set\n // intentionally and track it for potential reuse across columns\n // otherwise the dictionary is used for a single column only\n const id = type.id;\n if (id >= 0 && idMap.has(id)) {\n return idMap.get(id);\n } else {\n const dict = dictionaryValues(type, ctx);\n if (id >= 0) idMap.set(id, dict);\n dicts.add(dict);\n return dict;\n }\n },\n /**\n * Finish building dictionary values columns and assign them to\n * their corresponding dictionary batches.\n * @param {ExtractionOptions} options\n */\n finish(options) {\n dicts.forEach(dict => dict.finish(options));\n }\n };\n}\n\n/**\n * Builder helper for creating dictionary values.\n * @param {DictionaryType} type\n * The dictionary data type.\n * @param {ReturnType<builderContext>} ctx\n * The builder context.\n */\nexport function dictionaryValues(type, ctx) {\n const keys = Object.create(null);\n const values = ctx.builder(type.dictionary);\n const batches = [];\n\n values.init();\n let index = -1;\n\n return {\n type,\n values,\n\n add(batch) {\n batches.push(batch);\n return batch;\n },\n\n key(value) {\n const v = keyString(value);\n let k = keys[v];\n if (k === undefined) {\n keys[v] = k = ++index;\n values.set(value, k);\n }\n return k;\n },\n\n finish(options) {\n const valueType = type.dictionary;\n const batch = new (batchType(valueType, options))(values.done());\n const dictionary = new Column([batch]);\n batches.forEach(batch => batch.setDictionary(dictionary));\n }\n };\n}\n\n/**\n * Builder for dictionary-typed data batches.\n */\nexport class DictionaryBuilder extends ValidityBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n this.dict = ctx.dictionary(type);\n }\n\n init() {\n this.values = buffer(this.type.indices.values);\n return super.init();\n }\n\n set(value, index) {\n if (super.set(value, index)) {\n this.values.set(this.dict.key(value), index);\n }\n }\n\n done() {\n return {\n ...super.done(),\n values: this.values.array(this.index + 1)\n };\n }\n\n batch() {\n // register batch with dictionary\n // batch will be updated when the dictionary is finished\n return this.dict.add(super.batch());\n }\n}\n","/**\n * @import { DataType, IntType, UnionType } from '../types.js'\n */\nimport { bool, dateDay, dictionary, field, fixedSizeList, float64, int16, int32, int64, int8, list, nullType, struct, timestamp, utf8 } from '../data-types.js';\nimport { isArray } from '../util/arrays.js';\n\n/**\n * Infer the data type for a given input array.\n * @param {(visitor: (value: any) => void) => void} visit\n * A function that applies a callback to successive data values.\n * @returns {DataType} The data type.\n */\nexport function inferType(visit) {\n const profile = profiler();\n visit(value => profile.add(value));\n return profile.type();\n}\n\nfunction profiler() {\n let length = 0;\n let nullCount = 0;\n let boolCount = 0;\n let numberCount = 0;\n let intCount = 0;\n let bigintCount = 0;\n let dateCount = 0;\n let dayCount = 0;\n let stringCount = 0;\n let arrayCount = 0;\n let structCount = 0;\n let min = Infinity;\n let max = -Infinity;\n let minLength = Infinity;\n let maxLength = -Infinity;\n let minBigInt;\n let maxBigInt;\n let arrayProfile;\n let structProfiles = {};\n\n return {\n add(value) {\n length++;\n if (value == null) {\n nullCount++;\n return;\n }\n switch (typeof value) {\n case 'string':\n stringCount++;\n break;\n case 'number':\n numberCount++;\n if (value < min) min = value;\n if (value > max) max = value;\n if (Number.isInteger(value)) intCount++;\n break;\n case 'bigint':\n bigintCount++;\n if (minBigInt === undefined) {\n minBigInt = maxBigInt = value;\n } else {\n if (value < minBigInt) minBigInt = value;\n if (value > maxBigInt) maxBigInt = value;\n }\n break;\n case 'boolean':\n boolCount++;\n break;\n case 'object':\n if (value instanceof Date) {\n dateCount++;\n // 1 day = 1000ms * 60s * 60min * 24hr = 86400000\n if ((+value % 864e5) === 0) dayCount++;\n } else if (isArray(value)) {\n arrayCount++;\n const len = value.length;\n if (len < minLength) minLength = len;\n if (len > maxLength) maxLength = len;\n arrayProfile ??= profiler();\n value.forEach(arrayProfile.add);\n } else {\n structCount++;\n for (const key in value) {\n const fieldProfiler = structProfiles[key]\n ?? (structProfiles[key] = profiler());\n fieldProfiler.add(value[key]);\n }\n }\n }\n },\n type() {\n const valid = length - nullCount;\n return valid === 0 ? nullType()\n : intCount === valid ? intType(min, max)\n : numberCount === valid ? float64()\n : bigintCount === valid ? bigintType(minBigInt, maxBigInt)\n : boolCount === valid ? bool()\n : dayCount === valid ? dateDay()\n : dateCount === valid ? timestamp()\n : stringCount === valid ? dictionary(utf8())\n : arrayCount === valid ? arrayType(arrayProfile.type(), minLength, maxLength)\n : structCount === valid ? struct(\n Object.entries(structProfiles).map(_ => field(_[0], _[1].type()))\n )\n : unionType();\n }\n };\n}\n\n/**\n * Return a list or fixed list type.\n * @param {DataType} type The child data type.\n * @param {number} minLength The minumum list length.\n * @param {number} maxLength The maximum list length.\n * @returns {DataType} The data type.\n */\nfunction arrayType(type, minLength, maxLength) {\n return maxLength === minLength\n ? fixedSizeList(type, minLength)\n : list(type);\n}\n\n/**\n * @param {number} min\n * @param {number} max\n * @returns {DataType}\n */\nfunction intType(min, max) {\n const v = Math.max(Math.abs(min) - 1, max);\n return v < (1 << 7) ? int8()\n : v < (1 << 15) ? int16()\n : v < (2 ** 31) ? int32()\n : float64();\n}\n\n/**\n * @param {bigint} min\n * @param {bigint} max\n * @returns {IntType}\n */\nfunction bigintType(min, max) {\n const v = -min > max ? -min - 1n : max;\n if (v >= 2 ** 63) {\n throw new Error(`BigInt exceeds 64 bits: ${v}`);\n }\n return int64();\n}\n\n/**\n * @returns {UnionType}\n */\nfunction unionType() {\n throw new Error('Mixed types detected, please define a union type.');\n}\n","import { toOffset } from '../../util/numbers.js';\nimport { buffer } from '../buffer.js';\nimport { ValidityBuilder } from './validity.js';\n\n/**\n * Builder for batches of binary-typed data.\n */\nexport class BinaryBuilder extends ValidityBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n this.toOffset = toOffset(type.offsets);\n }\n\n init() {\n this.offsets = buffer(this.type.offsets);\n this.values = buffer();\n this.pos = 0;\n return super.init();\n }\n\n set(value, index) {\n const { offsets, values, toOffset } = this;\n if (super.set(value, index)) {\n values.write(value, this.pos);\n this.pos += value.length;\n }\n offsets.set(toOffset(this.pos), index + 1);\n }\n\n done() {\n return {\n ...super.done(),\n offsets: this.offsets.array(this.index + 2),\n values: this.values.array(this.pos + 1)\n };\n }\n}\n","import { bitmap } from '../buffer.js';\nimport { ValidityBuilder } from './validity.js';\n\n/**\n * Builder for batches of bool-typed data.\n */\nexport class BoolBuilder extends ValidityBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n }\n\n init() {\n this.values = bitmap();\n return super.init();\n }\n\n set(value, index) {\n super.set(value, index);\n if (value) this.values.set(index);\n }\n\n done() {\n return {\n ...super.done(),\n values: this.values.array((this.index >> 3) + 1)\n }\n }\n}\n","import { toDecimal } from '../../util/numbers.js';\nimport { buffer } from '../buffer.js';\nimport { ValidityBuilder } from './validity.js';\n\n/**\n * Builder for batches of decimal-typed data (64-bits or more).\n */\nexport class DecimalBuilder extends ValidityBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n this.scale = 10 ** type.scale;\n this.stride = type.bitWidth >> 6;\n }\n\n init() {\n this.values = buffer(this.type.values);\n return super.init();\n }\n\n set(value, index) {\n const { scale, stride, values } = this;\n if (super.set(value, index)) {\n values.prep((index + 1) * stride);\n // @ts-ignore\n toDecimal(value, values.buf, index * stride, stride, scale);\n }\n }\n\n done() {\n const { index, stride, values } = this;\n return {\n ...super.done(),\n values: values.array((index + 1) * stride)\n };\n }\n}\n","import { buffer } from '../buffer.js';\nimport { ValidityBuilder } from './validity.js';\n\n/**\n * Builder for fixed-size-binary-typed data batches.\n */\nexport class FixedSizeBinaryBuilder extends ValidityBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n this.stride = type.stride;\n }\n\n init() {\n this.values = buffer();\n return super.init();\n }\n\n set(value, index) {\n if (super.set(value, index)) {\n this.values.write(value, index * this.stride);\n }\n }\n\n done() {\n const { stride, values } = this;\n return {\n ...super.done(),\n values: values.array(stride * (this.index + 1))\n };\n }\n}\n","import { ValidityBuilder } from './validity.js';\n\n/**\n * Builder for fixed-size-list-typed data batches.\n */\nexport class FixedSizeListBuilder extends ValidityBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n this.child = ctx.builder(this.type.children[0].type);\n this.stride = type.stride;\n }\n\n init() {\n this.child.init();\n return super.init();\n }\n\n set(value, index) {\n const { child, stride } = this;\n const base = index * stride;\n if (super.set(value, index)) {\n for (let i = 0; i < stride; ++i) {\n child.set(value[i], base + i);\n }\n } else {\n child.index = base + stride;\n }\n }\n\n done() {\n const { child } = this;\n return {\n ...super.done(),\n children: [ child.batch() ]\n };\n }\n}\n","import { toMonthDayNanoBytes } from '../../util/numbers.js';\nimport { buffer } from '../buffer.js';\nimport { ValidityBuilder } from './validity.js';\n\n/**\n * Builder for day/time interval-typed data batches.\n */\nexport class IntervalDayTimeBuilder extends ValidityBuilder {\n init() {\n this.values = buffer(this.type.values);\n return super.init();\n }\n\n set(value, index) {\n if (super.set(value, index)) {\n const i = index << 1;\n this.values.set(value[0], i);\n this.values.set(value[1], i + 1);\n }\n }\n\n done() {\n return {\n ...super.done(),\n values: this.values.array((this.index + 1) << 1)\n }\n }\n}\n\n/**\n * Builder for month/day/nano interval-typed data batches.\n */\nexport class IntervalMonthDayNanoBuilder extends ValidityBuilder {\n init() {\n this.values = buffer();\n return super.init();\n }\n\n set(value, index) {\n if (super.set(value, index)) {\n this.values.write(toMonthDayNanoBytes(value), index << 4);\n }\n }\n\n done() {\n return {\n ...super.done(),\n values: this.values.array((this.index + 1) << 4)\n }\n }\n}\n","import { toOffset } from '../../util/numbers.js';\nimport { buffer } from '../buffer.js';\nimport { ValidityBuilder } from './validity.js';\n\n/**\n * Abstract class for building list data batches.\n */\nexport class AbstractListBuilder extends ValidityBuilder {\n constructor(type, ctx, child) {\n super(type, ctx);\n this.child = child;\n }\n\n init() {\n this.child.init();\n const offsetType = this.type.offsets;\n this.offsets = buffer(offsetType);\n this.toOffset = toOffset(offsetType);\n this.pos = 0;\n return super.init();\n }\n\n done() {\n return {\n ...super.done(),\n offsets: this.offsets.array(this.index + 2),\n children: [ this.child.batch() ]\n };\n }\n}\n\n/**\n * Builder for list-typed data batches.\n */\nexport class ListBuilder extends AbstractListBuilder {\n constructor(type, ctx) {\n super(type, ctx, ctx.builder(type.children[0].type));\n }\n\n set(value, index) {\n const { child, offsets, toOffset } = this;\n if (super.set(value, index)) {\n value.forEach(v => child.set(v, this.pos++));\n }\n offsets.set(toOffset(this.pos), index + 1);\n }\n}\n","import { ValidityBuilder } from './validity.js';\n\n/**\n * Abstract class for building list-typed data batches.\n */\nexport class AbstractStructBuilder extends ValidityBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n this.children = type.children.map(c => ctx.builder(c.type));\n }\n\n init() {\n this.children.forEach(c => c.init());\n return super.init();\n }\n\n done() {\n const { children } = this;\n children.forEach(c => c.index = this.index);\n return {\n ...super.done(),\n children: children.map(c => c.batch())\n };\n }\n}\n\n/**\n * Builder for struct-typed data batches.\n */\nexport class StructBuilder extends AbstractStructBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n this.setters = this.children.map((child, i) => {\n const name = type.children[i].name;\n return (value, index) => child.set(value?.[name], index);\n });\n }\n\n set(value, index) {\n super.set(value, index);\n const setters = this.setters;\n for (let i = 0; i < setters.length; ++i) {\n setters[i](value, index);\n }\n }\n}\n","import { AbstractListBuilder } from './list.js';\nimport { AbstractStructBuilder } from './struct.js';\n\n/**\n * Builder for map-typed data batches.\n */\nexport class MapBuilder extends AbstractListBuilder {\n constructor(type, ctx) {\n super(type, ctx, new MapStructBuilder(type.children[0].type, ctx));\n }\n\n set(value, index) {\n const { child, offsets, toOffset } = this;\n if (super.set(value, index)) {\n for (const keyValuePair of value) {\n child.set(keyValuePair, this.pos++);\n }\n }\n offsets.set(toOffset(this.pos), index + 1);\n }\n}\n\n/**\n * Builder for key-value struct batches within a map.\n */\nclass MapStructBuilder extends AbstractStructBuilder {\n set(value, index) {\n super.set(value, index);\n const [key, val] = this.children;\n key.set(value[0], index);\n val.set(value[1], index);\n }\n}\n","import { keyString } from '../../util/strings.js';\nimport { BatchBuilder } from './batch.js';\n\nconst NO_VALUE = {}; // empty object that fails strict equality\n\n/**\n * Builder for run-end-encoded-typed data batches.\n */\nexport class RunEndEncodedBuilder extends BatchBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n this.children = type.children.map(c => ctx.builder(c.type));\n }\n\n init() {\n this.pos = 0;\n this.key = null;\n this.value = NO_VALUE;\n this.children.forEach(c => c.init());\n return super.init();\n }\n\n next() {\n const [runs, vals] = this.children;\n runs.set(this.index + 1, this.pos);\n vals.set(this.value, this.pos++);\n }\n\n set(value, index) {\n // perform fast strict equality test\n if (value !== this.value) {\n // if no match, fallback to key string test\n const key = keyString(value);\n if (key !== this.key) {\n // if key doesn't match, write prior run and update\n if (this.key) this.next();\n this.key = key;\n this.value = value;\n }\n }\n this.index = index;\n }\n\n done() {\n this.next();\n const { children, index, type } = this;\n return {\n length: index + 1,\n nullCount: 0,\n type,\n children: children.map(c => c.batch())\n };\n }\n}\n","import { int8Array } from '../../util/arrays.js';\nimport { BatchBuilder } from './batch.js';\nimport { buffer } from '../buffer.js';\n\n/**\n * Abstract class for building union-typed data batches.\n */\nexport class AbstractUnionBuilder extends BatchBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n this.children = type.children.map(c => ctx.builder(c.type));\n this.typeMap = type.typeMap;\n this.lookup = type.typeIdForValue;\n }\n\n init() {\n this.nullCount = 0;\n this.typeIds = buffer(int8Array);\n this.children.forEach(c => c.init());\n return super.init();\n }\n\n set(value, index) {\n const { children, lookup, typeMap, typeIds } = this;\n this.index = index;\n const typeId = lookup(value, index);\n const child = children[typeMap[typeId]];\n typeIds.set(typeId, index);\n if (value == null) ++this.nullCount;\n // @ts-ignore\n this.update(value, index, child);\n }\n\n done() {\n const { children, nullCount, type, typeIds } = this;\n const length = this.index + 1;\n return {\n length,\n nullCount,\n type,\n typeIds: typeIds.array(length),\n children: children.map(c => c.batch())\n };\n }\n}\n\n/**\n * Builder for sparse union-typed data batches.\n */\nexport class SparseUnionBuilder extends AbstractUnionBuilder {\n update(value, index, child) {\n // update selected child with value\n // then set all other children to null\n child.set(value, index);\n this.children.forEach(c => { if (c !== child) c.set(null, index) });\n }\n}\n\n/**\n * Builder for dense union-typed data batches.\n */\nexport class DenseUnionBuilder extends AbstractUnionBuilder {\n init() {\n this.offsets = buffer(this.type.offsets);\n return super.init();\n }\n\n update(value, index, child) {\n const offset = child.index + 1;\n child.set(value, offset);\n this.offsets.set(offset, index);\n }\n\n done() {\n return {\n ...super.done(),\n offsets: this.offsets.array(this.index + 1)\n };\n }\n}\n","import { encodeUtf8 } from '../../util/strings.js';\nimport { BinaryBuilder } from './binary.js';\n\n/**\n * Builder for utf8-typed data batches.\n */\nexport class Utf8Builder extends BinaryBuilder {\n set(value, index) {\n super.set(value && encodeUtf8(value), index);\n }\n}\n","import { toBigInt } from '../../util/numbers.js';\nimport { buffer } from '../buffer.js';\nimport { ValidityBuilder } from './validity.js';\n\n/**\n * Builder for data batches that can be accessed directly as typed arrays.\n */\nexport class DirectBuilder extends ValidityBuilder {\n constructor(type, ctx) {\n super(type, ctx);\n this.values = buffer(type.values);\n }\n\n init() {\n this.values = buffer(this.type.values);\n return super.init();\n }\n\n /**\n * @param {*} value\n * @param {number} index\n * @returns {boolean | void}\n */\n set(value, index) {\n if (super.set(value, index)) {\n this.values.set(value, index);\n }\n }\n\n done() {\n return {\n ...super.done(),\n values: this.values.array(this.index + 1)\n };\n }\n}\n\n/**\n * Builder for int64/uint64 data batches written as bigints.\n */\nexport class Int64Builder extends DirectBuilder {\n set(value, index) {\n super.set(value == null ? value : toBigInt(value), index);\n }\n}\n\n/**\n * Builder for data batches whose values must pass through a transform\n * function prior to be written to a backing buffer.\n */\nexport class TransformBuilder extends DirectBuilder {\n constructor(type, ctx, transform) {\n super(type, ctx);\n this.transform = transform;\n }\n set(value, index) {\n super.set(value == null ? value : this.transform(value), index);\n }\n}\n","/**\n * @import { DataType, ExtractionOptions } from '../types.js'\n * @import { BatchBuilder } from './builders/batch.js'\n */\nimport { batchType } from '../batch-type.js';\nimport { IntervalUnit, Type } from '../constants.js';\nimport { invalidDataType } from '../data-types.js';\nimport { isInt64ArrayType } from '../util/arrays.js';\nimport { toBigInt, toDateDay, toDecimal32, toFloat16, toTimestamp } from '../util/numbers.js';\nimport { BinaryBuilder } from './builders/binary.js';\nimport { BoolBuilder } from './builders/bool.js';\nimport { DecimalBuilder } from './builders/decimal.js';\nimport { DictionaryBuilder, dictionaryContext } from './builders/dictionary.js';\nimport { FixedSizeBinaryBuilder } from './builders/fixed-size-binary.js';\nimport { FixedSizeListBuilder } from './builders/fixed-size-list.js';\nimport { IntervalDayTimeBuilder, IntervalMonthDayNanoBuilder } from './builders/interval.js';\nimport { ListBuilder } from './builders/list.js';\nimport { MapBuilder } from './builders/map.js';\nimport { RunEndEncodedBuilder } from './builders/run-end-encoded.js';\nimport { StructBuilder } from './builders/struct.js';\nimport { DenseUnionBuilder, SparseUnionBuilder } from './builders/union.js';\nimport { Utf8Builder } from './builders/utf8.js';\nimport { DirectBuilder, Int64Builder, TransformBuilder } from './builders/values.js';\n\n/**\n * Create a context object for shared builder state.\n * @param {ExtractionOptions} [options] Batch extraction options.\n* @param {ReturnType<dictionaryContext>} [dictionaries]\n * Context object for tracking dictionaries.\n */\nexport function builderContext(\n options = {},\n dictionaries = dictionaryContext()\n) {\n return {\n batchType: type => batchType(type, options),\n builder(type) { return builder(type, this); },\n dictionary(type) { return dictionaries.get(type, this); },\n finish: () => dictionaries.finish(options)\n };\n}\n\n/**\n * Returns a batch builder for the given type and builder context.\n * @param {DataType} type A data type.\n * @param {ReturnType<builderContext>} [ctx] A builder context.\n * @returns {BatchBuilder}\n */\nexport function builder(type, ctx = builderContext()) {\n const { typeId } = type;\n switch (typeId) {\n case Type.Int:\n case Type.Time:\n case Type.Duration:\n return isInt64ArrayType(type.values)\n ? new Int64Builder(type, ctx)\n : new DirectBuilder(type, ctx);\n case Type.Float:\n return type.precision\n ? new DirectBuilder(type, ctx)\n : new TransformBuilder(type, ctx, toFloat16)\n case Type.Binary:\n case Type.LargeBinary:\n return new BinaryBuilder(type, ctx);\n case Type.Utf8:\n case Type.LargeUtf8:\n return new Utf8Builder(type, ctx);\n case Type.Bool:\n return new BoolBuilder(type, ctx);\n case Type.Decimal:\n return type.bitWidth === 32\n ? new TransformBuilder(type, ctx, toDecimal32(type.scale))\n : new DecimalBuilder(type, ctx);\n case Type.Date:\n return new TransformBuilder(type, ctx, type.unit ? toBigInt : toDateDay);\n case Type.Timestamp:\n return new TransformBuilder(type, ctx, toTimestamp(type.unit));\n case Type.Interval:\n switch (type.unit) {\n case IntervalUnit.DAY_TIME:\n return new IntervalDayTimeBuilder(type, ctx);\n case IntervalUnit.MONTH_DAY_NANO:\n return new IntervalMonthDayNanoBuilder(type, ctx);\n }\n // case IntervalUnit.YEAR_MONTH:\n return new DirectBuilder(type, ctx);\n case Type.List:\n case Type.LargeList:\n return new ListBuilder(type, ctx);\n case Type.Struct:\n return new StructBuilder(type, ctx);\n case Type.Union:\n return type.mode\n ? new DenseUnionBuilder(type, ctx)\n : new SparseUnionBuilder(type, ctx);\n case Type.FixedSizeBinary:\n return new FixedSizeBinaryBuilder(type, ctx);\n case Type.FixedSizeList:\n return new FixedSizeListBuilder(type, ctx);\n case Type.Map:\n return new MapBuilder(type, ctx);\n case Type.RunEndEncoded:\n return new RunEndEncodedBuilder(type, ctx);\n\n case Type.Dictionary:\n return new DictionaryBuilder(type, ctx);\n }\n // case Type.BinaryView:\n // case Type.Utf8View:\n // case Type.ListView:\n // case Type.LargeListView:\n throw new Error(invalidDataType(typeId));\n}\n","/**\n * @import { ColumnBuilderOptions, DataType, NullType } from '../types.js'\n * @import { dictionaryContext } from './builders/dictionary.js'\n */\nimport { NullBatch } from '../batch.js';\nimport { Column } from '../column.js';\nimport { inferType } from './infer-type.js';\nimport { builder, builderContext } from './builder.js';\nimport { Type } from '../constants.js';\nimport { isIterable } from '../util/objects.js';\n\n/**\n * Create a new column by iterating over provided values.\n * @template T\n * @param {Iterable | ((callback: (value: any) => void) => void)} values\n * Either an iterable object or a visitor function that applies a callback\n * to successive data values (akin to Array.forEach).\n * @param {DataType} [type] The data type.\n * @param {ColumnBuilderOptions} [options]\n * Builder options for the generated column.\n * @param {ReturnType<dictionaryContext>} [dicts]\n * Dictionary context object, for internal use only.\n * @returns {Column<T>} The generated column.\n */\nexport function columnFromValues(values, type, options = {}, dicts) {\n const visit = isIterable(values)\n ? callback => { for (const value of values) callback(value); }\n : values;\n\n type ??= inferType(visit);\n const { maxBatchRows = Infinity, ...opt } = options;\n let data;\n\n if (type.typeId === Type.Null) {\n let length = 0;\n visit(() => ++length);\n data = nullBatches(type, length, maxBatchRows);\n } else {\n const ctx = builderContext(opt, dicts);\n const b = builder(type, ctx).init();\n const next = b => data.push(b.batch());\n data = [];\n\n let row = 0;\n visit(value => {\n b.set(value, row++);\n if (row >= maxBatchRows) {\n next(b);\n row = 0;\n }\n });\n if (row) next(b);\n\n // resolve dictionaries\n ctx.finish();\n }\n\n return new Column(data, type);\n}\n\n/**\n * Create null batches with the given batch size limit.\n * @param {NullType} type The null data type.\n * @param {number} length The total column length.\n * @param {number} limit The maximum batch size.\n * @returns {NullBatch[]} The null batches.\n */\nfunction nullBatches(type, length, limit) {\n const data = [];\n const batch = length => new NullBatch({ length, nullCount: length, type });\n const numBatches = Math.floor(length / limit);\n for (let i = 0; i < numBatches; ++i) {\n data.push(batch(limit));\n }\n const rem = length % limit;\n if (rem) data.push(batch(rem));\n return data;\n}\n","/**\n * @import { ColumnBuilderOptions, DataType, TypedArray, TypedArrayConstructor } from '../types.js'\n * @import { dictionaryContext } from './builders/dictionary.js'\n */\nimport { float32Array, float64Array, int16Array, int32Array, int64Array, int8Array, isInt64ArrayType, isTypedArray, uint16Array, uint32Array, uint64Array, uint8Array } from '../util/arrays.js';\nimport { DirectBatch, Int64Batch } from '../batch.js';\nimport { Column } from '../column.js';\nimport { float32, float64, int16, int32, int64, int8, uint16, uint32, uint64, uint8 } from '../data-types.js';\nimport { columnFromValues } from './column-from-values.js';\n\n/**\n * Create a new column from a provided data array.\n * @template T\n * @param {Array | TypedArray} array The input data.\n * @param {DataType} [type] The data type.\n * If not specified, type inference is attempted.\n * @param {ColumnBuilderOptions} [options]\n * Builder options for the generated column.\n * @param {ReturnType<dictionaryContext>} [dicts]\n * Builder context object, for internal use only.\n * @returns {Column<T>} The generated column.\n */\nexport function columnFromArray(array, type, options = {}, dicts) {\n return !type && isTypedArray(array)\n ? columnFromTypedArray(array, options)\n : columnFromValues(v => array.forEach(v), type, options, dicts);\n}\n\n/**\n * Create a new column from a typed array input.\n * @template T\n * @param {TypedArray} values The input data.\n * @param {ColumnBuilderOptions} options\n * Builder options for the generated column.\n * @returns {Column<T>} The generated column.\n */\nfunction columnFromTypedArray(values, { maxBatchRows, useBigInt }) {\n const arrayType = /** @type {TypedArrayConstructor} */ (\n values.constructor\n );\n const type = typeForTypedArray(arrayType);\n const length = values.length;\n const limit = Math.min(maxBatchRows || Infinity, length);\n const numBatches = Math.floor(length / limit);\n\n const batches = [];\n const batchType = isInt64ArrayType(arrayType) && !useBigInt ? Int64Batch : DirectBatch;\n const add = (start, end) => batches.push(new batchType({\n length: end - start,\n nullCount: 0,\n type,\n validity: new uint8Array(0),\n values: values.subarray(start, end)\n }));\n\n let idx = 0;\n for (let i = 0; i < numBatches; ++i) add(idx, idx += limit);\n if (idx < length) add(idx, length);\n\n return new Column(batches);\n}\n\n/**\n * Return an Arrow data type for a given typed array type.\n * @param {TypedArrayConstructor} arrayType The typed array type.\n * @returns {DataType} The data type.\n */\nfunction typeForTypedArray(arrayType) {\n switch (arrayType) {\n case float32Array: return float32();\n case float64Array: return float64();\n case int8Array: return int8();\n case int16Array: return int16();\n case int32Array: return int32();\n case int64Array: return int64();\n case uint8Array: return uint8();\n case uint16Array: return uint16();\n case uint32Array: return uint32();\n case uint64Array: return uint64();\n }\n}\n","/**\n * @import { Column } from '../column.js'\n */\nimport { Endianness, Version } from '../constants.js';\nimport { field } from '../data-types.js';\nimport { Table } from '../table.js';\n\n/**\n * Create a new table from a collection of columns. Columns are assumed\n * to have the same record batch sizes.\n * @param {[string, Column][] | Record<string, Column>} data The columns,\n * as an object with name keys, or an array of [name, column] pairs.\n * @param {boolean} [useProxy] Flag indicating if row proxy\n * objects should be used to represent table rows (default `false`).\n * @returns {Table} The new table.\n */\nexport function tableFromColumns(data, useProxy) {\n const fields = [];\n const entries = Array.isArray(data) ? data : Object.entries(data);\n const length = entries[0]?.[1].length;\n\n const columns = entries.map(([name, col]) => {\n if (col.length !== length) {\n throw new Error('All columns must have the same length.');\n }\n fields.push(field(name, col.type));\n return col;\n });\n\n const schema = {\n version: Version.V5,\n endianness: Endianness.Little,\n fields,\n metadata: null\n };\n\n return new Table(schema, columns, useProxy);\n}\n","/**\n * @import { Column } from '../column.js'\n * @import { TableBuilderOptions, TypedArray } from '../types.js'\n * @import { Table } from '../table.js'\n */\nimport { dictionaryContext } from './builders/dictionary.js';\nimport { columnFromArray } from './column-from-array.js';\nimport { tableFromColumns } from './table-from-columns.js';\n\n/**\n * Create a new table from the provided arrays.\n * @param {[string, Array | TypedArray][]\n * | Record<string, Array | TypedArray>} data\n * The input data as a collection of named arrays.\n * @param {TableBuilderOptions} options\n * Table builder options, including an optional type map.\n * @returns {Table} The new table.\n */\nexport function tableFromArrays(data, options = {}) {\n const { types = {}, ...opt } = options;\n const dicts = dictionaryContext();\n const entries = Array.isArray(data) ? data : Object.entries(data);\n const columns = entries.map(([name, array]) =>\n /** @type {[string, Column]} */ (\n [ name, columnFromArray(array, types[name], opt, dicts)]\n ));\n return tableFromColumns(columns, options.useProxy);\n}\n","/**\n * Ducklings Workers - Minimal DuckDB for Cloudflare Workers\n *\n * This package provides a lightweight DuckDB binding for WebAssembly,\n * designed for Cloudflare Workers and serverless environments.\n *\n * IMPORTANT: In this build, query() and execute() are async and return Promises.\n * Always use: `await conn.query(...)` or `await conn.execute(...)`\n *\n * @packageDocumentation\n */\n\nimport {\n bool,\n type DataType,\n dateDay,\n float32,\n float64,\n int8,\n int16,\n int32,\n int64,\n type Table,\n TimeUnit,\n tableFromArrays,\n timestamp,\n uint8,\n uint16,\n uint32,\n uint64,\n utf8,\n} from '@uwdata/flechette';\n\n/**\n * DuckDB type constants mapping to the C API type IDs.\n * @category Types\n */\nexport const DuckDBType = {\n INVALID: 0,\n BOOLEAN: 1,\n TINYINT: 2,\n SMALLINT: 3,\n INTEGER: 4,\n BIGINT: 5,\n UTINYINT: 6,\n USMALLINT: 7,\n UINTEGER: 8,\n UBIGINT: 9,\n FLOAT: 10,\n DOUBLE: 11,\n TIMESTAMP: 12,\n DATE: 13,\n TIME: 14,\n INTERVAL: 15,\n HUGEINT: 16,\n UHUGEINT: 32,\n VARCHAR: 17,\n BLOB: 18,\n DECIMAL: 19,\n TIMESTAMP_S: 20,\n TIMESTAMP_MS: 21,\n TIMESTAMP_NS: 22,\n ENUM: 23,\n LIST: 24,\n STRUCT: 25,\n MAP: 26,\n ARRAY: 33,\n UUID: 27,\n UNION: 28,\n BIT: 29,\n TIME_TZ: 30,\n TIMESTAMP_TZ: 31,\n} as const;\n\n/**\n * Type ID from DuckDB type constants.\n * @category Types\n */\nexport type DuckDBTypeId = (typeof DuckDBType)[keyof typeof DuckDBType];\n\n/**\n * Database access mode.\n * @category Configuration\n */\nexport enum AccessMode {\n /** DuckDB determines mode based on context (resolves to READ_WRITE for in-memory) */\n AUTOMATIC = 'automatic',\n /** Read-only mode - all write operations are blocked */\n READ_ONLY = 'read_only',\n /** Read-write mode - allows both reads and writes */\n READ_WRITE = 'read_write',\n}\n\n/**\n * DuckDB configuration options.\n * @category Configuration\n */\nexport interface DuckDBConfig {\n /**\n * Database access mode.\n * Use READ_ONLY to prevent any data modification.\n * @default AccessMode.AUTOMATIC\n */\n accessMode?: AccessMode;\n\n /**\n * Enable external access (file I/O, httpfs, etc.).\n * Set to false to prevent all external data access.\n * WARNING: Setting to false will disable httpfs functionality.\n * @default true\n */\n enableExternalAccess?: boolean;\n\n /**\n * Lock configuration after startup.\n * Prevents runtime configuration changes via SQL SET commands.\n * @default true (secure default)\n */\n lockConfiguration?: boolean;\n\n /**\n * Custom configuration options.\n * Key-value pairs passed directly to duckdb_set_config.\n * @see https://duckdb.org/docs/configuration/overview\n */\n customConfig?: Record<string, string>;\n}\n\n/**\n * Error thrown by DuckDB operations.\n * @category Types\n */\nexport class DuckDBError extends Error {\n public readonly code?: string;\n public readonly query?: string;\n\n constructor(message: string, code?: string, query?: string) {\n super(message);\n this.name = 'DuckDBError';\n this.code = code;\n this.query = query;\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, DuckDBError);\n }\n }\n}\n\n/**\n * Options for SQL sanitization.\n * @category Security\n */\nexport interface SanitizeSqlOptions {\n /** Allow PRAGMA statements (default: false) */\n allowPragma?: boolean;\n /** Allow COPY ... TO statements (default: false) */\n allowCopyTo?: boolean;\n /** Allow EXPORT DATABASE statements (default: false) */\n allowExportDatabase?: boolean;\n /** Allow duckdb_secrets() function (default: false) */\n allowSecretsFunction?: boolean;\n}\n\n/**\n * Result of SQL sanitization check.\n * @category Security\n */\nexport interface SanitizeResult {\n /** Whether the SQL is considered safe */\n safe: boolean;\n /** The original SQL string */\n sql: string;\n /** Reason why the SQL was blocked (if unsafe) */\n reason?: string;\n /** The pattern that matched (if unsafe) */\n matchedPattern?: string;\n}\n\n/**\n * Strips SQL comments to prevent bypass attempts.\n * @internal\n */\nfunction stripSqlComments(sql: string): string {\n // Remove /* ... */ block comments (non-greedy)\n let result = sql.replace(/\\/\\*[\\s\\S]*?\\*\\//g, ' ');\n // Remove -- line comments\n result = result.replace(/--[^\\n\\r]*/g, ' ');\n // Remove # line comments (MySQL-style, supported by DuckDB)\n result = result.replace(/#[^\\n\\r]*/g, ' ');\n return result;\n}\n\n/**\n * Dangerous SQL patterns to block.\n * @internal\n */\nconst DANGEROUS_PATTERNS = {\n secretsFunction: {\n pattern: /\\bduckdb_secrets\\s*\\(/i,\n message: 'Access to duckdb_secrets() is not allowed',\n },\n pragma: {\n pattern: /^\\s*PRAGMA\\b/im,\n message: 'PRAGMA statements are not allowed',\n },\n copyTo: {\n pattern: /\\bCOPY\\b[\\s\\S]+?\\bTO\\b\\s+['\"`]/i,\n message: 'COPY ... TO statements are not allowed',\n },\n exportDatabase: {\n pattern: /\\bEXPORT\\s+DATABASE\\b/i,\n message: 'EXPORT DATABASE statements are not allowed',\n },\n} as const;\n\n/**\n * Checks if a SQL statement contains dangerous patterns.\n *\n * This function does not throw - it returns a result object indicating\n * whether the SQL is safe or not. Use this when you want to handle\n * unsafe SQL yourself.\n *\n * @category Security\n * @param sql - The SQL statement to check\n * @param options - Options to selectively allow certain patterns\n * @returns A SanitizeResult object with safety status\n *\n * @example\n * ```typescript\n * const result = checkSql(\"SELECT * FROM duckdb_secrets()\");\n * if (!result.safe) {\n * console.log(`Blocked: ${result.reason}`);\n * }\n * ```\n */\nexport function checkSql(sql: string, options: SanitizeSqlOptions = {}): SanitizeResult {\n // Strip comments before checking patterns\n const strippedSql = stripSqlComments(sql);\n\n // Check each pattern unless explicitly allowed\n if (\n !options.allowSecretsFunction &&\n DANGEROUS_PATTERNS.secretsFunction.pattern.test(strippedSql)\n ) {\n return {\n safe: false,\n sql,\n reason: DANGEROUS_PATTERNS.secretsFunction.message,\n matchedPattern: 'duckdb_secrets()',\n };\n }\n\n if (!options.allowPragma && DANGEROUS_PATTERNS.pragma.pattern.test(strippedSql)) {\n return {\n safe: false,\n sql,\n reason: DANGEROUS_PATTERNS.pragma.message,\n matchedPattern: 'PRAGMA',\n };\n }\n\n if (!options.allowCopyTo && DANGEROUS_PATTERNS.copyTo.pattern.test(strippedSql)) {\n return {\n safe: false,\n sql,\n reason: DANGEROUS_PATTERNS.copyTo.message,\n matchedPattern: 'COPY ... TO',\n };\n }\n\n if (!options.allowExportDatabase && DANGEROUS_PATTERNS.exportDatabase.pattern.test(strippedSql)) {\n return {\n safe: false,\n sql,\n reason: DANGEROUS_PATTERNS.exportDatabase.message,\n matchedPattern: 'EXPORT DATABASE',\n };\n }\n\n return { safe: true, sql };\n}\n\n/**\n * Sanitizes a SQL statement by checking for dangerous patterns.\n *\n * This function throws a DuckDBError if the SQL contains dangerous patterns.\n * Use this in request handlers to automatically reject unsafe queries.\n *\n * **Blocked patterns:**\n * - `duckdb_secrets()` - Exposes database credentials\n * - `PRAGMA` - Can modify database settings\n * - `COPY ... TO` - Writes files to disk (COPY FROM is allowed)\n * - `EXPORT DATABASE` - Exports database to files\n *\n * Note: SET commands are blocked separately by `lockConfiguration: true` in DuckDBConfig.\n *\n * @category Security\n * @param sql - The SQL statement to sanitize\n * @param options - Options to selectively allow certain patterns\n * @returns The original SQL if safe\n * @throws DuckDBError with code 'SANITIZE_ERROR' if dangerous patterns detected\n *\n * @example\n * ```typescript\n * import { sanitizeSql, DuckDBError } from '@ducklings/workers';\n *\n * // In a request handler\n * try {\n * const safeSql = sanitizeSql(userInput);\n * const result = await conn.query(safeSql);\n * return Response.json({ data: result });\n * } catch (e) {\n * if (e instanceof DuckDBError && e.code === 'SANITIZE_ERROR') {\n * return Response.json({ error: e.message }, { status: 400 });\n * }\n * throw e;\n * }\n * ```\n */\nexport function sanitizeSql(sql: string, options: SanitizeSqlOptions = {}): string {\n const result = checkSql(sql, options);\n\n if (!result.safe) {\n throw new DuckDBError(result.reason!, 'SANITIZE_ERROR', sql);\n }\n\n return sql;\n}\n\n/**\n * Column metadata for query results.\n * @category Types\n */\nexport interface ColumnInfo {\n name: string;\n type: DuckDBTypeId;\n alias?: string;\n}\n\n// Emscripten module interface\ninterface EmscriptenModule {\n ccall: (\n name: string,\n returnType: string | null,\n argTypes: string[],\n args: unknown[],\n opts?: { async?: boolean },\n ) => unknown | Promise<unknown>;\n cwrap: (\n name: string,\n returnType: string | null,\n argTypes: string[],\n ) => (...args: unknown[]) => unknown;\n getValue: (ptr: number, type: string) => number;\n setValue: (ptr: number, value: number, type: string) => void;\n UTF8ToString: (ptr: number) => string;\n stringToUTF8: (str: string, outPtr: number, maxBytesToWrite: number) => void;\n lengthBytesUTF8: (str: string) => number;\n _malloc: (size: number) => number;\n _free: (ptr: number) => void;\n stackAlloc: (size: number) => number;\n stackSave: () => number;\n stackRestore: (ptr: number) => void;\n HEAPU8: Uint8Array;\n HEAP8: Int8Array;\n HEAP16: Int16Array;\n HEAP32: Int32Array;\n HEAPU16: Uint16Array;\n HEAPU32: Uint32Array;\n HEAPF32: Float32Array;\n HEAPF64: Float64Array;\n}\n\n// Module state\nlet module: EmscriptenModule | null = null;\nlet initPromise: Promise<EmscriptenModule> | null = null;\n\n/**\n * Helper to get the current module, throwing if not initialized.\n */\nfunction getModule(): EmscriptenModule {\n if (!module) {\n throw new DuckDBError('DuckDB WASM not initialized. Call init() first.');\n }\n return module;\n}\n\n/**\n * Options for initializing the DuckDB WASM module (workers build).\n * @category Types\n */\nexport interface InitOptions {\n /**\n * Pre-compiled WebAssembly.Module (required for Cloudflare Workers)\n * In Workers, import the WASM file directly and pass it here.\n *\n * @example\n * ```typescript\n * import wasmModule from '@ducklings/workers/wasm';\n * await init({ wasmModule });\n * ```\n */\n wasmModule: WebAssembly.Module;\n}\n\n/**\n * Initialize the DuckDB WASM module (workers build with Asyncify).\n *\n * This version is optimized for Cloudflare Workers and uses the workers-specific\n * WASM build that includes Asyncify support for async HTTP operations.\n *\n * @category Database\n * @param options - Initialization options with pre-compiled WASM module\n * @returns Promise that resolves when initialization is complete\n *\n * @example\n * ```typescript\n * import { init, DuckDB } from '@ducklings/workers';\n * import wasmModule from '@ducklings/workers/wasm';\n *\n * await init({ wasmModule });\n *\n * const db = new DuckDB();\n * const conn = db.connect();\n *\n * // httpfs works in CF Workers with this build!\n * const result = await conn.query(\"SELECT * FROM 'https://example.com/data.parquet'\");\n * ```\n */\nexport async function init(options: InitOptions): Promise<void> {\n if (module) {\n return;\n }\n\n if (initPromise) {\n await initPromise;\n return;\n }\n\n if (!options?.wasmModule) {\n throw new Error(\n 'Workers build requires a pre-compiled WASM module. ' +\n 'Import the WASM file and pass it as { wasmModule }.',\n );\n }\n\n initPromise = (async () => {\n // Dynamic import of the workers-specific Emscripten-generated JavaScript\n const DuckDBModule = (await import('./wasm/duckdb-workers.js')).default;\n\n // Initialize the Emscripten module with pre-compiled WASM\n const config: Record<string, unknown> = {\n instantiateWasm: (\n imports: WebAssembly.Imports,\n receiveInstance: (instance: WebAssembly.Instance) => void,\n ) => {\n WebAssembly.instantiate(options.wasmModule, imports).then((instance) => {\n receiveInstance(instance);\n });\n return {}; // Return empty exports, will be filled by receiveInstance\n },\n };\n\n const mod = await DuckDBModule(config);\n return mod as EmscriptenModule;\n })();\n\n module = await initPromise;\n}\n\n/**\n * Returns the DuckDB library version.\n * @category Database\n */\nexport function version(): string {\n if (!module) {\n throw new DuckDBError('DuckDB WASM not initialized. Call init() first.');\n }\n const versionPtr = module.ccall('duckdb_library_version', 'number', [], []) as number;\n return module.UTF8ToString(versionPtr);\n}\n\n/**\n * Reads column data from DuckDB result with proper type conversion.\n * @internal\n */\nfunction readColumnData(\n mod: EmscriptenModule,\n dataPtr: number,\n nullmaskPtr: number,\n rowCount: number,\n duckdbType: number,\n): unknown[] {\n const result: unknown[] = new Array(rowCount);\n const hasNullmask = nullmaskPtr !== 0;\n\n switch (duckdbType) {\n case DuckDBType.BOOLEAN: {\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = mod.HEAPU8[dataPtr + i] !== 0;\n }\n }\n break;\n }\n\n case DuckDBType.TINYINT: {\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = mod.HEAP8[dataPtr + i];\n }\n }\n break;\n }\n\n case DuckDBType.SMALLINT: {\n const offset = dataPtr >> 1;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = mod.HEAP16[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.INTEGER: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = mod.HEAP32[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.BIGINT: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n const low = mod.HEAPU32[offset + i * 2];\n const high = mod.HEAP32[offset + i * 2 + 1];\n // Check if value fits in safe integer range before computing\n // Safe range: high is 0 (positive small) or -1 (negative small)\n if (high === 0 && low <= 0x1fffffffffffff) {\n result[i] = low;\n } else if (high === -1 && low >= 0x80000000) {\n // Small negative number\n result[i] = high * 0x100000000 + low;\n } else {\n // Large value - return as string for JSON compatibility\n // Compute using BigInt for precision, then convert to string\n const bigValue = BigInt(high) * BigInt(0x100000000) + BigInt(low >>> 0);\n result[i] = bigValue.toString();\n }\n }\n }\n break;\n }\n\n case DuckDBType.UTINYINT: {\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = mod.HEAPU8[dataPtr + i];\n }\n }\n break;\n }\n\n case DuckDBType.USMALLINT: {\n const offset = dataPtr >> 1;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = mod.HEAPU16[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.UINTEGER: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = mod.HEAPU32[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.UBIGINT: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n const low = mod.HEAPU32[offset + i * 2];\n const high = mod.HEAPU32[offset + i * 2 + 1];\n // Check if value fits in safe integer range before computing\n if (high === 0 && low <= 0x1fffffffffffff) {\n result[i] = low;\n } else {\n // Large value - return as string for JSON compatibility\n const bigValue = BigInt(high) * BigInt(0x100000000) + BigInt(low);\n result[i] = bigValue.toString();\n }\n }\n }\n break;\n }\n\n case DuckDBType.FLOAT: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = mod.HEAPF32[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.DOUBLE: {\n const offset = dataPtr >> 3;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = mod.HEAPF64[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.DATE: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n const days = mod.HEAP32[offset + i];\n const date = new Date(days * 24 * 60 * 60 * 1000);\n result[i] = date.toISOString().split('T')[0];\n }\n }\n break;\n }\n\n case DuckDBType.TIMESTAMP:\n case DuckDBType.TIMESTAMP_TZ: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && mod.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n // Timestamp is stored as microseconds since epoch\n const low = mod.HEAPU32[offset + i * 2];\n const high = mod.HEAP32[offset + i * 2 + 1];\n const micros = BigInt(high) * BigInt(0x100000000) + BigInt(low >>> 0);\n const millis = Number(micros / BigInt(1000));\n const date = new Date(millis);\n result[i] = date.toISOString();\n }\n }\n break;\n }\n\n default:\n // Return null for unsupported types - will be handled by varchar fallback\n for (let i = 0; i < rowCount; i++) {\n result[i] = null;\n }\n break;\n }\n\n return result;\n}\n\n/**\n * A prepared SQL statement with parameter binding.\n * @category Query Results\n */\nexport class PreparedStatement {\n private stmtPtr: number;\n private closed = false;\n private readonly sql: string;\n\n /** @internal */\n constructor(stmtPtr: number, _connPtr: number, sql: string) {\n this.stmtPtr = stmtPtr;\n this.sql = sql;\n }\n\n parameterCount(): number {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n return mod.ccall('duckdb_nparams', 'number', ['number'], [this.stmtPtr]) as number;\n }\n\n bindBoolean(index: number, value: boolean): this {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n const result = mod.ccall(\n 'duckdb_bind_boolean',\n 'number',\n ['number', 'number', 'number', 'number'],\n [this.stmtPtr, index, 0, value ? 1 : 0],\n ) as number;\n if (result !== 0) throw new DuckDBError(`Failed to bind boolean at index ${index}`);\n return this;\n }\n\n bindInt32(index: number, value: number): this {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n const result = mod.ccall(\n 'duckdb_bind_int32',\n 'number',\n ['number', 'number', 'number', 'number'],\n [this.stmtPtr, index, 0, value],\n ) as number;\n if (result !== 0) throw new DuckDBError(`Failed to bind int32 at index ${index}`);\n return this;\n }\n\n bindInt64(index: number, value: bigint | number): this {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n const val = BigInt(value);\n const valLow = Number(val & BigInt(0xffffffff));\n const valHigh = Number((val >> BigInt(32)) & BigInt(0xffffffff));\n const result = mod.ccall(\n 'duckdb_bind_int64',\n 'number',\n ['number', 'number', 'number', 'number', 'number'],\n [this.stmtPtr, index, 0, valLow, valHigh],\n ) as number;\n if (result !== 0) throw new DuckDBError(`Failed to bind int64 at index ${index}`);\n return this;\n }\n\n bindFloat(index: number, value: number): this {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n const result = mod.ccall(\n 'duckdb_bind_float',\n 'number',\n ['number', 'number', 'number', 'number'],\n [this.stmtPtr, index, 0, value],\n ) as number;\n if (result !== 0) throw new DuckDBError(`Failed to bind float at index ${index}`);\n return this;\n }\n\n bindDouble(index: number, value: number): this {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n const result = mod.ccall(\n 'duckdb_bind_double',\n 'number',\n ['number', 'number', 'number', 'number'],\n [this.stmtPtr, index, 0, value],\n ) as number;\n if (result !== 0) throw new DuckDBError(`Failed to bind double at index ${index}`);\n return this;\n }\n\n bindString(index: number, value: string): this {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n const result = mod.ccall(\n 'duckdb_bind_varchar',\n 'number',\n ['number', 'number', 'number', 'string'],\n [this.stmtPtr, index, 0, value],\n ) as number;\n if (result !== 0) throw new DuckDBError(`Failed to bind string at index ${index}`);\n return this;\n }\n\n bindBlob(index: number, value: Uint8Array): this {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n const ptr = mod._malloc(value.length);\n try {\n mod.HEAPU8.set(value, ptr);\n const result = mod.ccall(\n 'duckdb_bind_blob',\n 'number',\n ['number', 'number', 'number', 'number', 'number', 'number'],\n [this.stmtPtr, index, 0, ptr, value.length, 0],\n ) as number;\n if (result !== 0) throw new DuckDBError(`Failed to bind blob at index ${index}`);\n } finally {\n mod._free(ptr);\n }\n return this;\n }\n\n bindNull(index: number): this {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n const result = mod.ccall(\n 'duckdb_bind_null',\n 'number',\n ['number', 'number', 'number'],\n [this.stmtPtr, index, 0],\n ) as number;\n if (result !== 0) throw new DuckDBError(`Failed to bind null at index ${index}`);\n return this;\n }\n\n bindTimestamp(index: number, value: Date): this {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n const micros = BigInt(value.getTime()) * BigInt(1000);\n const tsLow = Number(micros & BigInt(0xffffffff));\n const tsHigh = Number((micros >> BigInt(32)) & BigInt(0xffffffff));\n const result = mod.ccall(\n 'duckdb_bind_timestamp',\n 'number',\n ['number', 'number', 'number', 'number', 'number'],\n [this.stmtPtr, index, 0, tsLow, tsHigh],\n ) as number;\n if (result !== 0) throw new DuckDBError(`Failed to bind timestamp at index ${index}`);\n return this;\n }\n\n bindDate(index: number, value: Date): this {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n const days = Math.floor(value.getTime() / (24 * 60 * 60 * 1000));\n const result = mod.ccall(\n 'duckdb_bind_date',\n 'number',\n ['number', 'number', 'number', 'number'],\n [this.stmtPtr, index, 0, days],\n ) as number;\n if (result !== 0) throw new DuckDBError(`Failed to bind date at index ${index}`);\n return this;\n }\n\n bind(index: number, value: unknown): this {\n if (value === null || value === undefined) return this.bindNull(index);\n if (typeof value === 'boolean') return this.bindBoolean(index, value);\n if (typeof value === 'number') {\n if (Number.isInteger(value) && value >= -2147483648 && value <= 2147483647) {\n return this.bindInt32(index, value);\n }\n return this.bindDouble(index, value);\n }\n if (typeof value === 'bigint') return this.bindInt64(index, value);\n if (typeof value === 'string') return this.bindString(index, value);\n if (value instanceof Date) return this.bindTimestamp(index, value);\n if (value instanceof Uint8Array) return this.bindBlob(index, value);\n return this.bindString(index, String(value));\n }\n\n /**\n * Executes the prepared statement and returns results as an array of objects.\n * @returns Promise resolving to array of result rows\n */\n async run<T = Record<string, unknown>>(): Promise<T[]> {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n\n const resultPtr = mod._malloc(64);\n try {\n const status = (await mod.ccall(\n 'duckdb_execute_prepared',\n 'number',\n ['number', 'number'],\n [this.stmtPtr, resultPtr],\n { async: true },\n )) as number;\n\n if (status !== 0) {\n const errorPtr = mod.ccall(\n 'duckdb_result_error',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n const errorMsg = errorPtr\n ? mod.UTF8ToString(errorPtr)\n : 'Prepared statement execution failed';\n mod.ccall('duckdb_destroy_result', null, ['number'], [resultPtr]);\n throw new DuckDBError(errorMsg, undefined, this.sql);\n }\n\n const columnCount = mod.ccall(\n 'duckdb_column_count',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n const rowCount = mod.ccall('duckdb_row_count', 'number', ['number'], [resultPtr]) as number;\n\n // Get column metadata (name and type)\n const columns: { name: string; type: number }[] = [];\n for (let i = 0; i < columnCount; i++) {\n const namePtr = mod.ccall(\n 'duckdb_column_name',\n 'number',\n ['number', 'number'],\n [resultPtr, i],\n ) as number;\n\n const type = mod.ccall(\n 'duckdb_column_type',\n 'number',\n ['number', 'number'],\n [resultPtr, i],\n ) as number;\n\n columns.push({\n name: mod.UTF8ToString(namePtr),\n type,\n });\n }\n\n // Extract column data with proper types\n const columnData: unknown[][] = [];\n for (let colIdx = 0; colIdx < columnCount; colIdx++) {\n const col = columns[colIdx];\n\n const dataPtr = mod.ccall(\n 'duckdb_column_data',\n 'number',\n ['number', 'number'],\n [resultPtr, colIdx],\n ) as number;\n\n const nullmaskPtr = mod.ccall(\n 'duckdb_nullmask_data',\n 'number',\n ['number', 'number'],\n [resultPtr, colIdx],\n ) as number;\n\n if (col.type === DuckDBType.VARCHAR || dataPtr === 0) {\n // VARCHAR or unsupported type - use value_varchar\n const values: unknown[] = new Array(rowCount);\n for (let rowIdx = 0; rowIdx < rowCount; rowIdx++) {\n const isNull = mod.ccall(\n 'duckdb_value_is_null',\n 'number',\n ['number', 'number', 'number', 'number', 'number'],\n [resultPtr, colIdx, 0, rowIdx, 0],\n ) as number;\n\n if (isNull) {\n values[rowIdx] = null;\n } else {\n const strPtr = mod.ccall(\n 'duckdb_value_varchar',\n 'number',\n ['number', 'number', 'number', 'number', 'number'],\n [resultPtr, colIdx, 0, rowIdx, 0],\n ) as number;\n if (strPtr) {\n values[rowIdx] = mod.UTF8ToString(strPtr);\n mod._free(strPtr);\n } else {\n values[rowIdx] = null;\n }\n }\n }\n columnData.push(values);\n } else {\n // Use type-specific extraction\n columnData.push(readColumnData(mod, dataPtr, nullmaskPtr, rowCount, col.type));\n }\n }\n\n // Build result rows\n const rows: T[] = new Array(rowCount);\n for (let rowIdx = 0; rowIdx < rowCount; rowIdx++) {\n const row: Record<string, unknown> = {};\n for (let colIdx = 0; colIdx < columnCount; colIdx++) {\n row[columns[colIdx].name] = columnData[colIdx][rowIdx];\n }\n rows[rowIdx] = row as T;\n }\n\n mod.ccall('duckdb_destroy_result', null, ['number'], [resultPtr]);\n return rows;\n } finally {\n mod._free(resultPtr);\n }\n }\n\n /**\n * Executes the prepared statement without returning results.\n * @returns Promise resolving to number of rows affected\n */\n async execute(): Promise<number> {\n if (this.closed) throw new DuckDBError('Statement is closed');\n const mod = getModule();\n\n const resultPtr = mod._malloc(64);\n try {\n const status = (await mod.ccall(\n 'duckdb_execute_prepared',\n 'number',\n ['number', 'number'],\n [this.stmtPtr, resultPtr],\n { async: true },\n )) as number;\n\n if (status !== 0) {\n const errorPtr = mod.ccall(\n 'duckdb_result_error',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n const errorMsg = errorPtr\n ? mod.UTF8ToString(errorPtr)\n : 'Prepared statement execution failed';\n mod.ccall('duckdb_destroy_result', null, ['number'], [resultPtr]);\n throw new DuckDBError(errorMsg, undefined, this.sql);\n }\n\n const rowsChanged = mod.ccall(\n 'duckdb_rows_changed',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n mod.ccall('duckdb_destroy_result', null, ['number'], [resultPtr]);\n return rowsChanged;\n } finally {\n mod._free(resultPtr);\n }\n }\n\n close(): void {\n if (this.closed) return;\n const mod = getModule();\n const stmtPtrPtr = mod._malloc(4);\n try {\n mod.setValue(stmtPtrPtr, this.stmtPtr, 'i32');\n mod.ccall('duckdb_destroy_prepare', null, ['number'], [stmtPtrPtr]);\n } finally {\n mod._free(stmtPtrPtr);\n }\n this.closed = true;\n this.stmtPtr = 0;\n }\n}\n\n/**\n * A chunk of data from a streaming query result.\n * @category Query Results\n */\nexport class DataChunk {\n private chunkPtr: number;\n private destroyed = false;\n private readonly columns: ColumnInfo[];\n\n /** @internal */\n constructor(chunkPtr: number, columns: ColumnInfo[]) {\n this.chunkPtr = chunkPtr;\n this.columns = columns;\n }\n\n get rowCount(): number {\n if (this.destroyed) return 0;\n const mod = getModule();\n return mod.ccall('duckdb_data_chunk_get_size', 'number', ['number'], [this.chunkPtr]) as number;\n }\n\n get columnCount(): number {\n if (this.destroyed) return 0;\n const mod = getModule();\n return mod.ccall(\n 'duckdb_data_chunk_get_column_count',\n 'number',\n ['number'],\n [this.chunkPtr],\n ) as number;\n }\n\n getColumnInfo(): ColumnInfo[] {\n return this.columns;\n }\n\n getColumn(columnIndex: number): unknown[] {\n if (this.destroyed) throw new DuckDBError('DataChunk has been destroyed');\n const mod = getModule();\n const rows = this.rowCount;\n\n const vectorPtr = mod.ccall(\n 'duckdb_data_chunk_get_vector',\n 'number',\n ['number', 'number'],\n [this.chunkPtr, columnIndex],\n ) as number;\n\n if (!vectorPtr) throw new DuckDBError(`Failed to get vector for column ${columnIndex}`);\n\n const dataPtr = mod.ccall(\n 'duckdb_vector_get_data',\n 'number',\n ['number'],\n [vectorPtr],\n ) as number;\n const validityPtr = mod.ccall(\n 'duckdb_vector_get_validity',\n 'number',\n ['number'],\n [vectorPtr],\n ) as number;\n\n const columnType = this.columns[columnIndex]?.type ?? DuckDBType.VARCHAR;\n return this.readVectorData(dataPtr, validityPtr, rows, columnType);\n }\n\n toArray<T = Record<string, unknown>>(): T[] {\n if (this.destroyed) return [];\n const rows = this.rowCount;\n const cols = this.columnCount;\n\n const columnData: unknown[][] = [];\n for (let c = 0; c < cols; c++) {\n columnData.push(this.getColumn(c));\n }\n\n const result: T[] = new Array(rows);\n for (let r = 0; r < rows; r++) {\n const row: Record<string, unknown> = {};\n for (let c = 0; c < cols; c++) {\n row[this.columns[c].name] = columnData[c][r];\n }\n result[r] = row as T;\n }\n return result;\n }\n\n private readVectorData(\n dataPtr: number,\n validityPtr: number,\n rowCount: number,\n duckdbType: number,\n ): unknown[] {\n const mod = getModule();\n const result: unknown[] = new Array(rowCount);\n\n const isRowNull = (rowIdx: number): boolean => {\n if (validityPtr === 0) return false;\n return (\n (mod.ccall(\n 'duckdb_validity_row_is_valid',\n 'number',\n ['number', 'number'],\n [validityPtr, rowIdx],\n ) as number) === 0\n );\n };\n\n switch (duckdbType) {\n case DuckDBType.BOOLEAN:\n for (let i = 0; i < rowCount; i++) {\n result[i] = isRowNull(i) ? null : mod.HEAPU8[dataPtr + i] !== 0;\n }\n break;\n\n case DuckDBType.TINYINT:\n for (let i = 0; i < rowCount; i++) {\n result[i] = isRowNull(i) ? null : mod.HEAP8[dataPtr + i];\n }\n break;\n\n case DuckDBType.SMALLINT: {\n const offset = dataPtr >> 1;\n for (let i = 0; i < rowCount; i++) {\n result[i] = isRowNull(i) ? null : mod.HEAP16[offset + i];\n }\n break;\n }\n\n case DuckDBType.INTEGER: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n result[i] = isRowNull(i) ? null : mod.HEAP32[offset + i];\n }\n break;\n }\n\n case DuckDBType.BIGINT: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (isRowNull(i)) {\n result[i] = null;\n } else {\n const low = mod.HEAPU32[offset + i * 2];\n const high = mod.HEAP32[offset + i * 2 + 1];\n result[i] = high * 0x100000000 + low;\n }\n }\n break;\n }\n\n case DuckDBType.FLOAT: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n result[i] = isRowNull(i) ? null : mod.HEAPF32[offset + i];\n }\n break;\n }\n\n case DuckDBType.DOUBLE: {\n const offset = dataPtr >> 3;\n for (let i = 0; i < rowCount; i++) {\n result[i] = isRowNull(i) ? null : mod.HEAPF64[offset + i];\n }\n break;\n }\n\n case DuckDBType.DATE: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (isRowNull(i)) {\n result[i] = null;\n } else {\n const days = mod.HEAP32[offset + i];\n const date = new Date(days * 24 * 60 * 60 * 1000);\n result[i] = date.toISOString().split('T')[0];\n }\n }\n break;\n }\n\n case DuckDBType.TIMESTAMP:\n case DuckDBType.TIMESTAMP_TZ: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (isRowNull(i)) {\n result[i] = null;\n } else {\n const low = mod.HEAPU32[offset + i * 2];\n const high = mod.HEAP32[offset + i * 2 + 1];\n const micros = high * 0x100000000 + low;\n const date = new Date(micros / 1000);\n result[i] = date.toISOString();\n }\n }\n break;\n }\n\n default:\n for (let i = 0; i < rowCount; i++) {\n if (isRowNull(i)) {\n result[i] = null;\n } else {\n const strBase = dataPtr + i * 16;\n const length = mod.HEAP32[strBase >> 2];\n\n if (length <= 12) {\n let str = '';\n for (let j = 0; j < length; j++) {\n str += String.fromCharCode(mod.HEAPU8[strBase + 4 + j]);\n }\n result[i] = str;\n } else {\n const strPtr = mod.HEAP32[(strBase + 8) >> 2];\n result[i] = mod.UTF8ToString(strPtr);\n }\n }\n }\n break;\n }\n\n return result;\n }\n\n destroy(): void {\n if (this.destroyed) return;\n const mod = getModule();\n const chunkPtrPtr = mod._malloc(4);\n try {\n mod.setValue(chunkPtrPtr, this.chunkPtr, 'i32');\n mod.ccall('duckdb_destroy_data_chunk', null, ['number'], [chunkPtrPtr]);\n } finally {\n mod._free(chunkPtrPtr);\n }\n this.destroyed = true;\n this.chunkPtr = 0;\n }\n}\n\n/**\n * A streaming query result that yields data in chunks.\n * @category Query Results\n */\nexport class StreamingResult implements Iterable<DataChunk> {\n private resultPtr: number;\n private closed = false;\n private readonly columns: ColumnInfo[];\n private currentChunkIndex = 0;\n private readonly totalChunks: number;\n\n /** @internal */\n constructor(resultPtr: number, columns: ColumnInfo[]) {\n this.resultPtr = resultPtr;\n this.columns = columns;\n\n const mod = getModule();\n this.totalChunks = mod.ccall(\n 'duckdb_result_chunk_count',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n }\n\n getColumns(): ColumnInfo[] {\n return this.columns;\n }\n\n get columnCount(): number {\n return this.columns.length;\n }\n\n get chunkCount(): number {\n return this.totalChunks;\n }\n\n nextChunk(): DataChunk | null {\n if (this.closed || this.currentChunkIndex >= this.totalChunks) {\n return null;\n }\n\n const mod = getModule();\n const chunkPtr = mod.ccall(\n 'duckdb_result_get_chunk',\n 'number',\n ['number', 'number'],\n [this.resultPtr, this.currentChunkIndex],\n ) as number;\n\n if (!chunkPtr) return null;\n\n this.currentChunkIndex++;\n return new DataChunk(chunkPtr, this.columns);\n }\n\n reset(): void {\n this.currentChunkIndex = 0;\n }\n\n *[Symbol.iterator](): Iterator<DataChunk> {\n this.reset();\n let chunk: DataChunk | null;\n while ((chunk = this.nextChunk()) !== null) {\n try {\n yield chunk;\n } finally {\n chunk.destroy();\n }\n }\n }\n\n toArray<T = Record<string, unknown>>(): T[] {\n const allRows: T[] = [];\n for (const chunk of this) {\n allRows.push(...chunk.toArray<T>());\n }\n return allRows;\n }\n\n toArrowTable(): Table {\n const columnData: Record<string, unknown[]> = {};\n const types: Record<string, DataType> = {};\n\n for (const col of this.columns) {\n columnData[col.name] = [];\n types[col.name] = this.getFlechetteType(col.type);\n }\n\n for (const chunk of this) {\n for (let c = 0; c < this.columns.length; c++) {\n const colName = this.columns[c].name;\n const chunkData = chunk.getColumn(c);\n columnData[colName].push(...chunkData);\n }\n }\n\n return tableFromArrays(columnData, { types });\n }\n\n private getFlechetteType(duckdbType: DuckDBTypeId): DataType {\n switch (duckdbType) {\n case DuckDBType.BOOLEAN:\n return bool();\n case DuckDBType.TINYINT:\n return int8();\n case DuckDBType.SMALLINT:\n return int16();\n case DuckDBType.INTEGER:\n return int32();\n case DuckDBType.BIGINT:\n return int64();\n case DuckDBType.UTINYINT:\n return uint8();\n case DuckDBType.USMALLINT:\n return uint16();\n case DuckDBType.UINTEGER:\n return uint32();\n case DuckDBType.UBIGINT:\n return uint64();\n case DuckDBType.FLOAT:\n return float32();\n case DuckDBType.DOUBLE:\n return float64();\n case DuckDBType.VARCHAR:\n return utf8();\n case DuckDBType.DATE:\n return dateDay();\n case DuckDBType.TIMESTAMP:\n case DuckDBType.TIMESTAMP_TZ:\n return timestamp(TimeUnit.MICROSECOND);\n default:\n return utf8();\n }\n }\n\n close(): void {\n if (this.closed) return;\n const mod = getModule();\n mod.ccall('duckdb_destroy_result', null, ['number'], [this.resultPtr]);\n this.closed = true;\n this.resultPtr = 0;\n }\n}\n\n/**\n * DuckDB database instance for Cloudflare Workers.\n *\n * @category Database\n * @example\n * ```typescript\n * import { init, DuckDB, AccessMode } from '@ducklings/workers';\n * import wasmModule from '@ducklings/workers/wasm';\n *\n * await init({ wasmModule });\n *\n * // Default configuration (httpfs enabled, config locked)\n * const db = new DuckDB();\n *\n * // Or with custom security configuration\n * const secureDb = new DuckDB({\n * accessMode: AccessMode.READ_ONLY,\n * lockConfiguration: true,\n * });\n *\n * const conn = db.connect();\n * const result = await conn.query('SELECT 42 as answer');\n * console.log(result);\n *\n * conn.close();\n * db.close();\n * ```\n */\nexport class DuckDB {\n private dbPtr: number = 0;\n private closed: boolean = false;\n\n /**\n * Creates a new DuckDB database instance.\n *\n * @param config - Optional configuration options\n */\n constructor(config: DuckDBConfig = {}) {\n if (!module) {\n throw new DuckDBError('DuckDB WASM not initialized. Call init() first.');\n }\n\n // Store module reference for use in closures\n const mod = module;\n\n // Apply defaults\n const finalConfig = {\n accessMode: config.accessMode ?? AccessMode.AUTOMATIC,\n enableExternalAccess: config.enableExternalAccess ?? true,\n lockConfiguration: config.lockConfiguration ?? true,\n customConfig: config.customConfig ?? {},\n };\n\n // Create config object\n const configPtrPtr = mod._malloc(4);\n const result = mod.ccall(\n 'duckdb_create_config',\n 'number',\n ['number'],\n [configPtrPtr],\n ) as number;\n\n if (result !== 0) {\n mod._free(configPtrPtr);\n throw new DuckDBError('Failed to create DuckDB configuration');\n }\n\n const configPtr = mod.getValue(configPtrPtr, 'i32');\n mod._free(configPtrPtr);\n\n try {\n // Helper to set config option\n const setConfig = (name: string, value: string) => {\n const setResult = mod.ccall(\n 'duckdb_set_config',\n 'number',\n ['number', 'string', 'string'],\n [configPtr, name, value],\n ) as number;\n if (setResult !== 0) {\n throw new DuckDBError(`Failed to set config option: ${name}`);\n }\n };\n\n // Apply access mode\n if (finalConfig.accessMode !== AccessMode.AUTOMATIC) {\n setConfig('access_mode', finalConfig.accessMode);\n }\n\n // Apply external access setting\n if (finalConfig.enableExternalAccess === false) {\n setConfig('enable_external_access', 'false');\n }\n\n // Apply custom config options\n for (const [key, value] of Object.entries(finalConfig.customConfig)) {\n setConfig(key, value);\n }\n\n // Open database with config\n const dbPtrPtr = mod._malloc(4);\n const errorPtrPtr = mod._malloc(4);\n\n try {\n const openResult = mod.ccall(\n 'duckdb_open_ext',\n 'number',\n ['string', 'number', 'number', 'number'],\n [':memory:', dbPtrPtr, configPtr, errorPtrPtr],\n ) as number;\n\n if (openResult !== 0) {\n const errorPtr = mod.getValue(errorPtrPtr, 'i32');\n const errorMsg = errorPtr ? mod.UTF8ToString(errorPtr) : 'Unknown error';\n throw new DuckDBError(`Failed to open database: ${errorMsg}`);\n }\n\n this.dbPtr = mod.getValue(dbPtrPtr, 'i32');\n } finally {\n mod._free(dbPtrPtr);\n mod._free(errorPtrPtr);\n }\n\n // Initialize httpfs (only if external access enabled)\n if (finalConfig.enableExternalAccess !== false) {\n mod.ccall('duckdb_wasm_httpfs_init', null, ['number'], [this.dbPtr]);\n }\n\n // Lock configuration (secure default)\n if (finalConfig.lockConfiguration !== false) {\n // Use direct ccall for synchronous execution during construction\n const connPtrPtr = mod._malloc(4);\n try {\n const connResult = mod.ccall(\n 'duckdb_connect',\n 'number',\n ['number', 'number'],\n [this.dbPtr, connPtrPtr],\n ) as number;\n\n if (connResult === 0) {\n const connPtr = mod.getValue(connPtrPtr, 'i32');\n const resultPtr = mod._malloc(64);\n try {\n mod.ccall(\n 'duckdb_query',\n 'number',\n ['number', 'string', 'number'],\n [connPtr, 'SET lock_configuration = true', resultPtr],\n );\n mod.ccall('duckdb_destroy_result', null, ['number'], [resultPtr]);\n } finally {\n mod._free(resultPtr);\n }\n mod.ccall('duckdb_disconnect', null, ['number'], [connPtrPtr]);\n }\n } finally {\n mod._free(connPtrPtr);\n }\n }\n } finally {\n // Destroy config object\n const configPtrPtrForDestroy = mod._malloc(4);\n mod.setValue(configPtrPtrForDestroy, configPtr, 'i32');\n mod.ccall('duckdb_destroy_config', null, ['number'], [configPtrPtrForDestroy]);\n mod._free(configPtrPtrForDestroy);\n }\n }\n\n /**\n * Creates a new DuckDB database instance asynchronously.\n *\n * @param config - Optional configuration options\n */\n static async create(config?: DuckDBConfig): Promise<DuckDB> {\n return new DuckDB(config);\n }\n\n connect(): Connection {\n if (this.closed || !module) {\n throw new DuckDBError('Database is closed');\n }\n\n const connPtrPtr = module._malloc(4);\n try {\n const result = module.ccall(\n 'duckdb_connect',\n 'number',\n ['number', 'number'],\n [this.dbPtr, connPtrPtr],\n ) as number;\n\n if (result !== 0) {\n throw new DuckDBError('Failed to create connection');\n }\n\n const connPtr = module.getValue(connPtrPtr, '*');\n return new Connection(connPtr);\n } finally {\n module._free(connPtrPtr);\n }\n }\n\n close(): void {\n if (this.closed || !module) return;\n\n const dbPtrPtr = module._malloc(4);\n try {\n module.setValue(dbPtrPtr, this.dbPtr, '*');\n module.ccall('duckdb_close', null, ['number'], [dbPtrPtr]);\n } finally {\n module._free(dbPtrPtr);\n }\n\n this.closed = true;\n this.dbPtr = 0;\n }\n}\n\n/**\n * A connection to a DuckDB database (async API for Cloudflare Workers).\n *\n * All query methods in this class are async and return Promises.\n * @category Connection\n */\nexport class Connection {\n private connPtr: number;\n private closed: boolean = false;\n\n /** @internal */\n constructor(connPtr: number) {\n this.connPtr = connPtr;\n }\n\n /**\n * Executes a SQL query and returns the results.\n * This is async to support httpfs in Cloudflare Workers.\n *\n * @param sql - The SQL query to execute\n * @returns Promise resolving to array of result rows as objects\n */\n async query<T = Record<string, unknown>>(sql: string): Promise<T[]> {\n if (this.closed || !module) {\n throw new DuckDBError('Connection is closed');\n }\n\n const resultPtr = module._malloc(64);\n try {\n const status = (await module.ccall(\n 'duckdb_query',\n 'number',\n ['number', 'string', 'number'],\n [this.connPtr, sql, resultPtr],\n { async: true },\n )) as number;\n\n if (status !== 0) {\n const errorPtr = module.ccall(\n 'duckdb_result_error',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n\n const error = errorPtr ? module.UTF8ToString(errorPtr) : 'Query failed';\n module.ccall('duckdb_destroy_result', null, ['number'], [resultPtr]);\n throw new DuckDBError(error, undefined, sql);\n }\n\n const columnCount = module.ccall(\n 'duckdb_column_count',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n\n const columns: { name: string; type: number }[] = [];\n for (let i = 0; i < columnCount; i++) {\n const namePtr = module.ccall(\n 'duckdb_column_name',\n 'number',\n ['number', 'number'],\n [resultPtr, i],\n ) as number;\n\n const type = module.ccall(\n 'duckdb_column_type',\n 'number',\n ['number', 'number'],\n [resultPtr, i],\n ) as number;\n\n columns.push({\n name: module.UTF8ToString(namePtr),\n type,\n });\n }\n\n const rowCount = module.ccall(\n 'duckdb_row_count',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n\n const columnData: unknown[][] = [];\n for (let colIdx = 0; colIdx < columnCount; colIdx++) {\n const col = columns[colIdx];\n\n const dataPtr = module.ccall(\n 'duckdb_column_data',\n 'number',\n ['number', 'number'],\n [resultPtr, colIdx],\n ) as number;\n\n const nullmaskPtr = module.ccall(\n 'duckdb_nullmask_data',\n 'number',\n ['number', 'number'],\n [resultPtr, colIdx],\n ) as number;\n\n if (col.type === DuckDBType.VARCHAR || dataPtr === 0) {\n const values: unknown[] = new Array(rowCount);\n for (let rowIdx = 0; rowIdx < rowCount; rowIdx++) {\n const isNull = module.ccall(\n 'duckdb_value_is_null',\n 'number',\n ['number', 'number', 'number', 'number', 'number'],\n [resultPtr, colIdx, 0, rowIdx, 0],\n ) as number;\n\n if (isNull) {\n values[rowIdx] = null;\n } else {\n const strPtr = module.ccall(\n 'duckdb_value_varchar',\n 'number',\n ['number', 'number', 'number', 'number', 'number'],\n [resultPtr, colIdx, 0, rowIdx, 0],\n ) as number;\n if (strPtr) {\n values[rowIdx] = module.UTF8ToString(strPtr);\n module._free(strPtr);\n } else {\n values[rowIdx] = null;\n }\n }\n }\n columnData.push(values);\n } else {\n columnData.push(this.readColumnData(dataPtr, nullmaskPtr, rowCount, col.type));\n }\n }\n\n const rows: T[] = new Array(rowCount);\n for (let rowIdx = 0; rowIdx < rowCount; rowIdx++) {\n const row: Record<string, unknown> = {};\n for (let colIdx = 0; colIdx < columnCount; colIdx++) {\n row[columns[colIdx].name] = columnData[colIdx][rowIdx];\n }\n rows[rowIdx] = row as T;\n }\n\n module.ccall('duckdb_destroy_result', null, ['number'], [resultPtr]);\n\n return rows;\n } finally {\n module._free(resultPtr);\n }\n }\n\n private readColumnData(\n dataPtr: number,\n nullmaskPtr: number,\n rowCount: number,\n duckdbType: number,\n ): unknown[] {\n if (!module) return [];\n\n const result: unknown[] = new Array(rowCount);\n const hasNullmask = nullmaskPtr !== 0;\n\n switch (duckdbType) {\n case DuckDBType.BOOLEAN: {\n const boolPtr = dataPtr;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = module.HEAPU8[boolPtr + i] !== 0;\n }\n }\n break;\n }\n\n case DuckDBType.TINYINT: {\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = module.HEAP8[dataPtr + i];\n }\n }\n break;\n }\n\n case DuckDBType.SMALLINT: {\n const offset = dataPtr >> 1;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = module.HEAP16[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.INTEGER: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = module.HEAP32[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.BIGINT: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n const low = module.HEAPU32[offset + i * 2];\n const high = module.HEAP32[offset + i * 2 + 1];\n // Check if value fits in safe integer range before computing\n if (high === 0 && low <= 0x1fffffffffffff) {\n result[i] = low;\n } else if (high === -1 && low >= 0x80000000) {\n // Small negative number\n result[i] = high * 0x100000000 + low;\n } else {\n // Large value - return as string for JSON compatibility\n const bigValue = BigInt(high) * BigInt(0x100000000) + BigInt(low >>> 0);\n result[i] = bigValue.toString();\n }\n }\n }\n break;\n }\n\n case DuckDBType.UTINYINT: {\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = module.HEAPU8[dataPtr + i];\n }\n }\n break;\n }\n\n case DuckDBType.USMALLINT: {\n const offset = dataPtr >> 1;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = module.HEAPU16[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.UINTEGER: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = module.HEAPU32[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.UBIGINT: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n const low = module.HEAPU32[offset + i * 2];\n const high = module.HEAPU32[offset + i * 2 + 1];\n // Check if value fits in safe integer range before computing\n if (high === 0 && low <= 0x1fffffffffffff) {\n result[i] = low;\n } else {\n // Large value - return as string for JSON compatibility\n const bigValue = BigInt(high) * BigInt(0x100000000) + BigInt(low);\n result[i] = bigValue.toString();\n }\n }\n }\n break;\n }\n\n case DuckDBType.FLOAT: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = module.HEAPF32[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.DOUBLE: {\n const offset = dataPtr >> 3;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n result[i] = module.HEAPF64[offset + i];\n }\n }\n break;\n }\n\n case DuckDBType.DATE: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n const days = module.HEAP32[offset + i];\n const date = new Date(days * 24 * 60 * 60 * 1000);\n result[i] = date.toISOString().split('T')[0];\n }\n }\n break;\n }\n\n case DuckDBType.TIMESTAMP:\n case DuckDBType.TIMESTAMP_TZ: {\n const offset = dataPtr >> 2;\n for (let i = 0; i < rowCount; i++) {\n if (hasNullmask && module.HEAPU8[nullmaskPtr + i]) {\n result[i] = null;\n } else {\n // Timestamp is stored as microseconds since epoch\n const low = module.HEAPU32[offset + i * 2];\n const high = module.HEAP32[offset + i * 2 + 1];\n const micros = BigInt(high) * BigInt(0x100000000) + BigInt(low >>> 0);\n const millis = Number(micros / BigInt(1000));\n const date = new Date(millis);\n result[i] = date.toISOString();\n }\n }\n break;\n }\n\n default:\n for (let i = 0; i < rowCount; i++) {\n result[i] = null;\n }\n break;\n }\n\n return result;\n }\n\n /**\n * Executes a SQL query and returns results as an Arrow table.\n *\n * @param sql - The SQL query to execute\n * @returns Promise resolving to Arrow Table\n */\n async queryArrow(sql: string): Promise<Table> {\n if (this.closed || !module) {\n throw new DuckDBError('Connection is closed');\n }\n\n const resultPtr = module._malloc(64);\n try {\n const status = (await module.ccall(\n 'duckdb_query',\n 'number',\n ['number', 'string', 'number'],\n [this.connPtr, sql, resultPtr],\n { async: true },\n )) as number;\n\n if (status !== 0) {\n const errorPtr = module.ccall(\n 'duckdb_result_error',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n const error = errorPtr ? module.UTF8ToString(errorPtr) : 'Query failed';\n module.ccall('duckdb_destroy_result', null, ['number'], [resultPtr]);\n throw new DuckDBError(error, undefined, sql);\n }\n\n const columnCount = module.ccall(\n 'duckdb_column_count',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n\n const rowCount = module.ccall(\n 'duckdb_row_count',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n\n const columns: { name: string; type: number; flechetteType: DataType }[] = [];\n for (let i = 0; i < columnCount; i++) {\n const namePtr = module.ccall(\n 'duckdb_column_name',\n 'number',\n ['number', 'number'],\n [resultPtr, i],\n ) as number;\n\n const type = module.ccall(\n 'duckdb_column_type',\n 'number',\n ['number', 'number'],\n [resultPtr, i],\n ) as number;\n\n columns.push({\n name: module.UTF8ToString(namePtr),\n type,\n flechetteType: this.getFlechetteType(type) || utf8(),\n });\n }\n\n const tableData: Record<string, unknown[]> = {};\n const types: Record<string, DataType> = {};\n\n for (let colIdx = 0; colIdx < columnCount; colIdx++) {\n const col = columns[colIdx];\n\n const dataPtr = module.ccall(\n 'duckdb_column_data',\n 'number',\n ['number', 'number'],\n [resultPtr, colIdx],\n ) as number;\n\n const nullmaskPtr = module.ccall(\n 'duckdb_nullmask_data',\n 'number',\n ['number', 'number'],\n [resultPtr, colIdx],\n ) as number;\n\n if (col.type === DuckDBType.VARCHAR || dataPtr === 0) {\n const values: unknown[] = new Array(rowCount);\n for (let rowIdx = 0; rowIdx < rowCount; rowIdx++) {\n const isNull = module.ccall(\n 'duckdb_value_is_null',\n 'number',\n ['number', 'number', 'number', 'number', 'number'],\n [resultPtr, colIdx, 0, rowIdx, 0],\n ) as number;\n\n if (isNull) {\n values[rowIdx] = null;\n } else {\n const strPtr = module.ccall(\n 'duckdb_value_varchar',\n 'number',\n ['number', 'number', 'number', 'number', 'number'],\n [resultPtr, colIdx, 0, rowIdx, 0],\n ) as number;\n if (strPtr) {\n values[rowIdx] = module.UTF8ToString(strPtr);\n module._free(strPtr);\n } else {\n values[rowIdx] = null;\n }\n }\n }\n tableData[col.name] = values;\n } else {\n tableData[col.name] = this.readColumnData(dataPtr, nullmaskPtr, rowCount, col.type);\n }\n\n types[col.name] = col.flechetteType;\n }\n\n module.ccall('duckdb_destroy_result', null, ['number'], [resultPtr]);\n\n return tableFromArrays(tableData, { types });\n } finally {\n module._free(resultPtr);\n }\n }\n\n private getFlechetteType(duckdbType: number): DataType | null {\n switch (duckdbType) {\n case DuckDBType.BOOLEAN:\n return bool();\n case DuckDBType.TINYINT:\n return int8();\n case DuckDBType.SMALLINT:\n return int16();\n case DuckDBType.INTEGER:\n return int32();\n case DuckDBType.BIGINT:\n return int64();\n case DuckDBType.UTINYINT:\n return uint8();\n case DuckDBType.USMALLINT:\n return uint16();\n case DuckDBType.UINTEGER:\n return uint32();\n case DuckDBType.UBIGINT:\n return uint64();\n case DuckDBType.FLOAT:\n return float32();\n case DuckDBType.DOUBLE:\n return float64();\n case DuckDBType.VARCHAR:\n return utf8();\n case DuckDBType.DATE:\n return dateDay();\n case DuckDBType.TIMESTAMP:\n case DuckDBType.TIMESTAMP_TZ:\n return timestamp(TimeUnit.MICROSECOND);\n default:\n return utf8();\n }\n }\n\n /**\n * Executes a SQL statement without returning results.\n *\n * @param sql - The SQL statement to execute\n * @returns Promise resolving to number of rows affected\n */\n async execute(sql: string): Promise<number> {\n if (this.closed || !module) {\n throw new DuckDBError('Connection is closed');\n }\n\n const resultPtr = module._malloc(64);\n try {\n const status = (await module.ccall(\n 'duckdb_query',\n 'number',\n ['number', 'string', 'number'],\n [this.connPtr, sql, resultPtr],\n { async: true },\n )) as number;\n\n if (status !== 0) {\n const errorPtr = module.ccall(\n 'duckdb_result_error',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n\n const error = errorPtr ? module.UTF8ToString(errorPtr) : 'Query failed';\n module.ccall('duckdb_destroy_result', null, ['number'], [resultPtr]);\n throw new DuckDBError(error, undefined, sql);\n }\n\n const rowsChanged = module.ccall(\n 'duckdb_rows_changed',\n 'number',\n ['number'],\n [resultPtr],\n ) as number;\n\n module.ccall('duckdb_destroy_result', null, ['number'], [resultPtr]);\n return rowsChanged;\n } finally {\n module._free(resultPtr);\n }\n }\n\n /**\n * Creates a prepared statement for the given SQL.\n *\n * @param sql - The SQL statement to prepare (use ? for parameters)\n * @returns A PreparedStatement instance\n */\n prepare(sql: string): PreparedStatement {\n if (this.closed || !module) {\n throw new DuckDBError('Connection is closed');\n }\n\n const stmtPtrPtr = module._malloc(4);\n try {\n const result = module.ccall(\n 'duckdb_prepare',\n 'number',\n ['number', 'string', 'number'],\n [this.connPtr, sql, stmtPtrPtr],\n ) as number;\n\n if (result !== 0) {\n const stmtPtr = module.getValue(stmtPtrPtr, '*');\n if (stmtPtr) {\n const errorPtr = module.ccall(\n 'duckdb_prepare_error',\n 'number',\n ['number'],\n [stmtPtr],\n ) as number;\n const error = errorPtr ? module.UTF8ToString(errorPtr) : 'Failed to prepare statement';\n module.ccall('duckdb_destroy_prepare', null, ['number'], [stmtPtr]);\n throw new DuckDBError(error, undefined, sql);\n }\n throw new DuckDBError('Failed to prepare statement', undefined, sql);\n }\n\n const stmtPtr = module.getValue(stmtPtrPtr, '*');\n return new PreparedStatement(stmtPtr, this.connPtr, sql);\n } finally {\n module._free(stmtPtrPtr);\n }\n }\n\n async beginTransaction(): Promise<void> {\n await this.execute('BEGIN TRANSACTION');\n }\n\n async commit(): Promise<void> {\n await this.execute('COMMIT');\n }\n\n async rollback(): Promise<void> {\n await this.execute('ROLLBACK');\n }\n\n async transaction<T>(fn: () => Promise<T>): Promise<T> {\n await this.beginTransaction();\n try {\n const result = await fn();\n await this.commit();\n return result;\n } catch (e) {\n await this.rollback();\n throw e;\n }\n }\n\n close(): void {\n if (this.closed || !module) return;\n\n const connPtrPtr = module._malloc(4);\n try {\n module.setValue(connPtrPtr, this.connPtr, '*');\n module.ccall('duckdb_disconnect', null, ['number'], [connPtrPtr]);\n } finally {\n module._free(connPtrPtr);\n }\n\n this.closed = true;\n this.connPtr = 0;\n }\n}\n\n// Re-export Flechette types and utilities\nexport type { Table } from '@uwdata/flechette';\nexport { tableFromArrays, tableFromIPC, tableToIPC } from '@uwdata/flechette';\n"]}