@delali/narsil 0.3.1-next.156 → 0.3.1-next.160
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.
- package/dist/adapters/filesystem.mjs +3 -3
- package/dist/adapters/gcs.mjs +3 -3
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/adapters/s3.mjs +3 -3
- package/dist/browser/{chunk-3V7DNNZL.mjs → chunk-4RNSFVWI.mjs} +20997 -19899
- package/dist/browser/chunk-MMHIIL5B.mjs +564 -0
- package/dist/browser/chunk-MZHQ65VI.mjs +1228 -0
- package/dist/browser/chunk-WC2DEXWU.mjs +29 -0
- package/dist/browser/{chunk-VLJQW4J6.mjs → core-leaf-TJAGWPZZ.mjs} +4674 -3102
- package/dist/browser/{durability-config-TIYKW6XX.mjs → durability-config-SGB5ZP5K.mjs} +8 -3
- package/dist/browser/embed-RF2MPGAO.mjs +222 -0
- package/dist/{geo-index-MRH5JMIR.mjs → browser/geo-index-GNHY4PUB.mjs} +190 -93
- package/dist/{react-native/chunks/module-TTEVPRCW.mjs → browser/module-362VSIGR.mjs} +1570 -275
- package/dist/browser/msgpack-leaf-44XNWSSY.mjs +302 -0
- package/dist/browser/optional-reads-XMVPG6HG.mjs +3230 -0
- package/dist/browser/optional-writes-WMZX4OEC.mjs +3196 -0
- package/dist/browser/phrase-module-22TKMXWI.mjs +616 -0
- package/dist/browser/resolve-vector-text-KI65IHMD.mjs +60 -0
- package/dist/{react-native/chunks/restore-hooks-IBGIY3DR.mjs → browser/restore-queue-S4BWOGMU.mjs} +98 -36
- package/dist/{react-native/chunks/runtime-R5E3TB3J.mjs → browser/runtime-NU6VOVH2.mjs} +61 -25
- package/dist/browser/segment-codec-leaf-A427QJUX.mjs +554 -0
- package/dist/browser/segment-merge-leaf-7BZ54JPI.mjs +1636 -0
- package/dist/browser/storage-leaf-X6CNRHJS.mjs +18221 -0
- package/dist/browser/store-leaf-AEMTAVHX.mjs +2069 -0
- package/dist/browser/{chunk-SSTPBZZX.mjs → suggestions-leaf-3Y6MR6OF.mjs} +441 -119
- package/dist/browser/worker-copies-WQCPP3TS.mjs +2750 -0
- package/dist/{capabilities-Da4ywVVl.d.ts → capabilities-BKDrry0z.d.ts} +2 -2
- package/dist/chunk-2JRERUNZ.mjs +217 -0
- package/dist/chunk-2RIS76RJ.mjs +212 -0
- package/dist/chunk-3B775F3C.mjs +252 -0
- package/dist/{chunk-K5QFDYST.mjs → chunk-3D6RZGJH.mjs} +3 -3
- package/dist/{chunk-INJYO3BU.mjs → chunk-4CAMH7FO.mjs} +1 -1
- package/dist/{chunk-U476IXKQ.mjs → chunk-4PY4JYMY.mjs} +2 -1
- package/dist/chunk-6EZW2GQL.mjs +978 -0
- package/dist/chunk-75UNINFA.mjs +271 -0
- package/dist/chunk-77AUVDQ5.mjs +7 -0
- package/dist/{browser/chunk-23XRXIBW.mjs → chunk-7MWYORQC.mjs} +10 -3
- package/dist/{chunk-TGP5M5R7.mjs → chunk-7T4LAYT4.mjs} +1 -1
- package/dist/{chunk-XIHUI4KB.mjs → chunk-AB27FWZM.mjs} +8 -3
- package/dist/{chunk-XAXKV65G.mjs → chunk-BXM7XM4G.mjs} +7 -3
- package/dist/{chunk-HJJI72X7.mjs → chunk-C7YQHCSO.mjs} +1 -1
- package/dist/{chunk-RVGRFOGN.mjs → chunk-D456ZFPQ.mjs} +2 -1
- package/dist/{chunk-KKQC526K.mjs → chunk-E2F6LZR3.mjs} +19 -21
- package/dist/{chunk-I2KPOLOZ.mjs → chunk-FE3MRIBN.mjs} +104 -13
- package/dist/{chunk-KYYABCSW.mjs → chunk-FETZYCH7.mjs} +15 -1
- package/dist/{chunk-ZKP7G7TV.mjs → chunk-FVZ5DB6Y.mjs} +3 -2
- package/dist/{chunk-2UV4QBHW.mjs → chunk-GF4K7IUK.mjs} +317 -120
- package/dist/chunk-GXCDWLQI.mjs +193 -0
- package/dist/{chunk-25KDNIZZ.mjs → chunk-H64YDF5M.mjs} +3 -3
- package/dist/{browser/chunk-CRE3G7F3.mjs → chunk-HOOR4CP5.mjs} +63 -7
- package/dist/chunk-IB4BYLE3.mjs +127 -0
- package/dist/{chunk-3C7MTCCI.mjs → chunk-IE3Q62QD.mjs} +2 -2
- package/dist/chunk-IH3G6SJO.mjs +40 -0
- package/dist/chunk-JV74RKCY.mjs +3041 -0
- package/dist/{chunk-FRBFVQFN.mjs → chunk-K67I3RF4.mjs} +261 -101
- package/dist/chunk-KLVMK3R5.mjs +47 -0
- package/dist/{chunk-5VV4R6P7.mjs → chunk-LAWIJRMJ.mjs} +4154 -2577
- package/dist/chunk-LF4GB4PO.mjs +281 -0
- package/dist/chunk-NC4QLCZC.mjs +59 -0
- package/dist/chunk-OOO54OVC.mjs +627 -0
- package/dist/chunk-OUWZKNO3.mjs +207 -0
- package/dist/{chunk-FJKKCV4D.mjs → chunk-P5YLI5ED.mjs} +343 -182
- package/dist/{chunk-6I6AYAXS.mjs → chunk-PTTMGRG5.mjs} +9 -10
- package/dist/{browser/chunk-SRMZXJSL.mjs → chunk-Q3ZZH5Z7.mjs} +6 -0
- package/dist/chunk-QBVTYY4J.mjs +54 -0
- package/dist/{react-native/chunks/chunk-GXX3DQXP.mjs → chunk-R4CE4IVU.mjs} +352 -165
- package/dist/chunk-S2POFTLN.mjs +10 -0
- package/dist/{chunk-KJ3RTZDJ.mjs → chunk-S3BSDBF7.mjs} +10 -3
- package/dist/{chunk-FAKFUDZZ.mjs → chunk-SHGN3QIF.mjs} +80 -13
- package/dist/chunk-SXIRM4MX.mjs +3549 -0
- package/dist/{react-native/chunks/chunk-EJ33LCHV.mjs → chunk-TGPKS2UM.mjs} +47 -1
- package/dist/chunk-TINW4BSH.mjs +31301 -0
- package/dist/{cold-module-6MO2XJF2.mjs → chunk-TSLV5P2J.mjs} +397 -79
- package/dist/{chunk-HHBUCIUY.mjs → chunk-TW543F33.mjs} +3 -3
- package/dist/chunk-U6B7DUQW.mjs +788 -0
- package/dist/{chunk-FYOVBEMM.mjs → chunk-V3SGPXWQ.mjs} +8 -9
- package/dist/chunk-W34VJXY7.mjs +4723 -0
- package/dist/chunk-YETKPX5M.mjs +5 -0
- package/dist/chunk-ZQ6QY42L.mjs +59 -0
- package/dist/{client-DRv7UVeY.d.ts → client-CTp8RRiK.d.ts} +16 -4
- package/dist/client.d.ts +8 -8
- package/dist/client.mjs +70 -18
- package/dist/{config-DMwffLKn.d.ts → config-PCNzWjHL.d.ts} +6 -3
- package/dist/{config-CoSig5Ox.d.ts → config-_WT5grSL.d.ts} +3 -3
- package/dist/core-leaf-KXFGP74A.mjs +7 -0
- package/dist/digest-leaf-KXBGKYHZ.mjs +1 -0
- package/dist/direct-executor-MKTZBR26.mjs +16 -0
- package/dist/distribution/coordinator/etcd.d.ts +2 -2
- package/dist/distribution/coordinator/etcd.mjs +7 -4
- package/dist/distribution/coordinator/in-memory.d.ts +2 -2
- package/dist/distribution/coordinator/in-memory.mjs +1 -2
- package/dist/distribution/transport/grpc.mjs +7 -2
- package/dist/distribution/transport/tcp.mjs +7 -1
- package/dist/distribution.d.ts +7 -7
- package/dist/distribution.mjs +1192 -1077
- package/dist/{react-native/chunks/durability-config-QXVZEO7T.mjs → durability-config-XV4XR7Y4.mjs} +7 -3
- package/dist/embed-4H7RTBVL.mjs +221 -0
- package/dist/embeddings/openai.mjs +2 -2
- package/dist/{engine-CFxPYqEk.d.ts → engine-DBRVR_d-.d.ts} +1252 -1239
- package/dist/{browser/geo-index-HHWGMNIS.mjs → geo-index-2ZMMWWSK.mjs} +190 -92
- package/dist/{index-C4AmUnl1.d.ts → index-Ck9w5WHz.d.ts} +1 -1
- package/dist/index.browser.mjs +4 -15
- package/dist/index.d.ts +1495 -78
- package/dist/index.mjs +14 -50
- package/dist/index.react-native.mjs +11 -28
- package/dist/invalidation/filesystem.mjs +1 -2
- package/dist/languages/albanian.mjs +1 -1
- package/dist/languages/amharic.mjs +1 -1
- package/dist/languages/arabic.mjs +1 -1
- package/dist/languages/armenian.mjs +1 -1
- package/dist/languages/azerbaijani.mjs +1 -1
- package/dist/languages/bambara.mjs +1 -1
- package/dist/languages/basque.mjs +1 -1
- package/dist/languages/belarusian.mjs +1 -1
- package/dist/languages/bengali.mjs +1 -1
- package/dist/languages/bosnian.mjs +1 -1
- package/dist/languages/breton.mjs +1 -1
- package/dist/languages/bulgarian.mjs +1 -1
- package/dist/languages/burmese.mjs +1 -1
- package/dist/languages/catalan.mjs +1 -1
- package/dist/languages/chinese.mjs +1 -1
- package/dist/languages/croatian.mjs +1 -1
- package/dist/languages/czech.mjs +1 -1
- package/dist/languages/dagbani.mjs +1 -1
- package/dist/languages/danish.mjs +1 -1
- package/dist/languages/dutch.mjs +1 -1
- package/dist/languages/english.mjs +1 -1
- package/dist/languages/esperanto.mjs +1 -1
- package/dist/languages/estonian.mjs +1 -1
- package/dist/languages/ewe.mjs +1 -1
- package/dist/languages/faroese.mjs +1 -1
- package/dist/languages/fijian.mjs +1 -1
- package/dist/languages/finnish.mjs +1 -1
- package/dist/languages/french.mjs +1 -1
- package/dist/languages/ga.mjs +1 -1
- package/dist/languages/galician.mjs +1 -1
- package/dist/languages/georgian.mjs +1 -1
- package/dist/languages/german.mjs +1 -1
- package/dist/languages/greek.mjs +1 -1
- package/dist/languages/guarani.mjs +1 -1
- package/dist/languages/gujarati.mjs +1 -1
- package/dist/languages/haitian-creole.mjs +1 -1
- package/dist/languages/hausa.mjs +1 -1
- package/dist/languages/hawaiian.mjs +1 -1
- package/dist/languages/hebrew.mjs +1 -1
- package/dist/languages/hindi.mjs +1 -1
- package/dist/languages/hungarian.mjs +1 -1
- package/dist/languages/icelandic.mjs +1 -1
- package/dist/languages/igbo.mjs +1 -1
- package/dist/languages/indonesian.mjs +1 -1
- package/dist/languages/irish.mjs +1 -1
- package/dist/languages/italian.mjs +1 -1
- package/dist/languages/japanese.mjs +1 -1
- package/dist/languages/kannada.mjs +1 -1
- package/dist/languages/kazakh.mjs +1 -1
- package/dist/languages/khmer.mjs +1 -1
- package/dist/languages/kinyarwanda.mjs +1 -1
- package/dist/languages/kirundi.mjs +1 -1
- package/dist/languages/korean.mjs +1 -1
- package/dist/languages/kurmanji.mjs +1 -1
- package/dist/languages/kyrgyz.mjs +1 -1
- package/dist/languages/lao.mjs +1 -1
- package/dist/languages/latin.mjs +1 -1
- package/dist/languages/latvian.mjs +1 -1
- package/dist/languages/lingala.mjs +1 -1
- package/dist/languages/lithuanian.mjs +1 -1
- package/dist/languages/luxembourgish.mjs +1 -1
- package/dist/languages/macedonian.mjs +1 -1
- package/dist/languages/malagasy.mjs +1 -1
- package/dist/languages/malay.mjs +1 -1
- package/dist/languages/malayalam.mjs +1 -1
- package/dist/languages/maltese.mjs +1 -1
- package/dist/languages/maori.mjs +1 -1
- package/dist/languages/marathi.mjs +1 -1
- package/dist/languages/nepali.mjs +1 -1
- package/dist/languages/norwegian.mjs +1 -1
- package/dist/languages/oromo.mjs +1 -1
- package/dist/languages/persian.mjs +1 -1
- package/dist/languages/polish.mjs +1 -1
- package/dist/languages/portuguese.mjs +1 -1
- package/dist/languages/punjabi.mjs +1 -1
- package/dist/languages/romanian.mjs +1 -1
- package/dist/languages/russian.mjs +1 -1
- package/dist/languages/samoan.mjs +1 -1
- package/dist/languages/sanskrit.mjs +1 -1
- package/dist/languages/scottish-gaelic.mjs +1 -1
- package/dist/languages/serbian.mjs +1 -1
- package/dist/languages/shona.mjs +1 -1
- package/dist/languages/sinhala.mjs +1 -1
- package/dist/languages/slovak.mjs +1 -1
- package/dist/languages/slovenian.mjs +1 -1
- package/dist/languages/sorani.mjs +1 -1
- package/dist/languages/spanish.mjs +1 -1
- package/dist/languages/swahili.mjs +1 -1
- package/dist/languages/swedish.mjs +1 -1
- package/dist/languages/tagalog.mjs +1 -1
- package/dist/languages/tamil.mjs +1 -1
- package/dist/languages/tatar.mjs +1 -1
- package/dist/languages/telugu.mjs +1 -1
- package/dist/languages/thai.mjs +1 -1
- package/dist/languages/tibetan.mjs +1 -1
- package/dist/languages/tigrinya.mjs +1 -1
- package/dist/languages/tongan.mjs +1 -1
- package/dist/languages/turkish.mjs +1 -1
- package/dist/languages/twi.mjs +1 -1
- package/dist/languages/ukrainian.mjs +1 -1
- package/dist/languages/urdu.mjs +1 -1
- package/dist/languages/vietnamese.mjs +1 -1
- package/dist/languages/welsh.mjs +1 -1
- package/dist/languages/wolof.mjs +1 -1
- package/dist/languages/xhosa.mjs +1 -1
- package/dist/languages/yoruba.mjs +1 -1
- package/dist/languages/zulu.mjs +1 -1
- package/dist/{long-query-thread-YA4IAYSY.mjs → long-query-thread-JMGNGF6V.mjs} +74 -58
- package/dist/{module-N55W4Q5C.mjs → module-ZJ6ARG6V.mjs} +444 -111
- package/dist/msgpack-leaf-5WFRP6JM.mjs +9 -0
- package/dist/optional-reads-BR3BOVZW.mjs +3373 -0
- package/dist/optional-writes-DDFHYUOH.mjs +218 -0
- package/dist/{paged-partition-archive-PXW5XAYU.mjs → paged-partition-archive-G576XGVE.mjs} +29 -69
- package/dist/partial-words.browser.mjs +1649 -0
- package/dist/partial-words.mjs +15 -14
- package/dist/{chunk-CITFCZKF.mjs → pattern.browser.mjs} +153 -186
- package/dist/pattern.mjs +6 -8
- package/dist/persistence/durability/checkpoint-worker.d.ts +32 -24
- package/dist/persistence/durability/checkpoint-worker.mjs +27 -58
- package/dist/phrase-module-XK3T44VU.mjs +634 -0
- package/dist/query-actions-OMXJEC2J.mjs +118 -0
- package/dist/query-suggestions/merge-worker.mjs +18 -54
- package/dist/query-suggestions.browser.mjs +26 -226
- package/dist/query-suggestions.d.ts +2 -2
- package/dist/query-suggestions.mjs +16 -67
- package/dist/react-native/chunks/chunk-4EXKQ2IB.mjs +565 -0
- package/dist/react-native/chunks/chunk-52QD7CBJ.mjs +52 -0
- package/dist/react-native/chunks/chunk-72OKYHZL.mjs +969 -0
- package/dist/react-native/chunks/chunk-AQOWRH2C.mjs +802 -0
- package/dist/react-native/chunks/chunk-FTQ7JNMU.mjs +898 -0
- package/dist/react-native/chunks/chunk-G3CUQ333.mjs +42 -0
- package/dist/{chunk-TBC3XUL2.mjs → react-native/chunks/chunk-HRDMIQ63.mjs} +53 -1
- package/dist/react-native/chunks/{chunk-KV46CT4D.mjs → chunk-IY6U6HRA.mjs} +63 -7
- package/dist/react-native/chunks/chunk-J2NQW353.mjs +212 -0
- package/dist/react-native/chunks/chunk-L4R5ITVG.mjs +29047 -0
- package/dist/react-native/chunks/chunk-OK3WUA6N.mjs +54 -0
- package/dist/react-native/chunks/{chunk-MVXELMJX.mjs → chunk-PVMEHBQO.mjs} +1 -1
- package/dist/react-native/chunks/{chunk-DZ7H7D2C.mjs → chunk-TQ26BKBH.mjs} +6 -0
- package/dist/react-native/chunks/{chunk-6VBXNFLE.mjs → chunk-VUJCSQG5.mjs} +3 -1
- package/dist/react-native/chunks/{chunk-ENLMYKSX.mjs → chunk-XEGKQKLY.mjs} +5385 -3114
- package/dist/react-native/chunks/chunk-YOTP2FPE.mjs +232 -0
- package/dist/react-native/chunks/chunk-ZIU6TWXG.mjs +127 -0
- package/dist/react-native/chunks/core-leaf-5B4JXCVA.mjs +6 -0
- package/dist/react-native/chunks/digest-leaf-X6OIFDIU.mjs +1 -0
- package/dist/{durability-config-GE4U7MCZ.mjs → react-native/chunks/durability-config-3IOXIPYZ.mjs} +7 -3
- package/dist/react-native/chunks/embed-3WQ2CCR5.mjs +221 -0
- package/dist/react-native/chunks/{geo-index-PX3BIHAH.mjs → geo-index-QEYKEVPH.mjs} +190 -93
- package/dist/react-native/chunks/{chunk-CKNRFDTZ.mjs → gzip.react-native-DLO4WW27.mjs} +2 -1
- package/dist/{browser/module-TCT66FWA.mjs → react-native/chunks/module-VUA27HZZ.mjs} +1018 -540
- package/dist/react-native/chunks/msgpack-leaf-TR66ZVAX.mjs +7 -0
- package/dist/react-native/chunks/optional-reads-WDTLLHUT.mjs +3364 -0
- package/dist/react-native/chunks/optional-writes-FZV3QW34.mjs +267 -0
- package/dist/react-native/chunks/phrase-module-KCQWVXYZ.mjs +635 -0
- package/dist/react-native/chunks/resolve-vector-text-LXRYXF7M.mjs +59 -0
- package/dist/react-native/chunks/restore-queue-EI2V2I4S.mjs +179 -0
- package/dist/{browser/runtime-OTAGEFQW.mjs → react-native/chunks/runtime-BUCSAK4U.mjs} +61 -25
- package/dist/react-native/chunks/segment-codec-leaf-6ULP7H3I.mjs +12 -0
- package/dist/react-native/chunks/segment-merge-leaf-F4GQZNK6.mjs +13 -0
- package/dist/react-native/chunks/storage-leaf-OAXBU2L6.mjs +18042 -0
- package/dist/react-native/chunks/store-leaf-GY2ZZFXB.mjs +14 -0
- package/dist/react-native/chunks/{chunk-UQ4OAXKU.mjs → suggestions-leaf-SQEZ4IBS.mjs} +332 -118
- package/dist/react-native/chunks/worker-copies-EEHSCFJW.mjs +2627 -0
- package/dist/react-native/partial-words.mjs +954 -35
- package/dist/react-native/pattern.mjs +238 -111
- package/dist/react-native/query-suggestions.mjs +33 -239
- package/dist/react-native/sync.mjs +127 -50
- package/dist/react-native/synonyms.mjs +256 -112
- package/dist/react.d.ts +9 -9
- package/dist/react.mjs +6 -0
- package/dist/{rerank-MQ37IYRV.mjs → rerank-Y6MWBMTT.mjs} +17 -8
- package/dist/rerankers/http.mjs +2 -2
- package/dist/resolve-vector-text-4PDRTPNQ.mjs +2 -0
- package/dist/restore-queue-KPYSRJ4A.mjs +184 -0
- package/dist/runtime-4GKUIAKV.mjs +595 -0
- package/dist/{schema-Jwt928nJ.d.ts → schema-C_7yRJLt.d.ts} +1 -1
- package/dist/segment-codec-leaf-6IFBSBPN.mjs +17 -0
- package/dist/segment-merge-leaf-VE3FUSVE.mjs +17 -0
- package/dist/server.d.ts +35 -13
- package/dist/server.mjs +90 -101
- package/dist/{browser/durability-wiring-A7BVG2DW.mjs → storage-leaf-HMIIOUYN.mjs} +2348 -902
- package/dist/store-leaf-M7T7SUZJ.mjs +19 -0
- package/dist/stored-values-BWIMpiT_.d.ts +25 -0
- package/dist/suggestions-leaf-Q3Q5D6XV.mjs +53 -0
- package/dist/sync/filesystem.d.ts +3 -3
- package/dist/sync/filesystem.mjs +27 -11
- package/dist/sync/indexeddb.browser.mjs +287 -0
- package/dist/sync/indexeddb.d.ts +3 -3
- package/dist/sync/indexeddb.mjs +7 -2
- package/dist/sync.browser.mjs +120 -70
- package/dist/sync.d.ts +4 -4
- package/dist/sync.mjs +121 -57
- package/dist/{chunk-I5B7RXU7.mjs → synonyms.browser.mjs} +248 -135
- package/dist/synonyms.mjs +15 -11
- package/dist/{tasks-qrJojgST.d.ts → tasks-B4tT4vmP.d.ts} +4 -4
- package/dist/thread-SNILJXX3.mjs +30 -0
- package/dist/{types-BZCGjfLn.d.ts → types-CTg0KaMy.d.ts} +2 -2
- package/dist/vector/search-worker.d.ts +7 -1
- package/dist/vector/search-worker.mjs +9 -13
- package/dist/worker-copies-ZLZS2CUM.mjs +2152 -0
- package/dist/workers/entry.mjs +60 -30
- package/openapi.json +137 -50
- package/package.json +233 -8
- package/dist/analysis-change-5BQOQ4BF.mjs +0 -55
- package/dist/analysis-change-entry-TXX6JSMX.mjs +0 -1
- package/dist/archive-history-E4R73RWD.mjs +0 -29
- package/dist/browser/analysis-change-435CUEPZ.mjs +0 -933
- package/dist/browser/analysis-change-entry-HZXKPPGV.mjs +0 -1
- package/dist/browser/archive-history-4IP5XQZY.mjs +0 -29
- package/dist/browser/chunk-2CFI5VVV.mjs +0 -241
- package/dist/browser/chunk-2TI4SSUP.mjs +0 -315
- package/dist/browser/chunk-3I27KXQD.mjs +0 -34
- package/dist/browser/chunk-3SSRJMFN.mjs +0 -100
- package/dist/browser/chunk-4NGKC4H4.mjs +0 -2635
- package/dist/browser/chunk-4RD3AFSB.mjs +0 -32
- package/dist/browser/chunk-5W3MMTLG.mjs +0 -19
- package/dist/browser/chunk-6LWDPLTB.mjs +0 -177
- package/dist/browser/chunk-7IGKGWSQ.mjs +0 -79
- package/dist/browser/chunk-7U3WVJUP.mjs +0 -150
- package/dist/browser/chunk-ATEBYXP6.mjs +0 -10
- package/dist/browser/chunk-BHFQATSC.mjs +0 -432
- package/dist/browser/chunk-DSXIBE6N.mjs +0 -78
- package/dist/browser/chunk-EA63E3D2.mjs +0 -857
- package/dist/browser/chunk-ELV4OZOI.mjs +0 -29
- package/dist/browser/chunk-EXQZGUQH.mjs +0 -193
- package/dist/browser/chunk-G64Q6OJF.mjs +0 -96
- package/dist/browser/chunk-GPPOG6PT.mjs +0 -9
- package/dist/browser/chunk-HOZW3PKP.mjs +0 -9
- package/dist/browser/chunk-IZXVW2ZJ.mjs +0 -217
- package/dist/browser/chunk-JPTQZWJQ.mjs +0 -10
- package/dist/browser/chunk-K4Q6KX3R.mjs +0 -2528
- package/dist/browser/chunk-KZWSX6BH.mjs +0 -645
- package/dist/browser/chunk-MGI4BCXC.mjs +0 -63
- package/dist/browser/chunk-ML7THVLJ.mjs +0 -38
- package/dist/browser/chunk-MOG4OVDK.mjs +0 -51
- package/dist/browser/chunk-NLWTBAGB.mjs +0 -111
- package/dist/browser/chunk-NQAME3RK.mjs +0 -21
- package/dist/browser/chunk-NXQG7DRA.mjs +0 -318
- package/dist/browser/chunk-OEDCEZXJ.mjs +0 -92
- package/dist/browser/chunk-OIZS5KIX.mjs +0 -6
- package/dist/browser/chunk-RA6LSBCM.mjs +0 -43
- package/dist/browser/chunk-STOWQFT3.mjs +0 -1829
- package/dist/browser/chunk-TK63WFXK.mjs +0 -90
- package/dist/browser/chunk-TY7L6OXO.mjs +0 -69
- package/dist/browser/chunk-U3JOQGWX.mjs +0 -19
- package/dist/browser/chunk-U4YDIBUT.mjs +0 -653
- package/dist/browser/chunk-VI7BQR4U.mjs +0 -21
- package/dist/browser/chunk-WI4MR75E.mjs +0 -86
- package/dist/browser/chunk-WN464PTL.mjs +0 -375
- package/dist/browser/chunk-WXLBZJMT.mjs +0 -25
- package/dist/browser/chunk-XAWNZ4G2.mjs +0 -151
- package/dist/browser/chunk-ZI2V4VD7.mjs +0 -21
- package/dist/browser/cold-module-2EHCIV4K.mjs +0 -759
- package/dist/browser/engine-hooks-E4UD67JD.mjs +0 -17
- package/dist/browser/gzip-5S7ROJFJ.mjs +0 -1
- package/dist/browser/import-DXYB6756.mjs +0 -19
- package/dist/browser/methods-KTQCSIN4.mjs +0 -30
- package/dist/browser/module-NIYMEA5R.mjs +0 -23
- package/dist/browser/operations-OJ3BXS55.mjs +0 -5
- package/dist/browser/phrase-module-HAT3TLZN.mjs +0 -328
- package/dist/browser/pool-3JLET5RO.mjs +0 -297
- package/dist/browser/release-76MXRPGV.mjs +0 -33
- package/dist/browser/restore-hooks-YPN4ZFCY.mjs +0 -114
- package/dist/browser/restore-queue-G3RQGL3Y.mjs +0 -55
- package/dist/browser/retention-ZWVMNC3Q.mjs +0 -210
- package/dist/browser/snapshot-VEQNIE6C.mjs +0 -963
- package/dist/browser/start-BM442C6R.mjs +0 -25
- package/dist/browser/sync-state-P5XG6LTQ.mjs +0 -15
- package/dist/browser/write-2EVMZWDE.mjs +0 -194
- package/dist/chunk-2NE7VCYE.mjs +0 -212
- package/dist/chunk-37CD3OKS.mjs +0 -87
- package/dist/chunk-3HYC4JRF.mjs +0 -50
- package/dist/chunk-3MXV3VHR.mjs +0 -46
- package/dist/chunk-3OH67G7R.mjs +0 -214
- package/dist/chunk-46KY2PJD.mjs +0 -905
- package/dist/chunk-4KKXNJM6.mjs +0 -242
- package/dist/chunk-5YNRKI2C.mjs +0 -81
- package/dist/chunk-6HTGOXIK.mjs +0 -875
- package/dist/chunk-6OEGXLBX.mjs +0 -57
- package/dist/chunk-6RC4K46J.mjs +0 -86
- package/dist/chunk-7GFE3PEY.mjs +0 -40
- package/dist/chunk-7GXJUJ24.mjs +0 -49
- package/dist/chunk-7LXHHCXZ.mjs +0 -1397
- package/dist/chunk-7V5IUP2T.mjs +0 -63
- package/dist/chunk-A4L7YTKX.mjs +0 -458
- package/dist/chunk-BEZH7VEH.mjs +0 -23
- package/dist/chunk-BTPGQC6Z.mjs +0 -27
- package/dist/chunk-BU4SAIC4.mjs +0 -196
- package/dist/chunk-BWZ3P4MU.mjs +0 -20
- package/dist/chunk-CSLGFPFQ.mjs +0 -218
- package/dist/chunk-CZQ33DLW.mjs +0 -78
- package/dist/chunk-DP5C7YFQ.mjs +0 -543
- package/dist/chunk-DWEPMFJE.mjs +0 -240
- package/dist/chunk-EEBCDP36.mjs +0 -32
- package/dist/chunk-EFBDHH5P.mjs +0 -7081
- package/dist/chunk-FB6463IN.mjs +0 -1499
- package/dist/chunk-FCJ553HS.mjs +0 -655
- package/dist/chunk-FNGAM5B7.mjs +0 -2639
- package/dist/chunk-FOCV4CBZ.mjs +0 -87
- package/dist/chunk-FQBFZAWG.mjs +0 -27
- package/dist/chunk-G6HRSGOU.mjs +0 -74
- package/dist/chunk-GES7U2PM.mjs +0 -68
- package/dist/chunk-GH4WQ22V.mjs +0 -34
- package/dist/chunk-GQPTDQCL.mjs +0 -54
- package/dist/chunk-HFPMMRQT.mjs +0 -206
- package/dist/chunk-HJSN7UYG.mjs +0 -10
- package/dist/chunk-I53G4JAU.mjs +0 -1974
- package/dist/chunk-I54T6CQP.mjs +0 -117
- package/dist/chunk-IPN7S4KX.mjs +0 -130
- package/dist/chunk-J4IJTTEX.mjs +0 -226
- package/dist/chunk-JDJBQLRO.mjs +0 -1126
- package/dist/chunk-JWRUUCWD.mjs +0 -151
- package/dist/chunk-K4ZIGL2O.mjs +0 -290
- package/dist/chunk-KAKQ74LS.mjs +0 -53
- package/dist/chunk-KF4EXSM4.mjs +0 -21
- package/dist/chunk-KHKIRS5D.mjs +0 -113
- package/dist/chunk-KOKM4PQN.mjs +0 -52
- package/dist/chunk-KP7TYHWT.mjs +0 -92
- package/dist/chunk-KZ3NX2P7.mjs +0 -21
- package/dist/chunk-L5ORED7V.mjs +0 -25
- package/dist/chunk-L6V6BST3.mjs +0 -1435
- package/dist/chunk-LHKOSI2J.mjs +0 -58
- package/dist/chunk-LQG5G2LY.mjs +0 -39
- package/dist/chunk-MATMVH65.mjs +0 -9
- package/dist/chunk-MP7ABPTD.mjs +0 -189
- package/dist/chunk-MQOJIO5B.mjs +0 -316
- package/dist/chunk-NF4DT3IH.mjs +0 -85
- package/dist/chunk-ORN5BLL7.mjs +0 -11
- package/dist/chunk-P5ZI2P2W.mjs +0 -7481
- package/dist/chunk-PELHVTO7.mjs +0 -24
- package/dist/chunk-PWC4VB3Q.mjs +0 -106
- package/dist/chunk-Q2UL2TPC.mjs +0 -21
- package/dist/chunk-QHPYS427.mjs +0 -66
- package/dist/chunk-QJVOLKU6.mjs +0 -111
- package/dist/chunk-QOW2JPUI.mjs +0 -634
- package/dist/chunk-QYRNLLLI.mjs +0 -99
- package/dist/chunk-RDXO6JST.mjs +0 -63
- package/dist/chunk-RFBLQLLZ.mjs +0 -16
- package/dist/chunk-RLOES5SX.mjs +0 -31
- package/dist/chunk-RZWWB2XR.mjs +0 -96
- package/dist/chunk-S5LN746F.mjs +0 -10
- package/dist/chunk-SA5LOGO3.mjs +0 -470
- package/dist/chunk-SQJWAIF4.mjs +0 -12
- package/dist/chunk-TDIK6NTV.mjs +0 -10
- package/dist/chunk-TGS5UXBE.mjs +0 -216
- package/dist/chunk-TQXHPFWT.mjs +0 -177
- package/dist/chunk-TZ3355VS.mjs +0 -121
- package/dist/chunk-TZTRKM33.mjs +0 -74
- package/dist/chunk-U55XJEIG.mjs +0 -18
- package/dist/chunk-UHICS3JI.mjs +0 -83
- package/dist/chunk-VD7J552I.mjs +0 -28
- package/dist/chunk-VTTRFF2C.mjs +0 -3711
- package/dist/chunk-WX4LAO6M.mjs +0 -656
- package/dist/chunk-WZ7YV54N.mjs +0 -152
- package/dist/chunk-X5CV2E2B.mjs +0 -1
- package/dist/chunk-XXHN7J46.mjs +0 -101
- package/dist/chunk-Y4WPNHMC.mjs +0 -50
- package/dist/chunk-YEKL4JBK.mjs +0 -96
- package/dist/chunk-YTWZVGCB.mjs +0 -382
- package/dist/chunk-Z2KAFCRT.mjs +0 -30
- package/dist/chunk-ZXNQEW43.mjs +0 -18
- package/dist/chunk-ZYAY26KG.mjs +0 -29
- package/dist/direct-executor-FTMYY3TI.mjs +0 -34
- package/dist/durability-wiring-VIF5MOSY.mjs +0 -4064
- package/dist/engine-hooks-EGUGNZYE.mjs +0 -54
- package/dist/gzip-F4HMIEEQ.mjs +0 -1
- package/dist/import-XKDPJQDP.mjs +0 -56
- package/dist/methods-7IOINERF.mjs +0 -30
- package/dist/module-FQ4JWNQJ.mjs +0 -62
- package/dist/operations-G5EP6JPX.mjs +0 -5
- package/dist/phrase-module-XW5MKWP5.mjs +0 -330
- package/dist/pool-Y4A46T36.mjs +0 -298
- package/dist/react-native/chunks/analysis-change-LT5QBQ3H.mjs +0 -926
- package/dist/react-native/chunks/analysis-change-entry-SCVWK6OU.mjs +0 -1
- package/dist/react-native/chunks/archive-history-MJKUQLSU.mjs +0 -29
- package/dist/react-native/chunks/chunk-2PRHILX3.mjs +0 -529
- package/dist/react-native/chunks/chunk-3JWDECAZ.mjs +0 -858
- package/dist/react-native/chunks/chunk-3NQOVO3K.mjs +0 -1
- package/dist/react-native/chunks/chunk-3WI35N75.mjs +0 -226
- package/dist/react-native/chunks/chunk-4DII3ZSM.mjs +0 -73
- package/dist/react-native/chunks/chunk-4J74WHQM.mjs +0 -177
- package/dist/react-native/chunks/chunk-4JYO3JD2.mjs +0 -242
- package/dist/react-native/chunks/chunk-5CQX3XXV.mjs +0 -17
- package/dist/react-native/chunks/chunk-6WA3C3DV.mjs +0 -85
- package/dist/react-native/chunks/chunk-AAAETEJK.mjs +0 -27
- package/dist/react-native/chunks/chunk-AM7RSBPF.mjs +0 -32
- package/dist/react-native/chunks/chunk-C5G6TJ7A.mjs +0 -140
- package/dist/react-native/chunks/chunk-CHPTFFJM.mjs +0 -43
- package/dist/react-native/chunks/chunk-DIYDOIM4.mjs +0 -10
- package/dist/react-native/chunks/chunk-DNXOMPAQ.mjs +0 -191
- package/dist/react-native/chunks/chunk-DVDX4SDR.mjs +0 -375
- package/dist/react-native/chunks/chunk-DXRSEWA2.mjs +0 -12
- package/dist/react-native/chunks/chunk-F753DA54.mjs +0 -23
- package/dist/react-native/chunks/chunk-FHPW7P2O.mjs +0 -40
- package/dist/react-native/chunks/chunk-FTZHMRD2.mjs +0 -18
- package/dist/react-native/chunks/chunk-G43IPIDG.mjs +0 -151
- package/dist/react-native/chunks/chunk-HJBJBH26.mjs +0 -34
- package/dist/react-native/chunks/chunk-IO2SMUQD.mjs +0 -10
- package/dist/react-native/chunks/chunk-IYNT75CE.mjs +0 -111
- package/dist/react-native/chunks/chunk-JDOEEMEF.mjs +0 -38
- package/dist/react-native/chunks/chunk-JWUCMVRK.mjs +0 -15
- package/dist/react-native/chunks/chunk-LU3Y3P63.mjs +0 -68
- package/dist/react-native/chunks/chunk-LVIKKAA6.mjs +0 -93
- package/dist/react-native/chunks/chunk-LZSLNSUN.mjs +0 -193
- package/dist/react-native/chunks/chunk-MIP4SOR6.mjs +0 -22803
- package/dist/react-native/chunks/chunk-MJDQU5MW.mjs +0 -1225
- package/dist/react-native/chunks/chunk-MUWD2H2S.mjs +0 -21
- package/dist/react-native/chunks/chunk-NB3LP33V.mjs +0 -315
- package/dist/react-native/chunks/chunk-NNE4VDMM.mjs +0 -8
- package/dist/react-native/chunks/chunk-NVVRSRX5.mjs +0 -78
- package/dist/react-native/chunks/chunk-PB2YXVQW.mjs +0 -29
- package/dist/react-native/chunks/chunk-PDRWWPKV.mjs +0 -2532
- package/dist/react-native/chunks/chunk-PJHAB5ZY.mjs +0 -79
- package/dist/react-native/chunks/chunk-POPDAGH6.mjs +0 -2636
- package/dist/react-native/chunks/chunk-PSWKQVVT.mjs +0 -9
- package/dist/react-native/chunks/chunk-QUKQNI3H.mjs +0 -647
- package/dist/react-native/chunks/chunk-RDWG33MM.mjs +0 -79
- package/dist/react-native/chunks/chunk-SK2PWYDH.mjs +0 -654
- package/dist/react-native/chunks/chunk-SUPXRTMD.mjs +0 -96
- package/dist/react-native/chunks/chunk-TP6KCKER.mjs +0 -63
- package/dist/react-native/chunks/chunk-U4KSKA4Z.mjs +0 -23
- package/dist/react-native/chunks/chunk-UNUFZ2QY.mjs +0 -68
- package/dist/react-native/chunks/chunk-VWUDIOT6.mjs +0 -218
- package/dist/react-native/chunks/chunk-WBYQRHDY.mjs +0 -86
- package/dist/react-native/chunks/chunk-YH7QY657.mjs +0 -288
- package/dist/react-native/chunks/chunk-YZW4CHM6.mjs +0 -562
- package/dist/react-native/chunks/chunk-ZLWVW734.mjs +0 -100
- package/dist/react-native/chunks/chunk-ZXZFN7FI.mjs +0 -432
- package/dist/react-native/chunks/chunk-ZZT7CEN7.mjs +0 -92
- package/dist/react-native/chunks/cold-module-KVZYUGRY.mjs +0 -772
- package/dist/react-native/chunks/durability-wiring-34OYO32E.mjs +0 -4942
- package/dist/react-native/chunks/engine-hooks-M7JV46NH.mjs +0 -30
- package/dist/react-native/chunks/gzip.react-native-HLEPDKZ3.mjs +0 -3
- package/dist/react-native/chunks/import-H6AQREWI.mjs +0 -32
- package/dist/react-native/chunks/methods-6W5U4C3H.mjs +0 -30
- package/dist/react-native/chunks/module-LBZPGOWH.mjs +0 -36
- package/dist/react-native/chunks/operations-GNRMD6EX.mjs +0 -5
- package/dist/react-native/chunks/phrase-module-QK22HSQ2.mjs +0 -329
- package/dist/react-native/chunks/pool-JR3NJCAF.mjs +0 -297
- package/dist/react-native/chunks/release-D7ZTIANM.mjs +0 -33
- package/dist/react-native/chunks/restore-queue-ZZX54AH7.mjs +0 -55
- package/dist/react-native/chunks/retention-EW4TTDFB.mjs +0 -223
- package/dist/react-native/chunks/snapshot-REYVIN3X.mjs +0 -975
- package/dist/react-native/chunks/start-BQK6KN3R.mjs +0 -38
- package/dist/react-native/chunks/sync-state-PASCIHHT.mjs +0 -15
- package/dist/react-native/chunks/write-FQAYCZF5.mjs +0 -207
- package/dist/release-BH3DKW3T.mjs +0 -33
- package/dist/restore-hooks-CDERDEF4.mjs +0 -153
- package/dist/restore-queue-7NNSTROA.mjs +0 -55
- package/dist/retention-QSVBBNRM.mjs +0 -66
- package/dist/runtime-COIUORCN.mjs +0 -177
- package/dist/snapshot-RH4NSKIZ.mjs +0 -782
- package/dist/start-MCKCOGIW.mjs +0 -66
- package/dist/sync-state-ZWHLAFLE.mjs +0 -15
- package/dist/thread-O4SBJJJS.mjs +0 -50
- package/dist/write-3FK7NG3Y.mjs +0 -232
- /package/dist/browser/{chunk-M3MQE2X7.mjs → digest-leaf-64IPRPZD.mjs} +0 -0
- /package/dist/browser/{chunk-JNOAKDUM.mjs → gzip-JF3S6PPT.mjs} +0 -0
- /package/dist/{chunk-ZXNNR73R.mjs → gzip-2UCZW2MM.mjs} +0 -0
|
@@ -1,975 +0,0 @@
|
|
|
1
|
-
import { restoredConfigFields, restoredEmbedding, rejectSnapshot } from './chunk-LZSLNSUN.mjs';
|
|
2
|
-
import { indexMetadataOf, writeCheckpointSegments, writeLiveVectors, commitCheckpointManifest, SINGLE_NODE_PRIMARY_TERM, partitionContentsOf, unpackIndexSnapshotEnvelope, encodeSegmentManifest, loadSegmentedCheckpoint, writeMetadataEnvelope, readVectorFile, readGraphParts, documentsOfPayloadV2, deserializePayloadV1 } from './chunk-PDRWWPKV.mjs';
|
|
3
|
-
import { vectorsPerFile } from './chunk-SK2PWYDH.mjs';
|
|
4
|
-
import './chunk-HJBJBH26.mjs';
|
|
5
|
-
import './chunk-ENLMYKSX.mjs';
|
|
6
|
-
import './chunk-CKNRFDTZ.mjs';
|
|
7
|
-
import { readSegmentFile } from './chunk-3JWDECAZ.mjs';
|
|
8
|
-
import './chunk-QUKQNI3H.mjs';
|
|
9
|
-
import { DEFAULT_COMPACTION_THRESHOLD } from './chunk-F753DA54.mjs';
|
|
10
|
-
import { requireRestoreMemory, earlierSnapshotFootprint, storedBytesOfSegments, archiveFootprint } from './chunk-G43IPIDG.mjs';
|
|
11
|
-
import { MAX_SNAPSHOT_ANALYSIS_ATTEMPTS } from './chunk-PB2YXVQW.mjs';
|
|
12
|
-
import { createByteReader } from './chunk-NVVRSRX5.mjs';
|
|
13
|
-
import { ARCHIVE_CONFIG_ENTRY, ARCHIVE_MANIFEST_ENTRY, tarEnd, readSnapshotArchive, tarEntryHeaders, tarPadding, ARCHIVE_FILE_CHUNK_BYTES } from './chunk-NB3LP33V.mjs';
|
|
14
|
-
import { decodeSegmentManifest } from './chunk-4JYO3JD2.mjs';
|
|
15
|
-
import { decodeVectorIndexParts, vectorsToBytes, VECTOR_FILE_PAYLOAD_VERSION, bytesToVectors } from './chunk-DVDX4SDR.mjs';
|
|
16
|
-
import { manifestKey, manifestFileRefs } from './chunk-6WA3C3DV.mjs';
|
|
17
|
-
import { newSyncEpoch } from './chunk-JWUCMVRK.mjs';
|
|
18
|
-
import { storedStateOf } from './chunk-ZLWVW734.mjs';
|
|
19
|
-
import './chunk-ZXZFN7FI.mjs';
|
|
20
|
-
import { oneSyncChangeAtATime } from './chunk-Q32DDFKX.mjs';
|
|
21
|
-
import { encodeIndexConfiguration, ARRAY_POSITION_GAP, validatePatternValueLimit, requireSurfaceFormsForPartialFields, validateRequiredFieldsInSchema, validateEmbeddingConfig, storedArrayPositionGap, prepareStoredSynonyms, loadSchemaCodeFor, decodeEveryStoredDocument, isCompositePartition, arrayPositionsAreStale, insertDocumentVectors } from './chunk-MIP4SOR6.mjs';
|
|
22
|
-
import './chunk-NNE4VDMM.mjs';
|
|
23
|
-
import './chunk-IO2SMUQD.mjs';
|
|
24
|
-
import './chunk-YZW4CHM6.mjs';
|
|
25
|
-
import './chunk-LU3Y3P63.mjs';
|
|
26
|
-
import './chunk-AM7RSBPF.mjs';
|
|
27
|
-
import './chunk-MVXELMJX.mjs';
|
|
28
|
-
import './chunk-RDWG33MM.mjs';
|
|
29
|
-
import { raiseEarlierReleaseGraphSetting, validateVectorPromotion, validateVectorStorage, validateTextStorage, parseVectorDimension } from './chunk-GXX3DQXP.mjs';
|
|
30
|
-
import './chunk-UNUFZ2QY.mjs';
|
|
31
|
-
import './chunk-3NQOVO3K.mjs';
|
|
32
|
-
import { emitSyncChange } from './chunk-JDOEEMEF.mjs';
|
|
33
|
-
import './chunk-2PRHILX3.mjs';
|
|
34
|
-
import './chunk-PJHAB5ZY.mjs';
|
|
35
|
-
import { hasNrslMagic, HEADER_SIZE, readHeader, decodeIndexConfiguration } from './chunk-YH7QY657.mjs';
|
|
36
|
-
import './chunk-CHPTFFJM.mjs';
|
|
37
|
-
import { validateSchema, flattenSchema } from './chunk-DNXOMPAQ.mjs';
|
|
38
|
-
import './chunk-5CQX3XXV.mjs';
|
|
39
|
-
import { MAX_FILE_BYTES } from './chunk-6VBXNFLE.mjs';
|
|
40
|
-
import './chunk-C5G6TJ7A.mjs';
|
|
41
|
-
import { getLanguage, resolveIndexAnalysis } from './chunk-MJDQU5MW.mjs';
|
|
42
|
-
import './chunk-3WI35N75.mjs';
|
|
43
|
-
import './chunk-EJ33LCHV.mjs';
|
|
44
|
-
import './chunk-FHPW7P2O.mjs';
|
|
45
|
-
import './chunk-DXRSEWA2.mjs';
|
|
46
|
-
import './chunk-LVIKKAA6.mjs';
|
|
47
|
-
import './chunk-AAAETEJK.mjs';
|
|
48
|
-
import './chunk-FTZHMRD2.mjs';
|
|
49
|
-
import { NarsilError, ErrorCodes } from './chunk-DZ7H7D2C.mjs';
|
|
50
|
-
import { decode } from '@msgpack/msgpack';
|
|
51
|
-
|
|
52
|
-
// src/persistence/archive/memory-store.ts
|
|
53
|
-
function joined(chunks) {
|
|
54
|
-
let total = 0;
|
|
55
|
-
for (const chunk of chunks) total += chunk.byteLength;
|
|
56
|
-
const bytes = new Uint8Array(total);
|
|
57
|
-
let offset = 0;
|
|
58
|
-
for (const chunk of chunks) {
|
|
59
|
-
bytes.set(chunk, offset);
|
|
60
|
-
offset += chunk.byteLength;
|
|
61
|
-
}
|
|
62
|
-
return bytes;
|
|
63
|
-
}
|
|
64
|
-
function memoryCheckpointStore() {
|
|
65
|
-
const files = /* @__PURE__ */ new Map();
|
|
66
|
-
return {
|
|
67
|
-
files,
|
|
68
|
-
read: async (key) => files.get(key) ?? null,
|
|
69
|
-
write: async (key, chunks) => {
|
|
70
|
-
files.set(key, joined(chunks));
|
|
71
|
-
},
|
|
72
|
-
remove: async (key) => {
|
|
73
|
-
files.delete(key);
|
|
74
|
-
},
|
|
75
|
-
list: async (prefix) => [...files.keys()].filter((key) => key.startsWith(prefix)).sort(),
|
|
76
|
-
byteLength: async (key) => files.get(key)?.byteLength ?? null
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// src/persistence/archive/from-memory.ts
|
|
81
|
-
function frozenPlan(plan) {
|
|
82
|
-
const files = [];
|
|
83
|
-
for (let index = 0; index < plan.newFiles; index++) files.push(plan.readNewFile(index));
|
|
84
|
-
return { ...plan, readNewFile: (index) => files[index] };
|
|
85
|
-
}
|
|
86
|
-
function partitionVectorPlan(vectorIndex, docIds) {
|
|
87
|
-
const held = [];
|
|
88
|
-
const vectors = [];
|
|
89
|
-
for (const docId of docIds) {
|
|
90
|
-
const vector = vectorIndex.getVector(docId);
|
|
91
|
-
if (vector === null) continue;
|
|
92
|
-
held.push(docId);
|
|
93
|
-
vectors.push(Float32Array.from(vector));
|
|
94
|
-
}
|
|
95
|
-
const capacity = vectorsPerFile(vectorIndex.dimension, null);
|
|
96
|
-
const files = [];
|
|
97
|
-
for (let start = 0; start < held.length; start += capacity) {
|
|
98
|
-
const slice = held.slice(start, start + capacity);
|
|
99
|
-
const packed = new Float32Array(slice.length * vectorIndex.dimension);
|
|
100
|
-
for (let i = 0; i < slice.length; i++) packed.set(vectors[start + i], i * vectorIndex.dimension);
|
|
101
|
-
const payload = {
|
|
102
|
-
v: VECTOR_FILE_PAYLOAD_VERSION,
|
|
103
|
-
fieldName: vectorIndex.fieldName,
|
|
104
|
-
dimension: vectorIndex.dimension,
|
|
105
|
-
docIds: slice,
|
|
106
|
-
codes: null,
|
|
107
|
-
vectors: vectorsToBytes(packed)
|
|
108
|
-
};
|
|
109
|
-
files.push({ payload, ordinals: new Int32Array(slice.length), dead: null, magnitudes: null });
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
unchanged: false,
|
|
113
|
-
storesHeads: false,
|
|
114
|
-
kept: [],
|
|
115
|
-
keptFiles: [],
|
|
116
|
-
newFiles: files.length,
|
|
117
|
-
graphParts: null,
|
|
118
|
-
signature: { revision: 0, graphSize: -1, calibration: null },
|
|
119
|
-
readNewFile: (index) => files[index],
|
|
120
|
-
release: () => void 0
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function capture(input) {
|
|
124
|
-
const partitionIds = input.partitionId === null ? Array.from({ length: input.manager.partitionCount }, (_, partitionId) => partitionId) : [input.partitionId];
|
|
125
|
-
const { indexName } = input;
|
|
126
|
-
const writeRecords = input.writeRecords ?? null;
|
|
127
|
-
const targets = partitionIds.map((partitionId) => {
|
|
128
|
-
const target = {
|
|
129
|
-
partitionId,
|
|
130
|
-
lastSeqNo: input.appliedSeqNo(partitionId),
|
|
131
|
-
primaryTerm: SINGLE_NODE_PRIMARY_TERM
|
|
132
|
-
};
|
|
133
|
-
if (writeRecords !== null) target.termHistory = writeRecords.termHistoryOf(indexName, partitionId, target.lastSeqNo);
|
|
134
|
-
return target;
|
|
135
|
-
});
|
|
136
|
-
const contents = partitionIds.map(
|
|
137
|
-
(partitionId) => partitionContentsOf(
|
|
138
|
-
input.manager,
|
|
139
|
-
partitionId,
|
|
140
|
-
writeRecords === null ? void 0 : (segments) => writeRecords.captureSegments(indexName, partitionId, segments)
|
|
141
|
-
)
|
|
142
|
-
);
|
|
143
|
-
const plans = /* @__PURE__ */ new Map();
|
|
144
|
-
const partitionDocIds = input.partitionId === null ? null : [...input.manager.getPartition(input.partitionId).docIds()];
|
|
145
|
-
for (const [fieldPath, vectorIndex] of input.vectorIndexes) {
|
|
146
|
-
plans.set(
|
|
147
|
-
fieldPath,
|
|
148
|
-
partitionDocIds === null ? frozenPlan(vectorIndex.planCheckpoint(null)) : partitionVectorPlan(vectorIndex, partitionDocIds)
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
return { targets, contents, plans };
|
|
152
|
-
}
|
|
153
|
-
async function buildArchiveFromMemory(input) {
|
|
154
|
-
if (input.partitionId === null) {
|
|
155
|
-
for (const vectorIndex of input.vectorIndexes.values()) await vectorIndex.completeGraph();
|
|
156
|
-
}
|
|
157
|
-
const captured = capture(input);
|
|
158
|
-
const store = memoryCheckpointStore();
|
|
159
|
-
const written = await writeCheckpointSegments({
|
|
160
|
-
store,
|
|
161
|
-
metadata: input.metadata,
|
|
162
|
-
targets: captured.targets,
|
|
163
|
-
compactionThreshold: DEFAULT_COMPACTION_THRESHOLD,
|
|
164
|
-
prior: null,
|
|
165
|
-
wholePartitions: captured.contents,
|
|
166
|
-
keepsWriteRecords: input.writeRecords != null
|
|
167
|
-
});
|
|
168
|
-
const vectors = await writeLiveVectors({ store, indexName: input.indexName, plans: captured.plans, priorVectors: [] });
|
|
169
|
-
const refs = vectors.refs;
|
|
170
|
-
await commitCheckpointManifest(store, input.metadata, written, refs);
|
|
171
|
-
const manifestBytes = store.files.get(manifestKey(input.indexName));
|
|
172
|
-
const decoded = manifestBytes === void 0 ? null : await decodeSegmentManifest(manifestBytes, input.indexName);
|
|
173
|
-
if (manifestBytes === void 0 || decoded === null || decoded.kind !== "current") {
|
|
174
|
-
throw new NarsilError(
|
|
175
|
-
ErrorCodes.PERSISTENCE_SAVE_FAILED,
|
|
176
|
-
`The archive of index "${input.indexName}" holds no manifest`
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
return {
|
|
180
|
-
manifestBytes,
|
|
181
|
-
manifest: decoded.manifest,
|
|
182
|
-
readFile: async (ref) => {
|
|
183
|
-
const bytes = store.files.get(ref.key);
|
|
184
|
-
if (bytes === void 0) {
|
|
185
|
-
throw new NarsilError(ErrorCodes.PERSISTENCE_SAVE_FAILED, `The archive file "${ref.key}" is missing`, {
|
|
186
|
-
key: ref.key
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
return bytes;
|
|
190
|
-
},
|
|
191
|
-
readRange: async (ref, offset, length) => {
|
|
192
|
-
const bytes = store.files.get(ref.key);
|
|
193
|
-
if (bytes === void 0 || offset + length > bytes.byteLength) {
|
|
194
|
-
throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, `The archive file "${ref.key}" is missing`, {
|
|
195
|
-
key: ref.key
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
return bytes.subarray(offset, offset + length);
|
|
199
|
-
},
|
|
200
|
-
release: () => store.files.clear()
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// src/persistence/archive/write.ts
|
|
205
|
-
function entryChunks(name, bytes) {
|
|
206
|
-
return [...tarEntryHeaders(name, bytes.byteLength), bytes, tarPadding(bytes.byteLength)].filter(
|
|
207
|
-
(chunk) => chunk.byteLength > 0
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
async function* fileEntryChunks(source, name, ref) {
|
|
211
|
-
yield* tarEntryHeaders(name, ref.bytes).filter((chunk) => chunk.byteLength > 0);
|
|
212
|
-
for (let offset = 0; offset < ref.bytes; offset += ARCHIVE_FILE_CHUNK_BYTES) {
|
|
213
|
-
yield await source.readRange(ref, offset, Math.min(ARCHIVE_FILE_CHUNK_BYTES, ref.bytes - offset));
|
|
214
|
-
}
|
|
215
|
-
const padding = tarPadding(ref.bytes);
|
|
216
|
-
if (padding.byteLength > 0) yield padding;
|
|
217
|
-
}
|
|
218
|
-
async function* archiveChunks(source) {
|
|
219
|
-
yield* entryChunks(ARCHIVE_CONFIG_ENTRY, source.config);
|
|
220
|
-
yield* entryChunks(ARCHIVE_MANIFEST_ENTRY, source.manifestBytes);
|
|
221
|
-
const prefix = `${source.sourceIndexName}/`;
|
|
222
|
-
for (const ref of manifestFileRefs(source.manifest)) {
|
|
223
|
-
yield* fileEntryChunks(source, ref.key.slice(prefix.length), ref);
|
|
224
|
-
}
|
|
225
|
-
if (source.trailingEntries !== void 0) {
|
|
226
|
-
for await (const entry of source.trailingEntries()) yield* entryChunks(entry.name, entry.bytes);
|
|
227
|
-
}
|
|
228
|
-
yield tarEnd();
|
|
229
|
-
}
|
|
230
|
-
function archiveStream(source) {
|
|
231
|
-
const chunks = archiveChunks(source);
|
|
232
|
-
let released = false;
|
|
233
|
-
const release = () => {
|
|
234
|
-
if (released) return;
|
|
235
|
-
released = true;
|
|
236
|
-
source.release();
|
|
237
|
-
};
|
|
238
|
-
return new ReadableStream({
|
|
239
|
-
async pull(controller) {
|
|
240
|
-
try {
|
|
241
|
-
const step = await chunks.next();
|
|
242
|
-
if (step.done) {
|
|
243
|
-
release();
|
|
244
|
-
controller.close();
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
controller.enqueue(step.value);
|
|
248
|
-
} catch (error) {
|
|
249
|
-
release();
|
|
250
|
-
controller.error(error);
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
async cancel() {
|
|
254
|
-
release();
|
|
255
|
-
await chunks.return(void 0);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// src/persistence/archive/file-entry.ts
|
|
261
|
-
async function writeArchiveFile(store, key, chunks) {
|
|
262
|
-
const { directory } = store;
|
|
263
|
-
if (directory === void 0) {
|
|
264
|
-
const held = [];
|
|
265
|
-
for await (const chunk of chunks) held.push(chunk);
|
|
266
|
-
await store.write(key, held);
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
const receiving = `${key}.receiving`;
|
|
270
|
-
await directory.remove(receiving);
|
|
271
|
-
const handle = await directory.appendHandle(receiving);
|
|
272
|
-
try {
|
|
273
|
-
for await (const chunk of chunks) await handle.append(chunk);
|
|
274
|
-
await handle.sync();
|
|
275
|
-
} finally {
|
|
276
|
-
await handle.close();
|
|
277
|
-
}
|
|
278
|
-
await directory.move(receiving, key);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// src/persistence/archive/validate.ts
|
|
282
|
-
function requireDimension(key, found, expected) {
|
|
283
|
-
if (expected === found) return;
|
|
284
|
-
throw new NarsilError(
|
|
285
|
-
ErrorCodes.PERSISTENCE_LOAD_FAILED,
|
|
286
|
-
`The vector file "${key}" holds vectors of ${found} dimensions where the schema gives ${String(expected)}`,
|
|
287
|
-
{ key, found, expected }
|
|
288
|
-
);
|
|
289
|
-
}
|
|
290
|
-
function requireSchemaOfManifest(key, schema, manifest) {
|
|
291
|
-
for (const [field, type] of Object.entries(schema)) {
|
|
292
|
-
const listed = manifest.schema[field];
|
|
293
|
-
if (listed === void 0 || listed === type) continue;
|
|
294
|
-
throw new NarsilError(
|
|
295
|
-
ErrorCodes.PERSISTENCE_LOAD_FAILED,
|
|
296
|
-
`The segment "${key}" gives field "${field}" the type "${type}", while the manifest gives it "${listed}"`,
|
|
297
|
-
{ key, field }
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
async function validateStagedCheckpoint(store, manifest) {
|
|
302
|
-
for (const partition of manifest.partitions) {
|
|
303
|
-
for (const ref of partition.segments) {
|
|
304
|
-
const { directory } = store;
|
|
305
|
-
if (directory !== void 0) {
|
|
306
|
-
const { checkPagedSegmentFully, isPagedSegmentFile } = await import('./module-LBZPGOWH.mjs');
|
|
307
|
-
if (await isPagedSegmentFile(directory, ref.key)) {
|
|
308
|
-
requireSchemaOfManifest(ref.key, await checkPagedSegmentFully(directory, ref), manifest);
|
|
309
|
-
continue;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
const contents = await readSegmentFile(store, ref);
|
|
313
|
-
requireSchemaOfManifest(ref.key, contents.schema, manifest);
|
|
314
|
-
decodeEveryStoredDocument(contents.arrays.documentTable);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
for (const field of manifest.vectors) {
|
|
318
|
-
const fieldType = manifest.schema[field.fieldPath];
|
|
319
|
-
const dimension = fieldType === void 0 ? null : parseVectorDimension(fieldType);
|
|
320
|
-
for (const file of field.files) {
|
|
321
|
-
const { payload } = await readVectorFile(store, file, field.fieldPath);
|
|
322
|
-
requireDimension(file.key, payload.dimension, dimension);
|
|
323
|
-
}
|
|
324
|
-
await readGraphParts(store, field);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// src/workers/detached-index.ts
|
|
329
|
-
function attachablePolicy(shared) {
|
|
330
|
-
let attached = false;
|
|
331
|
-
const policy = {
|
|
332
|
-
get enabled() {
|
|
333
|
-
return attached && shared.enabled;
|
|
334
|
-
},
|
|
335
|
-
get count() {
|
|
336
|
-
return shared.count;
|
|
337
|
-
},
|
|
338
|
-
get host() {
|
|
339
|
-
return shared.host;
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
return {
|
|
343
|
-
policy,
|
|
344
|
-
attach() {
|
|
345
|
-
attached = true;
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
function createDetachedIndex(indexName, config, language, synonyms, executor) {
|
|
350
|
-
const { policy, attach } = attachablePolicy(executor.vectorWorkerCopies);
|
|
351
|
-
const entry = executor.createDetachedEntry(indexName, config, language, policy);
|
|
352
|
-
entry.manager.synonyms = synonyms;
|
|
353
|
-
return { indexName, manager: entry.manager, entry, attach };
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// src/engine/snapshot/restore-setup.ts
|
|
357
|
-
function prepareRestoredIndex(configuration, deps, reject) {
|
|
358
|
-
const configFields = restoredConfigFields(configuration, reject);
|
|
359
|
-
const embedding = restoredEmbedding(configuration.embedding, reject);
|
|
360
|
-
const languageName = configuration.language ?? "";
|
|
361
|
-
const language = getLanguage(languageName);
|
|
362
|
-
const schema = validateSchema(configuration.schema);
|
|
363
|
-
validatePatternValueLimit(configFields.patternValueLimit);
|
|
364
|
-
requireSurfaceFormsForPartialFields(schema, configFields.surfaceForms);
|
|
365
|
-
validateVectorPromotion(configFields.vectorPromotion);
|
|
366
|
-
validateVectorStorage(configFields.vectorPromotion, deps.filesystemDurability);
|
|
367
|
-
validateTextStorage(configFields.textStorage, deps.filesystemDurability);
|
|
368
|
-
if (configFields.required !== void 0 && configFields.required.length > 0) {
|
|
369
|
-
validateRequiredFieldsInSchema(configFields.required, schema);
|
|
370
|
-
}
|
|
371
|
-
const config = {
|
|
372
|
-
schema,
|
|
373
|
-
language: languageName,
|
|
374
|
-
...configFields,
|
|
375
|
-
...embedding !== void 0 ? {
|
|
376
|
-
embedding: {
|
|
377
|
-
fields: embedding.fields,
|
|
378
|
-
...embedding.adapter !== void 0 ? { adapter: embedding.adapter } : {}
|
|
379
|
-
}
|
|
380
|
-
} : {}
|
|
381
|
-
};
|
|
382
|
-
resolveIndexAnalysis(config);
|
|
383
|
-
const adapterName = embedding?.adapter ?? null;
|
|
384
|
-
let embeddingAdapter = null;
|
|
385
|
-
if (embedding !== void 0) {
|
|
386
|
-
const candidate = adapterName !== null ? deps.embeddingAdapters.get(adapterName) ?? null : deps.defaultEmbeddingAdapter;
|
|
387
|
-
if (candidate) {
|
|
388
|
-
validateEmbeddingConfig({ fields: embedding.fields, adapter: candidate }, schema, void 0);
|
|
389
|
-
embeddingAdapter = candidate;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
const storedRevision = typeof configuration.analysisRevision === "string" ? configuration.analysisRevision : null;
|
|
393
|
-
const synonyms = restoredSynonyms(configuration.synonyms, config, language, reject ?? rejectSnapshot);
|
|
394
|
-
const analysisGeneration = Number.isSafeInteger(configuration.analysisGeneration) ? Math.max(0, configuration.analysisGeneration) : 0;
|
|
395
|
-
return {
|
|
396
|
-
config,
|
|
397
|
-
language,
|
|
398
|
-
embeddingAdapter,
|
|
399
|
-
adapterName,
|
|
400
|
-
storedRevision,
|
|
401
|
-
analysisGeneration,
|
|
402
|
-
storedArrayPositionGap: storedArrayPositionGap(configuration.arrayPositionGap),
|
|
403
|
-
synonyms,
|
|
404
|
-
querySuggestions: storedStateOf(configuration)
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
function restoredSynonyms(raw, config, language, reject) {
|
|
408
|
-
if (raw === void 0 || raw === null) return null;
|
|
409
|
-
return prepareStoredSynonyms(raw, config, language, (message) => reject(`synonyms: ${message}`));
|
|
410
|
-
}
|
|
411
|
-
async function prepareDetachedIndex(indexName, prepared, partitionCount, deps) {
|
|
412
|
-
const loadingSchemaCode = loadSchemaCodeFor(prepared.config.schema);
|
|
413
|
-
if (loadingSchemaCode !== null) await loadingSchemaCode;
|
|
414
|
-
const detached = createDetachedIndex(
|
|
415
|
-
indexName,
|
|
416
|
-
prepared.config,
|
|
417
|
-
prepared.language,
|
|
418
|
-
prepared.synonyms?.lookup ?? null,
|
|
419
|
-
deps.executor
|
|
420
|
-
);
|
|
421
|
-
while (detached.manager.partitionCount < partitionCount) detached.manager.addPartition();
|
|
422
|
-
return detached;
|
|
423
|
-
}
|
|
424
|
-
function restoredRegistryEntry(prepared, manager, deps) {
|
|
425
|
-
return {
|
|
426
|
-
config: prepared.config,
|
|
427
|
-
language: prepared.language,
|
|
428
|
-
embeddingAdapter: prepared.embeddingAdapter,
|
|
429
|
-
embeddingAdapterName: prepared.adapterName,
|
|
430
|
-
vectorFieldPaths: deps.getVectorFieldPaths(prepared.config.schema),
|
|
431
|
-
indexUuid: null,
|
|
432
|
-
heldPartitions: null,
|
|
433
|
-
documentCount: manager.countDocuments(),
|
|
434
|
-
partitionCount: manager.partitionCount,
|
|
435
|
-
analysisRevision: prepared.storedRevision,
|
|
436
|
-
arrayPositionGap: prepared.storedArrayPositionGap,
|
|
437
|
-
synonyms: prepared.synonyms?.encoded ?? null,
|
|
438
|
-
analysisGeneration: prepared.analysisGeneration,
|
|
439
|
-
pendingAnalysis: null,
|
|
440
|
-
durableAnalysis: null,
|
|
441
|
-
sync: null,
|
|
442
|
-
querySuggestions: prepared.querySuggestions
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// src/engine/snapshot/replace.ts
|
|
447
|
-
function releaseTimedOut(indexName, timeoutMs) {
|
|
448
|
-
return new NarsilError(
|
|
449
|
-
ErrorCodes.WORKER_TIMEOUT,
|
|
450
|
-
`The restore of index "${indexName}" stopped because a worker held the index past ${timeoutMs} ms, and the index keeps its earlier contents`,
|
|
451
|
-
{ indexName, timeoutMs }
|
|
452
|
-
);
|
|
453
|
-
}
|
|
454
|
-
async function withinLimit(indexName, release, work, deps) {
|
|
455
|
-
release.settled = work.catch(() => {
|
|
456
|
-
release.reloads = true;
|
|
457
|
-
});
|
|
458
|
-
let timer;
|
|
459
|
-
const limit = new Promise((_, reject) => {
|
|
460
|
-
timer = setTimeout(() => {
|
|
461
|
-
release.timedOut = true;
|
|
462
|
-
reject(releaseTimedOut(indexName, deps.releaseTimeoutMs));
|
|
463
|
-
}, deps.releaseTimeoutMs);
|
|
464
|
-
});
|
|
465
|
-
try {
|
|
466
|
-
await Promise.race([work, limit]);
|
|
467
|
-
} finally {
|
|
468
|
-
clearTimeout(timer);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
function vectorIndexesOf(indexName, deps) {
|
|
472
|
-
const manager = deps.executor.getManager(indexName);
|
|
473
|
-
return manager === void 0 ? [] : [...manager.getVectorIndexes().values()];
|
|
474
|
-
}
|
|
475
|
-
async function holdVectorCopies(vectorIndexes, release) {
|
|
476
|
-
for (const vectorIndex of vectorIndexes) {
|
|
477
|
-
if (release.held.includes(vectorIndex)) continue;
|
|
478
|
-
release.held.push(vectorIndex);
|
|
479
|
-
await vectorIndex.holdWorkerCopies();
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
async function releaseCopies(indexName, release, deps) {
|
|
483
|
-
release.reloads = await deps.copies.releaseIndexCopies(indexName);
|
|
484
|
-
await holdVectorCopies(vectorIndexesOf(indexName, deps), release);
|
|
485
|
-
}
|
|
486
|
-
async function endRelease(indexName, release, deps) {
|
|
487
|
-
await release.settled;
|
|
488
|
-
for (const vectorIndex of release.held) vectorIndex.resumeWorkerCopies();
|
|
489
|
-
await deps.copies.endCopyRelease(indexName, release.reloads);
|
|
490
|
-
}
|
|
491
|
-
function persistedCheckpoint(indexName, partitionCount, deps) {
|
|
492
|
-
const durable = deps.durability?.manager;
|
|
493
|
-
if (durable === void 0) return [];
|
|
494
|
-
return Array.from({ length: partitionCount }, (_, partitionId) => ({
|
|
495
|
-
partitionId,
|
|
496
|
-
lastSeqNo: durable.highestPersistedSeqNo(indexName, partitionId),
|
|
497
|
-
primaryTerm: SINGLE_NODE_PRIMARY_TERM
|
|
498
|
-
}));
|
|
499
|
-
}
|
|
500
|
-
async function commitToStorage(indexName, restored, previousPartitions, deps) {
|
|
501
|
-
const durable = deps.durability?.manager;
|
|
502
|
-
const staging = restored.staging;
|
|
503
|
-
if (durable === void 0 || staging === null) return;
|
|
504
|
-
const previous = persistedCheckpoint(indexName, previousPartitions, deps);
|
|
505
|
-
if (previousPartitions > 0) await durable.unloadIndex(indexName);
|
|
506
|
-
const vectorIndexes = [...restored.detached.manager.getVectorIndexes().values()];
|
|
507
|
-
try {
|
|
508
|
-
for (const vectorIndex of vectorIndexes) await vectorIndex.releaseVectorFiles();
|
|
509
|
-
await staging.commit();
|
|
510
|
-
} catch (error) {
|
|
511
|
-
if (previousPartitions > 0) durable.adoptRestoredCheckpoint?.(indexName, previous);
|
|
512
|
-
throw error;
|
|
513
|
-
}
|
|
514
|
-
await staging.finish();
|
|
515
|
-
const relocate = await staging.relocation().catch(() => null);
|
|
516
|
-
if (relocate === null) return;
|
|
517
|
-
for (const vectorIndex of vectorIndexes) vectorIndex.relocateVectorFiles(relocate);
|
|
518
|
-
const { manager } = restored.detached;
|
|
519
|
-
for (let partitionId = 0; partitionId < manager.partitionCount; partitionId++) {
|
|
520
|
-
const partition = manager.getPartition(partitionId);
|
|
521
|
-
if (!isCompositePartition(partition)) continue;
|
|
522
|
-
for (const segment of partition.frozenSegments()) segment.paged?.relocate(relocate);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
function activate(indexName, restored, entry, deps) {
|
|
526
|
-
deps.executor.installDetachedIndex(restored.detached);
|
|
527
|
-
deps.indexRegistry.set(indexName, entry);
|
|
528
|
-
restored.detached.attach();
|
|
529
|
-
deps.clearAnalysisStale(indexName);
|
|
530
|
-
const { prepared } = restored;
|
|
531
|
-
if (prepared.storedRevision !== prepared.language.revision || arrayPositionsAreStale(prepared.config, prepared.storedArrayPositionGap)) {
|
|
532
|
-
deps.markAnalysisStale({
|
|
533
|
-
indexName,
|
|
534
|
-
language: prepared.language.name,
|
|
535
|
-
storedRevision: prepared.storedRevision,
|
|
536
|
-
currentRevision: prepared.language.revision
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
if (restored.staging !== null) deps.durability?.manager.adoptRestoredCheckpoint?.(indexName, restored.checkpoint);
|
|
540
|
-
deps.forgetWatermark(indexName);
|
|
541
|
-
}
|
|
542
|
-
async function replaceExisting(indexName, restored, entry, deps) {
|
|
543
|
-
const release = { reloads: false, held: [], settled: Promise.resolve(), timedOut: false };
|
|
544
|
-
try {
|
|
545
|
-
await deps.abandonAnalysisChange(indexName);
|
|
546
|
-
await withinLimit(indexName, release, releaseCopies(indexName, release, deps), deps);
|
|
547
|
-
await deps.indexState.replace(indexName, async (wasOpen) => {
|
|
548
|
-
await deps.abandonAnalysisRebuild(indexName);
|
|
549
|
-
const previous = wasOpen ? deps.executor.getManager(indexName) : void 0;
|
|
550
|
-
const vectorIndexes = previous === void 0 ? [] : vectorIndexesOf(indexName, deps);
|
|
551
|
-
await withinLimit(indexName, release, holdVectorCopies(vectorIndexes, release), deps);
|
|
552
|
-
for (const vectorIndex of vectorIndexes) await vectorIndex.releaseVectorFiles();
|
|
553
|
-
await commitToStorage(indexName, restored, previous?.partitionCount ?? 0, deps);
|
|
554
|
-
activate(indexName, restored, entry, deps);
|
|
555
|
-
await deps.querySuggestions?.afterActivate(entry);
|
|
556
|
-
});
|
|
557
|
-
} finally {
|
|
558
|
-
const ending = endRelease(indexName, release, deps).catch(() => void 0);
|
|
559
|
-
if (!release.timedOut) await ending;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
async function createFresh(indexName, restored, entry, deps) {
|
|
563
|
-
deps.copies.desyncIndex(indexName);
|
|
564
|
-
deps.executor.installDetachedIndex(restored.detached);
|
|
565
|
-
deps.indexRegistry.set(indexName, entry);
|
|
566
|
-
try {
|
|
567
|
-
await deps.indexState.registerReplacing(indexName, async () => {
|
|
568
|
-
await commitToStorage(indexName, restored, 0, deps);
|
|
569
|
-
activate(indexName, restored, entry, deps);
|
|
570
|
-
await deps.querySuggestions?.afterActivate(entry);
|
|
571
|
-
});
|
|
572
|
-
} catch (error) {
|
|
573
|
-
if (deps.indexRegistry.get(indexName) === entry) deps.indexRegistry.delete(indexName);
|
|
574
|
-
throw error;
|
|
575
|
-
} finally {
|
|
576
|
-
await deps.copies.resyncIndex(indexName, false).catch(() => void 0);
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
async function stageMetadata(indexName, staging, entry) {
|
|
580
|
-
const metadata = indexMetadataOf(indexName, entry, entry.partitionCount);
|
|
581
|
-
await staging.store.write(`${indexName}/meta`, [await writeMetadataEnvelope(metadata, { checksum: true })]);
|
|
582
|
-
}
|
|
583
|
-
async function installRestoredIndex(indexName, restored, deps, history = null) {
|
|
584
|
-
const entry = restoredRegistryEntry(restored.prepared, restored.detached.manager, deps);
|
|
585
|
-
const previousSync = deps.indexRegistry.get(indexName)?.sync ?? null;
|
|
586
|
-
if (previousSync !== null) entry.sync = { ...previousSync, active: false, epoch: newSyncEpoch() };
|
|
587
|
-
let replaced;
|
|
588
|
-
try {
|
|
589
|
-
if (deps.indexRegistry.has(indexName)) await deps.abandonAnalysisChange(indexName);
|
|
590
|
-
await deps.querySuggestions?.beforeInstall(entry, deps.indexRegistry.get(indexName));
|
|
591
|
-
if (restored.staging !== null) await stageMetadata(indexName, restored.staging, entry);
|
|
592
|
-
replaced = deps.indexRegistry.get(indexName);
|
|
593
|
-
if (replaced !== void 0) await replaceExisting(indexName, restored, entry, deps);
|
|
594
|
-
else await createFresh(indexName, restored, entry, deps);
|
|
595
|
-
} catch (error) {
|
|
596
|
-
if (deps.executor.getManager(indexName) === restored.detached.manager) deps.executor.dropIndex(indexName);
|
|
597
|
-
else deps.executor.discardDetachedIndex(restored.detached);
|
|
598
|
-
throw error;
|
|
599
|
-
}
|
|
600
|
-
await restored.staging?.removeRetired().catch(() => void 0);
|
|
601
|
-
const durable = deps.durability?.manager;
|
|
602
|
-
if (restored.staging === null && durable !== void 0) {
|
|
603
|
-
await durable.persistMetadata(indexName);
|
|
604
|
-
await durable.checkpoint(indexName);
|
|
605
|
-
}
|
|
606
|
-
if (previousSync !== null) {
|
|
607
|
-
const storage = durable?.syncStorage?.();
|
|
608
|
-
if (storage !== void 0)
|
|
609
|
-
await oneSyncChangeAtATime(deps.indexRegistry, indexName, () => storage.release(indexName));
|
|
610
|
-
emitSyncChange(deps.indexRegistry, { kind: "epoch", indexName });
|
|
611
|
-
}
|
|
612
|
-
await deps.querySuggestions?.afterInstall(entry, history);
|
|
613
|
-
if (replaced !== void 0) await deps.announceIndexDropped(indexName, replaced.config);
|
|
614
|
-
await deps.announceIndexCreated(indexName, restored.prepared.config);
|
|
615
|
-
for (const vectorIndex of restored.detached.manager.getVectorIndexes().values()) {
|
|
616
|
-
vectorIndex.scheduleBuild();
|
|
617
|
-
vectorIndex.startShuffledRebuildWhenDue();
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
// src/engine/snapshot/archive-restore.ts
|
|
622
|
-
function rejectConfiguration(message) {
|
|
623
|
-
throw new NarsilError(ErrorCodes.CONFIG_INVALID, `Invalid index configuration: ${message}`);
|
|
624
|
-
}
|
|
625
|
-
function renamed(manifest, sourceName, indexName) {
|
|
626
|
-
const rename = (key) => `${indexName}/${key.slice(sourceName.length + 1)}`;
|
|
627
|
-
return {
|
|
628
|
-
...manifest,
|
|
629
|
-
partitions: manifest.partitions.map((partition) => ({
|
|
630
|
-
...partition,
|
|
631
|
-
segments: partition.segments.map((segment) => ({ ...segment, key: rename(segment.key) }))
|
|
632
|
-
})),
|
|
633
|
-
vectors: manifest.vectors.map((field) => ({
|
|
634
|
-
...field,
|
|
635
|
-
files: field.files.map((file) => ({ ...file, key: rename(file.key) })),
|
|
636
|
-
graphParts: field.graphParts.map((part) => ({ ...part, key: rename(part.key) }))
|
|
637
|
-
}))
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
function requireSameSchema(prepared, manifest) {
|
|
641
|
-
const configured = flattenSchema(prepared.config.schema);
|
|
642
|
-
const keys = /* @__PURE__ */ new Set([...Object.keys(configured), ...Object.keys(manifest.schema)]);
|
|
643
|
-
for (const field of keys) {
|
|
644
|
-
if (configured[field] === manifest.schema[field]) continue;
|
|
645
|
-
throw new NarsilError(
|
|
646
|
-
ErrorCodes.PERSISTENCE_LOAD_FAILED,
|
|
647
|
-
`The archive's configuration gives field "${field}" another type than its manifest does`,
|
|
648
|
-
{ field }
|
|
649
|
-
);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
function partitionCountOf(manifest) {
|
|
653
|
-
let count = 1;
|
|
654
|
-
for (const partition of manifest.partitions) count = Math.max(count, partition.partitionId + 1);
|
|
655
|
-
return count;
|
|
656
|
-
}
|
|
657
|
-
function missingPart(what) {
|
|
658
|
-
throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, `The archive holds no ${what}`);
|
|
659
|
-
}
|
|
660
|
-
function keepsTextOnDisk(prepared, staging) {
|
|
661
|
-
return prepared.config.textStorage === "disk" && staging.directory !== void 0;
|
|
662
|
-
}
|
|
663
|
-
async function stageArchive(indexName, reader, staging, deps, staged) {
|
|
664
|
-
await readSnapshotArchive(reader, {
|
|
665
|
-
history: async (chunks) => {
|
|
666
|
-
if (staged.history === void 0) {
|
|
667
|
-
staged.history = await deps.querySuggestions?.historySink(staged.prepared?.querySuggestions ?? null) ?? null;
|
|
668
|
-
}
|
|
669
|
-
await staged.history?.add(chunks);
|
|
670
|
-
},
|
|
671
|
-
config: async (bytes) => {
|
|
672
|
-
staged.prepared = prepareRestoredIndex(await decodeIndexConfiguration(bytes), deps, rejectConfiguration);
|
|
673
|
-
},
|
|
674
|
-
manifest: async (manifest2, sourceName) => {
|
|
675
|
-
if (staged.prepared === null) missingPart("configuration");
|
|
676
|
-
requireSameSchema(staged.prepared, manifest2);
|
|
677
|
-
const replacesIndex = deps.indexRegistry.has(indexName);
|
|
678
|
-
const segmentBytes = keepsTextOnDisk(staged.prepared, staging) ? 0 : storedBytesOfSegments(manifest2);
|
|
679
|
-
requireRestoreMemory(
|
|
680
|
-
indexName,
|
|
681
|
-
archiveFootprint(staged.prepared, manifest2, replacesIndex, segmentBytes),
|
|
682
|
-
replacesIndex
|
|
683
|
-
);
|
|
684
|
-
staged.manifest = renamed(manifest2, sourceName, indexName);
|
|
685
|
-
},
|
|
686
|
-
file: async (entryName, _ref, chunks) => {
|
|
687
|
-
if (staged.manifest === null) missingPart("manifest");
|
|
688
|
-
await writeArchiveFile(staging, `${indexName}/${entryName}`, chunks);
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
const { prepared, manifest } = staged;
|
|
692
|
-
if (prepared === null) missingPart("configuration");
|
|
693
|
-
if (manifest === null) missingPart("manifest");
|
|
694
|
-
const { directory } = staging;
|
|
695
|
-
if (keepsTextOnDisk(prepared, staging) && directory !== void 0) {
|
|
696
|
-
const { bytesThatSegmentsHoldInMemory } = await import('./module-LBZPGOWH.mjs');
|
|
697
|
-
const replacesIndex = deps.indexRegistry.has(indexName);
|
|
698
|
-
const segmentBytes = await bytesThatSegmentsHoldInMemory(directory, manifest);
|
|
699
|
-
requireRestoreMemory(indexName, archiveFootprint(prepared, manifest, replacesIndex, segmentBytes), replacesIndex);
|
|
700
|
-
}
|
|
701
|
-
await validateStagedCheckpoint(staging, manifest);
|
|
702
|
-
return { prepared, manifest };
|
|
703
|
-
}
|
|
704
|
-
async function loadStagedIndex(indexName, staged, staging, store, deps) {
|
|
705
|
-
const { prepared, manifest } = staged;
|
|
706
|
-
await store.write(manifestKey(indexName), (await encodeSegmentManifest(manifest)).chunks);
|
|
707
|
-
const detached = await prepareDetachedIndex(indexName, prepared, partitionCountOf(manifest), deps);
|
|
708
|
-
try {
|
|
709
|
-
await loadSegmentedCheckpoint(
|
|
710
|
-
store,
|
|
711
|
-
indexName,
|
|
712
|
-
manifest,
|
|
713
|
-
{ manager: detached.manager, vectorIndexes: detached.manager.getVectorIndexes() },
|
|
714
|
-
true
|
|
715
|
-
);
|
|
716
|
-
} catch (error) {
|
|
717
|
-
deps.executor.discardDetachedIndex(detached);
|
|
718
|
-
throw error;
|
|
719
|
-
}
|
|
720
|
-
return { prepared, detached, staging, checkpoint: manifest.checkpoint };
|
|
721
|
-
}
|
|
722
|
-
async function restoreArchive(indexName, reader, deps) {
|
|
723
|
-
const staging = deps.durability?.manager.stageRestore?.(indexName) ?? null;
|
|
724
|
-
const store = staging?.store ?? memoryCheckpointStore();
|
|
725
|
-
const archive = { prepared: null, manifest: null, history: void 0 };
|
|
726
|
-
try {
|
|
727
|
-
const staged = await stageArchive(indexName, reader, store, deps, archive);
|
|
728
|
-
const restored = await loadStagedIndex(indexName, staged, staging, store, deps);
|
|
729
|
-
await installRestoredIndex(indexName, restored, deps, archive.history ?? null);
|
|
730
|
-
} catch (error) {
|
|
731
|
-
await archive.history?.abandon().catch(() => void 0);
|
|
732
|
-
throw error;
|
|
733
|
-
} finally {
|
|
734
|
-
await staging?.discard().catch(() => void 0);
|
|
735
|
-
await reader.close();
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
function invalidSnapshot(message, details) {
|
|
739
|
-
throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, message, details);
|
|
740
|
-
}
|
|
741
|
-
async function decodeEarlierSnapshot(data) {
|
|
742
|
-
const payloadBytes = await unpackIndexSnapshotEnvelope(data);
|
|
743
|
-
let decoded;
|
|
744
|
-
try {
|
|
745
|
-
decoded = decode(payloadBytes);
|
|
746
|
-
} catch (err) {
|
|
747
|
-
invalidSnapshot(`Snapshot data is not a Narsil snapshot: ${err instanceof Error ? err.message : String(err)}`, {
|
|
748
|
-
bytes: data.length
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
if (typeof decoded !== "object" || decoded === null || Array.isArray(decoded)) {
|
|
752
|
-
invalidSnapshot("Snapshot data does not hold a snapshot envelope", { bytes: data.length });
|
|
753
|
-
}
|
|
754
|
-
const envelope = decoded;
|
|
755
|
-
if (envelope.version !== 1 && envelope.version !== 2) {
|
|
756
|
-
invalidSnapshot(`Unsupported snapshot version: ${envelope.version}. Expected version 1 or 2`, {
|
|
757
|
-
version: envelope.version
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
if (!envelope.schema || typeof envelope.schema !== "object")
|
|
761
|
-
invalidSnapshot("Invalid snapshot: missing or invalid schema");
|
|
762
|
-
if (!envelope.language || typeof envelope.language !== "string") {
|
|
763
|
-
invalidSnapshot("Invalid snapshot: missing or invalid language");
|
|
764
|
-
}
|
|
765
|
-
if (!Array.isArray(envelope.partitions)) invalidSnapshot("Invalid snapshot: missing partitions");
|
|
766
|
-
return { ...envelope, vectorPromotion: raiseEarlierReleaseGraphSetting(envelope.vectorPromotion) };
|
|
767
|
-
}
|
|
768
|
-
function vectorsOfSnapshot(envelope) {
|
|
769
|
-
const byDocument = /* @__PURE__ */ new Map();
|
|
770
|
-
for (const [fieldPath, rawParts] of Object.entries(envelope.vectorIndexes ?? {})) {
|
|
771
|
-
for (const part of decodeVectorIndexParts(rawParts)) {
|
|
772
|
-
const values = bytesToVectors(part.vectors);
|
|
773
|
-
for (let i = 0; i < part.docIds.length; i++) {
|
|
774
|
-
let fields = byDocument.get(part.docIds[i]);
|
|
775
|
-
if (fields === void 0) {
|
|
776
|
-
fields = /* @__PURE__ */ new Map();
|
|
777
|
-
byDocument.set(part.docIds[i], fields);
|
|
778
|
-
}
|
|
779
|
-
fields.set(fieldPath, values.slice(i * part.dimension, (i + 1) * part.dimension));
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
return byDocument;
|
|
784
|
-
}
|
|
785
|
-
function footprintOf(envelope, prepared, replacesIndex) {
|
|
786
|
-
let partitionBytes = 0;
|
|
787
|
-
for (const payload of envelope.partitions ?? []) partitionBytes += payload.byteLength;
|
|
788
|
-
const vectorCounts = /* @__PURE__ */ new Map();
|
|
789
|
-
for (const [fieldPath, rawParts] of Object.entries(envelope.vectorIndexes ?? {})) {
|
|
790
|
-
let count = 0;
|
|
791
|
-
for (const part of decodeVectorIndexParts(rawParts)) count += part.docIds.length;
|
|
792
|
-
vectorCounts.set(fieldPath, count);
|
|
793
|
-
}
|
|
794
|
-
return earlierSnapshotFootprint(prepared, partitionBytes, vectorCounts, replacesIndex);
|
|
795
|
-
}
|
|
796
|
-
function documentsOfPartition(envelope, payload) {
|
|
797
|
-
return envelope.version === 2 ? documentsOfPayloadV2(payload).documents : deserializePayloadV1(payload).documents;
|
|
798
|
-
}
|
|
799
|
-
function insertRestoredDocument(manager, docId, fields, vectors) {
|
|
800
|
-
manager.insert(docId, fields, { skipClone: true });
|
|
801
|
-
if (vectors === void 0) return;
|
|
802
|
-
try {
|
|
803
|
-
insertDocumentVectors(docId, vectors, manager.getVectorIndexes(), manager.partitionIdOf(docId));
|
|
804
|
-
} catch (err) {
|
|
805
|
-
manager.remove(docId);
|
|
806
|
-
throw err;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
function insertSnapshotDocuments(envelope, manager) {
|
|
810
|
-
const vectors = vectorsOfSnapshot(envelope);
|
|
811
|
-
for (const payload of envelope.partitions ?? []) {
|
|
812
|
-
for (const [docId, stored] of Object.entries(documentsOfPartition(envelope, payload))) {
|
|
813
|
-
insertRestoredDocument(manager, docId, stored.fields, vectors.get(docId));
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
for (const vectorIndex of manager.getVectorIndexes().values()) vectorIndex.scheduleBuild();
|
|
817
|
-
}
|
|
818
|
-
async function stageBuiltIndex(indexName, prepared, built, staging, deps) {
|
|
819
|
-
const entry = restoredRegistryEntry(prepared, built.manager, deps);
|
|
820
|
-
const archive = await buildArchiveFromMemory({
|
|
821
|
-
indexName,
|
|
822
|
-
metadata: indexMetadataOf(indexName, entry, built.manager.partitionCount),
|
|
823
|
-
manager: built.manager,
|
|
824
|
-
vectorIndexes: built.manager.getVectorIndexes(),
|
|
825
|
-
appliedSeqNo: () => 0,
|
|
826
|
-
partitionId: null
|
|
827
|
-
});
|
|
828
|
-
try {
|
|
829
|
-
for (const ref of manifestFileRefs(archive.manifest))
|
|
830
|
-
await staging.store.write(ref.key, [await archive.readFile(ref)]);
|
|
831
|
-
} finally {
|
|
832
|
-
archive.release();
|
|
833
|
-
}
|
|
834
|
-
await validateStagedCheckpoint(staging.store, archive.manifest);
|
|
835
|
-
return archive.manifest;
|
|
836
|
-
}
|
|
837
|
-
async function buildRestoredIndex(indexName, envelope, prepared, staging, deps) {
|
|
838
|
-
const built = await prepareDetachedIndex(indexName, prepared, envelope.partitions?.length ?? 0, deps);
|
|
839
|
-
let manifest;
|
|
840
|
-
try {
|
|
841
|
-
insertSnapshotDocuments(envelope, built.manager);
|
|
842
|
-
if (staging === null) return { prepared, detached: built, staging: null, checkpoint: [] };
|
|
843
|
-
manifest = await stageBuiltIndex(indexName, prepared, built, staging, deps);
|
|
844
|
-
} catch (err) {
|
|
845
|
-
deps.executor.discardDetachedIndex(built);
|
|
846
|
-
throw err;
|
|
847
|
-
}
|
|
848
|
-
deps.executor.discardDetachedIndex(built);
|
|
849
|
-
return loadStagedIndex(indexName, { prepared, manifest }, staging, staging.store, deps);
|
|
850
|
-
}
|
|
851
|
-
async function restoreEarlierSnapshot(indexName, data, deps) {
|
|
852
|
-
const envelope = await decodeEarlierSnapshot(data);
|
|
853
|
-
const prepared = prepareRestoredIndex(envelope, deps);
|
|
854
|
-
const replacesIndex = deps.indexRegistry.has(indexName);
|
|
855
|
-
requireRestoreMemory(indexName, footprintOf(envelope, prepared, replacesIndex), replacesIndex);
|
|
856
|
-
const analysedNow = {
|
|
857
|
-
...prepared,
|
|
858
|
-
storedRevision: prepared.language.revision,
|
|
859
|
-
storedArrayPositionGap: ARRAY_POSITION_GAP
|
|
860
|
-
};
|
|
861
|
-
const staging = deps.durability?.manager.stageRestore?.(indexName) ?? null;
|
|
862
|
-
try {
|
|
863
|
-
await installRestoredIndex(
|
|
864
|
-
indexName,
|
|
865
|
-
await buildRestoredIndex(indexName, envelope, analysedNow, staging, deps),
|
|
866
|
-
deps
|
|
867
|
-
);
|
|
868
|
-
} finally {
|
|
869
|
-
await staging?.discard().catch(() => void 0);
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
// src/engine/snapshot/index.ts
|
|
874
|
-
var NRSL_MAGIC_BYTES = 4;
|
|
875
|
-
async function checkpointForArchive(deps) {
|
|
876
|
-
const durable = deps.durability?.manager;
|
|
877
|
-
if (durable?.openArchiveCheckpoint !== void 0) return durable.openArchiveCheckpoint(deps.indexName);
|
|
878
|
-
return buildArchiveFromMemory({
|
|
879
|
-
indexName: deps.indexName,
|
|
880
|
-
metadata: indexMetadataOf(deps.indexName, deps.entry, deps.manager.partitionCount),
|
|
881
|
-
manager: deps.manager,
|
|
882
|
-
vectorIndexes: deps.manager.getVectorIndexes(),
|
|
883
|
-
appliedSeqNo: (partitionId) => durable?.highestPersistedSeqNo(deps.indexName, partitionId) ?? 0,
|
|
884
|
-
partitionId: null
|
|
885
|
-
});
|
|
886
|
-
}
|
|
887
|
-
async function* queryHistoryEntries(core, indexName) {
|
|
888
|
-
const { historyArchiveEntries } = await import('./archive-history-MJKUQLSU.mjs');
|
|
889
|
-
yield* historyArchiveEntries(core, indexName);
|
|
890
|
-
}
|
|
891
|
-
async function createSnapshot(deps, coreWithAddedHistory) {
|
|
892
|
-
const trailingEntries = coreWithAddedHistory === null ? void 0 : () => queryHistoryEntries(coreWithAddedHistory, deps.indexName);
|
|
893
|
-
for (let attempt = 0; attempt < MAX_SNAPSHOT_ANALYSIS_ATTEMPTS; attempt += 1) {
|
|
894
|
-
const checkpoint = await checkpointForArchive(deps);
|
|
895
|
-
try {
|
|
896
|
-
if ((checkpoint.manifest.analysisGeneration ?? 0) === deps.entry.analysisGeneration) {
|
|
897
|
-
const config = await encodeIndexConfiguration(deps.entry);
|
|
898
|
-
return archiveStream({
|
|
899
|
-
...checkpoint,
|
|
900
|
-
config,
|
|
901
|
-
sourceIndexName: deps.indexName,
|
|
902
|
-
...trailingEntries !== void 0 ? { trailingEntries } : {}
|
|
903
|
-
});
|
|
904
|
-
}
|
|
905
|
-
} catch (error) {
|
|
906
|
-
checkpoint.release();
|
|
907
|
-
throw error;
|
|
908
|
-
}
|
|
909
|
-
checkpoint.release();
|
|
910
|
-
}
|
|
911
|
-
throw new NarsilError(
|
|
912
|
-
ErrorCodes.ANALYSIS_CHANGE_NOT_READY,
|
|
913
|
-
`The analysis of index "${deps.indexName}" changed while the engine wrote its snapshot, so try the snapshot again once the change has a durable checkpoint`,
|
|
914
|
-
{ indexName: deps.indexName }
|
|
915
|
-
);
|
|
916
|
-
}
|
|
917
|
-
function requireSnapshotSource(data) {
|
|
918
|
-
if (data instanceof Uint8Array) return data;
|
|
919
|
-
if (data !== null && typeof data === "object") {
|
|
920
|
-
if (typeof data.getReader === "function") return data;
|
|
921
|
-
if (typeof data[Symbol.asyncIterator] === "function") {
|
|
922
|
-
return data;
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
throw new NarsilError(
|
|
926
|
-
ErrorCodes.DOC_VALIDATION_FAILED,
|
|
927
|
-
"Snapshot data must be a Uint8Array, a ReadableStream of bytes, or an async iterable of bytes"
|
|
928
|
-
);
|
|
929
|
-
}
|
|
930
|
-
async function readEarlierSnapshotFile(reader) {
|
|
931
|
-
const length = HEADER_SIZE + readHeader(await reader.peek(HEADER_SIZE)).payloadLength;
|
|
932
|
-
if (length > MAX_FILE_BYTES) {
|
|
933
|
-
throw new NarsilError(
|
|
934
|
-
ErrorCodes.PERSISTENCE_LOAD_FAILED,
|
|
935
|
-
`The snapshot declares ${length} bytes, above the file size limit of ${MAX_FILE_BYTES}`,
|
|
936
|
-
{ bytes: length }
|
|
937
|
-
);
|
|
938
|
-
}
|
|
939
|
-
const bytes = await reader.readExactly(length) ?? new Uint8Array(0);
|
|
940
|
-
if (bytes.byteLength < length) {
|
|
941
|
-
throw new NarsilError(
|
|
942
|
-
ErrorCodes.PERSISTENCE_LOAD_FAILED,
|
|
943
|
-
"The snapshot ends before the payload its header declares"
|
|
944
|
-
);
|
|
945
|
-
}
|
|
946
|
-
const trailing = await reader.readExactly(1);
|
|
947
|
-
if (trailing !== null && trailing.byteLength > 0) {
|
|
948
|
-
throw new NarsilError(
|
|
949
|
-
ErrorCodes.PERSISTENCE_LOAD_FAILED,
|
|
950
|
-
"The snapshot holds bytes after the payload its header declares"
|
|
951
|
-
);
|
|
952
|
-
}
|
|
953
|
-
return bytes;
|
|
954
|
-
}
|
|
955
|
-
async function restoreFromSnapshot(indexName, data, deps) {
|
|
956
|
-
const reader = createByteReader(requireSnapshotSource(data));
|
|
957
|
-
const head = await reader.peek(NRSL_MAGIC_BYTES);
|
|
958
|
-
if (head.byteLength >= NRSL_MAGIC_BYTES && hasNrslMagic(head)) {
|
|
959
|
-
let bytes;
|
|
960
|
-
try {
|
|
961
|
-
bytes = await readEarlierSnapshotFile(reader);
|
|
962
|
-
} finally {
|
|
963
|
-
await reader.close();
|
|
964
|
-
}
|
|
965
|
-
await restoreEarlierSnapshot(indexName, bytes, deps);
|
|
966
|
-
return;
|
|
967
|
-
}
|
|
968
|
-
if (head.byteLength === 0) {
|
|
969
|
-
await reader.close();
|
|
970
|
-
throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, "Snapshot data is empty");
|
|
971
|
-
}
|
|
972
|
-
await restoreArchive(indexName, reader, deps);
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
export { checkpointForArchive, createSnapshot, restoreFromSnapshot };
|