@delali/narsil 0.3.1-next.144 → 0.3.1-next.146
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.d.ts +1 -1
- package/dist/adapters/filesystem.mjs +101 -13
- package/dist/adapters/gcs.d.ts +49 -0
- package/dist/adapters/gcs.mjs +213 -0
- package/dist/adapters/indexeddb.d.ts +1 -1
- package/dist/adapters/indexeddb.mjs +2 -7
- package/dist/adapters/memory.d.ts +1 -1
- package/dist/adapters/memory.mjs +5 -0
- package/dist/adapters/s3.d.ts +53 -0
- package/dist/adapters/s3.mjs +263 -0
- package/dist/{adapters-BQFQ4PRz.d.ts → adapters-pljAqmrC.d.ts} +33 -0
- package/dist/analysis-change-ZCJNYBJM.mjs +39 -0
- package/dist/{browser/analysis-change-entry-7HR4LWL3.mjs → analysis-change-entry-YN3ELL6C.mjs} +1 -1
- package/dist/browser/{analysis-change-JPV775LR.mjs → analysis-change-M65AZQQG.mjs} +8 -5
- package/dist/{analysis-change-entry-TZTG4AZB.mjs → browser/analysis-change-entry-H3YIOLXZ.mjs} +1 -1
- package/dist/browser/{chunk-VFYMPCOV.mjs → chunk-2JABMB4S.mjs} +10 -6
- package/dist/{chunk-46NZOPHS.mjs → browser/chunk-4DYLCICG.mjs} +2 -2
- package/dist/browser/{chunk-MZI3TEOW.mjs → chunk-4RD3AFSB.mjs} +1 -1
- package/dist/browser/{chunk-WCFCHIBB.mjs → chunk-5V74FFZE.mjs} +2 -2
- package/dist/{chunk-NN33CZRE.mjs → browser/chunk-6OWX3OP2.mjs} +2 -2
- package/dist/browser/chunk-BRWY3JCN.mjs +678 -0
- package/dist/browser/{chunk-5DB2VDGI.mjs → chunk-BVX2MEHA.mjs} +306 -607
- package/dist/browser/{chunk-KTOK275N.mjs → chunk-D6UFGBF5.mjs} +15 -45
- package/dist/browser/{chunk-D33A5VMU.mjs → chunk-IAXZAVYL.mjs} +25 -66
- package/dist/browser/chunk-JNOAKDUM.mjs +31 -0
- package/dist/browser/{chunk-LVY2LI35.mjs → chunk-KAEVGLYN.mjs} +2 -2
- package/dist/browser/{chunk-3ZBJYAS4.mjs → chunk-LURXVCHG.mjs} +1 -1
- package/dist/browser/chunk-MPK76GVS.mjs +63 -0
- package/dist/browser/{chunk-ZEV26AQ6.mjs → chunk-NVEJJP4R.mjs} +1 -1
- package/dist/browser/{chunk-HKX2G6WH.mjs → chunk-ODQP7P3H.mjs} +455 -66
- package/dist/browser/{chunk-35B42UFM.mjs → chunk-PIS7ZAP7.mjs} +12 -25
- package/dist/browser/{chunk-TCLEOZ4P.mjs → chunk-QMNZFFD3.mjs} +4 -3
- package/dist/browser/{chunk-R4WUDZQV.mjs → chunk-SRL47USS.mjs} +2 -2
- package/dist/browser/chunk-TY7L6OXO.mjs +69 -0
- package/dist/browser/{chunk-MVM33ZUL.mjs → chunk-W643QV3L.mjs} +6 -5
- package/dist/browser/chunk-WXLBZJMT.mjs +25 -0
- package/dist/browser/{chunk-MWUK3DA5.mjs → chunk-XILIT5MT.mjs} +8 -8
- package/dist/browser/{cold-module-MJMKNUYJ.mjs → cold-module-A5S6JFDN.mjs} +20 -20
- package/dist/browser/{durability-wiring-SNOWIT6Z.mjs → durability-wiring-W5AVV3RF.mjs} +120 -80
- package/dist/browser/gzip-5S7ROJFJ.mjs +1 -0
- package/dist/browser/import-PTT63AGK.mjs +12 -0
- package/dist/browser/{module-BUFNZMEU.mjs → module-CEKA7MQH.mjs} +13 -10
- package/dist/browser/module-X5PGOE47.mjs +4288 -0
- package/dist/browser/{phrase-module-HGVBO24W.mjs → phrase-module-CNKMUY4U.mjs} +2 -1
- package/dist/browser/pool-DTYSPBMQ.mjs +296 -0
- package/dist/{restore-queue-FEYAC4SB.mjs → browser/restore-queue-DD4LWZK7.mjs} +2 -2
- package/dist/browser/{runtime-VEUH674B.mjs → runtime-D2ULZGCN.mjs} +3 -2
- package/dist/browser/{snapshot-QXBKHJAG.mjs → snapshot-DQ6A4PQP.mjs} +20 -15
- package/dist/browser/{write-WHFBDWQS.mjs → write-MAGRAIEH.mjs} +14 -11
- package/dist/{capabilities-BCdUwK_L.d.ts → capabilities-BT-HLDC8.d.ts} +3 -3
- package/dist/{chunk-O4LJQI4G.mjs → chunk-2HJWQPR6.mjs} +126 -4
- package/dist/{chunk-Z4HFMYNX.mjs → chunk-3BVGJ4JR.mjs} +36 -13
- package/dist/{chunk-ZPWS2SKJ.mjs → chunk-3HV7M5OJ.mjs} +272 -112
- package/dist/{chunk-UIKN2OTQ.mjs → chunk-3MXV3VHR.mjs} +2 -23
- package/dist/{browser/chunk-CCOAOO73.mjs → chunk-3SBJVQLL.mjs} +2 -2
- package/dist/chunk-3TVDTACC.mjs +104 -0
- package/dist/{chunk-YH5OIL7B.mjs → chunk-5QMHMELB.mjs} +6 -1
- package/dist/{chunk-SBMAWTRG.mjs → chunk-5WB2A3XU.mjs} +84 -15
- package/dist/{chunk-NPNK57CA.mjs → chunk-65WCV5JO.mjs} +1 -1
- package/dist/chunk-6BWLDLS3.mjs +58 -0
- package/dist/{chunk-UUZCQQG2.mjs → chunk-6C5EX2QR.mjs} +3 -3
- package/dist/{chunk-VEFN6X6Q.mjs → chunk-6F6USYII.mjs} +120 -13
- package/dist/{chunk-AST3SHFA.mjs → chunk-7HKWO4BJ.mjs} +7 -7
- package/dist/{chunk-W2COJ5AH.mjs → chunk-7N223GWV.mjs} +2 -2
- package/dist/{chunk-GWOS5DYC.mjs → chunk-ADBS5XRI.mjs} +11 -13
- package/dist/{chunk-TNBIK2LQ.mjs → chunk-AWNHDBKV.mjs} +430 -75
- package/dist/{chunk-ZMBFWQXN.mjs → chunk-B2FTZNNF.mjs} +2 -2
- package/dist/chunk-B7XIOAMK.mjs +100 -0
- package/dist/{chunk-W55X2BYN.mjs → chunk-BEZH7VEH.mjs} +1 -1
- package/dist/{chunk-QSK35UC2.mjs → chunk-BTPGQC6Z.mjs} +3 -11
- package/dist/{chunk-LA4WNDHL.mjs → chunk-CYYSZPVV.mjs} +12 -14
- package/dist/{chunk-SRJBFG2T.mjs → chunk-DOY6EG76.mjs} +6 -7
- package/dist/{chunk-6SNBQESJ.mjs → chunk-F22IOCR2.mjs} +10 -6
- package/dist/{chunk-J6YVB2XM.mjs → chunk-IJPK5PGM.mjs} +1 -1
- package/dist/{chunk-L76W3IZJ.mjs → chunk-IRWP524D.mjs} +1 -1
- package/dist/{chunk-XS2VM7UE.mjs → chunk-IZT3G24Q.mjs} +2 -2
- package/dist/{chunk-NOT5QOHU.mjs → chunk-J7M73VY7.mjs} +1 -1
- package/dist/chunk-K5HSUPYS.mjs +11 -0
- package/dist/chunk-KAKQ74LS.mjs +53 -0
- package/dist/{chunk-ZSWHPKGM.mjs → chunk-KYVRZAYP.mjs} +69 -2
- package/dist/{chunk-NRUXBYPH.mjs → chunk-KZ5GQE4Z.mjs} +5 -5
- package/dist/{browser/chunk-XNWPP5NS.mjs → chunk-KZQIVGW7.mjs} +2 -2
- package/dist/{chunk-KZL72VTC.mjs → chunk-L7TIAYPX.mjs} +11 -10
- package/dist/{chunk-DD2673TX.mjs → chunk-LDGGR7YT.mjs} +4 -81
- package/dist/{chunk-XZ3SRNDJ.mjs → chunk-LJ4ENXOD.mjs} +77 -16
- package/dist/chunk-LQG5G2LY.mjs +39 -0
- package/dist/{chunk-HNHCNTVG.mjs → chunk-MDF6PDIA.mjs} +11 -0
- package/dist/{chunk-74XB2SXI.mjs → chunk-NVTFQFUL.mjs} +16 -2
- package/dist/{chunk-BOJZGUS6.mjs → chunk-NYSONUB7.mjs} +1 -1
- package/dist/{chunk-WJGO5PGV.mjs → chunk-O4KUNDVF.mjs} +31 -17
- package/dist/{chunk-PWIWSUCX.mjs → chunk-POUYICOU.mjs} +1 -1
- package/dist/{chunk-EBIHRL7B.mjs → chunk-Q2UL2TPC.mjs} +1 -1
- package/dist/{chunk-NJJCPFXN.mjs → chunk-QEYF2SQ6.mjs} +2 -2
- package/dist/{chunk-7AUASRE7.mjs → chunk-QN5WVV5K.mjs} +7 -7
- package/dist/{chunk-RIIUZJQ3.mjs → chunk-QYRNLLLI.mjs} +1 -1
- package/dist/chunk-SOUZMPME.mjs +1635 -0
- package/dist/{chunk-C3YDYX6C.mjs → chunk-T4CJDBBE.mjs} +1 -1
- package/dist/{chunk-YLNSJQLX.mjs → chunk-TTCKT2RT.mjs} +5 -5
- package/dist/{chunk-KEIYVZUX.mjs → chunk-U2726TL5.mjs} +5 -5
- package/dist/{chunk-RKAVHNRW.mjs → chunk-U46IZNCW.mjs} +10 -5
- package/dist/{chunk-BRUUBXCB.mjs → chunk-U6NE6RCV.mjs} +10 -38
- package/dist/{chunk-VJEGOELZ.mjs → chunk-VP6XRMWR.mjs} +4 -4
- package/dist/{chunk-IO5F7ZBE.mjs → chunk-VQDZVWN3.mjs} +874 -413
- package/dist/{chunk-IWVEG5CX.mjs → chunk-XIHUI4KB.mjs} +2 -2
- package/dist/{chunk-YHUTF6EA.mjs → chunk-XKPNKR3V.mjs} +17 -47
- package/dist/{chunk-HJJWY6PT.mjs → chunk-YGQOPB2Z.mjs} +1 -1
- package/dist/chunk-YKEHQUSZ.mjs +248 -0
- package/dist/{chunk-GLZHNSGB.mjs → chunk-ZAYWOHVG.mjs} +1 -1
- package/dist/{chunk-ICW45TTU.mjs → chunk-ZEKDO7YX.mjs} +2 -2
- package/dist/chunk-ZXNNR73R.mjs +31 -0
- package/dist/{chunk-VJS4JFBQ.mjs → chunk-ZXX5GZEX.mjs} +3 -1
- package/dist/{chunk-RHKRTYGO.mjs → chunk-ZYKUD5NX.mjs} +9 -7
- package/dist/{client-B12YFALP.d.ts → client-Cn3gNxUU.d.ts} +62 -5
- package/dist/client.d.ts +8 -8
- package/dist/client.mjs +46 -0
- package/dist/{cold-module-4X7WJCFM.mjs → cold-module-2WWGBFJC.mjs} +43 -49
- package/dist/{config-CIG5yDyg.d.ts → config-CfhH1IWQ.d.ts} +150 -3
- package/dist/{config-BhZxIeb1.d.ts → config-aIsy7mcL.d.ts} +63 -3
- package/dist/direct-executor-QLVHMELJ.mjs +24 -0
- package/dist/distribution/coordinator/etcd.d.ts +3 -3
- package/dist/distribution/coordinator/etcd.mjs +1 -1
- package/dist/distribution/coordinator/in-memory.d.ts +3 -3
- package/dist/distribution/transport/grpc.mjs +4 -4
- package/dist/distribution/transport/in-memory.mjs +2 -2
- package/dist/distribution/transport/tcp.mjs +3 -3
- package/dist/distribution.d.ts +8 -8
- package/dist/distribution.mjs +16116 -14537
- package/dist/{durability-wiring-324D2DDD.mjs → durability-wiring-GNWQSZI3.mjs} +142 -109
- package/dist/embeddings/openai.d.ts +1 -1
- package/dist/embeddings/openai.mjs +2 -2
- package/dist/{engine-CtzbHOmG.d.ts → engine-CJRUHXgf.d.ts} +3 -3
- package/dist/gzip-F4HMIEEQ.mjs +1 -0
- package/dist/import-DX55PN4G.mjs +41 -0
- package/dist/{index-DsEurhSl.d.ts → index-MsF7e5hL.d.ts} +2 -2
- package/dist/index.browser.mjs +7 -4
- package/dist/index.d.ts +542 -8
- package/dist/index.mjs +29 -32
- package/dist/index.react-native.mjs +19 -0
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/filesystem.mjs +1 -1
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/{long-query-thread-4SW7RWDE.mjs → long-query-thread-SCUE62TO.mjs} +23 -25
- package/dist/{module-DXSJ5LT2.mjs → module-HW6IXUM6.mjs} +603 -112
- package/dist/module-V5K4ZP23.mjs +45 -0
- package/dist/{paged-partition-archive-HFP45PLU.mjs → paged-partition-archive-FDIIWZNR.mjs} +42 -41
- package/dist/partial-words.mjs +7 -9
- package/dist/pattern.mjs +4 -6
- package/dist/persistence/durability/checkpoint-worker.d.ts +2 -2
- package/dist/persistence/durability/checkpoint-worker.mjs +36 -39
- package/dist/{phrase-module-5QHBD2VJ.mjs → phrase-module-OUQIRUQU.mjs} +1 -1
- package/dist/pool-UPV5PVPY.mjs +298 -0
- package/dist/react-native/chunks/analysis-change-HGW3L6NY.mjs +893 -0
- package/dist/react-native/chunks/analysis-change-entry-BNRU6STO.mjs +1 -0
- package/dist/react-native/chunks/chunk-2J2727V4.mjs +495 -0
- package/dist/react-native/chunks/chunk-3CTWSQRW.mjs +1251 -0
- package/dist/react-native/chunks/chunk-5FV4ZEVA.mjs +2619 -0
- package/dist/react-native/chunks/chunk-7VWQLEFV.mjs +642 -0
- package/dist/react-native/chunks/chunk-AAAETEJK.mjs +27 -0
- package/dist/react-native/chunks/chunk-AM7RSBPF.mjs +32 -0
- package/dist/react-native/chunks/chunk-B6OD63Z3.mjs +997 -0
- package/dist/react-native/chunks/chunk-BRNAVOKP.mjs +177 -0
- package/dist/react-native/chunks/chunk-DKJTZ625.mjs +207 -0
- package/dist/react-native/chunks/chunk-FKGG4UOF.mjs +177 -0
- package/dist/{browser/chunk-6RHTAVZX.mjs → react-native/chunks/chunk-GV5KFQ6M.mjs} +38 -15
- package/dist/react-native/chunks/chunk-HURV3ASY.mjs +4416 -0
- package/dist/react-native/chunks/chunk-IO2SMUQD.mjs +10 -0
- package/dist/react-native/chunks/chunk-JV6VQY2S.mjs +17 -0
- package/dist/react-native/chunks/chunk-KUJOBRKS.mjs +217 -0
- package/dist/react-native/chunks/chunk-KWRW5U65.mjs +226 -0
- package/dist/react-native/chunks/chunk-L4M7QJNP.mjs +110 -0
- package/dist/react-native/chunks/chunk-LQ6Q4L5B.mjs +360 -0
- package/dist/react-native/chunks/chunk-LQAKO5QV.mjs +523 -0
- package/dist/react-native/chunks/chunk-LRGWK367.mjs +11 -0
- package/dist/react-native/chunks/chunk-LVIKKAA6.mjs +93 -0
- package/dist/react-native/chunks/chunk-NFGBOI46.mjs +14 -0
- package/dist/react-native/chunks/chunk-NNE4VDMM.mjs +8 -0
- package/dist/react-native/chunks/chunk-PPEPTUVV.mjs +56 -0
- package/dist/react-native/chunks/chunk-PSWKQVVT.mjs +9 -0
- package/dist/{chunk-KGOXHLLZ.mjs → react-native/chunks/chunk-PU55IOG4.mjs} +228 -11
- package/dist/react-native/chunks/chunk-QC4ZRBSX.mjs +270 -0
- package/dist/react-native/chunks/chunk-R4EEMYM6.mjs +21 -0
- package/dist/react-native/chunks/chunk-R4OPUZQ5.mjs +86 -0
- package/dist/react-native/chunks/chunk-SLGIAD6B.mjs +2634 -0
- package/dist/react-native/chunks/chunk-TJMSKBEM.mjs +25 -0
- package/dist/react-native/chunks/chunk-TLYD7IJ2.mjs +23 -0
- package/dist/react-native/chunks/chunk-UFNCLEQM.mjs +73 -0
- package/dist/react-native/chunks/chunk-YH7W556M.mjs +179 -0
- package/dist/react-native/chunks/chunk-YJSMEKRE.mjs +22385 -0
- package/dist/react-native/chunks/chunk-ZCKNBPQ4.mjs +79 -0
- package/dist/react-native/chunks/cold-module-TSFWLYWC.mjs +755 -0
- package/dist/react-native/chunks/durability-wiring-PZR6KOQK.mjs +4509 -0
- package/dist/react-native/chunks/gzip.react-native-7JWCLVOB.mjs +3 -0
- package/dist/react-native/chunks/import-VTODLPLO.mjs +22 -0
- package/dist/{browser/module-BVP4TKZU.mjs → react-native/chunks/module-JBBH6PZH.mjs} +671 -146
- package/dist/react-native/chunks/module-VEK2KCKU.mjs +25 -0
- package/dist/react-native/chunks/phrase-module-76UAPPSG.mjs +329 -0
- package/dist/react-native/chunks/pool-CD4ANYUI.mjs +296 -0
- package/dist/react-native/chunks/release-D7ZTIANM.mjs +33 -0
- package/dist/react-native/chunks/replace-IMZUVUOE.mjs +57 -0
- package/dist/{browser/restore-queue-ONYNYUDE.mjs → react-native/chunks/restore-queue-OI5EH7R3.mjs} +2 -2
- package/dist/react-native/chunks/runtime-3MCDLJAF.mjs +559 -0
- package/dist/react-native/chunks/snapshot-AUZMEV36.mjs +1205 -0
- package/dist/react-native/chunks/write-DDC2QBRJ.mjs +197 -0
- package/dist/{chunk-DQNKVOJ2.mjs → react-native/partial-words.mjs} +13 -228
- package/dist/react-native/pattern.mjs +2442 -0
- package/dist/react-native/synonyms.mjs +460 -0
- package/dist/react.d.ts +11 -11
- package/dist/react.mjs +11 -0
- package/dist/{rerank-KTLC3E6N.mjs → rerank-3W54N6P2.mjs} +4 -4
- package/dist/rerankers/http.d.ts +1 -1
- package/dist/rerankers/http.mjs +2 -2
- package/dist/restore-queue-BQWWNNQI.mjs +41 -0
- package/dist/{runtime-DYV75DCB.mjs → runtime-L2DZYY6N.mjs} +5 -5
- package/dist/{schema-B-Runv0n.d.ts → schema-D33CyXCy.d.ts} +1 -1
- package/dist/server.d.ts +24 -12
- package/dist/server.mjs +159 -38
- package/dist/{snapshot-CGM65VCD.mjs → snapshot-EHXTOTW5.mjs} +47 -50
- package/dist/synonyms.mjs +3 -4
- package/dist/{tasks-CjRJRGTb.d.ts → tasks-C4ElXr4P.d.ts} +59 -7
- package/dist/thread-I7DVHHW7.mjs +31 -0
- package/dist/vector/search-worker.d.ts +2 -2
- package/dist/vector/search-worker.mjs +8 -7
- package/dist/workers/entry.mjs +9 -9
- package/dist/{write-2DZPEQL2.mjs → write-SDJXXQ2G.mjs} +36 -39
- package/openapi.json +349 -2
- package/package.json +108 -8
- package/dist/analysis-change-HQUT2Z3I.mjs +0 -43
- package/dist/browser/import-TLB2A5LJ.mjs +0 -9
- package/dist/chunk-5WYVUPGD.mjs +0 -427
- package/dist/chunk-AV4IJKD2.mjs +0 -35
- package/dist/chunk-GES7U2PM.mjs +0 -68
- package/dist/chunk-N37VMC62.mjs +0 -18
- package/dist/chunk-WNBRW4Q2.mjs +0 -128
- package/dist/chunk-WQBCBKY3.mjs +0 -8
- package/dist/chunk-ZATRDAYU.mjs +0 -160
- package/dist/direct-executor-7XOQ7VQP.mjs +0 -28
- package/dist/import-OOBUW3RR.mjs +0 -44
- package/dist/module-IYPLWHGC.mjs +0 -48
- package/dist/thread-KGNAIKPD.mjs +0 -33
- /package/dist/{chunk-22YPZVMG.mjs → chunk-ZXNQEW43.mjs} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/rerank/constants.ts
|
|
2
|
+
var DEFAULT_RERANK_TIMEOUT_MS = 3e4;
|
|
3
|
+
var MIN_RERANK_TIMEOUT_MS = 1;
|
|
4
|
+
var MAX_RERANK_TIMEOUT_MS = 2147483647;
|
|
5
|
+
var DEFAULT_MAX_RERANK_WINDOW = 100;
|
|
6
|
+
var MIN_RERANK_WINDOW = 1;
|
|
7
|
+
var MAX_RERANK_WINDOW = 1e3;
|
|
8
|
+
var DEFAULT_RERANK_WINDOW = 100;
|
|
9
|
+
|
|
10
|
+
export { DEFAULT_MAX_RERANK_WINDOW, DEFAULT_RERANK_TIMEOUT_MS, DEFAULT_RERANK_WINDOW, MAX_RERANK_TIMEOUT_MS, MAX_RERANK_WINDOW, MIN_RERANK_TIMEOUT_MS, MIN_RERANK_WINDOW };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/core/partition/constants.ts
|
|
2
|
+
var TARGET_BLOCK_ENTRIES = 128;
|
|
3
|
+
var PRUNING_REJECTION_SLACK = 1e-12;
|
|
4
|
+
var SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY = 1024;
|
|
5
|
+
var SEGMENT_TOKEN_TABLE_START = 1 << 12;
|
|
6
|
+
var PHRASE_ROWS_START = 16;
|
|
7
|
+
var PHRASE_SORT_RADIX_BITS = 11;
|
|
8
|
+
var PHRASE_SORT_CLOCK_ROWS = 65536;
|
|
9
|
+
var SEGMENT_POSTING_LOG_START = 1 << 14;
|
|
10
|
+
var SEGMENT_POSITION_POOL_START = 1 << 16;
|
|
11
|
+
var SEGMENT_FIELD_SCRATCH_START = 1 << 10;
|
|
12
|
+
var LOOKUP_KEY_SCRATCH_BYTES = 4096;
|
|
13
|
+
var FROZEN_REMOVAL_INDEX_MAX_PROCESS_FRACTION = 0.9;
|
|
14
|
+
var SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD = 1024;
|
|
15
|
+
var SORT_COLUMN_REBUILD_FRACTION_SHIFT = 2;
|
|
16
|
+
|
|
17
|
+
export { FROZEN_REMOVAL_INDEX_MAX_PROCESS_FRACTION, LOOKUP_KEY_SCRATCH_BYTES, PHRASE_ROWS_START, PHRASE_SORT_CLOCK_ROWS, PHRASE_SORT_RADIX_BITS, PRUNING_REJECTION_SLACK, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY, SEGMENT_FIELD_SCRATCH_START, SEGMENT_POSITION_POOL_START, SEGMENT_POSTING_LOG_START, SEGMENT_TOKEN_TABLE_START, SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD, SORT_COLUMN_REBUILD_FRACTION_SHIFT, TARGET_BLOCK_ENTRIES };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { chunksOf, restoredConfigFields, restoredEmbedding } from './chunk-QC4ZRBSX.mjs';
|
|
2
|
+
import { untagDocumentLine } from './chunk-BRNAVOKP.mjs';
|
|
3
|
+
import { requireConfigurationShape } from './chunk-YJSMEKRE.mjs';
|
|
4
|
+
import { turnsAreBudgeted, turnIsSpent, yieldTurn } from './chunk-LQAKO5QV.mjs';
|
|
5
|
+
import { MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, MAX_IMPORT_REFUSALS_REPORTED } from './chunk-AM7RSBPF.mjs';
|
|
6
|
+
import { flattenSchema } from './chunk-PU55IOG4.mjs';
|
|
7
|
+
import { NarsilError, ErrorCodes } from './chunk-YH7W556M.mjs';
|
|
8
|
+
|
|
9
|
+
// src/engine/export/lines.ts
|
|
10
|
+
var NEWLINE = 10;
|
|
11
|
+
function joined(parts, total) {
|
|
12
|
+
if (parts.length === 1) return parts[0];
|
|
13
|
+
const bytes = new Uint8Array(total);
|
|
14
|
+
let offset = 0;
|
|
15
|
+
for (const part of parts) {
|
|
16
|
+
bytes.set(part, offset);
|
|
17
|
+
offset += part.byteLength;
|
|
18
|
+
}
|
|
19
|
+
return bytes;
|
|
20
|
+
}
|
|
21
|
+
async function* exportLines(source, maxLineBytes) {
|
|
22
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
23
|
+
let parts = [];
|
|
24
|
+
let pending = 0;
|
|
25
|
+
let overflowing = false;
|
|
26
|
+
let line = 0;
|
|
27
|
+
const finishLine = () => {
|
|
28
|
+
line += 1;
|
|
29
|
+
if (overflowing) {
|
|
30
|
+
overflowing = false;
|
|
31
|
+
parts = [];
|
|
32
|
+
pending = 0;
|
|
33
|
+
return { line, refused: "too-long" };
|
|
34
|
+
}
|
|
35
|
+
const bytes = joined(parts, pending);
|
|
36
|
+
parts = [];
|
|
37
|
+
pending = 0;
|
|
38
|
+
try {
|
|
39
|
+
return { line, text: decoder.decode(bytes) };
|
|
40
|
+
} catch {
|
|
41
|
+
return { line, refused: "not-utf8" };
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
for await (const chunk of chunksOf(source)) {
|
|
45
|
+
let start = 0;
|
|
46
|
+
for (; ; ) {
|
|
47
|
+
const newline = chunk.indexOf(NEWLINE, start);
|
|
48
|
+
const end = newline < 0 ? chunk.byteLength : newline;
|
|
49
|
+
const piece = chunk.subarray(start, end);
|
|
50
|
+
if (!overflowing && pending + piece.byteLength <= maxLineBytes) {
|
|
51
|
+
if (piece.byteLength > 0) parts.push(piece.slice());
|
|
52
|
+
pending += piece.byteLength;
|
|
53
|
+
} else {
|
|
54
|
+
overflowing = true;
|
|
55
|
+
parts = [];
|
|
56
|
+
}
|
|
57
|
+
if (newline < 0) break;
|
|
58
|
+
yield finishLine();
|
|
59
|
+
start = newline + 1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (pending > 0 || overflowing) yield finishLine();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/engine/export/import.ts
|
|
66
|
+
var DOCUMENT_EXPORT_FORMAT = "narsil-export";
|
|
67
|
+
var DOCUMENT_EXPORT_VERSION = 1;
|
|
68
|
+
function invalidHeader(message) {
|
|
69
|
+
throw new NarsilError(ErrorCodes.CONFIG_INVALID, `The document export header ${message}`);
|
|
70
|
+
}
|
|
71
|
+
function isRecord(value) {
|
|
72
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
73
|
+
}
|
|
74
|
+
function configOfHeader(line) {
|
|
75
|
+
if (line === void 0) invalidHeader("is missing");
|
|
76
|
+
if (!("text" in line)) {
|
|
77
|
+
invalidHeader(
|
|
78
|
+
line.refused === "too-long" ? `passes the line limit of ${MAX_EXPORT_LINE_BYTES} bytes` : "is not UTF-8"
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
let raw;
|
|
82
|
+
try {
|
|
83
|
+
raw = JSON.parse(line.text);
|
|
84
|
+
} catch {
|
|
85
|
+
invalidHeader("is not JSON");
|
|
86
|
+
}
|
|
87
|
+
if (!isRecord(raw) || raw.format !== DOCUMENT_EXPORT_FORMAT || raw.version !== DOCUMENT_EXPORT_VERSION) {
|
|
88
|
+
invalidHeader(`must name format "${DOCUMENT_EXPORT_FORMAT}" and version ${DOCUMENT_EXPORT_VERSION}`);
|
|
89
|
+
}
|
|
90
|
+
const configuration = requireConfigurationShape(raw.index, "document export header");
|
|
91
|
+
const fields = restoredConfigFields(configuration, (message) => invalidHeader(message));
|
|
92
|
+
const embedding = restoredEmbedding(configuration.embedding, (message) => invalidHeader(message));
|
|
93
|
+
return {
|
|
94
|
+
schema: configuration.schema,
|
|
95
|
+
language: configuration.language,
|
|
96
|
+
...fields,
|
|
97
|
+
...embedding === void 0 ? {} : {
|
|
98
|
+
embedding: {
|
|
99
|
+
fields: embedding.fields,
|
|
100
|
+
...embedding.adapter === void 0 ? {} : { adapter: embedding.adapter }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async function prepareIndex(engine, indexName, config) {
|
|
106
|
+
if (!engine.listIndexes().some((index) => index.name === indexName)) {
|
|
107
|
+
await engine.createIndex(indexName, config);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const existing = flattenSchema(engine.getStats(indexName).schema);
|
|
111
|
+
const exported = flattenSchema(config.schema);
|
|
112
|
+
const fields = /* @__PURE__ */ new Set([...Object.keys(existing), ...Object.keys(exported)]);
|
|
113
|
+
for (const field of fields) {
|
|
114
|
+
if (existing[field] === exported[field]) continue;
|
|
115
|
+
throw new NarsilError(
|
|
116
|
+
ErrorCodes.CONFIG_INVALID,
|
|
117
|
+
`Index "${indexName}" gives field "${field}" another type than the export does, so the import cannot write into it`,
|
|
118
|
+
{ indexName, field }
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function highestReportedAt(refused) {
|
|
123
|
+
let highest = 0;
|
|
124
|
+
for (let at = 1; at < refused.length; at++) {
|
|
125
|
+
if (refused[at].line > refused[highest].line) highest = at;
|
|
126
|
+
}
|
|
127
|
+
return highest;
|
|
128
|
+
}
|
|
129
|
+
function refuse(state, line, code, message) {
|
|
130
|
+
state.result.refusedCount += 1;
|
|
131
|
+
const refused = state.result.refused;
|
|
132
|
+
if (refused.length < MAX_IMPORT_REFUSALS_REPORTED) {
|
|
133
|
+
refused.push({ line, code, message });
|
|
134
|
+
if (refused.length === MAX_IMPORT_REFUSALS_REPORTED) state.highestReported = highestReportedAt(refused);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (line >= refused[state.highestReported].line) return;
|
|
138
|
+
refused[state.highestReported] = { line, code, message };
|
|
139
|
+
state.highestReported = highestReportedAt(refused);
|
|
140
|
+
}
|
|
141
|
+
async function flush(state) {
|
|
142
|
+
if (state.batch.length === 0) return;
|
|
143
|
+
const batch = state.batch;
|
|
144
|
+
state.batch = [];
|
|
145
|
+
state.batchIds = /* @__PURE__ */ new Set();
|
|
146
|
+
const lineOf = new Map(batch.map((entry) => [entry.docId, entry.line]));
|
|
147
|
+
const inserts = [];
|
|
148
|
+
const updates = [];
|
|
149
|
+
for (const entry of batch) {
|
|
150
|
+
if (await state.engine.has(state.indexName, entry.docId))
|
|
151
|
+
updates.push({ docId: entry.docId, document: entry.document });
|
|
152
|
+
else inserts.push(entry.document);
|
|
153
|
+
}
|
|
154
|
+
for (const outcome of [
|
|
155
|
+
inserts.length === 0 ? null : await state.engine.insertBatch(state.indexName, inserts, { skipClone: true }),
|
|
156
|
+
updates.length === 0 ? null : await state.engine.updateBatch(state.indexName, updates)
|
|
157
|
+
]) {
|
|
158
|
+
if (outcome === null) continue;
|
|
159
|
+
state.result.imported += outcome.succeeded.length;
|
|
160
|
+
for (const failure of outcome.failed) {
|
|
161
|
+
const code = failure.error instanceof NarsilError ? failure.error.code : ErrorCodes.DOC_VALIDATION_FAILED;
|
|
162
|
+
refuse(state, lineOf.get(failure.docId) ?? 0, code, failure.error.message);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function takeLine(state, entry) {
|
|
167
|
+
if (!("text" in entry)) {
|
|
168
|
+
const message = entry.refused === "too-long" ? `The line passes the limit of ${MAX_EXPORT_LINE_BYTES} bytes` : "The line is not UTF-8";
|
|
169
|
+
refuse(state, entry.line, ErrorCodes.DOC_VALIDATION_FAILED, message);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (entry.text.length === 0) return;
|
|
173
|
+
let document;
|
|
174
|
+
try {
|
|
175
|
+
document = JSON.parse(entry.text);
|
|
176
|
+
} catch {
|
|
177
|
+
refuse(state, entry.line, ErrorCodes.DOC_VALIDATION_FAILED, "The line is not JSON");
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (!isRecord(document) || typeof document.id !== "string" || document.id.length === 0) {
|
|
181
|
+
refuse(state, entry.line, ErrorCodes.DOC_VALIDATION_FAILED, "The line holds no document with a string id");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
untagDocumentLine(entry.text, document);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
if (!(error instanceof NarsilError)) throw error;
|
|
188
|
+
refuse(state, entry.line, error.code, error.message);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (state.batchIds.has(document.id)) await flush(state);
|
|
192
|
+
state.batch.push({ line: entry.line, docId: document.id, document });
|
|
193
|
+
state.batchIds.add(document.id);
|
|
194
|
+
if (state.batch.length >= IMPORT_BATCH_DOCUMENTS) await flush(state);
|
|
195
|
+
}
|
|
196
|
+
async function readDocumentExport(engine, indexName, source) {
|
|
197
|
+
const lines = exportLines(source, MAX_EXPORT_LINE_BYTES);
|
|
198
|
+
const header = await lines.next();
|
|
199
|
+
await prepareIndex(engine, indexName, configOfHeader(header.done === true ? void 0 : header.value));
|
|
200
|
+
const state = {
|
|
201
|
+
engine,
|
|
202
|
+
indexName,
|
|
203
|
+
batch: [],
|
|
204
|
+
batchIds: /* @__PURE__ */ new Set(),
|
|
205
|
+
result: { imported: 0, refusedCount: 0, refused: [] },
|
|
206
|
+
highestReported: 0
|
|
207
|
+
};
|
|
208
|
+
for await (const entry of lines) {
|
|
209
|
+
await takeLine(state, entry);
|
|
210
|
+
if (turnsAreBudgeted && turnIsSpent()) await yieldTurn();
|
|
211
|
+
}
|
|
212
|
+
await flush(state);
|
|
213
|
+
state.result.refused.sort((a, b) => a.line - b.line);
|
|
214
|
+
return state.result;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export { DOCUMENT_EXPORT_FORMAT, DOCUMENT_EXPORT_VERSION, readDocumentExport };
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { compareCodePoints } from './chunk-PPEPTUVV.mjs';
|
|
2
|
+
|
|
3
|
+
// src/core/ordering/fold-table.ts
|
|
4
|
+
var SINGLE_FOLDS = "1t,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;2j,lj;b,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;2,w;1,w;1,w;1,w;1,w;1,w;1,w;y,1;2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-tzk;1,-tzk;1,-tzk;1,-tzk;1,-tzk;1,-tzk;ggy,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;xy,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;3t,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;1,14;4d,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;2,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;1,13;2,13;1,13;1,13;1,13;1,13;1,13;1,13;2,13;1,13;1d7,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;1,1s;4e,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;27v,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;1,w;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qh;1,q6,qh;2,qf,n6;1,qf,n6,qh;5,qf,qh;6,qh,lk,lc;1,qh,lk,ld;3,qh,n6;1,qh,lk,n6;b,qt,lk,lc;1,qt,lk,ld;1,qp,lv;2,qt,n6;1,qt,lk,n6;b,67w,qh;1,qx,qh;1,r2,qh;2,qx,n6;1,qx,n6,qh;5,qx,qh;179g,2u,2u;1,2u,2x;1,2u,30;1,2u,2u,2x;1,2u,2u,30;1,37,38;1,37,38;d,12s,12u;1,12s,12d;1,12s,12j;1,132,12u;1,12s,12l;";
|
|
6
|
+
var singleTable = null;
|
|
7
|
+
var multiTable = null;
|
|
8
|
+
function singleFoldTable() {
|
|
9
|
+
if (singleTable === null) {
|
|
10
|
+
singleTable = /* @__PURE__ */ new Map();
|
|
11
|
+
let source = 0;
|
|
12
|
+
for (const entry of SINGLE_FOLDS.split(";")) {
|
|
13
|
+
if (entry.length === 0) continue;
|
|
14
|
+
const [delta, offset] = entry.split(",");
|
|
15
|
+
source += Number.parseInt(delta, 36);
|
|
16
|
+
singleTable.set(source, source + Number.parseInt(offset, 36));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return singleTable;
|
|
20
|
+
}
|
|
21
|
+
function multiFoldTable() {
|
|
22
|
+
if (multiTable === null) {
|
|
23
|
+
multiTable = /* @__PURE__ */ new Map();
|
|
24
|
+
let source = 0;
|
|
25
|
+
for (const entry of MULTI_FOLDS.split(";")) {
|
|
26
|
+
if (entry.length === 0) continue;
|
|
27
|
+
const parts = entry.split(",");
|
|
28
|
+
source += Number.parseInt(parts[0], 36);
|
|
29
|
+
multiTable.set(
|
|
30
|
+
source,
|
|
31
|
+
parts.slice(1).map((cp) => Number.parseInt(cp, 36))
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return multiTable;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/core/ordering/fold-compare.ts
|
|
39
|
+
var EXHAUSTED = -1;
|
|
40
|
+
function foldOf(codePoint, single, multi) {
|
|
41
|
+
if (codePoint < 128) return codePoint >= 65 && codePoint <= 90 ? codePoint + 32 : codePoint;
|
|
42
|
+
return single.get(codePoint) ?? multi.get(codePoint) ?? codePoint;
|
|
43
|
+
}
|
|
44
|
+
function nextFoldedCodePoint(text, cursor, single, multi) {
|
|
45
|
+
if (cursor.pending !== null) {
|
|
46
|
+
const cp2 = cursor.pending[cursor.pendingIndex];
|
|
47
|
+
cursor.pendingIndex++;
|
|
48
|
+
if (cursor.pendingIndex === cursor.pending.length) {
|
|
49
|
+
cursor.pending = null;
|
|
50
|
+
cursor.pendingIndex = 0;
|
|
51
|
+
}
|
|
52
|
+
return cp2;
|
|
53
|
+
}
|
|
54
|
+
if (cursor.index >= text.length) return EXHAUSTED;
|
|
55
|
+
let cp = text.charCodeAt(cursor.index);
|
|
56
|
+
cursor.index++;
|
|
57
|
+
if (cp >= 55296 && cp < 56320 && cursor.index < text.length) {
|
|
58
|
+
const low = text.charCodeAt(cursor.index);
|
|
59
|
+
if (low >= 56320 && low < 57344) {
|
|
60
|
+
cp = 65536 + (cp - 55296 << 10) + (low - 56320);
|
|
61
|
+
cursor.index++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const folded = foldOf(cp, single, multi);
|
|
65
|
+
if (typeof folded === "number") return folded;
|
|
66
|
+
if (folded.length > 1) {
|
|
67
|
+
cursor.pending = folded;
|
|
68
|
+
cursor.pendingIndex = 1;
|
|
69
|
+
}
|
|
70
|
+
return folded[0];
|
|
71
|
+
}
|
|
72
|
+
function compareCaseFolded(a, b) {
|
|
73
|
+
const shorter = a.length < b.length ? a.length : b.length;
|
|
74
|
+
let start = 0;
|
|
75
|
+
while (start < shorter && a.charCodeAt(start) === b.charCodeAt(start)) start++;
|
|
76
|
+
if (start === a.length && start === b.length) return 0;
|
|
77
|
+
if (start > 0) {
|
|
78
|
+
const previous = a.charCodeAt(start - 1);
|
|
79
|
+
if (previous >= 55296 && previous < 56320) start--;
|
|
80
|
+
}
|
|
81
|
+
const single = singleFoldTable();
|
|
82
|
+
const multi = multiFoldTable();
|
|
83
|
+
const aCursor = { index: start, pending: null, pendingIndex: 0 };
|
|
84
|
+
const bCursor = { index: start, pending: null, pendingIndex: 0 };
|
|
85
|
+
for (; ; ) {
|
|
86
|
+
const aCp = nextFoldedCodePoint(a, aCursor, single, multi);
|
|
87
|
+
const bCp = nextFoldedCodePoint(b, bCursor, single, multi);
|
|
88
|
+
if (aCp !== bCp) return aCp - bCp;
|
|
89
|
+
if (aCp === EXHAUSTED) return 0;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function compareSortStrings(a, b) {
|
|
93
|
+
const folded = compareCaseFolded(a, b);
|
|
94
|
+
if (folded !== 0) return folded;
|
|
95
|
+
return compareCodePoints(a, b);
|
|
96
|
+
}
|
|
97
|
+
function appendFoldedCodePoint(codePoint, out) {
|
|
98
|
+
const folded = foldOf(codePoint, singleFoldTable(), multiFoldTable());
|
|
99
|
+
if (typeof folded === "number") {
|
|
100
|
+
out.push(folded);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
for (const foldedCodePoint of folded) out.push(foldedCodePoint);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/core/ordering/constants.ts
|
|
107
|
+
var SORT_VALUE_MAX_CODE_POINTS = 512;
|
|
108
|
+
|
|
109
|
+
// src/core/ordering/sort-values.ts
|
|
110
|
+
var SORT_MODES = ["min", "max", "avg", "median"];
|
|
111
|
+
function isSortMode(value) {
|
|
112
|
+
return value === "min" || value === "max" || value === "avg" || value === "median";
|
|
113
|
+
}
|
|
114
|
+
function defaultSortMode(direction) {
|
|
115
|
+
return direction === "desc" ? "max" : "min";
|
|
116
|
+
}
|
|
117
|
+
function sortModeOf(entry) {
|
|
118
|
+
return entry.mode ?? defaultSortMode(entry.direction);
|
|
119
|
+
}
|
|
120
|
+
function truncateSortString(value) {
|
|
121
|
+
if (value.length <= SORT_VALUE_MAX_CODE_POINTS) return value;
|
|
122
|
+
let index = 0;
|
|
123
|
+
let counted = 0;
|
|
124
|
+
while (index < value.length && counted < SORT_VALUE_MAX_CODE_POINTS) {
|
|
125
|
+
const unit = value.charCodeAt(index);
|
|
126
|
+
if (unit >= 55296 && unit < 56320 && index + 1 < value.length) {
|
|
127
|
+
const low = value.charCodeAt(index + 1);
|
|
128
|
+
if (low >= 56320 && low < 57344) index++;
|
|
129
|
+
}
|
|
130
|
+
index++;
|
|
131
|
+
counted++;
|
|
132
|
+
}
|
|
133
|
+
return value.slice(0, index);
|
|
134
|
+
}
|
|
135
|
+
function toComparableSortValue(value) {
|
|
136
|
+
if (typeof value === "string") return truncateSortString(value);
|
|
137
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
138
|
+
if (typeof value === "boolean") return value;
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
function numericReduction(values, mode) {
|
|
142
|
+
const numbers = [];
|
|
143
|
+
for (const element of values) {
|
|
144
|
+
if (typeof element === "number" && Number.isFinite(element)) numbers.push(element);
|
|
145
|
+
}
|
|
146
|
+
if (numbers.length === 0) return null;
|
|
147
|
+
if (mode === "avg") {
|
|
148
|
+
let mean = 0;
|
|
149
|
+
for (let index = 0; index < numbers.length; index++) {
|
|
150
|
+
mean += (numbers[index] - mean) / (index + 1);
|
|
151
|
+
}
|
|
152
|
+
return mean;
|
|
153
|
+
}
|
|
154
|
+
numbers.sort((a, b) => a - b);
|
|
155
|
+
const middle = numbers.length >> 1;
|
|
156
|
+
if (numbers.length % 2 === 1) return numbers[middle];
|
|
157
|
+
return numbers[middle - 1] / 2 + numbers[middle] / 2;
|
|
158
|
+
}
|
|
159
|
+
function toReducedSortValue(value, mode) {
|
|
160
|
+
if (!Array.isArray(value)) return toComparableSortValue(value);
|
|
161
|
+
if (mode === "avg" || mode === "median") return numericReduction(value, mode);
|
|
162
|
+
let chosen = null;
|
|
163
|
+
for (const element of value) {
|
|
164
|
+
const comparable = toComparableSortValue(element);
|
|
165
|
+
if (comparable === null) continue;
|
|
166
|
+
if (chosen === null) {
|
|
167
|
+
chosen = comparable;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const comparison = comparePresentValues(comparable, chosen);
|
|
171
|
+
if (mode === "min" ? comparison < 0 : comparison > 0) chosen = comparable;
|
|
172
|
+
}
|
|
173
|
+
return chosen;
|
|
174
|
+
}
|
|
175
|
+
function readSortField(document, path) {
|
|
176
|
+
const segments = path.split(".");
|
|
177
|
+
let current = document;
|
|
178
|
+
for (const segment of segments) {
|
|
179
|
+
if (current === null || current === void 0 || typeof current !== "object") return void 0;
|
|
180
|
+
if (!Object.hasOwn(current, segment)) return void 0;
|
|
181
|
+
current = current[segment];
|
|
182
|
+
}
|
|
183
|
+
return current;
|
|
184
|
+
}
|
|
185
|
+
function typeRank(value) {
|
|
186
|
+
if (typeof value === "number") return 0;
|
|
187
|
+
if (typeof value === "string") return 1;
|
|
188
|
+
return 2;
|
|
189
|
+
}
|
|
190
|
+
function comparePresentValues(a, b) {
|
|
191
|
+
const rankDifference = typeRank(a) - typeRank(b);
|
|
192
|
+
if (rankDifference !== 0) return rankDifference;
|
|
193
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
194
|
+
if (typeof a === "string" && typeof b === "string") return compareSortStrings(a, b);
|
|
195
|
+
if (a === b) return 0;
|
|
196
|
+
return a ? 1 : -1;
|
|
197
|
+
}
|
|
198
|
+
function compareComparableValues(a, b, direction) {
|
|
199
|
+
if (a === null && b === null) return 0;
|
|
200
|
+
if (a === null) return 1;
|
|
201
|
+
if (b === null) return -1;
|
|
202
|
+
const comparison = comparePresentValues(a, b);
|
|
203
|
+
if (comparison === 0) return 0;
|
|
204
|
+
return direction === "desc" ? -comparison : comparison;
|
|
205
|
+
}
|
|
206
|
+
function compareComparableKeys(aKey, bKey, directions) {
|
|
207
|
+
for (let i = 0; i < directions.length; i++) {
|
|
208
|
+
const comparison = compareComparableValues(aKey[i] ?? null, bKey[i] ?? null, directions[i]);
|
|
209
|
+
if (comparison !== 0) return comparison;
|
|
210
|
+
}
|
|
211
|
+
return 0;
|
|
212
|
+
}
|
|
213
|
+
function compareSortValues(aValues, bValues, directions) {
|
|
214
|
+
for (let i = 0; i < directions.length; i++) {
|
|
215
|
+
const a = toComparableSortValue(aValues[i]);
|
|
216
|
+
const b = toComparableSortValue(bValues[i]);
|
|
217
|
+
if (a === null && b === null) continue;
|
|
218
|
+
if (a === null) return 1;
|
|
219
|
+
if (b === null) return -1;
|
|
220
|
+
const comparison = comparePresentValues(a, b);
|
|
221
|
+
if (comparison !== 0) return directions[i] === "desc" ? -comparison : comparison;
|
|
222
|
+
}
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export { SORT_MODES, SORT_VALUE_MAX_CODE_POINTS, appendFoldedCodePoint, compareComparableKeys, compareComparableValues, compareSortValues, defaultSortMode, isSortMode, readSortField, singleFoldTable, sortModeOf, toComparableSortValue, toReducedSortValue, truncateSortString };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// src/core/hash.ts
|
|
2
|
+
var FNV_OFFSET_BASIS = 2166136261;
|
|
3
|
+
var FNV_PRIME = 16777619;
|
|
4
|
+
var encoder = new TextEncoder();
|
|
5
|
+
function fnv1aBytes(bytes) {
|
|
6
|
+
return fnv1aContinue(FNV_OFFSET_BASIS, bytes, bytes.length) >>> 0;
|
|
7
|
+
}
|
|
8
|
+
function fnv1aContinue(start, bytes, length) {
|
|
9
|
+
let hash = start;
|
|
10
|
+
for (let i = 0; i < length; i++) {
|
|
11
|
+
hash = Math.imul(hash ^ bytes[i], FNV_PRIME);
|
|
12
|
+
}
|
|
13
|
+
return hash;
|
|
14
|
+
}
|
|
15
|
+
var scratchNumber = new Float64Array(1);
|
|
16
|
+
var scratchBytes = new Uint8Array(scratchNumber.buffer);
|
|
17
|
+
var HOST_IS_LITTLE_ENDIAN = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
|
|
18
|
+
function fnv1aContinueTaggedNumbers(start, tag, numbers) {
|
|
19
|
+
let hash = start;
|
|
20
|
+
const b = scratchBytes;
|
|
21
|
+
for (let i = 0; i < numbers.length; i++) {
|
|
22
|
+
scratchNumber[0] = Math.fround(numbers[i]);
|
|
23
|
+
hash = Math.imul(hash ^ tag, FNV_PRIME);
|
|
24
|
+
if (HOST_IS_LITTLE_ENDIAN) {
|
|
25
|
+
hash = Math.imul(hash ^ b[7], FNV_PRIME);
|
|
26
|
+
hash = Math.imul(hash ^ b[6], FNV_PRIME);
|
|
27
|
+
hash = Math.imul(hash ^ b[5], FNV_PRIME);
|
|
28
|
+
hash = Math.imul(hash ^ b[4], FNV_PRIME);
|
|
29
|
+
hash = Math.imul(hash ^ b[3], FNV_PRIME);
|
|
30
|
+
hash = Math.imul(hash ^ b[2], FNV_PRIME);
|
|
31
|
+
hash = Math.imul(hash ^ b[1], FNV_PRIME);
|
|
32
|
+
hash = Math.imul(hash ^ b[0], FNV_PRIME);
|
|
33
|
+
} else {
|
|
34
|
+
for (let at = 0; at < 8; at++) hash = Math.imul(hash ^ b[at], FNV_PRIME);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return hash;
|
|
38
|
+
}
|
|
39
|
+
function fnv1a(input) {
|
|
40
|
+
return fnv1aBytes(encoder.encode(input));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/workers/constants.ts
|
|
44
|
+
var WORKER_YOUNG_GENERATION_MB = 24;
|
|
45
|
+
var MIN_WORKER_COUNT = 2;
|
|
46
|
+
var MAX_WORKER_COUNT = 8;
|
|
47
|
+
var FALLBACK_CPU_COUNT = 4;
|
|
48
|
+
var MIN_CORES_FOR_SEVERAL_REQUEST_THREADS = 3;
|
|
49
|
+
var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
50
|
+
var SHUTDOWN_TIMEOUT_MS = 5e3;
|
|
51
|
+
|
|
52
|
+
// src/vector/constants.ts
|
|
53
|
+
var WASM_PAGE_BYTES = 65536;
|
|
54
|
+
var MAX_WASM_PAGES = 65536;
|
|
55
|
+
var VECTOR_STORE_INITIAL_CAPACITY = 16;
|
|
56
|
+
var VECTOR_BLOCK_INITIAL_SLOTS = 256;
|
|
57
|
+
var DISK_STORAGE_BLOCK_BYTES = 67108864;
|
|
58
|
+
var UNPLACED_FLAG_CHUNK_ORDINALS = 1024;
|
|
59
|
+
var VECTOR_SCRATCH_SLOTS = 64;
|
|
60
|
+
var SCRATCH_SLOTS_PER_THREAD_POOL = 31;
|
|
61
|
+
var NATIVE_THREAD_SEARCH_SLOTS = 4;
|
|
62
|
+
var NATIVE_THREAD_SCAN_CHUNK_ORDINALS = 16384;
|
|
63
|
+
var MAX_VECTOR_ORDINALS_ON_A_PHONE = 1048576;
|
|
64
|
+
var MAX_DOC_ID_TABLE_BYTES_ON_A_PHONE = 67108864;
|
|
65
|
+
var VECTOR_BLOCK_BYTES_ON_A_PHONE = 67108864;
|
|
66
|
+
var VECTOR_SEARCH_TIMEOUT_MS = 3e4;
|
|
67
|
+
var VECTOR_SEARCH_LOAD_TIMEOUT_MS = 3e5;
|
|
68
|
+
var VECTOR_INSERT_TIMEOUT_MS = 6e5;
|
|
69
|
+
var NATIVE_ATTACH_RETRY_MS = 1e3;
|
|
70
|
+
var MAX_RENUMBERED_SEARCH_ATTEMPTS = 3;
|
|
71
|
+
var LOCK_SPIN_ITERATIONS = 128;
|
|
72
|
+
var LOCK_WAIT_SLICE_MS = 20;
|
|
73
|
+
var GRAPH_LOCK_WAIT_SLICE_MS = 1;
|
|
74
|
+
var GRAPH_LOCK_WAIT_DEADLINE_MS = 1e4;
|
|
75
|
+
var GRAPH_BUILD_DISPATCH_CHUNK = 64;
|
|
76
|
+
var GRAPH_BUILD_CHUNKS_IN_FLIGHT_PER_WORKER = 2;
|
|
77
|
+
|
|
78
|
+
// src/workers/worker-count.ts
|
|
79
|
+
function detectCpuCount() {
|
|
80
|
+
try {
|
|
81
|
+
if (navigator?.hardwareConcurrency) {
|
|
82
|
+
return navigator.hardwareConcurrency;
|
|
83
|
+
}
|
|
84
|
+
if (typeof process !== "undefined") {
|
|
85
|
+
const ap = process.availableParallelism;
|
|
86
|
+
if (typeof ap === "function") {
|
|
87
|
+
return ap();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
return FALLBACK_CPU_COUNT;
|
|
92
|
+
}
|
|
93
|
+
return FALLBACK_CPU_COUNT;
|
|
94
|
+
}
|
|
95
|
+
function resolveWorkerCount(requested) {
|
|
96
|
+
if (requested !== void 0 && requested > 0) {
|
|
97
|
+
return Math.min(requested, SCRATCH_SLOTS_PER_THREAD_POOL);
|
|
98
|
+
}
|
|
99
|
+
return Math.max(MIN_WORKER_COUNT, Math.min(MAX_WORKER_COUNT, detectCpuCount() - 1));
|
|
100
|
+
}
|
|
101
|
+
function resolveRequestThreadCount(requested) {
|
|
102
|
+
if (detectCpuCount() < MIN_CORES_FOR_SEVERAL_REQUEST_THREADS) return 1;
|
|
103
|
+
return resolveWorkerCount(requested);
|
|
104
|
+
}
|
|
105
|
+
function splitWorkerBudget(total) {
|
|
106
|
+
const keyword = Math.ceil(total / 2);
|
|
107
|
+
return { keyword, vector: total - keyword };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { DEFAULT_REQUEST_TIMEOUT_MS, DISK_STORAGE_BLOCK_BYTES, FNV_OFFSET_BASIS, FNV_PRIME, GRAPH_BUILD_CHUNKS_IN_FLIGHT_PER_WORKER, GRAPH_BUILD_DISPATCH_CHUNK, GRAPH_LOCK_WAIT_DEADLINE_MS, GRAPH_LOCK_WAIT_SLICE_MS, LOCK_SPIN_ITERATIONS, LOCK_WAIT_SLICE_MS, MAX_DOC_ID_TABLE_BYTES_ON_A_PHONE, MAX_RENUMBERED_SEARCH_ATTEMPTS, MAX_VECTOR_ORDINALS_ON_A_PHONE, MAX_WASM_PAGES, NATIVE_ATTACH_RETRY_MS, NATIVE_THREAD_SCAN_CHUNK_ORDINALS, NATIVE_THREAD_SEARCH_SLOTS, SHUTDOWN_TIMEOUT_MS, UNPLACED_FLAG_CHUNK_ORDINALS, VECTOR_BLOCK_BYTES_ON_A_PHONE, VECTOR_BLOCK_INITIAL_SLOTS, VECTOR_INSERT_TIMEOUT_MS, VECTOR_SCRATCH_SLOTS, VECTOR_SEARCH_LOAD_TIMEOUT_MS, VECTOR_SEARCH_TIMEOUT_MS, VECTOR_STORE_INITIAL_CAPACITY, WASM_PAGE_BYTES, WORKER_YOUNG_GENERATION_MB, fnv1a, fnv1aContinue, fnv1aContinueTaggedNumbers, resolveRequestThreadCount, resolveWorkerCount, splitWorkerBudget };
|