@delali/narsil 0.3.1-next.145 → 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.mjs +2 -2
- package/dist/adapters/gcs.mjs +2 -2
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/adapters/s3.mjs +2 -2
- package/dist/analysis-change-ZCJNYBJM.mjs +39 -0
- package/dist/{analysis-change-entry-V4SQQSXQ.mjs → analysis-change-entry-YN3ELL6C.mjs} +1 -1
- package/dist/browser/{analysis-change-QTCQ5ETU.mjs → analysis-change-M65AZQQG.mjs} +8 -5
- package/dist/browser/{analysis-change-entry-KYEQSP3I.mjs → analysis-change-entry-H3YIOLXZ.mjs} +1 -1
- package/dist/browser/{chunk-GP4QLUQM.mjs → chunk-2JABMB4S.mjs} +10 -6
- package/dist/browser/{chunk-5WYWLTM5.mjs → chunk-4DYLCICG.mjs} +2 -2
- package/dist/browser/{chunk-75PMIFQA.mjs → chunk-4RD3AFSB.mjs} +1 -1
- package/dist/browser/{chunk-XWMEGKDC.mjs → chunk-5V74FFZE.mjs} +2 -2
- package/dist/browser/{chunk-PMBSBSCN.mjs → chunk-6OWX3OP2.mjs} +2 -2
- package/dist/browser/chunk-BRWY3JCN.mjs +678 -0
- package/dist/browser/{chunk-ZALEKEUH.mjs → chunk-BVX2MEHA.mjs} +306 -607
- package/dist/browser/{chunk-FXPMF65P.mjs → chunk-D6UFGBF5.mjs} +15 -45
- package/dist/browser/{chunk-QNDWMPV2.mjs → chunk-IAXZAVYL.mjs} +25 -66
- package/dist/browser/chunk-JNOAKDUM.mjs +31 -0
- package/dist/browser/{chunk-BTMRV5MY.mjs → chunk-KAEVGLYN.mjs} +2 -2
- package/dist/browser/{chunk-FHO5N7FD.mjs → chunk-LURXVCHG.mjs} +1 -1
- package/dist/browser/chunk-MPK76GVS.mjs +63 -0
- package/dist/browser/{chunk-6OFS7RUN.mjs → chunk-NVEJJP4R.mjs} +1 -1
- package/dist/browser/{chunk-U77XQJOY.mjs → chunk-ODQP7P3H.mjs} +455 -66
- package/dist/browser/{chunk-IFGTRRPU.mjs → chunk-PIS7ZAP7.mjs} +3 -25
- package/dist/browser/{chunk-XIHLIMFX.mjs → chunk-QMNZFFD3.mjs} +4 -3
- package/dist/browser/{chunk-AOKLYVTT.mjs → chunk-SRL47USS.mjs} +2 -2
- package/dist/browser/chunk-TY7L6OXO.mjs +69 -0
- package/dist/browser/{chunk-LGJ6XMH5.mjs → chunk-W643QV3L.mjs} +6 -5
- package/dist/browser/chunk-WXLBZJMT.mjs +25 -0
- package/dist/browser/{chunk-ZKVDQ5ZH.mjs → chunk-XILIT5MT.mjs} +8 -8
- package/dist/browser/{cold-module-Y2IJAP7S.mjs → cold-module-A5S6JFDN.mjs} +20 -20
- package/dist/browser/{durability-wiring-MLXZ5QQF.mjs → durability-wiring-W5AVV3RF.mjs} +53 -30
- package/dist/browser/gzip-5S7ROJFJ.mjs +1 -0
- package/dist/browser/import-PTT63AGK.mjs +12 -0
- package/dist/browser/{module-5LMDGXQH.mjs → module-CEKA7MQH.mjs} +13 -10
- package/dist/browser/module-X5PGOE47.mjs +4288 -0
- package/dist/browser/{phrase-module-KXNRTWCS.mjs → phrase-module-CNKMUY4U.mjs} +2 -1
- package/dist/browser/pool-DTYSPBMQ.mjs +296 -0
- package/dist/{restore-queue-UAVGBSJG.mjs → browser/restore-queue-DD4LWZK7.mjs} +2 -2
- package/dist/browser/{runtime-ZNEGK33G.mjs → runtime-D2ULZGCN.mjs} +3 -2
- package/dist/browser/{snapshot-2EGS2FYU.mjs → snapshot-DQ6A4PQP.mjs} +18 -14
- package/dist/browser/{write-WMZA6NSF.mjs → write-MAGRAIEH.mjs} +14 -11
- package/dist/{capabilities-CNnzGtqP.d.ts → capabilities-BT-HLDC8.d.ts} +2 -2
- package/dist/{chunk-FRJ5RGX7.mjs → chunk-2HJWQPR6.mjs} +2 -2
- package/dist/{chunk-DKMZ7JFW.mjs → chunk-3BVGJ4JR.mjs} +10 -4
- package/dist/{chunk-QYMAYU7M.mjs → chunk-3HV7M5OJ.mjs} +155 -149
- package/dist/chunk-3MXV3VHR.mjs +46 -0
- package/dist/{chunk-6FOJKNUR.mjs → chunk-3SBJVQLL.mjs} +2 -2
- package/dist/{chunk-PRID7CA6.mjs → chunk-3TVDTACC.mjs} +1 -1
- package/dist/{chunk-RTVAWNUL.mjs → chunk-5WB2A3XU.mjs} +9 -6
- package/dist/{chunk-LWFK3TC2.mjs → chunk-65WCV5JO.mjs} +1 -1
- package/dist/{chunk-G6Q5DEF5.mjs → chunk-6BWLDLS3.mjs} +3 -46
- package/dist/{chunk-W6M4RRAT.mjs → chunk-6C5EX2QR.mjs} +3 -3
- package/dist/{chunk-HOC5JP2H.mjs → chunk-6F6USYII.mjs} +119 -11
- package/dist/{chunk-7523VCM4.mjs → chunk-7HKWO4BJ.mjs} +7 -7
- package/dist/{chunk-ONDEEBTA.mjs → chunk-7N223GWV.mjs} +2 -2
- package/dist/{chunk-UGQULMSU.mjs → chunk-ADBS5XRI.mjs} +10 -10
- package/dist/{chunk-MJTEU2XK.mjs → chunk-AWNHDBKV.mjs} +429 -73
- package/dist/{chunk-2E2ZFOPT.mjs → chunk-B2FTZNNF.mjs} +2 -2
- package/dist/{chunk-NWTEJ2T7.mjs → chunk-B7XIOAMK.mjs} +3 -3
- package/dist/{chunk-W55X2BYN.mjs → chunk-BEZH7VEH.mjs} +1 -1
- package/dist/chunk-BTPGQC6Z.mjs +27 -0
- package/dist/{chunk-KG5N7LE6.mjs → chunk-CYYSZPVV.mjs} +11 -11
- package/dist/{chunk-HTMUGEFU.mjs → chunk-DOY6EG76.mjs} +6 -6
- package/dist/{chunk-UHVTEVF5.mjs → chunk-F22IOCR2.mjs} +10 -6
- package/dist/{chunk-FTQLF5JI.mjs → chunk-IRWP524D.mjs} +1 -1
- package/dist/{chunk-XLAI4OIO.mjs → chunk-IZT3G24Q.mjs} +2 -2
- package/dist/{chunk-SE7MKJVK.mjs → chunk-J7M73VY7.mjs} +1 -1
- package/dist/chunk-KAKQ74LS.mjs +53 -0
- package/dist/{chunk-GVPYMSLO.mjs → chunk-KYVRZAYP.mjs} +1 -1
- package/dist/{chunk-F442VZUL.mjs → chunk-KZ5GQE4Z.mjs} +5 -5
- package/dist/{chunk-WDEWU46C.mjs → chunk-KZQIVGW7.mjs} +2 -2
- package/dist/{chunk-7AJAW6NN.mjs → chunk-L7TIAYPX.mjs} +8 -8
- package/dist/{chunk-GRFXSEFF.mjs → chunk-LDGGR7YT.mjs} +4 -81
- package/dist/{chunk-WMIV7PJ7.mjs → chunk-LJ4ENXOD.mjs} +15 -14
- package/dist/chunk-LQG5G2LY.mjs +39 -0
- package/dist/{chunk-IQHZMCLX.mjs → chunk-MDF6PDIA.mjs} +2 -0
- package/dist/{chunk-QXH2CS4V.mjs → chunk-NVTFQFUL.mjs} +7 -26
- package/dist/{chunk-5K2JHKM3.mjs → chunk-NYSONUB7.mjs} +1 -1
- package/dist/{chunk-OH7SX5MY.mjs → chunk-O4KUNDVF.mjs} +12 -10
- package/dist/{chunk-EBIHRL7B.mjs → chunk-Q2UL2TPC.mjs} +1 -1
- package/dist/{chunk-RNUP6WZ6.mjs → chunk-QEYF2SQ6.mjs} +2 -2
- package/dist/{chunk-RVBUQITB.mjs → chunk-QN5WVV5K.mjs} +7 -7
- package/dist/{chunk-RIIUZJQ3.mjs → chunk-QYRNLLLI.mjs} +1 -1
- package/dist/{chunk-BTARFTEN.mjs → chunk-SOUZMPME.mjs} +4 -4
- package/dist/{chunk-ISUOSACK.mjs → chunk-T4CJDBBE.mjs} +1 -1
- package/dist/{chunk-DHEJAGVW.mjs → chunk-TTCKT2RT.mjs} +5 -5
- package/dist/{chunk-QU2XF7VI.mjs → chunk-U2726TL5.mjs} +5 -4
- package/dist/{chunk-LYKUJNAV.mjs → chunk-U46IZNCW.mjs} +2 -2
- package/dist/{chunk-SNB4DYL3.mjs → chunk-U6NE6RCV.mjs} +4 -4
- package/dist/{chunk-SA52N7G3.mjs → chunk-VP6XRMWR.mjs} +4 -4
- package/dist/{chunk-YUCGFPMS.mjs → chunk-VQDZVWN3.mjs} +449 -405
- package/dist/{chunk-IWVEG5CX.mjs → chunk-XIHUI4KB.mjs} +2 -2
- package/dist/{chunk-IV2XTSS2.mjs → chunk-XKPNKR3V.mjs} +16 -46
- package/dist/{chunk-UQS5PAS5.mjs → chunk-YGQOPB2Z.mjs} +1 -1
- package/dist/{chunk-SVO6NV4D.mjs → chunk-YKEHQUSZ.mjs} +4 -4
- package/dist/{chunk-6Z22L5RN.mjs → chunk-ZAYWOHVG.mjs} +1 -1
- package/dist/{chunk-QLDLQW36.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-X5SBWARI.mjs → chunk-ZYKUD5NX.mjs} +9 -7
- package/dist/{client-DoYPHcUn.d.ts → client-Cn3gNxUU.d.ts} +3 -3
- package/dist/client.d.ts +5 -5
- package/dist/client.mjs +2 -0
- package/dist/{cold-module-NUD332YD.mjs → cold-module-2WWGBFJC.mjs} +36 -33
- package/dist/{config-CuUfls_H.d.ts → config-CfhH1IWQ.d.ts} +1 -1
- package/dist/{config-Dzs46im6.d.ts → config-aIsy7mcL.d.ts} +52 -1
- package/dist/direct-executor-QLVHMELJ.mjs +24 -0
- package/dist/distribution/coordinator/etcd.mjs +1 -1
- package/dist/distribution/transport/grpc.mjs +1 -1
- package/dist/distribution.d.ts +4 -4
- package/dist/distribution.mjs +150 -255
- package/dist/{durability-wiring-K7RDXWL6.mjs → durability-wiring-GNWQSZI3.mjs} +67 -42
- package/dist/embeddings/openai.mjs +2 -2
- package/dist/{engine-C0ifUEcm.d.ts → engine-CJRUHXgf.d.ts} +1 -1
- package/dist/gzip-F4HMIEEQ.mjs +1 -0
- package/dist/import-DX55PN4G.mjs +41 -0
- package/dist/index.browser.mjs +7 -4
- package/dist/index.d.ts +539 -5
- package/dist/index.mjs +22 -16
- package/dist/index.react-native.mjs +19 -0
- package/dist/{long-query-thread-FKVHRCHF.mjs → long-query-thread-SCUE62TO.mjs} +20 -17
- package/dist/{module-GJUKW5VU.mjs → module-HW6IXUM6.mjs} +601 -108
- package/dist/{module-TMFIWOD2.mjs → module-V5K4ZP23.mjs} +29 -23
- package/dist/{paged-partition-archive-WNUEMYWM.mjs → paged-partition-archive-FDIIWZNR.mjs} +31 -25
- package/dist/partial-words.mjs +5 -5
- package/dist/pattern.mjs +3 -3
- package/dist/persistence/durability/checkpoint-worker.mjs +28 -22
- package/dist/{phrase-module-OMY3QQV7.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-K7UFXEJS.mjs → react-native/chunks/chunk-GV5KFQ6M.mjs} +12 -6
- 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/react-native/chunks/chunk-PU55IOG4.mjs +910 -0
- 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-Q6VFGLMG.mjs → react-native/chunks/module-JBBH6PZH.mjs} +609 -144
- 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-SOAHKZSQ.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/react-native/partial-words.mjs +733 -0
- package/dist/react-native/pattern.mjs +2442 -0
- package/dist/react-native/synonyms.mjs +460 -0
- package/dist/react.d.ts +7 -7
- package/dist/react.mjs +2 -0
- package/dist/{rerank-ZZ5CHKLW.mjs → rerank-3W54N6P2.mjs} +4 -4
- package/dist/rerankers/http.mjs +2 -2
- package/dist/restore-queue-BQWWNNQI.mjs +41 -0
- package/dist/{runtime-RAOCKSYA.mjs → runtime-L2DZYY6N.mjs} +5 -5
- package/dist/server.d.ts +8 -8
- package/dist/server.mjs +32 -28
- package/dist/{snapshot-DB5ZVCDN.mjs → snapshot-EHXTOTW5.mjs} +39 -33
- package/dist/synonyms.mjs +3 -3
- package/dist/{tasks-ChWp0wrF.d.ts → tasks-C4ElXr4P.d.ts} +2 -2
- package/dist/thread-I7DVHHW7.mjs +31 -0
- package/dist/vector/search-worker.mjs +7 -5
- package/dist/workers/entry.mjs +9 -9
- package/dist/{write-KZVTLGCI.mjs → write-SDJXXQ2G.mjs} +29 -23
- package/package.json +88 -7
- package/dist/analysis-change-D5APH4Z3.mjs +0 -34
- package/dist/browser/import-FTMLTPGQ.mjs +0 -9
- package/dist/direct-executor-FDQYQEJQ.mjs +0 -22
- package/dist/import-6KXFY6XI.mjs +0 -35
- package/dist/thread-OV6T555H.mjs +0 -28
- /package/dist/{chunk-22YPZVMG.mjs → chunk-ZXNQEW43.mjs} +0 -0
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { fnv1a, createRequestId, FNV_OFFSET_BASIS, fnv1aContinue, isValidWorkerResponse, fnv1aContinueTaggedNumbers } from './chunk-MPK76GVS.mjs';
|
|
1
2
|
import { DEFAULT_MAX_RERANK_WINDOW, DEFAULT_RERANK_TIMEOUT_MS } from './chunk-JPTQZWJQ.mjs';
|
|
2
3
|
import { TARGET_BLOCK_ENTRIES, bitsetHas, createBitSet, LOOKUP_KEY_SCRATCH_BYTES, GrowableUint32, SEGMENT_TOKEN_TABLE_START, SEGMENT_POSTING_LOG_START, SEGMENT_POSITION_POOL_START, SEGMENT_FIELD_SCRATCH_START, bitsetIsEmpty, bitsetSet, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY, PRUNING_REJECTION_SLACK, bitsetOrInto, bitsetAndNotInto, bitsetAndInto, SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD, SORT_COLUMN_REBUILD_FRACTION_SHIFT, bitsetFromSet } from './chunk-26A5JFT2.mjs';
|
|
3
|
-
import { MAX_DOCUMENT_ENCODING_DEPTH, singleFoldTable, appendFoldedCodePoint, compareCodePoints, EARLIER_RELEASE_MIN_M, MIN_M, MAX_M, MAX_FILE_BYTES, DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES, CHECKSUM_YIELD_CHUNK_BYTES, detectRuntime,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { MAX_DOCUMENT_ENCODING_DEPTH, singleFoldTable, appendFoldedCodePoint, compareCodePoints, EARLIER_RELEASE_MIN_M, MIN_M, MAX_M, createDocIdMap, MAX_FILE_BYTES, DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES, CHECKSUM_YIELD_CHUNK_BYTES, detectRuntime, toReducedSortValue, compareComparableValues, defaultSortMode, resolveWorkerEntry, missingWorkerEntry, countWrite, holdsUnpairedSurrogate, readSortField, truncateSortString, exceedsCodePoints, turnIsSpent, yieldTurn, toComparableSortValue, SORT_VALUE_MAX_CODE_POINTS, compareComparableKeys, sortModeOf, isSortMode, SORT_MODES, MIN_OVERSAMPLE, compareSortValues, noteThreadSlotGone, threadSlotOfWorker, codePointCount, turnsAreBudgeted, indexChangeOutsideExternalWaits, changeIndexOutsideExternalWaits } from './chunk-IAXZAVYL.mjs';
|
|
5
|
+
import { splitWorkerBudget, resolveWorkerCount, DEFAULT_REQUEST_TIMEOUT_MS, resolveRequestThreadCount, MAX_RENUMBERED_SEARCH_ATTEMPTS, SHUTDOWN_TIMEOUT_MS, DEFAULT_BACKPRESSURE_LIMIT, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH } from './chunk-TY7L6OXO.mjs';
|
|
6
|
+
import { MAX_INDEX_CONFIGURATION_BYTES, ABSOLUTE_WINDOWS_PATH_PATTERN, MODULE_URL_SCHEME_PATTERN, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, STATISTICS_BROADCAST_INTERVAL_MS, MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN, MAX_SUGGEST_LIMIT, FOREIGN_STATS_TTL_MS, HEAP_PRESSURE_WARNING_FRACTION, DEFAULT_SUGGEST_LIMIT, DEFAULT_LIMIT, DEFAULT_OFFSET, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION, BATCH_CHUNK_SIZE, MAX_DOC_ID_LENGTH } from './chunk-4RD3AFSB.mjs';
|
|
7
|
+
import { DEFAULT_FUZZY_PREFIX_LENGTH, MAX_CURSOR_LENGTH, MAX_CURSOR_ANCHOR_CODE_POINTS, MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, BM25_DISPLAYED_NAME_LENGTH, RESULT_WINDOW, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, DEFAULT_PAGE_SIZE, DEFAULT_MAX_PER_GROUP, PREFIX_MAX_EXPANSIONS, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-WXLBZJMT.mjs';
|
|
8
|
+
import { ErrorCodes, NarsilError, createNarsilError } from './chunk-PIS7ZAP7.mjs';
|
|
6
9
|
import { Encoder, Decoder, decode, encode } from '@msgpack/msgpack';
|
|
7
10
|
|
|
8
11
|
// src/analysis/registry.ts
|
|
@@ -2123,6 +2126,13 @@ function getLanguage(name) {
|
|
|
2123
2126
|
return lang;
|
|
2124
2127
|
}
|
|
2125
2128
|
|
|
2129
|
+
// src/engine/memory/write-block.browser.ts
|
|
2130
|
+
function validateMemorySettings(_settings) {
|
|
2131
|
+
}
|
|
2132
|
+
function createMemoryWriteBlock(_deps) {
|
|
2133
|
+
return void 0;
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2126
2136
|
// src/engine/config-keys.ts
|
|
2127
2137
|
var NARSIL_CONFIG_KEYS = {
|
|
2128
2138
|
persistence: true,
|
|
@@ -2139,7 +2149,8 @@ var NARSIL_CONFIG_KEYS = {
|
|
|
2139
2149
|
analysis: true,
|
|
2140
2150
|
lifecycle: true,
|
|
2141
2151
|
patternWorkCap: true,
|
|
2142
|
-
events: true
|
|
2152
|
+
events: true,
|
|
2153
|
+
memory: true
|
|
2143
2154
|
};
|
|
2144
2155
|
var EVENT_NAMES = {
|
|
2145
2156
|
write: true,
|
|
@@ -2217,6 +2228,7 @@ function requireKnownConfig(config) {
|
|
|
2217
2228
|
requireKnownKeys("workers.", config.workers, WORKER_CONFIG_KEYS);
|
|
2218
2229
|
requireKnownKeys("lifecycle.", config.lifecycle, LIFECYCLE_CONFIG_KEYS);
|
|
2219
2230
|
requireKnownKeys("analysis.", config.analysis, ANALYSIS_CONFIG_KEYS);
|
|
2231
|
+
validateMemorySettings(config.memory);
|
|
2220
2232
|
requireNamedPlugins(config.plugins);
|
|
2221
2233
|
requireValidPatternWorkCap(config.patternWorkCap);
|
|
2222
2234
|
requireEventListeners(config.events);
|
|
@@ -2287,48 +2299,6 @@ var PATTERN_TEST_OPERATORS = ["eq", "ne", "in", "nin", "startsWith", "endsWith",
|
|
|
2287
2299
|
var PATTERN_EXPRESSION_OPERATORS = ["wildcard", "regex"];
|
|
2288
2300
|
var PATTERN_ELEMENT_OPERATORS = ["matchesAny", "containsAll"];
|
|
2289
2301
|
|
|
2290
|
-
// src/core/hash.ts
|
|
2291
|
-
var FNV_OFFSET_BASIS = 2166136261;
|
|
2292
|
-
var FNV_PRIME = 16777619;
|
|
2293
|
-
var encoder = new TextEncoder();
|
|
2294
|
-
function fnv1aBytes(bytes) {
|
|
2295
|
-
return fnv1aContinue(FNV_OFFSET_BASIS, bytes, bytes.length) >>> 0;
|
|
2296
|
-
}
|
|
2297
|
-
function fnv1aContinue(start, bytes, length) {
|
|
2298
|
-
let hash = start;
|
|
2299
|
-
for (let i = 0; i < length; i++) {
|
|
2300
|
-
hash = Math.imul(hash ^ bytes[i], FNV_PRIME);
|
|
2301
|
-
}
|
|
2302
|
-
return hash;
|
|
2303
|
-
}
|
|
2304
|
-
var scratchNumber = new Float64Array(1);
|
|
2305
|
-
var scratchBytes = new Uint8Array(scratchNumber.buffer);
|
|
2306
|
-
var HOST_IS_LITTLE_ENDIAN = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
|
|
2307
|
-
function fnv1aContinueTaggedNumbers(start, tag, numbers) {
|
|
2308
|
-
let hash = start;
|
|
2309
|
-
const b = scratchBytes;
|
|
2310
|
-
for (let i = 0; i < numbers.length; i++) {
|
|
2311
|
-
scratchNumber[0] = Math.fround(numbers[i]);
|
|
2312
|
-
hash = Math.imul(hash ^ tag, FNV_PRIME);
|
|
2313
|
-
if (HOST_IS_LITTLE_ENDIAN) {
|
|
2314
|
-
hash = Math.imul(hash ^ b[7], FNV_PRIME);
|
|
2315
|
-
hash = Math.imul(hash ^ b[6], FNV_PRIME);
|
|
2316
|
-
hash = Math.imul(hash ^ b[5], FNV_PRIME);
|
|
2317
|
-
hash = Math.imul(hash ^ b[4], FNV_PRIME);
|
|
2318
|
-
hash = Math.imul(hash ^ b[3], FNV_PRIME);
|
|
2319
|
-
hash = Math.imul(hash ^ b[2], FNV_PRIME);
|
|
2320
|
-
hash = Math.imul(hash ^ b[1], FNV_PRIME);
|
|
2321
|
-
hash = Math.imul(hash ^ b[0], FNV_PRIME);
|
|
2322
|
-
} else {
|
|
2323
|
-
for (let at = 0; at < 8; at++) hash = Math.imul(hash ^ b[at], FNV_PRIME);
|
|
2324
|
-
}
|
|
2325
|
-
}
|
|
2326
|
-
return hash;
|
|
2327
|
-
}
|
|
2328
|
-
function fnv1a(input) {
|
|
2329
|
-
return fnv1aBytes(encoder.encode(input));
|
|
2330
|
-
}
|
|
2331
|
-
|
|
2332
2302
|
// src/partitioning/router.ts
|
|
2333
2303
|
function createPartitionRouter() {
|
|
2334
2304
|
function route(docId, partitionCount) {
|
|
@@ -3378,25 +3348,40 @@ function documentValueBytes(value) {
|
|
|
3378
3348
|
return PRIMITIVE_SLOT_BYTES;
|
|
3379
3349
|
}
|
|
3380
3350
|
function createDocumentStore() {
|
|
3381
|
-
const
|
|
3382
|
-
const
|
|
3351
|
+
const internalIds = createDocIdMap();
|
|
3352
|
+
const storedById = [];
|
|
3383
3353
|
const reverseMap = [];
|
|
3384
3354
|
const lengthColumns = /* @__PURE__ */ new Map();
|
|
3385
3355
|
let nextInternalId = 0;
|
|
3386
3356
|
let numberingResets = 0;
|
|
3387
3357
|
let sortedIds = null;
|
|
3388
3358
|
let storedContentBytes = 0;
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3359
|
+
let storedCount = 0;
|
|
3360
|
+
let newestNumberedDocId;
|
|
3361
|
+
function storedOf(docId) {
|
|
3362
|
+
const internalId = internalIds.get(docId);
|
|
3363
|
+
return internalId === void 0 ? void 0 : storedById[internalId];
|
|
3364
|
+
}
|
|
3365
|
+
function putStored(docId, internalId, stored) {
|
|
3366
|
+
if (storedById[internalId] === void 0) {
|
|
3367
|
+
storedCount++;
|
|
3394
3368
|
sortedIds = null;
|
|
3369
|
+
if (docId !== newestNumberedDocId) {
|
|
3370
|
+
internalIds.delete(docId);
|
|
3371
|
+
internalIds.set(docId, internalId);
|
|
3372
|
+
newestNumberedDocId = docId;
|
|
3373
|
+
}
|
|
3395
3374
|
}
|
|
3396
|
-
|
|
3375
|
+
storedById[internalId] = stored;
|
|
3376
|
+
}
|
|
3377
|
+
function replaceStored(docId, document, fieldLengths) {
|
|
3378
|
+
const internalId = assignInternalId(docId);
|
|
3379
|
+
const existing = storedById[internalId];
|
|
3380
|
+
if (existing !== void 0) storedContentBytes -= documentValueBytes(existing.fields);
|
|
3381
|
+
writeFieldLengths(internalId, fieldLengths);
|
|
3397
3382
|
const fields = documentWithOwnBuffers(document);
|
|
3398
3383
|
storedContentBytes += documentValueBytes(fields);
|
|
3399
|
-
|
|
3384
|
+
putStored(docId, internalId, { fields, fieldLengths });
|
|
3400
3385
|
}
|
|
3401
3386
|
function writeFieldLengths(internalId, fieldLengths) {
|
|
3402
3387
|
for (const fieldName of Object.keys(fieldLengths)) {
|
|
@@ -3411,26 +3396,36 @@ function createDocumentStore() {
|
|
|
3411
3396
|
}
|
|
3412
3397
|
}
|
|
3413
3398
|
function assignInternalId(docId) {
|
|
3414
|
-
const existing =
|
|
3399
|
+
const existing = internalIds.get(docId);
|
|
3415
3400
|
if (existing !== void 0) return existing;
|
|
3416
3401
|
const internalId = nextInternalId++;
|
|
3417
|
-
|
|
3402
|
+
internalIds.set(docId, internalId);
|
|
3403
|
+
newestNumberedDocId = docId;
|
|
3418
3404
|
reverseMap[internalId] = docId;
|
|
3419
3405
|
return internalId;
|
|
3420
3406
|
}
|
|
3421
3407
|
function clearMappings() {
|
|
3422
|
-
|
|
3408
|
+
internalIds.clear();
|
|
3409
|
+
storedById.length = 0;
|
|
3423
3410
|
reverseMap.length = 0;
|
|
3424
3411
|
nextInternalId = 0;
|
|
3412
|
+
storedCount = 0;
|
|
3413
|
+
newestNumberedDocId = void 0;
|
|
3425
3414
|
numberingResets++;
|
|
3426
3415
|
sortedIds = null;
|
|
3427
3416
|
}
|
|
3417
|
+
function* storedEntries() {
|
|
3418
|
+
for (const [docId, internalId] of internalIds) {
|
|
3419
|
+
const stored = storedById[internalId];
|
|
3420
|
+
if (stored !== void 0) yield [docId, stored];
|
|
3421
|
+
}
|
|
3422
|
+
}
|
|
3428
3423
|
const idResolver = {
|
|
3429
3424
|
toExternal(internalId) {
|
|
3430
3425
|
return reverseMap[internalId];
|
|
3431
3426
|
},
|
|
3432
3427
|
toInternal(externalId) {
|
|
3433
|
-
return
|
|
3428
|
+
return internalIds.get(externalId);
|
|
3434
3429
|
},
|
|
3435
3430
|
isLive(internalId) {
|
|
3436
3431
|
return reverseMap[internalId] !== void 0;
|
|
@@ -3444,39 +3439,36 @@ function createDocumentStore() {
|
|
|
3444
3439
|
replaceStored(docId, document, fieldLengths);
|
|
3445
3440
|
},
|
|
3446
3441
|
get(docId) {
|
|
3447
|
-
return
|
|
3442
|
+
return storedOf(docId);
|
|
3448
3443
|
},
|
|
3449
3444
|
remove(docId) {
|
|
3450
|
-
const
|
|
3451
|
-
const
|
|
3452
|
-
if (
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
for (const column of lengthColumns.values()) {
|
|
3462
|
-
if (internalId < column.length) column[internalId] = 0;
|
|
3463
|
-
}
|
|
3464
|
-
}
|
|
3445
|
+
const internalId = internalIds.get(docId);
|
|
3446
|
+
const existing = internalId === void 0 ? void 0 : storedById[internalId];
|
|
3447
|
+
if (internalId === void 0 || existing === void 0) return false;
|
|
3448
|
+
storedContentBytes -= documentValueBytes(existing.fields);
|
|
3449
|
+
sortedIds = null;
|
|
3450
|
+
storedCount--;
|
|
3451
|
+
internalIds.delete(docId);
|
|
3452
|
+
storedById[internalId] = void 0;
|
|
3453
|
+
reverseMap[internalId] = void 0;
|
|
3454
|
+
for (const column of lengthColumns.values()) {
|
|
3455
|
+
if (internalId < column.length) column[internalId] = 0;
|
|
3465
3456
|
}
|
|
3466
|
-
return
|
|
3457
|
+
return true;
|
|
3467
3458
|
},
|
|
3468
3459
|
has(docId) {
|
|
3469
|
-
return
|
|
3460
|
+
return storedOf(docId) !== void 0;
|
|
3470
3461
|
},
|
|
3471
3462
|
count() {
|
|
3472
|
-
return
|
|
3463
|
+
return storedCount;
|
|
3473
3464
|
},
|
|
3474
3465
|
all() {
|
|
3475
|
-
return
|
|
3466
|
+
return storedEntries();
|
|
3476
3467
|
},
|
|
3477
3468
|
sortedDocIds() {
|
|
3478
3469
|
if (sortedIds === null) {
|
|
3479
|
-
const ids =
|
|
3470
|
+
const ids = [];
|
|
3471
|
+
for (const [docId] of storedEntries()) ids.push(docId);
|
|
3480
3472
|
ids.sort(compareCodePoints);
|
|
3481
3473
|
sortedIds = ids;
|
|
3482
3474
|
}
|
|
@@ -3486,29 +3478,28 @@ function createDocumentStore() {
|
|
|
3486
3478
|
sortedIds = null;
|
|
3487
3479
|
},
|
|
3488
3480
|
clear() {
|
|
3489
|
-
docs.clear();
|
|
3490
3481
|
lengthColumns.clear();
|
|
3491
3482
|
clearMappings();
|
|
3492
3483
|
storedContentBytes = 0;
|
|
3493
3484
|
},
|
|
3494
3485
|
serialize() {
|
|
3495
3486
|
const result = {};
|
|
3496
|
-
for (const [docId, stored] of
|
|
3487
|
+
for (const [docId, stored] of storedEntries()) {
|
|
3497
3488
|
result[docId] = stored;
|
|
3498
3489
|
}
|
|
3499
3490
|
return result;
|
|
3500
3491
|
},
|
|
3501
3492
|
deserialize(data) {
|
|
3502
|
-
docs.clear();
|
|
3503
3493
|
lengthColumns.clear();
|
|
3504
3494
|
clearMappings();
|
|
3505
3495
|
storedContentBytes = 0;
|
|
3506
3496
|
for (const docId of Object.keys(data)) {
|
|
3507
3497
|
const stored = data[docId];
|
|
3508
|
-
|
|
3498
|
+
const internalId = assignInternalId(docId);
|
|
3499
|
+
writeFieldLengths(internalId, stored.fieldLengths);
|
|
3509
3500
|
const fields = documentWithOwnBuffers(stored.fields);
|
|
3510
3501
|
storedContentBytes += documentValueBytes(fields);
|
|
3511
|
-
|
|
3502
|
+
putStored(docId, internalId, fields === stored.fields ? stored : { fields, fieldLengths: stored.fieldLengths });
|
|
3512
3503
|
}
|
|
3513
3504
|
},
|
|
3514
3505
|
fieldLengthColumn(fieldName) {
|
|
@@ -3518,14 +3509,14 @@ function createDocumentStore() {
|
|
|
3518
3509
|
return assignInternalId(docId);
|
|
3519
3510
|
},
|
|
3520
3511
|
getInternalId(docId) {
|
|
3521
|
-
return
|
|
3512
|
+
return internalIds.get(docId);
|
|
3522
3513
|
},
|
|
3523
3514
|
getExternalId(internalId) {
|
|
3524
3515
|
return reverseMap[internalId];
|
|
3525
3516
|
},
|
|
3526
3517
|
*allInternalIds() {
|
|
3527
|
-
for (
|
|
3528
|
-
yield internalId;
|
|
3518
|
+
for (let internalId = 0; internalId < reverseMap.length; internalId++) {
|
|
3519
|
+
if (reverseMap[internalId] !== void 0) yield internalId;
|
|
3529
3520
|
}
|
|
3530
3521
|
},
|
|
3531
3522
|
internalIdCapacity() {
|
|
@@ -3542,85 +3533,17 @@ function createDocumentStore() {
|
|
|
3542
3533
|
},
|
|
3543
3534
|
fieldReader(fieldPath) {
|
|
3544
3535
|
return (internalId) => {
|
|
3545
|
-
const
|
|
3546
|
-
const stored = docId === void 0 ? void 0 : docs.get(docId);
|
|
3536
|
+
const stored = storedById[internalId];
|
|
3547
3537
|
return stored === void 0 ? void 0 : getNestedValue(stored.fields, fieldPath);
|
|
3548
3538
|
};
|
|
3549
3539
|
},
|
|
3550
3540
|
projectedDocument(docId, projection) {
|
|
3551
|
-
const stored =
|
|
3541
|
+
const stored = storedOf(docId);
|
|
3552
3542
|
return stored === void 0 ? void 0 : cloneProjected(stored.fields, projection);
|
|
3553
3543
|
}
|
|
3554
3544
|
};
|
|
3555
3545
|
}
|
|
3556
3546
|
|
|
3557
|
-
// src/core/fuzzy.ts
|
|
3558
|
-
var FIRST_SURROGATE = 55296;
|
|
3559
|
-
var LAST_SURROGATE = 57343;
|
|
3560
|
-
var LAST_BASIC_PLANE_CODE_POINT = 65535;
|
|
3561
|
-
function hasSurrogate(text) {
|
|
3562
|
-
for (let index = 0; index < text.length; index++) {
|
|
3563
|
-
const unit = text.charCodeAt(index);
|
|
3564
|
-
if (unit >= FIRST_SURROGATE && unit <= LAST_SURROGATE) return true;
|
|
3565
|
-
}
|
|
3566
|
-
return false;
|
|
3567
|
-
}
|
|
3568
|
-
function fuzzyPrefixOf(queryTerm, prefixLength) {
|
|
3569
|
-
let end = 0;
|
|
3570
|
-
for (let counted = 0; counted < prefixLength && end < queryTerm.length; counted++) {
|
|
3571
|
-
const codePoint = queryTerm.codePointAt(end);
|
|
3572
|
-
end += codePoint !== void 0 && codePoint > LAST_BASIC_PLANE_CODE_POINT ? 2 : 1;
|
|
3573
|
-
}
|
|
3574
|
-
return queryTerm.slice(0, end);
|
|
3575
|
-
}
|
|
3576
|
-
function fuzzyTermMatches(queryTerm, indexTerm, tolerance, prefixLength) {
|
|
3577
|
-
if (queryTerm === indexTerm) return true;
|
|
3578
|
-
if (tolerance <= 0) return false;
|
|
3579
|
-
if (!indexTerm.startsWith(fuzzyPrefixOf(queryTerm, prefixLength))) return false;
|
|
3580
|
-
return boundedLevenshtein(queryTerm, indexTerm, tolerance).withinTolerance;
|
|
3581
|
-
}
|
|
3582
|
-
function boundedLevenshtein(a, b, tolerance) {
|
|
3583
|
-
if (tolerance < 0) return { distance: -1, withinTolerance: false, cells: 0 };
|
|
3584
|
-
if (a === b) return { distance: 0, withinTolerance: true, cells: 0 };
|
|
3585
|
-
return tabulatedLevenshtein(a, b, tolerance);
|
|
3586
|
-
}
|
|
3587
|
-
function tabulatedLevenshtein(a, b, tolerance) {
|
|
3588
|
-
if (tolerance < 0) return { distance: -1, withinTolerance: false, cells: 0 };
|
|
3589
|
-
if (hasSurrogate(a) || hasSurrogate(b)) return bandedDistance(Array.from(a), Array.from(b), tolerance);
|
|
3590
|
-
return bandedDistance(a, b, tolerance);
|
|
3591
|
-
}
|
|
3592
|
-
function bandedDistance(a, b, tolerance) {
|
|
3593
|
-
const m = a.length;
|
|
3594
|
-
const n = b.length;
|
|
3595
|
-
const beyond = tolerance + 1;
|
|
3596
|
-
if (Math.abs(m - n) > tolerance) return { distance: beyond, withinTolerance: false, cells: 0 };
|
|
3597
|
-
let previous = new Uint32Array(n + 1).fill(beyond);
|
|
3598
|
-
let current = new Uint32Array(n + 1).fill(beyond);
|
|
3599
|
-
const firstRowEnd = Math.min(n, tolerance);
|
|
3600
|
-
for (let j = 0; j <= firstRowEnd; j++) previous[j] = j;
|
|
3601
|
-
let cells = 0;
|
|
3602
|
-
for (let i = 1; i <= m; i++) {
|
|
3603
|
-
const low = Math.max(1, i - tolerance);
|
|
3604
|
-
const high = Math.min(n, i + tolerance);
|
|
3605
|
-
current[low - 1] = low === 1 ? i : beyond;
|
|
3606
|
-
let rowMin = current[low - 1];
|
|
3607
|
-
const character = a[i - 1];
|
|
3608
|
-
if (high >= low) cells += high - low + 1;
|
|
3609
|
-
for (let j = low; j <= high; j++) {
|
|
3610
|
-
const substitution = previous[j - 1] + (character === b[j - 1] ? 0 : 1);
|
|
3611
|
-
const cell = Math.min(previous[j] + 1, current[j - 1] + 1, substitution, beyond);
|
|
3612
|
-
current[j] = cell;
|
|
3613
|
-
if (cell < rowMin) rowMin = cell;
|
|
3614
|
-
}
|
|
3615
|
-
if (rowMin > tolerance) return { distance: beyond, withinTolerance: false, cells };
|
|
3616
|
-
const finished = previous;
|
|
3617
|
-
previous = current;
|
|
3618
|
-
current = finished;
|
|
3619
|
-
}
|
|
3620
|
-
const distance = previous[n];
|
|
3621
|
-
return { distance, withinTolerance: distance <= tolerance, cells };
|
|
3622
|
-
}
|
|
3623
|
-
|
|
3624
3547
|
// src/core/inverted-index/constants.ts
|
|
3625
3548
|
var TERM_TABLE_START_CAPACITY = 1 << 10;
|
|
3626
3549
|
var POSTING_POOL_START_ENTRIES = 1 << 12;
|
|
@@ -4392,6 +4315,73 @@ var LivePostings = class {
|
|
|
4392
4315
|
}
|
|
4393
4316
|
};
|
|
4394
4317
|
|
|
4318
|
+
// src/core/fuzzy.ts
|
|
4319
|
+
var FIRST_SURROGATE = 55296;
|
|
4320
|
+
var LAST_SURROGATE = 57343;
|
|
4321
|
+
var LAST_BASIC_PLANE_CODE_POINT = 65535;
|
|
4322
|
+
function hasSurrogate(text) {
|
|
4323
|
+
for (let index = 0; index < text.length; index++) {
|
|
4324
|
+
const unit = text.charCodeAt(index);
|
|
4325
|
+
if (unit >= FIRST_SURROGATE && unit <= LAST_SURROGATE) return true;
|
|
4326
|
+
}
|
|
4327
|
+
return false;
|
|
4328
|
+
}
|
|
4329
|
+
function fuzzyPrefixOf(queryTerm, prefixLength) {
|
|
4330
|
+
let end = 0;
|
|
4331
|
+
for (let counted = 0; counted < prefixLength && end < queryTerm.length; counted++) {
|
|
4332
|
+
const codePoint = queryTerm.codePointAt(end);
|
|
4333
|
+
end += codePoint !== void 0 && codePoint > LAST_BASIC_PLANE_CODE_POINT ? 2 : 1;
|
|
4334
|
+
}
|
|
4335
|
+
return queryTerm.slice(0, end);
|
|
4336
|
+
}
|
|
4337
|
+
function fuzzyTermMatches(queryTerm, indexTerm, tolerance, prefixLength) {
|
|
4338
|
+
if (queryTerm === indexTerm) return true;
|
|
4339
|
+
if (tolerance <= 0) return false;
|
|
4340
|
+
if (!indexTerm.startsWith(fuzzyPrefixOf(queryTerm, prefixLength))) return false;
|
|
4341
|
+
return boundedLevenshtein(queryTerm, indexTerm, tolerance).withinTolerance;
|
|
4342
|
+
}
|
|
4343
|
+
function boundedLevenshtein(a, b, tolerance) {
|
|
4344
|
+
if (tolerance < 0) return { distance: -1, withinTolerance: false, cells: 0 };
|
|
4345
|
+
if (a === b) return { distance: 0, withinTolerance: true, cells: 0 };
|
|
4346
|
+
return tabulatedLevenshtein(a, b, tolerance);
|
|
4347
|
+
}
|
|
4348
|
+
function tabulatedLevenshtein(a, b, tolerance) {
|
|
4349
|
+
if (tolerance < 0) return { distance: -1, withinTolerance: false, cells: 0 };
|
|
4350
|
+
if (hasSurrogate(a) || hasSurrogate(b)) return bandedDistance(Array.from(a), Array.from(b), tolerance);
|
|
4351
|
+
return bandedDistance(a, b, tolerance);
|
|
4352
|
+
}
|
|
4353
|
+
function bandedDistance(a, b, tolerance) {
|
|
4354
|
+
const m = a.length;
|
|
4355
|
+
const n = b.length;
|
|
4356
|
+
const beyond = tolerance + 1;
|
|
4357
|
+
if (Math.abs(m - n) > tolerance) return { distance: beyond, withinTolerance: false, cells: 0 };
|
|
4358
|
+
let previous = new Uint32Array(n + 1).fill(beyond);
|
|
4359
|
+
let current = new Uint32Array(n + 1).fill(beyond);
|
|
4360
|
+
const firstRowEnd = Math.min(n, tolerance);
|
|
4361
|
+
for (let j = 0; j <= firstRowEnd; j++) previous[j] = j;
|
|
4362
|
+
let cells = 0;
|
|
4363
|
+
for (let i = 1; i <= m; i++) {
|
|
4364
|
+
const low = Math.max(1, i - tolerance);
|
|
4365
|
+
const high = Math.min(n, i + tolerance);
|
|
4366
|
+
current[low - 1] = low === 1 ? i : beyond;
|
|
4367
|
+
let rowMin = current[low - 1];
|
|
4368
|
+
const character = a[i - 1];
|
|
4369
|
+
if (high >= low) cells += high - low + 1;
|
|
4370
|
+
for (let j = low; j <= high; j++) {
|
|
4371
|
+
const substitution = previous[j - 1] + (character === b[j - 1] ? 0 : 1);
|
|
4372
|
+
const cell = Math.min(previous[j] + 1, current[j - 1] + 1, substitution, beyond);
|
|
4373
|
+
current[j] = cell;
|
|
4374
|
+
if (cell < rowMin) rowMin = cell;
|
|
4375
|
+
}
|
|
4376
|
+
if (rowMin > tolerance) return { distance: beyond, withinTolerance: false, cells };
|
|
4377
|
+
const finished = previous;
|
|
4378
|
+
previous = current;
|
|
4379
|
+
current = finished;
|
|
4380
|
+
}
|
|
4381
|
+
const distance = previous[n];
|
|
4382
|
+
return { distance, withinTolerance: distance <= tolerance, cells };
|
|
4383
|
+
}
|
|
4384
|
+
|
|
4395
4385
|
// src/core/inverted-index/index.ts
|
|
4396
4386
|
function fieldIndexFor(fieldNameTable, fieldName) {
|
|
4397
4387
|
let index = fieldNameTable.indexMap.get(fieldName);
|
|
@@ -4887,6 +4877,14 @@ function countFieldValues(state, fieldPath, fieldType, bitset, matched) {
|
|
|
4887
4877
|
}
|
|
4888
4878
|
return countValuesFromDocuments(state, fieldPath, matched);
|
|
4889
4879
|
}
|
|
4880
|
+
function sortFacetedNumbers(state, config, schema) {
|
|
4881
|
+
const flatSchema = getFlatSchema(state, schema);
|
|
4882
|
+
for (const fieldPath of Object.keys(config)) {
|
|
4883
|
+
const fieldType = flatSchema[fieldPath];
|
|
4884
|
+
if (fieldType !== "number" && fieldType !== "number[]") continue;
|
|
4885
|
+
state.numericIndexes.get(fieldPath)?.sortPending();
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4890
4888
|
function computeFacets(state, matched, config, schema) {
|
|
4891
4889
|
const result = {};
|
|
4892
4890
|
const flatSchema = getFlatSchema(state, schema);
|
|
@@ -5881,6 +5879,7 @@ function createNumericIndex() {
|
|
|
5881
5879
|
}
|
|
5882
5880
|
return seen.size;
|
|
5883
5881
|
},
|
|
5882
|
+
sortPending: ensureSorted,
|
|
5884
5883
|
clear() {
|
|
5885
5884
|
entries = [];
|
|
5886
5885
|
discardPending();
|
|
@@ -7641,6 +7640,13 @@ function textRangeBitsetOf(state, fieldPath, fieldType, bounds, capacity) {
|
|
|
7641
7640
|
const resolver = state.docStore.resolver();
|
|
7642
7641
|
return selectTextRange(column, bounds, capacity, (internalId) => resolver.isLive(internalId));
|
|
7643
7642
|
}
|
|
7643
|
+
function prepareSortColumnsOf(state, request) {
|
|
7644
|
+
const set = ensureColumns(state);
|
|
7645
|
+
const { fields, directions, fieldTypes, modes } = request;
|
|
7646
|
+
for (let index = 0; index < fields.length; index++) {
|
|
7647
|
+
set.column(fields[index], fieldTypes[index], modes[index] ?? defaultSortMode(directions[index] ?? "asc"));
|
|
7648
|
+
}
|
|
7649
|
+
}
|
|
7644
7650
|
function sortedPageOf(state, request) {
|
|
7645
7651
|
ensureColumns(state);
|
|
7646
7652
|
return selectSortedPage(state, request);
|
|
@@ -7676,6 +7682,22 @@ function refreshSortColumns(state) {
|
|
|
7676
7682
|
function sortColumnBytes(state) {
|
|
7677
7683
|
return state.sortColumns === null ? 0 : state.sortColumns.estimateBytes();
|
|
7678
7684
|
}
|
|
7685
|
+
function sortedReadsOf(state) {
|
|
7686
|
+
return {
|
|
7687
|
+
prepareSortedPage(request) {
|
|
7688
|
+
prepareSortColumnsOf(state, request);
|
|
7689
|
+
},
|
|
7690
|
+
prepareFacets(config, schema) {
|
|
7691
|
+
sortFacetedNumbers(state, config, schema);
|
|
7692
|
+
},
|
|
7693
|
+
sortedPage(request) {
|
|
7694
|
+
return sortedPageOf(state, request);
|
|
7695
|
+
},
|
|
7696
|
+
sortValues(docId, fields, fieldTypes, modes) {
|
|
7697
|
+
return sortValuesOf(state, docId, fields, fieldTypes, modes);
|
|
7698
|
+
}
|
|
7699
|
+
};
|
|
7700
|
+
}
|
|
7679
7701
|
|
|
7680
7702
|
// src/core/partition/filters.ts
|
|
7681
7703
|
function presentBitsetOf(state, fieldPath, type, capacity) {
|
|
@@ -7820,7 +7842,7 @@ function requireLoadedPhraseCode() {
|
|
|
7820
7842
|
}
|
|
7821
7843
|
function loadPhraseCode() {
|
|
7822
7844
|
if (loading === null) {
|
|
7823
|
-
loading = import('./phrase-module-
|
|
7845
|
+
loading = import('./phrase-module-CNKMUY4U.mjs').then(
|
|
7824
7846
|
(code) => {
|
|
7825
7847
|
loaded = code;
|
|
7826
7848
|
return code;
|
|
@@ -10101,12 +10123,7 @@ function createPartitionIndex(partitionId, trackPositions = true) {
|
|
|
10101
10123
|
searchFulltextMatches(params) {
|
|
10102
10124
|
return searchFulltextMatches(state, params);
|
|
10103
10125
|
},
|
|
10104
|
-
|
|
10105
|
-
return sortedPageOf(state, request);
|
|
10106
|
-
},
|
|
10107
|
-
sortValues(docId, fields, fieldTypes, modes) {
|
|
10108
|
-
return sortValuesOf(state, docId, fields, fieldTypes, modes);
|
|
10109
|
-
},
|
|
10126
|
+
...sortedReadsOf(state),
|
|
10110
10127
|
applyFilters(filters, schema, meter) {
|
|
10111
10128
|
return applyPartitionFilters(state, filters, schema, meter);
|
|
10112
10129
|
},
|
|
@@ -10744,6 +10761,9 @@ function compositeSortedPage(subs, layout, request) {
|
|
|
10744
10761
|
if (merged.length > request.limit) merged.length = request.limit;
|
|
10745
10762
|
return merged;
|
|
10746
10763
|
}
|
|
10764
|
+
function prepareCompositeSortColumns(subs, request) {
|
|
10765
|
+
for (const sub of subs) prepareSortColumnsOf(sub, request);
|
|
10766
|
+
}
|
|
10747
10767
|
function compositeSortValues(subs, docId, fields, fieldTypes, modes) {
|
|
10748
10768
|
for (const sub of subs) {
|
|
10749
10769
|
if (sub.docStore.has(docId)) {
|
|
@@ -10980,6 +11000,12 @@ function createCompositePartition(partitionId, trackPositions = true, existingLi
|
|
|
10980
11000
|
computeFacets(matched, config, schema) {
|
|
10981
11001
|
return compositeFacets(subs(), layout, matched, config, schema);
|
|
10982
11002
|
},
|
|
11003
|
+
prepareSortedPage(request) {
|
|
11004
|
+
prepareCompositeSortColumns(subs(), request);
|
|
11005
|
+
},
|
|
11006
|
+
prepareFacets(config, schema) {
|
|
11007
|
+
live.prepareFacets(config, schema);
|
|
11008
|
+
},
|
|
10983
11009
|
sortedPage(request) {
|
|
10984
11010
|
return compositeSortedPage(subs(), layout(), request);
|
|
10985
11011
|
},
|
|
@@ -11330,7 +11356,7 @@ function createPartitionManager(indexName, initialConfig, initialLanguage, route
|
|
|
11330
11356
|
const trackPositions = config.trackPositions ?? true;
|
|
11331
11357
|
const vecIndexes = vectorIndexes ?? /* @__PURE__ */ new Map();
|
|
11332
11358
|
let partitions = [];
|
|
11333
|
-
const docPartitionMap =
|
|
11359
|
+
const docPartitionMap = createDocIdMap();
|
|
11334
11360
|
const writeLogs = createWriteLogRecorder();
|
|
11335
11361
|
for (let i = 0; i < count; i++) {
|
|
11336
11362
|
partitions.push(createPartitionIndex(i, trackPositions));
|
|
@@ -12535,6 +12561,7 @@ async function fanOutQuery(manager, params, language, schema, config, searchOpti
|
|
|
12535
12561
|
const partitionFacets = [];
|
|
12536
12562
|
const everyValue = params.facets ? everyValueFacetConfig(params.facets) : void 0;
|
|
12537
12563
|
for (const partition of partitions) {
|
|
12564
|
+
if (turnIsSpent()) await yieldTurn();
|
|
12538
12565
|
options.patternWork?.clock?.check();
|
|
12539
12566
|
const result = dispatchSinglePartition(partition, params, language, schema, options);
|
|
12540
12567
|
if (everyValue) {
|
|
@@ -12873,14 +12900,14 @@ function decodeMapWithoutFields(bytes, skippedFields) {
|
|
|
12873
12900
|
}
|
|
12874
12901
|
|
|
12875
12902
|
// src/serialization/msgpack-path.ts
|
|
12876
|
-
var
|
|
12877
|
-
var PROTO_KEY_BYTES =
|
|
12903
|
+
var encoder = new TextEncoder();
|
|
12904
|
+
var PROTO_KEY_BYTES = encoder.encode("__proto__");
|
|
12878
12905
|
var MISSING = { found: false, value: void 0 };
|
|
12879
12906
|
var pathDecoder = new Decoder();
|
|
12880
12907
|
function encodePathSegments(segments) {
|
|
12881
12908
|
if (segments.length === 0) return null;
|
|
12882
12909
|
if (segments.some((segment) => PROTOTYPE_POLLUTION_KEYS.has(segment))) return null;
|
|
12883
|
-
return segments.map((segment) =>
|
|
12910
|
+
return segments.map((segment) => encoder.encode(segment));
|
|
12884
12911
|
}
|
|
12885
12912
|
function isStringTag(tag) {
|
|
12886
12913
|
return tag >= 160 && tag <= 191 || tag === 217 || tag === 218 || tag === 219;
|
|
@@ -13102,18 +13129,18 @@ function wrapDocumentArray(documents) {
|
|
|
13102
13129
|
// src/core/partition/frozen/string-blob.ts
|
|
13103
13130
|
var SURROGATE = /[\ud800-\udfff]/;
|
|
13104
13131
|
var UTF8_BYTES_PER_UTF16_UNIT = 3;
|
|
13105
|
-
var
|
|
13132
|
+
var encoder2 = new TextEncoder();
|
|
13106
13133
|
var lookupKeyBytes = new Uint8Array(LOOKUP_KEY_SCRATCH_BYTES);
|
|
13107
13134
|
function encodeLookupKey(text) {
|
|
13108
|
-
if (text.length * UTF8_BYTES_PER_UTF16_UNIT > LOOKUP_KEY_SCRATCH_BYTES) return
|
|
13109
|
-
const { written } =
|
|
13135
|
+
if (text.length * UTF8_BYTES_PER_UTF16_UNIT > LOOKUP_KEY_SCRATCH_BYTES) return encoder2.encode(text);
|
|
13136
|
+
const { written } = encoder2.encodeInto(text, lookupKeyBytes);
|
|
13110
13137
|
return lookupKeyBytes.subarray(0, written);
|
|
13111
13138
|
}
|
|
13112
13139
|
function encodeOneByOne(strings) {
|
|
13113
13140
|
const encoded = new Array(strings.length);
|
|
13114
13141
|
let blobLength = 0;
|
|
13115
13142
|
for (let i = 0; i < strings.length; i++) {
|
|
13116
|
-
encoded[i] =
|
|
13143
|
+
encoded[i] = encoder2.encode(strings[i]);
|
|
13117
13144
|
blobLength += encoded[i].length;
|
|
13118
13145
|
}
|
|
13119
13146
|
const blob = new Uint8Array(blobLength);
|
|
@@ -13137,7 +13164,7 @@ function basicPlaneUtf8Bytes(text) {
|
|
|
13137
13164
|
function encodeStringBlob(strings) {
|
|
13138
13165
|
const joined = strings.join("");
|
|
13139
13166
|
if (SURROGATE.test(joined)) return encodeOneByOne(strings);
|
|
13140
|
-
const blob =
|
|
13167
|
+
const blob = encoder2.encode(joined);
|
|
13141
13168
|
const offsets = new Uint32Array(strings.length + 1);
|
|
13142
13169
|
let cursor = 0;
|
|
13143
13170
|
for (let i = 0; i < strings.length; i++) {
|
|
@@ -13990,7 +14017,7 @@ function decodeSurfaceTable(table) {
|
|
|
13990
14017
|
}
|
|
13991
14018
|
|
|
13992
14019
|
// src/core/partition/frozen/token-table.ts
|
|
13993
|
-
var
|
|
14020
|
+
var encoder3 = new TextEncoder();
|
|
13994
14021
|
var decoder3 = new TextDecoder();
|
|
13995
14022
|
function compareBytes2(blob, start, end, query) {
|
|
13996
14023
|
const length = end - start;
|
|
@@ -14080,7 +14107,7 @@ function wrapFrozenTokenTable(data) {
|
|
|
14080
14107
|
return documentFrequencies[sortedIndex];
|
|
14081
14108
|
},
|
|
14082
14109
|
prefixRange(prefix) {
|
|
14083
|
-
const bytes =
|
|
14110
|
+
const bytes = encoder3.encode(prefix);
|
|
14084
14111
|
const start = lowerBound3(bytes);
|
|
14085
14112
|
return { start, end: prefixEnd(start, bytes) };
|
|
14086
14113
|
},
|
|
@@ -14098,8 +14125,8 @@ function wrapFrozenTokenTable(data) {
|
|
|
14098
14125
|
fromCodePoint = unit;
|
|
14099
14126
|
toCodePoint = nextCodePoint(unit);
|
|
14100
14127
|
}
|
|
14101
|
-
const from =
|
|
14102
|
-
const to =
|
|
14128
|
+
const from = encoder3.encode(String.fromCodePoint(fromCodePoint));
|
|
14129
|
+
const to = encoder3.encode(String.fromCodePoint(toCodePoint));
|
|
14103
14130
|
return { start: lowerBound3(from), end: lowerBound3(to) };
|
|
14104
14131
|
}
|
|
14105
14132
|
};
|
|
@@ -15326,7 +15353,7 @@ async function attachSegments(entry, action) {
|
|
|
15326
15353
|
growPartitionsTo(entry.manager, segment.partitionId);
|
|
15327
15354
|
const surfaceForms = segment.survivingSurfaceForms;
|
|
15328
15355
|
const spellings = surfaceForms === void 0 ? void 0 : NO_REMOVED_SPELLINGS;
|
|
15329
|
-
const frozen = isPagedSnapshot(segment.snapshot) ? (await import('./module-
|
|
15356
|
+
const frozen = isPagedSnapshot(segment.snapshot) ? (await import('./module-CEKA7MQH.mjs')).createPagedFrozenSegment(segment.snapshot) : createSharedFrozenSegment(segment.snapshot, surfaceForms);
|
|
15330
15357
|
for (const docId of segment.tombstonedDocIds ?? []) frozen.tombstoneDocument(docId, spellings);
|
|
15331
15358
|
entry.manager.attachFrozenSegment(segment.partitionId, frozen);
|
|
15332
15359
|
}
|
|
@@ -15381,7 +15408,7 @@ function runSegmentAction(entry, action) {
|
|
|
15381
15408
|
case "attachSegments":
|
|
15382
15409
|
return attachSegments(entry, action);
|
|
15383
15410
|
case "adoptDiskSegments":
|
|
15384
|
-
return import('./module-
|
|
15411
|
+
return import('./module-CEKA7MQH.mjs').then((code) => code.adoptSegmentsOnWorker(entry.manager, action));
|
|
15385
15412
|
case "compactSegments": {
|
|
15386
15413
|
const partition = requireComposite(entry, action.indexName, action.partitionId, "compact");
|
|
15387
15414
|
return mergeFrozenSegments(
|
|
@@ -15429,7 +15456,7 @@ function requireLoadedVectorCode() {
|
|
|
15429
15456
|
function loadVectorCode() {
|
|
15430
15457
|
if (loaded2 !== null) return Promise.resolve(loaded2);
|
|
15431
15458
|
if (loading2 === null) {
|
|
15432
|
-
loading2 = import('./module-
|
|
15459
|
+
loading2 = import('./module-X5PGOE47.mjs').then(
|
|
15433
15460
|
(code) => {
|
|
15434
15461
|
loaded2 = code;
|
|
15435
15462
|
return code;
|
|
@@ -15845,7 +15872,7 @@ var TEXT_REBUILD_SWITCH_BACKLOG_DOCUMENTS = 1e3;
|
|
|
15845
15872
|
// src/partitioning/rewrite-spill-of.ts
|
|
15846
15873
|
async function rewriteSpillOf(storage, manager, target) {
|
|
15847
15874
|
if (storage === void 0 || (target?.config ?? manager.config).textStorage !== "disk") return null;
|
|
15848
|
-
const { openRewriteSpill } = await import('./module-
|
|
15875
|
+
const { openRewriteSpill } = await import('./module-CEKA7MQH.mjs');
|
|
15849
15876
|
return openRewriteSpill(storage, manager, target);
|
|
15850
15877
|
}
|
|
15851
15878
|
|
|
@@ -16407,6 +16434,12 @@ function validateDocId(docId) {
|
|
|
16407
16434
|
);
|
|
16408
16435
|
}
|
|
16409
16436
|
}
|
|
16437
|
+
function validateBatchList(given, listed) {
|
|
16438
|
+
if (Array.isArray(given)) return;
|
|
16439
|
+
throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `A batch takes its ${listed} as an array`, {
|
|
16440
|
+
received: given === null ? "null" : typeof given
|
|
16441
|
+
});
|
|
16442
|
+
}
|
|
16410
16443
|
function validatePartitionConfig(partitions) {
|
|
16411
16444
|
const { maxDocsPerPartition, maxPartitions, watermark } = partitions;
|
|
16412
16445
|
if (maxDocsPerPartition !== void 0 && (!Number.isInteger(maxDocsPerPartition) || maxDocsPerPartition < 1)) {
|
|
@@ -16532,7 +16565,7 @@ async function createIndexFromMetadata(deps, metadata, loadData) {
|
|
|
16532
16565
|
const existing = deps.indexRegistry.get(metadata.indexName);
|
|
16533
16566
|
if (existing !== void 0) {
|
|
16534
16567
|
if ((metadata.analysisGeneration ?? 0) > existing.analysisGeneration) {
|
|
16535
|
-
const { adoptSavedAnalysis } = await import('./analysis-change-
|
|
16568
|
+
const { adoptSavedAnalysis } = await import('./analysis-change-M65AZQQG.mjs');
|
|
16536
16569
|
adoptSavedAnalysis(deps.executor.getManager(metadata.indexName), existing, metadata);
|
|
16537
16570
|
}
|
|
16538
16571
|
if (loadData && deps.executor.getManager(metadata.indexName) === void 0) {
|
|
@@ -17484,26 +17517,6 @@ async function loadIndexOntoWorkers(indexName, executors, source, manager, onDro
|
|
|
17484
17517
|
return copyLoad;
|
|
17485
17518
|
}
|
|
17486
17519
|
|
|
17487
|
-
// src/workers/protocol.ts
|
|
17488
|
-
var nextRequestSequence = 0;
|
|
17489
|
-
function createRequestId() {
|
|
17490
|
-
nextRequestSequence += 1;
|
|
17491
|
-
return String(nextRequestSequence);
|
|
17492
|
-
}
|
|
17493
|
-
function isValidWorkerResponse(msg) {
|
|
17494
|
-
if (msg === null || msg === void 0 || typeof msg !== "object") {
|
|
17495
|
-
return false;
|
|
17496
|
-
}
|
|
17497
|
-
const candidate = msg;
|
|
17498
|
-
if (typeof candidate.requestId !== "string") {
|
|
17499
|
-
return false;
|
|
17500
|
-
}
|
|
17501
|
-
if (candidate.type !== "success" && candidate.type !== "error") {
|
|
17502
|
-
return false;
|
|
17503
|
-
}
|
|
17504
|
-
return true;
|
|
17505
|
-
}
|
|
17506
|
-
|
|
17507
17520
|
// src/engine/orchestration/constants.ts
|
|
17508
17521
|
var DEFAULT_COPY_THRESHOLD = 1e3;
|
|
17509
17522
|
var DEFAULT_COPY_IDLE_TIMEOUT_MS = 3e5;
|
|
@@ -17907,6 +17920,10 @@ function markCopiesLoaded(state, indexName, copyLoad) {
|
|
|
17907
17920
|
requestId: `copy-loaded-${copyLoad}`
|
|
17908
17921
|
});
|
|
17909
17922
|
}
|
|
17923
|
+
function copiesWillReceive(state, indexName) {
|
|
17924
|
+
if (state.copyLoadBuffers.has(indexName) || state.replicationQueues.has(indexName)) return true;
|
|
17925
|
+
return state.workerPool !== null && state.scaledOutIndexes.has(indexName);
|
|
17926
|
+
}
|
|
17910
17927
|
async function replicateToWorkers(state, action) {
|
|
17911
17928
|
if (!("indexName" in action)) {
|
|
17912
17929
|
if (state.workerPool === null) return;
|
|
@@ -17914,6 +17931,7 @@ async function replicateToWorkers(state, action) {
|
|
|
17914
17931
|
await dispatchToWorkers(state, action);
|
|
17915
17932
|
return;
|
|
17916
17933
|
}
|
|
17934
|
+
if (!copiesWillReceive(state, action.indexName)) return;
|
|
17917
17935
|
const detached = detachCallerDocuments(state, action);
|
|
17918
17936
|
const loading3 = state.copyLoadBuffers.get(action.indexName);
|
|
17919
17937
|
if (loading3 !== void 0) {
|
|
@@ -18380,297 +18398,6 @@ async function createWorkerFactory(entryPoint) {
|
|
|
18380
18398
|
throw new NarsilError(ErrorCodes.WORKER_CRASHED, `No worker support available on runtime "${runtime.runtime}"`);
|
|
18381
18399
|
}
|
|
18382
18400
|
|
|
18383
|
-
// src/workers/pool-memory.ts
|
|
18384
|
-
function toFinite(value) {
|
|
18385
|
-
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
18386
|
-
}
|
|
18387
|
-
function toHeapLimit(value) {
|
|
18388
|
-
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : null;
|
|
18389
|
-
}
|
|
18390
|
-
async function memoryStatsOf(slots) {
|
|
18391
|
-
const indices = [];
|
|
18392
|
-
const pending = [];
|
|
18393
|
-
for (const [slotIndex, slot] of slots) {
|
|
18394
|
-
indices.push(slotIndex);
|
|
18395
|
-
pending.push(
|
|
18396
|
-
slot.executor.execute({ type: "memoryReport", requestId: createRequestId() }).catch(() => null)
|
|
18397
|
-
);
|
|
18398
|
-
}
|
|
18399
|
-
const reports = await Promise.all(pending);
|
|
18400
|
-
const stats = [];
|
|
18401
|
-
for (let n = 0; n < indices.length; n++) {
|
|
18402
|
-
const report = reports[n];
|
|
18403
|
-
stats.push({
|
|
18404
|
-
workerId: indices[n],
|
|
18405
|
-
heapUsed: toFinite(report?.heapUsed),
|
|
18406
|
-
heapTotal: toFinite(report?.heapTotal),
|
|
18407
|
-
heapLimit: toHeapLimit(report?.heapLimit),
|
|
18408
|
-
external: toFinite(report?.external)
|
|
18409
|
-
});
|
|
18410
|
-
}
|
|
18411
|
-
return stats;
|
|
18412
|
-
}
|
|
18413
|
-
|
|
18414
|
-
// src/workers/pool.ts
|
|
18415
|
-
function createWorkerPool(config) {
|
|
18416
|
-
const workerCount = resolveWorkerCount(config.count);
|
|
18417
|
-
const queryWorkerCount = workerCount - Math.min(config.longQueryWorkers ?? 0, workerCount - 1);
|
|
18418
|
-
const workers = /* @__PURE__ */ new Map();
|
|
18419
|
-
const deadSlots = /* @__PURE__ */ new Set();
|
|
18420
|
-
const goneSlots = /* @__PURE__ */ new Set();
|
|
18421
|
-
const threadsStillRunning = /* @__PURE__ */ new Set();
|
|
18422
|
-
const waitingForEveryThread = [];
|
|
18423
|
-
const indexAssignment = /* @__PURE__ */ new Map();
|
|
18424
|
-
let isShutdown = false;
|
|
18425
|
-
function handleWorkerDeath(slotIndex, error) {
|
|
18426
|
-
if (isShutdown) {
|
|
18427
|
-
return;
|
|
18428
|
-
}
|
|
18429
|
-
const slot = workers.get(slotIndex);
|
|
18430
|
-
if (slot !== void 0 && !slot.serving) {
|
|
18431
|
-
workers.delete(slotIndex);
|
|
18432
|
-
goneSlots.delete(slotIndex);
|
|
18433
|
-
return;
|
|
18434
|
-
}
|
|
18435
|
-
if (deadSlots.has(slotIndex)) {
|
|
18436
|
-
return;
|
|
18437
|
-
}
|
|
18438
|
-
deadSlots.add(slotIndex);
|
|
18439
|
-
const indexNames = slot ? [...slot.indexes].sort() : [];
|
|
18440
|
-
workers.delete(slotIndex);
|
|
18441
|
-
config.onWorkerCrash?.(slotIndex, indexNames, error);
|
|
18442
|
-
}
|
|
18443
|
-
function handleWorkerGone(slotIndex) {
|
|
18444
|
-
if (!deadSlots.has(slotIndex) || workers.has(slotIndex)) {
|
|
18445
|
-
return;
|
|
18446
|
-
}
|
|
18447
|
-
goneSlots.add(slotIndex);
|
|
18448
|
-
config.onWorkerGone?.(slotIndex);
|
|
18449
|
-
}
|
|
18450
|
-
function spawnSlot(slotIndex, serving) {
|
|
18451
|
-
const slot = {
|
|
18452
|
-
executor: config.workerFactory(
|
|
18453
|
-
slotIndex,
|
|
18454
|
-
(error) => handleWorkerDeath(slotIndex, error),
|
|
18455
|
-
() => {
|
|
18456
|
-
noteThreadGone(slot.executor);
|
|
18457
|
-
handleWorkerGone(slotIndex);
|
|
18458
|
-
}
|
|
18459
|
-
),
|
|
18460
|
-
indexes: /* @__PURE__ */ new Set(),
|
|
18461
|
-
inFlight: 0,
|
|
18462
|
-
serving
|
|
18463
|
-
};
|
|
18464
|
-
threadsStillRunning.add(slot.executor);
|
|
18465
|
-
workers.set(slotIndex, slot);
|
|
18466
|
-
return slot;
|
|
18467
|
-
}
|
|
18468
|
-
function noteThreadGone(executor) {
|
|
18469
|
-
threadsStillRunning.delete(executor);
|
|
18470
|
-
if (threadsStillRunning.size > 0) return;
|
|
18471
|
-
for (const resume of waitingForEveryThread.splice(0)) resume();
|
|
18472
|
-
}
|
|
18473
|
-
function whenEveryThreadIsGone() {
|
|
18474
|
-
if (threadsStillRunning.size === 0) return Promise.resolve();
|
|
18475
|
-
return new Promise((resolve) => {
|
|
18476
|
-
waitingForEveryThread.push(resolve);
|
|
18477
|
-
});
|
|
18478
|
-
}
|
|
18479
|
-
function shutDownUntilTheThreadIsGone(executor) {
|
|
18480
|
-
return executor.shutdown().then(() => noteThreadGone(executor));
|
|
18481
|
-
}
|
|
18482
|
-
function ensureWorker(slotIndex) {
|
|
18483
|
-
const slot = workers.get(slotIndex);
|
|
18484
|
-
if (slot !== void 0) return slot;
|
|
18485
|
-
if (deadSlots.has(slotIndex)) return void 0;
|
|
18486
|
-
return spawnSlot(slotIndex, true);
|
|
18487
|
-
}
|
|
18488
|
-
function deadWorkerIds() {
|
|
18489
|
-
return [...deadSlots].filter((slotIndex) => goneSlots.has(slotIndex) && !workers.has(slotIndex)).sort((a, b) => a - b);
|
|
18490
|
-
}
|
|
18491
|
-
function spawnReplacement(slotIndex) {
|
|
18492
|
-
if (isShutdown || !deadSlots.has(slotIndex) || !goneSlots.has(slotIndex) || workers.has(slotIndex)) return null;
|
|
18493
|
-
const slot = spawnSlot(slotIndex, false);
|
|
18494
|
-
return {
|
|
18495
|
-
workerId: slotIndex,
|
|
18496
|
-
executor: slot.executor,
|
|
18497
|
-
hold(indexName) {
|
|
18498
|
-
slot.indexes.add(indexName);
|
|
18499
|
-
},
|
|
18500
|
-
admit() {
|
|
18501
|
-
if (workers.get(slotIndex) !== slot) return;
|
|
18502
|
-
deadSlots.delete(slotIndex);
|
|
18503
|
-
goneSlots.delete(slotIndex);
|
|
18504
|
-
slot.serving = true;
|
|
18505
|
-
},
|
|
18506
|
-
abandon() {
|
|
18507
|
-
if (workers.get(slotIndex) === slot) workers.delete(slotIndex);
|
|
18508
|
-
void shutDownUntilTheThreadIsGone(slot.executor).catch(() => void 0);
|
|
18509
|
-
}
|
|
18510
|
-
};
|
|
18511
|
-
}
|
|
18512
|
-
function isLongQueryWorker(workerId) {
|
|
18513
|
-
return workerId >= queryWorkerCount;
|
|
18514
|
-
}
|
|
18515
|
-
function assignSlot(indexName) {
|
|
18516
|
-
const preferred = fnv1a(indexName) % queryWorkerCount;
|
|
18517
|
-
for (let probe = 0; probe < queryWorkerCount; probe++) {
|
|
18518
|
-
const candidate = (preferred + probe) % queryWorkerCount;
|
|
18519
|
-
if (!deadSlots.has(candidate)) {
|
|
18520
|
-
return candidate;
|
|
18521
|
-
}
|
|
18522
|
-
}
|
|
18523
|
-
throw new NarsilError(ErrorCodes.WORKER_CRASHED, `Every worker in the pool has crashed`);
|
|
18524
|
-
}
|
|
18525
|
-
function addIndex(indexName) {
|
|
18526
|
-
if (isShutdown) {
|
|
18527
|
-
throw new NarsilError(ErrorCodes.WORKER_CRASHED, "Worker pool has been shut down");
|
|
18528
|
-
}
|
|
18529
|
-
if (indexAssignment.has(indexName)) {
|
|
18530
|
-
return;
|
|
18531
|
-
}
|
|
18532
|
-
const slotIndex = assignSlot(indexName);
|
|
18533
|
-
const slot = ensureWorker(slotIndex);
|
|
18534
|
-
if (!slot) {
|
|
18535
|
-
throw new NarsilError(ErrorCodes.WORKER_CRASHED, `Worker ${slotIndex} for index "${indexName}" has crashed`);
|
|
18536
|
-
}
|
|
18537
|
-
slot.indexes.add(indexName);
|
|
18538
|
-
indexAssignment.set(indexName, slotIndex);
|
|
18539
|
-
}
|
|
18540
|
-
function removeIndex(indexName) {
|
|
18541
|
-
for (const slot of workers.values()) slot.indexes.delete(indexName);
|
|
18542
|
-
indexAssignment.delete(indexName);
|
|
18543
|
-
}
|
|
18544
|
-
function getExecutor(indexName) {
|
|
18545
|
-
if (isShutdown) {
|
|
18546
|
-
throw new NarsilError(ErrorCodes.WORKER_CRASHED, "Worker pool has been shut down");
|
|
18547
|
-
}
|
|
18548
|
-
const slotIndex = indexAssignment.get(indexName);
|
|
18549
|
-
if (slotIndex === void 0) {
|
|
18550
|
-
throw new NarsilError(ErrorCodes.INDEX_NOT_FOUND, `Index "${indexName}" is not registered in the worker pool`);
|
|
18551
|
-
}
|
|
18552
|
-
const slot = workers.get(slotIndex);
|
|
18553
|
-
if (slot?.serving) {
|
|
18554
|
-
return slot.executor;
|
|
18555
|
-
}
|
|
18556
|
-
for (const survivor of workers.values()) {
|
|
18557
|
-
if (survivor.serving && survivor.indexes.has(indexName)) {
|
|
18558
|
-
return survivor.executor;
|
|
18559
|
-
}
|
|
18560
|
-
}
|
|
18561
|
-
throw new NarsilError(ErrorCodes.WORKER_CRASHED, `Every worker holding index "${indexName}" has crashed`);
|
|
18562
|
-
}
|
|
18563
|
-
async function shutdown() {
|
|
18564
|
-
if (isShutdown) {
|
|
18565
|
-
return;
|
|
18566
|
-
}
|
|
18567
|
-
isShutdown = true;
|
|
18568
|
-
const shutdownPromises = [...threadsStillRunning].map((executor) => {
|
|
18569
|
-
let timeoutId;
|
|
18570
|
-
const timeoutPromise = new Promise((resolve) => {
|
|
18571
|
-
timeoutId = setTimeout(resolve, SHUTDOWN_TIMEOUT_MS);
|
|
18572
|
-
});
|
|
18573
|
-
return Promise.race([shutDownUntilTheThreadIsGone(executor), timeoutPromise]).finally(
|
|
18574
|
-
() => clearTimeout(timeoutId)
|
|
18575
|
-
);
|
|
18576
|
-
});
|
|
18577
|
-
await Promise.allSettled(shutdownPromises);
|
|
18578
|
-
indexAssignment.clear();
|
|
18579
|
-
}
|
|
18580
|
-
function getAllExecutors() {
|
|
18581
|
-
return [...workers.values()].map((slot) => slot.executor);
|
|
18582
|
-
}
|
|
18583
|
-
function executorEntries() {
|
|
18584
|
-
return [...workers].map(([workerId, slot]) => ({ workerId, executor: slot.executor }));
|
|
18585
|
-
}
|
|
18586
|
-
function executorsHolding(indexName) {
|
|
18587
|
-
const holders = [];
|
|
18588
|
-
for (const slot of workers.values()) {
|
|
18589
|
-
if (slot.indexes.has(indexName)) holders.push(slot.executor);
|
|
18590
|
-
}
|
|
18591
|
-
return holders;
|
|
18592
|
-
}
|
|
18593
|
-
function lease(workerId, slot) {
|
|
18594
|
-
slot.inFlight += 1;
|
|
18595
|
-
let released = false;
|
|
18596
|
-
return {
|
|
18597
|
-
workerId,
|
|
18598
|
-
executor: slot.executor,
|
|
18599
|
-
release() {
|
|
18600
|
-
if (released) return;
|
|
18601
|
-
released = true;
|
|
18602
|
-
slot.inFlight -= 1;
|
|
18603
|
-
}
|
|
18604
|
-
};
|
|
18605
|
-
}
|
|
18606
|
-
function leaseLeastBusy(indexName) {
|
|
18607
|
-
let chosenId = -1;
|
|
18608
|
-
let chosen = null;
|
|
18609
|
-
for (const [workerId, slot] of workers) {
|
|
18610
|
-
if (!slot.serving || isLongQueryWorker(workerId)) continue;
|
|
18611
|
-
if (indexName !== void 0 && !slot.indexes.has(indexName)) continue;
|
|
18612
|
-
if (chosen === null || slot.inFlight < chosen.inFlight) {
|
|
18613
|
-
chosenId = workerId;
|
|
18614
|
-
chosen = slot;
|
|
18615
|
-
}
|
|
18616
|
-
if (chosen.inFlight === 0) break;
|
|
18617
|
-
}
|
|
18618
|
-
return chosen === null ? null : lease(chosenId, chosen);
|
|
18619
|
-
}
|
|
18620
|
-
function queriesInFlight() {
|
|
18621
|
-
let total = 0;
|
|
18622
|
-
for (const [workerId, slot] of workers) {
|
|
18623
|
-
if (slot.serving && !isLongQueryWorker(workerId)) total += slot.inFlight;
|
|
18624
|
-
}
|
|
18625
|
-
return total;
|
|
18626
|
-
}
|
|
18627
|
-
function leaseIdle(limit) {
|
|
18628
|
-
const leases = [];
|
|
18629
|
-
for (const [workerId, slot] of workers) {
|
|
18630
|
-
if (leases.length >= limit) break;
|
|
18631
|
-
if (slot.serving && slot.inFlight === 0 && !isLongQueryWorker(workerId)) leases.push(lease(workerId, slot));
|
|
18632
|
-
}
|
|
18633
|
-
return leases;
|
|
18634
|
-
}
|
|
18635
|
-
function addIndexToAll(indexName) {
|
|
18636
|
-
if (isShutdown) {
|
|
18637
|
-
throw new NarsilError(ErrorCodes.WORKER_CRASHED, "Worker pool has been shut down");
|
|
18638
|
-
}
|
|
18639
|
-
for (let i = 0; i < workerCount; i++) {
|
|
18640
|
-
ensureWorker(i)?.indexes.add(indexName);
|
|
18641
|
-
}
|
|
18642
|
-
indexAssignment.set(indexName, assignSlot(indexName));
|
|
18643
|
-
}
|
|
18644
|
-
function spawnAll() {
|
|
18645
|
-
if (isShutdown) {
|
|
18646
|
-
throw new NarsilError(ErrorCodes.WORKER_CRASHED, "Worker pool has been shut down");
|
|
18647
|
-
}
|
|
18648
|
-
for (let i = 0; i < workerCount; i++) ensureWorker(i);
|
|
18649
|
-
}
|
|
18650
|
-
return {
|
|
18651
|
-
getExecutor,
|
|
18652
|
-
getAllExecutors,
|
|
18653
|
-
executorEntries,
|
|
18654
|
-
executorsHolding,
|
|
18655
|
-
leaseLeastBusy,
|
|
18656
|
-
leaseIdle,
|
|
18657
|
-
isLongQueryWorker,
|
|
18658
|
-
queriesInFlight,
|
|
18659
|
-
spawnAll,
|
|
18660
|
-
deadWorkerIds,
|
|
18661
|
-
spawnReplacement,
|
|
18662
|
-
get workerCount() {
|
|
18663
|
-
return workerCount;
|
|
18664
|
-
},
|
|
18665
|
-
addIndex,
|
|
18666
|
-
addIndexToAll,
|
|
18667
|
-
removeIndex,
|
|
18668
|
-
getMemoryStats: () => memoryStatsOf(workers.entries()),
|
|
18669
|
-
shutdown,
|
|
18670
|
-
whenEveryThreadIsGone
|
|
18671
|
-
};
|
|
18672
|
-
}
|
|
18673
|
-
|
|
18674
18401
|
// src/engine/orchestration/vector-copies.ts
|
|
18675
18402
|
function holdsIndex(state, indexName) {
|
|
18676
18403
|
return state.scaledOutIndexes.has(indexName) || state.copyLoadBuffers.has(indexName);
|
|
@@ -18960,7 +18687,7 @@ async function startPool(state) {
|
|
|
18960
18687
|
);
|
|
18961
18688
|
}
|
|
18962
18689
|
eligibleIndexNames(state);
|
|
18963
|
-
const factory = await createWorkerFactory();
|
|
18690
|
+
const [factory, { createWorkerPool }] = await Promise.all([createWorkerFactory(), import('./pool-DTYSPBMQ.mjs')]);
|
|
18964
18691
|
let started = null;
|
|
18965
18692
|
const pool = createWorkerPool({
|
|
18966
18693
|
count: state.keywordWorkerCount + state.longQueryWorkerCount,
|
|
@@ -19651,7 +19378,7 @@ async function emitWriteEventAfter(source, indexName, write) {
|
|
|
19651
19378
|
// src/engine/core.ts
|
|
19652
19379
|
async function createEngineCore(config, hooks, capacityScope = "index") {
|
|
19653
19380
|
validateWorkerConfig(config?.workers, config?.lifecycle);
|
|
19654
|
-
const rerankSettings = config?.rerankTimeout === void 0 && config?.maxRerankWindow === void 0 ? { timeoutMs: DEFAULT_RERANK_TIMEOUT_MS, maxWindow: DEFAULT_MAX_RERANK_WINDOW } : (await import('./runtime-
|
|
19381
|
+
const rerankSettings = config?.rerankTimeout === void 0 && config?.maxRerankWindow === void 0 ? { timeoutMs: DEFAULT_RERANK_TIMEOUT_MS, maxWindow: DEFAULT_MAX_RERANK_WINDOW } : (await import('./runtime-D2ULZGCN.mjs')).resolveRerankSettings(config);
|
|
19655
19382
|
const eventHandlers = eventHandlersOf(config?.events);
|
|
19656
19383
|
const vectorWorkerCount = splitWorkerBudget(resolveWorkerCount(config?.workers?.count)).vector;
|
|
19657
19384
|
const vectorCopyPolicy = {
|
|
@@ -19662,7 +19389,7 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
|
|
|
19662
19389
|
if (config?.lifecycle !== void 0 && durabilityTier === null) {
|
|
19663
19390
|
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "Index lifecycle settings require durability");
|
|
19664
19391
|
}
|
|
19665
|
-
const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-
|
|
19392
|
+
const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-W5AVV3RF.mjs');
|
|
19666
19393
|
const filesystemDurability = durabilityTier?.kind === "wal";
|
|
19667
19394
|
const executor = createDirectExecutor({
|
|
19668
19395
|
vectorWorkerCopies: vectorCopyPolicy,
|
|
@@ -19847,7 +19574,7 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
|
|
|
19847
19574
|
requireManager,
|
|
19848
19575
|
resumeChange: async (indexName) => {
|
|
19849
19576
|
if ((indexRegistry.get(indexName)?.pendingAnalysis ?? null) === null) return;
|
|
19850
|
-
await (await import('./analysis-change-entry-
|
|
19577
|
+
await (await import('./analysis-change-entry-H3YIOLXZ.mjs')).resumeChangeOf(engineCore, indexName);
|
|
19851
19578
|
},
|
|
19852
19579
|
onClose: hooks?.onIndexClose,
|
|
19853
19580
|
onOpen: (indexName) => {
|
|
@@ -19874,7 +19601,9 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
|
|
|
19874
19601
|
bufferedDocState: (indexName, docId) => waqMap.get(indexName)?.bufferedDocState(docId),
|
|
19875
19602
|
capacityScope,
|
|
19876
19603
|
checkWatermark: watermarkNotifier.check,
|
|
19877
|
-
checkHeapPressure: heapPressureNotifier.check
|
|
19604
|
+
checkHeapPressure: heapPressureNotifier.check,
|
|
19605
|
+
memoryWriteBlock: createMemoryWriteBlock({
|
|
19606
|
+
settings: config?.memory})
|
|
19878
19607
|
};
|
|
19879
19608
|
const rebalanceCtx = {
|
|
19880
19609
|
router: rebalanceRouter,
|
|
@@ -19929,7 +19658,7 @@ async function startEngineCore(core, config) {
|
|
|
19929
19658
|
checkHeapAfterRecovery(core);
|
|
19930
19659
|
}
|
|
19931
19660
|
if (core.invalidation) await core.invalidation.start();
|
|
19932
|
-
if (core.durability) await (await import('./analysis-change-entry-
|
|
19661
|
+
if (core.durability) await (await import('./analysis-change-entry-H3YIOLXZ.mjs')).resumeEveryChange(core);
|
|
19933
19662
|
if (config?.lifecycle === void 0) await core.analysisRebuild.reviewStaleIndexes();
|
|
19934
19663
|
} catch (err) {
|
|
19935
19664
|
await core.durability?.manager.shutdown().catch(() => void 0);
|
|
@@ -19967,7 +19696,7 @@ async function shutdownEngine(core) {
|
|
|
19967
19696
|
}
|
|
19968
19697
|
}
|
|
19969
19698
|
if (core.rerankAdapters.size > 0) {
|
|
19970
|
-
await (await import('./runtime-
|
|
19699
|
+
await (await import('./runtime-D2ULZGCN.mjs')).shutdownRerankAdapters(core.rerankAdapters);
|
|
19971
19700
|
}
|
|
19972
19701
|
await orchestrator.shutdown();
|
|
19973
19702
|
await executor.shutdown();
|
|
@@ -20298,34 +20027,17 @@ function loadFailed(message, details) {
|
|
|
20298
20027
|
throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, message, details);
|
|
20299
20028
|
}
|
|
20300
20029
|
async function gunzipWithinLimit(compressed, what) {
|
|
20301
|
-
const
|
|
20302
|
-
|
|
20303
|
-
|
|
20304
|
-
|
|
20305
|
-
|
|
20306
|
-
let step;
|
|
20307
|
-
try {
|
|
20308
|
-
step = await reader.read();
|
|
20309
|
-
} catch (error) {
|
|
20310
|
-
loadFailed(`The ${what} holds a gzip payload that fails to inflate`, {
|
|
20311
|
-
cause: error instanceof Error ? error.message : String(error)
|
|
20312
|
-
});
|
|
20313
|
-
}
|
|
20314
|
-
if (step.done) break;
|
|
20315
|
-
total += step.value.byteLength;
|
|
20316
|
-
if (total > MAX_FILE_BYTES) {
|
|
20317
|
-
await reader.cancel();
|
|
20030
|
+
const { gunzip } = await import('./gzip-5S7ROJFJ.mjs');
|
|
20031
|
+
try {
|
|
20032
|
+
return await gunzip(compressed, MAX_FILE_BYTES);
|
|
20033
|
+
} catch (error) {
|
|
20034
|
+
if (error?.code === "EFBIG") {
|
|
20318
20035
|
loadFailed(`The ${what} inflates past the file size limit of ${MAX_FILE_BYTES} bytes`);
|
|
20319
20036
|
}
|
|
20320
|
-
|
|
20321
|
-
|
|
20322
|
-
|
|
20323
|
-
let offset = 0;
|
|
20324
|
-
for (const chunk of chunks) {
|
|
20325
|
-
inflated.set(chunk, offset);
|
|
20326
|
-
offset += chunk.byteLength;
|
|
20037
|
+
loadFailed(`The ${what} holds a gzip payload that fails to inflate`, {
|
|
20038
|
+
cause: error instanceof Error ? error.message : String(error)
|
|
20039
|
+
});
|
|
20327
20040
|
}
|
|
20328
|
-
return inflated;
|
|
20329
20041
|
}
|
|
20330
20042
|
async function openChecksummedEnvelope(data, expected) {
|
|
20331
20043
|
const { envelopeFormatVersion, what } = expected;
|
|
@@ -20625,7 +20337,7 @@ async function dropEngineIndex(core, name) {
|
|
|
20625
20337
|
const entry = core.requireIndex(name);
|
|
20626
20338
|
const changeRecorded = () => entry.pendingAnalysis !== null || entry.durableAnalysis !== null;
|
|
20627
20339
|
const abandonChange = async () => {
|
|
20628
|
-
await (await import('./analysis-change-entry-
|
|
20340
|
+
await (await import('./analysis-change-entry-H3YIOLXZ.mjs')).abandonChangeOf(core, name);
|
|
20629
20341
|
};
|
|
20630
20342
|
if (changeRecorded()) await abandonChange();
|
|
20631
20343
|
await core.indexState.drop(name, async () => {
|
|
@@ -20911,18 +20623,24 @@ async function rollbackInsertedDocument(ctx, indexName, docId, inserted, origina
|
|
|
20911
20623
|
return;
|
|
20912
20624
|
}
|
|
20913
20625
|
try {
|
|
20914
|
-
await
|
|
20915
|
-
|
|
20626
|
+
await changeIndexOutsideExternalWaits(async () => {
|
|
20627
|
+
await ctx.executor.execute({ type: "remove", indexName, docId, requestId: docId });
|
|
20628
|
+
removeDocumentVectors(docId, ctx.requireManager(indexName).getVectorIndexes());
|
|
20629
|
+
});
|
|
20916
20630
|
} catch (rollbackError) {
|
|
20917
20631
|
rollbackFailed(docId, originalError, rollbackError);
|
|
20918
20632
|
}
|
|
20919
20633
|
}
|
|
20920
20634
|
async function rollbackRemovedDocument(ctx, indexName, docId, restoreDoc, originalError) {
|
|
20921
|
-
if (restoreDoc === void 0
|
|
20635
|
+
if (restoreDoc === void 0) {
|
|
20922
20636
|
return;
|
|
20923
20637
|
}
|
|
20638
|
+
const manager = ctx.requireManager(indexName);
|
|
20924
20639
|
try {
|
|
20925
|
-
await
|
|
20640
|
+
await changeIndexOutsideExternalWaits(async () => {
|
|
20641
|
+
if (manager.has(docId)) return;
|
|
20642
|
+
await ctx.executor.execute({ type: "insert", indexName, docId, document: restoreDoc, requestId: docId });
|
|
20643
|
+
});
|
|
20926
20644
|
} catch (rollbackError) {
|
|
20927
20645
|
rollbackFailed(docId, originalError, rollbackError);
|
|
20928
20646
|
}
|
|
@@ -20932,7 +20650,9 @@ async function rollbackUpdatedDocument(ctx, indexName, docId, restoreDoc, origin
|
|
|
20932
20650
|
return;
|
|
20933
20651
|
}
|
|
20934
20652
|
try {
|
|
20935
|
-
await
|
|
20653
|
+
await changeIndexOutsideExternalWaits(async () => {
|
|
20654
|
+
await ctx.executor.execute({ type: "update", indexName, docId, document: restoreDoc, requestId: docId });
|
|
20655
|
+
});
|
|
20936
20656
|
} catch (rollbackError) {
|
|
20937
20657
|
rollbackFailed(docId, originalError, rollbackError);
|
|
20938
20658
|
}
|
|
@@ -21113,7 +20833,7 @@ async function insertDocument(ctx, indexName, document, docId, options) {
|
|
|
21113
20833
|
}
|
|
21114
20834
|
let inserted = false;
|
|
21115
20835
|
let buffered = false;
|
|
21116
|
-
const
|
|
20836
|
+
const insertIntoIndex = async () => {
|
|
21117
20837
|
admitInsert(ctx, indexName, insertManager, resolvedDocId);
|
|
21118
20838
|
if (ctx.bufferIfRebalancing(indexName, { action: "insert", docId: resolvedDocId, document, indexName })) {
|
|
21119
20839
|
buffered = true;
|
|
@@ -21148,6 +20868,7 @@ async function insertDocument(ctx, indexName, document, docId, options) {
|
|
|
21148
20868
|
throw err;
|
|
21149
20869
|
}
|
|
21150
20870
|
};
|
|
20871
|
+
const applyInsert = indexChangeOutsideExternalWaits(insertIntoIndex);
|
|
21151
20872
|
if (ctx.durability) {
|
|
21152
20873
|
try {
|
|
21153
20874
|
await ctx.durability.recordInsertOrUpdate(indexName, resolvedDocId, document, applyInsert);
|
|
@@ -21202,6 +20923,7 @@ async function recordChunk(ctx, indexName, mutations, applies) {
|
|
|
21202
20923
|
}
|
|
21203
20924
|
const failures = [];
|
|
21204
20925
|
for (const apply of applies) {
|
|
20926
|
+
if (turnsAreBudgeted && turnIsSpent()) await yieldTurn();
|
|
21205
20927
|
try {
|
|
21206
20928
|
await apply();
|
|
21207
20929
|
failures.push(null);
|
|
@@ -21215,7 +20937,7 @@ async function recordChunk(ctx, indexName, mutations, applies) {
|
|
|
21215
20937
|
// src/engine/mutations/insert-batch-apply.ts
|
|
21216
20938
|
function applyOf(ctx, indexName, doc, options, progress) {
|
|
21217
20939
|
const manager = ctx.requireManager(indexName);
|
|
21218
|
-
|
|
20940
|
+
const insertIntoIndex = async () => {
|
|
21219
20941
|
if (ctx.abortController.signal.aborted) {
|
|
21220
20942
|
progress.skipped = true;
|
|
21221
20943
|
throw ctx.abortController.signal.reason;
|
|
@@ -21254,6 +20976,7 @@ function applyOf(ctx, indexName, doc, options, progress) {
|
|
|
21254
20976
|
throw vecErr;
|
|
21255
20977
|
}
|
|
21256
20978
|
};
|
|
20979
|
+
return indexChangeOutsideExternalWaits(insertIntoIndex);
|
|
21257
20980
|
}
|
|
21258
20981
|
async function applyInsertChunk(ctx, indexName, docs, options) {
|
|
21259
20982
|
const progress = docs.map(() => ({ inserted: false, buffered: false, skipped: false }));
|
|
@@ -21539,7 +21262,7 @@ function attachOnce(manager, attachment) {
|
|
|
21539
21262
|
}
|
|
21540
21263
|
function applyOfMergedDocument(ctx, indexName, doc, attachment, progress) {
|
|
21541
21264
|
const manager = ctx.requireManager(indexName);
|
|
21542
|
-
|
|
21265
|
+
const attachToIndex = async () => {
|
|
21543
21266
|
attachOnce(manager, attachment);
|
|
21544
21267
|
progress.applied = true;
|
|
21545
21268
|
try {
|
|
@@ -21562,6 +21285,7 @@ function applyOfMergedDocument(ctx, indexName, doc, attachment, progress) {
|
|
|
21562
21285
|
throw vecErr;
|
|
21563
21286
|
}
|
|
21564
21287
|
};
|
|
21288
|
+
return indexChangeOutsideExternalWaits(attachToIndex);
|
|
21565
21289
|
}
|
|
21566
21290
|
function chunksOfWholeSegments(built, frozen, memberIndexes, admitted) {
|
|
21567
21291
|
const chunks = [];
|
|
@@ -21747,6 +21471,7 @@ async function insertBatchViaSegments(ctx, indexName, documents, options) {
|
|
|
21747
21471
|
async function insertDocumentBatch(ctx, indexName, documents, options) {
|
|
21748
21472
|
ctx.guardShutdown();
|
|
21749
21473
|
const entry = ctx.requireIndex(indexName);
|
|
21474
|
+
validateBatchList(documents, "documents");
|
|
21750
21475
|
await ctx.orchestrator.scaleOutBeforeBatch(indexName, documents.length);
|
|
21751
21476
|
const copiesBuildSegments = ctx.orchestrator.segmentBuildConcurrency(indexName) > 0;
|
|
21752
21477
|
if (documents.length >= MIN_DOCUMENTS_FOR_SEGMENTS && !ctx.isRebalancing(indexName) && copiesBuildSegments) {
|
|
@@ -21811,6 +21536,7 @@ async function insertDocumentBatch(ctx, indexName, documents, options) {
|
|
|
21811
21536
|
}
|
|
21812
21537
|
const prepared = [];
|
|
21813
21538
|
for (let i = chunkStart; i < chunkEnd; i++) {
|
|
21539
|
+
if (turnsAreBudgeted && turnIsSpent()) await yieldTurn();
|
|
21814
21540
|
if (ctx.abortController.signal.aborted) break;
|
|
21815
21541
|
if (chunkFailedIndexes.has(i)) continue;
|
|
21816
21542
|
const batchDocId = providedDocId(documents[i]) ?? ctx.idGenerator();
|
|
@@ -21854,6 +21580,7 @@ async function insertDocumentBatch(ctx, indexName, documents, options) {
|
|
|
21854
21580
|
const replicatedAsSegments = copiesBuildSegments && await replicateAsSegments(ctx, indexName, replicableIds, replicableDocs, options?.skipClone);
|
|
21855
21581
|
if (!replicatedAsSegments) {
|
|
21856
21582
|
for (let i = 0; i < replicableIds.length; i++) {
|
|
21583
|
+
if (turnsAreBudgeted && turnIsSpent()) await yieldTurn();
|
|
21857
21584
|
await ctx.orchestrator.replicateToWorkers({
|
|
21858
21585
|
type: "insert",
|
|
21859
21586
|
indexName,
|
|
@@ -21901,7 +21628,7 @@ async function prepareRemoval(ctx, indexName, docId) {
|
|
|
21901
21628
|
}
|
|
21902
21629
|
function applyOfRemoval(ctx, indexName, prepared) {
|
|
21903
21630
|
const { docId, removedSpellings } = prepared;
|
|
21904
|
-
|
|
21631
|
+
const removeFromIndex = async () => {
|
|
21905
21632
|
if (ctx.isRebalancing(indexName)) {
|
|
21906
21633
|
const bufferedState = ctx.bufferedDocState(indexName, docId);
|
|
21907
21634
|
const exists = bufferedState !== void 0 ? bufferedState === "present" : ctx.requireManager(indexName).has(docId);
|
|
@@ -21916,6 +21643,7 @@ function applyOfRemoval(ctx, indexName, prepared) {
|
|
|
21916
21643
|
await ctx.executor.execute({ type: "remove", indexName, docId, requestId: docId, removedSpellings });
|
|
21917
21644
|
removeDocumentVectors(docId, ctx.requireManager(indexName).getVectorIndexes());
|
|
21918
21645
|
};
|
|
21646
|
+
return indexChangeOutsideExternalWaits(removeFromIndex);
|
|
21919
21647
|
}
|
|
21920
21648
|
async function settleRemoval(ctx, indexName, prepared) {
|
|
21921
21649
|
const { docId, removedSpellings } = prepared;
|
|
@@ -21953,6 +21681,7 @@ async function removeDocument(ctx, indexName, docId, options) {
|
|
|
21953
21681
|
async function removeDocumentBatch(ctx, indexName, docIds, options) {
|
|
21954
21682
|
ctx.guardShutdown();
|
|
21955
21683
|
ctx.requireIndex(indexName);
|
|
21684
|
+
validateBatchList(docIds, "document IDs");
|
|
21956
21685
|
const succeeded = [];
|
|
21957
21686
|
const failed = [];
|
|
21958
21687
|
const manager = ctx.requireManager(indexName);
|
|
@@ -21962,6 +21691,7 @@ async function removeDocumentBatch(ctx, indexName, docIds, options) {
|
|
|
21962
21691
|
const chunkEnd = Math.min(chunkStart + BATCH_CHUNK_SIZE, docIds.length);
|
|
21963
21692
|
const prepared = [];
|
|
21964
21693
|
for (let i = chunkStart; i < chunkEnd; i++) {
|
|
21694
|
+
if (turnsAreBudgeted && turnIsSpent()) await yieldTurn();
|
|
21965
21695
|
try {
|
|
21966
21696
|
prepared.push(await prepareRemoval(ctx, indexName, docIds[i]));
|
|
21967
21697
|
} catch (err) {
|
|
@@ -22106,7 +21836,7 @@ async function prepareUpdate(ctx, indexName, entry, docId, document) {
|
|
|
22106
21836
|
function applyOfUpdate(ctx, indexName, prepared) {
|
|
22107
21837
|
const manager = ctx.requireManager(indexName);
|
|
22108
21838
|
const { docId, document, partitionDoc, rollbackDoc, extractedVectors, removedSpellings } = prepared;
|
|
22109
|
-
|
|
21839
|
+
const updateInIndex = async () => {
|
|
22110
21840
|
if (ctx.isRebalancing(indexName)) {
|
|
22111
21841
|
const bufferedState = ctx.bufferedDocState(indexName, docId);
|
|
22112
21842
|
const exists = bufferedState !== void 0 ? bufferedState === "present" : manager.has(docId);
|
|
@@ -22142,6 +21872,7 @@ function applyOfUpdate(ctx, indexName, prepared) {
|
|
|
22142
21872
|
throw err;
|
|
22143
21873
|
}
|
|
22144
21874
|
};
|
|
21875
|
+
return indexChangeOutsideExternalWaits(updateInIndex);
|
|
22145
21876
|
}
|
|
22146
21877
|
async function updateDocument(ctx, indexName, docId, document, options) {
|
|
22147
21878
|
ctx.guardShutdown();
|
|
@@ -22181,6 +21912,7 @@ function requireUpdateEntry(update) {
|
|
|
22181
21912
|
async function updateDocumentBatch(ctx, indexName, updates, options) {
|
|
22182
21913
|
ctx.guardShutdown();
|
|
22183
21914
|
const entry = ctx.requireIndex(indexName);
|
|
21915
|
+
validateBatchList(updates, "updates");
|
|
22184
21916
|
const succeeded = [];
|
|
22185
21917
|
const failed = [];
|
|
22186
21918
|
const updateBatchManager = ctx.requireManager(indexName);
|
|
@@ -22190,6 +21922,7 @@ async function updateDocumentBatch(ctx, indexName, updates, options) {
|
|
|
22190
21922
|
const chunkEnd = Math.min(chunkStart + BATCH_CHUNK_SIZE, updates.length);
|
|
22191
21923
|
const prepared = [];
|
|
22192
21924
|
for (let i = chunkStart; i < chunkEnd; i++) {
|
|
21925
|
+
if (turnsAreBudgeted && turnIsSpent()) await yieldTurn();
|
|
22193
21926
|
const update = updates[i];
|
|
22194
21927
|
const docId = reportedDocIdOf(update);
|
|
22195
21928
|
try {
|
|
@@ -22233,53 +21966,6 @@ async function updateDocumentBatch(ctx, indexName, updates, options) {
|
|
|
22233
21966
|
return { succeeded, failed };
|
|
22234
21967
|
}
|
|
22235
21968
|
|
|
22236
|
-
// src/engine/vector-maintenance.ts
|
|
22237
|
-
function resolveVectorIndexes(manager, indexName, fieldName) {
|
|
22238
|
-
const all = manager.getVectorIndexes();
|
|
22239
|
-
if (fieldName === void 0) return all;
|
|
22240
|
-
const idx = all.get(fieldName);
|
|
22241
|
-
if (!idx) {
|
|
22242
|
-
throw new NarsilError(ErrorCodes.INDEX_NOT_FOUND, `Vector field "${fieldName}" not found in index "${indexName}"`, {
|
|
22243
|
-
indexName,
|
|
22244
|
-
fieldName
|
|
22245
|
-
});
|
|
22246
|
-
}
|
|
22247
|
-
const single = /* @__PURE__ */ new Map();
|
|
22248
|
-
single.set(fieldName, idx);
|
|
22249
|
-
return single;
|
|
22250
|
-
}
|
|
22251
|
-
function compactVectors(manager, indexName, fieldName) {
|
|
22252
|
-
const indexes = resolveVectorIndexes(manager, indexName, fieldName);
|
|
22253
|
-
for (const [, idx] of indexes) {
|
|
22254
|
-
idx.compact();
|
|
22255
|
-
}
|
|
22256
|
-
}
|
|
22257
|
-
async function optimizeVectors(manager, indexName, fieldName) {
|
|
22258
|
-
const indexes = resolveVectorIndexes(manager, indexName, fieldName);
|
|
22259
|
-
for (const [, idx] of indexes) {
|
|
22260
|
-
await idx.optimize();
|
|
22261
|
-
}
|
|
22262
|
-
}
|
|
22263
|
-
function getVectorMaintenanceStatus(manager) {
|
|
22264
|
-
const indexes = manager.getVectorIndexes();
|
|
22265
|
-
const results = [];
|
|
22266
|
-
for (const [field, idx] of indexes) {
|
|
22267
|
-
const status = idx.maintenanceStatus();
|
|
22268
|
-
results.push({
|
|
22269
|
-
fieldName: field,
|
|
22270
|
-
tombstoneRatio: status.tombstoneRatio,
|
|
22271
|
-
graphCount: status.graphCount,
|
|
22272
|
-
bufferSize: status.bufferSize,
|
|
22273
|
-
building: status.building,
|
|
22274
|
-
waitingForMemory: status.waitingForMemory,
|
|
22275
|
-
loadingFromFiles: status.loadingFromFiles === true,
|
|
22276
|
-
estimatedCompactMs: status.estimatedCompactMs,
|
|
22277
|
-
estimatedOptimizeMs: status.estimatedOptimizeMs
|
|
22278
|
-
});
|
|
22279
|
-
}
|
|
22280
|
-
return results;
|
|
22281
|
-
}
|
|
22282
|
-
|
|
22283
21969
|
// src/runtime/process-memory.ts
|
|
22284
21970
|
function readProcessMemory() {
|
|
22285
21971
|
const proc = globalThis.process;
|
|
@@ -22410,14 +22096,14 @@ function portabilityOperations(core, config, engine) {
|
|
|
22410
22096
|
return {
|
|
22411
22097
|
snapshot(indexName) {
|
|
22412
22098
|
return withOpenIndex2(indexName, async () => {
|
|
22413
|
-
const { createSnapshot } = await import('./snapshot-
|
|
22099
|
+
const { createSnapshot } = await import('./snapshot-DQ6A4PQP.mjs');
|
|
22414
22100
|
return createSnapshot(snapshotDepsOf(indexName));
|
|
22415
22101
|
});
|
|
22416
22102
|
},
|
|
22417
22103
|
async restore(indexName, data) {
|
|
22418
22104
|
core.guardShutdown();
|
|
22419
22105
|
validateIndexName(indexName);
|
|
22420
|
-
const restored = import('./restore-queue-
|
|
22106
|
+
const restored = import('./restore-queue-DD4LWZK7.mjs').then(
|
|
22421
22107
|
({ queueRestore }) => queueRestore(core, restoreHost, restoresInFlight, indexName, data)
|
|
22422
22108
|
);
|
|
22423
22109
|
await emitWriteEventAfter(core, indexName, restored);
|
|
@@ -22426,8 +22112,8 @@ function portabilityOperations(core, config, engine) {
|
|
|
22426
22112
|
exportDocuments(indexName) {
|
|
22427
22113
|
return withOpenIndex2(indexName, async () => {
|
|
22428
22114
|
const [{ checkpointForArchive }, { documentExportStream }] = await Promise.all([
|
|
22429
|
-
import('./snapshot-
|
|
22430
|
-
import('./write-
|
|
22115
|
+
import('./snapshot-DQ6A4PQP.mjs'),
|
|
22116
|
+
import('./write-MAGRAIEH.mjs')
|
|
22431
22117
|
]);
|
|
22432
22118
|
const header = indexConfigurationOf(core.requireIndex(indexName));
|
|
22433
22119
|
return documentExportStream(header, await checkpointForArchive(snapshotDepsOf(indexName)));
|
|
@@ -22435,7 +22121,7 @@ function portabilityOperations(core, config, engine) {
|
|
|
22435
22121
|
},
|
|
22436
22122
|
importDocumentExport(indexName, data) {
|
|
22437
22123
|
core.guardShutdown();
|
|
22438
|
-
const imported = import('./import-
|
|
22124
|
+
const imported = import('./import-PTT63AGK.mjs').then(
|
|
22439
22125
|
({ readDocumentExport }) => readDocumentExport(engine(), indexName, data)
|
|
22440
22126
|
);
|
|
22441
22127
|
return emitWriteEventAfter(core, indexName, imported);
|
|
@@ -22454,7 +22140,7 @@ var LIST_TAG = 6;
|
|
|
22454
22140
|
var MAP_TAG = 7;
|
|
22455
22141
|
var LENGTH_BYTES = 4;
|
|
22456
22142
|
var LAST_ASCII_UNIT = 127;
|
|
22457
|
-
var
|
|
22143
|
+
var encoder4 = new TextEncoder();
|
|
22458
22144
|
function flush(stream) {
|
|
22459
22145
|
stream.hash = fnv1aContinue(stream.hash, stream.bytes, stream.length);
|
|
22460
22146
|
stream.length = 0;
|
|
@@ -22488,7 +22174,7 @@ function writeNumber(stream, value) {
|
|
|
22488
22174
|
stream.length += 8;
|
|
22489
22175
|
}
|
|
22490
22176
|
function writeEncodedString(stream, value) {
|
|
22491
|
-
const encoded =
|
|
22177
|
+
const encoded = encoder4.encode(value);
|
|
22492
22178
|
writeUint32(stream, encoded.length);
|
|
22493
22179
|
ensureCapacity(stream, encoded.length);
|
|
22494
22180
|
stream.bytes.set(encoded, stream.length);
|
|
@@ -23650,7 +23336,7 @@ var runtimeHost = {
|
|
|
23650
23336
|
function sortsWithoutScores(params) {
|
|
23651
23337
|
return params.includeScores !== true && params.includeScoreComponents !== true && params.minScore === void 0 && params.group === void 0 && params.pinned === void 0 && (params.termMatch === void 0 || params.termMatch === "any");
|
|
23652
23338
|
}
|
|
23653
|
-
function executeSortedQueryPage(params, context, limit, offset, sortSignature) {
|
|
23339
|
+
async function executeSortedQueryPage(params, context, limit, offset, sortSignature) {
|
|
23654
23340
|
const { manager, language, config } = context;
|
|
23655
23341
|
const schema = config.schema;
|
|
23656
23342
|
let anchorKey = null;
|
|
@@ -23676,6 +23362,13 @@ function executeSortedQueryPage(params, context, limit, offset, sortSignature) {
|
|
|
23676
23362
|
let count = 0;
|
|
23677
23363
|
const clock = context.patternWork.clock;
|
|
23678
23364
|
for (const partition of partitions) {
|
|
23365
|
+
if (turnIsSpent()) await yieldTurn();
|
|
23366
|
+
partition.prepareSortedPage({ fields, directions, fieldTypes, modes });
|
|
23367
|
+
if (partitionFacetConfig !== void 0) {
|
|
23368
|
+
if (turnIsSpent()) await yieldTurn();
|
|
23369
|
+
partition.prepareFacets(partitionFacetConfig, schema);
|
|
23370
|
+
}
|
|
23371
|
+
if (turnIsSpent()) await yieldTurn();
|
|
23679
23372
|
clock?.check();
|
|
23680
23373
|
const matches = fulltextMatches(partition, params, language, schema, options);
|
|
23681
23374
|
clock?.check();
|
|
@@ -23735,7 +23428,7 @@ function requireCursorDepth(cursor, signature, binding) {
|
|
|
23735
23428
|
}
|
|
23736
23429
|
function hybridSearchOf(params, context, limit, offset, cursorDepth) {
|
|
23737
23430
|
if ((params.hybrid?.depth ?? null) === null) return executeHybridSearch(params, context, limit, offset, cursorDepth);
|
|
23738
|
-
return import('./runtime-
|
|
23431
|
+
return import('./runtime-D2ULZGCN.mjs').then(
|
|
23739
23432
|
(runtime) => runtime.searchFixedDepthHybrid(params, context, { cursorDepth: cursorDepth ?? 0, offset, limit }, runtimeHost)
|
|
23740
23433
|
);
|
|
23741
23434
|
}
|
|
@@ -23745,7 +23438,7 @@ function executeQuery(request, callerContext) {
|
|
|
23745
23438
|
if (loadingPhraseCode === null) return runQuery(request, callerContext);
|
|
23746
23439
|
return loadingPhraseCode.then(() => runQuery(request, callerContext));
|
|
23747
23440
|
}
|
|
23748
|
-
return import('./runtime-
|
|
23441
|
+
return import('./runtime-D2ULZGCN.mjs').then(
|
|
23749
23442
|
(runtime) => runtime.executeRerankedQuery(request, callerContext, executeQuery, runtimeHost)
|
|
23750
23443
|
);
|
|
23751
23444
|
}
|
|
@@ -23781,7 +23474,7 @@ async function runQuery(request, callerContext) {
|
|
|
23781
23474
|
let facets;
|
|
23782
23475
|
let groups;
|
|
23783
23476
|
if (sortSignature !== null && hasTerm && !isVectorOnly && !isHybridMode && sortsWithoutScores(params)) {
|
|
23784
|
-
const page = executeSortedQueryPage(params, context, limit, offset, sortSignature);
|
|
23477
|
+
const page = await executeSortedQueryPage(params, context, limit, offset, sortSignature);
|
|
23785
23478
|
paginated = page.hits;
|
|
23786
23479
|
nextCursor = page.cursor;
|
|
23787
23480
|
count = page.count;
|
|
@@ -24144,7 +23837,7 @@ async function runEngineQuery(core, indexName, params, options) {
|
|
|
24144
23837
|
const manager = core.requireManager(indexName);
|
|
24145
23838
|
const scoped = scopedParams(params, options);
|
|
24146
23839
|
await core.pluginRegistry.runHook("beforeSearch", { indexName, params: scoped });
|
|
24147
|
-
const rerank = scoped.rerank === void 0 ? void 0 : await import('./runtime-
|
|
23840
|
+
const rerank = scoped.rerank === void 0 ? void 0 : await import('./runtime-D2ULZGCN.mjs');
|
|
24148
23841
|
const resolvedParams = await resolveVectorText(
|
|
24149
23842
|
rerank === void 0 ? scoped : rerank.withRerankQueryText(scoped),
|
|
24150
23843
|
entry.embeddingAdapter,
|
|
@@ -24312,6 +24005,9 @@ function createNarsilFromCore(core, config) {
|
|
|
24312
24005
|
const written = starting === void 0 ? withOpenIndex2(indexName, action) : starting.then(() => withOpenIndex2(indexName, action));
|
|
24313
24006
|
return emitWriteEventAfter(core, indexName, written);
|
|
24314
24007
|
}
|
|
24008
|
+
function withCountedWrite(indexName, action) {
|
|
24009
|
+
return countWrite(() => withOpenIndexWrite(indexName, action));
|
|
24010
|
+
}
|
|
24315
24011
|
const narsil = {
|
|
24316
24012
|
createIndex(name, indexConfig) {
|
|
24317
24013
|
return emitWriteEventAfter(
|
|
@@ -24373,22 +24069,22 @@ function createNarsilFromCore(core, config) {
|
|
|
24373
24069
|
return executor.getManager(indexName)?.getPartitionStats() ?? [];
|
|
24374
24070
|
},
|
|
24375
24071
|
insert(indexName, document, docId, options) {
|
|
24376
|
-
return
|
|
24072
|
+
return withCountedWrite(indexName, () => insertDocument(mutationCtx, indexName, document, docId, options));
|
|
24377
24073
|
},
|
|
24378
24074
|
insertBatch(indexName, documents, options) {
|
|
24379
|
-
return
|
|
24075
|
+
return withCountedWrite(indexName, () => insertDocumentBatch(mutationCtx, indexName, documents, options));
|
|
24380
24076
|
},
|
|
24381
24077
|
remove(indexName, docId, options) {
|
|
24382
|
-
return
|
|
24078
|
+
return withCountedWrite(indexName, () => removeDocument(mutationCtx, indexName, docId, options));
|
|
24383
24079
|
},
|
|
24384
24080
|
removeBatch(indexName, docIds, options) {
|
|
24385
|
-
return
|
|
24081
|
+
return withCountedWrite(indexName, () => removeDocumentBatch(mutationCtx, indexName, docIds, options));
|
|
24386
24082
|
},
|
|
24387
24083
|
update(indexName, docId, document, options) {
|
|
24388
|
-
return
|
|
24084
|
+
return withCountedWrite(indexName, () => updateDocument(mutationCtx, indexName, docId, document, options));
|
|
24389
24085
|
},
|
|
24390
24086
|
updateBatch(indexName, updates, options) {
|
|
24391
|
-
return
|
|
24087
|
+
return withCountedWrite(indexName, () => updateDocumentBatch(mutationCtx, indexName, updates, options));
|
|
24392
24088
|
},
|
|
24393
24089
|
waitForWrites(indexName) {
|
|
24394
24090
|
guardShutdown();
|
|
@@ -24438,7 +24134,7 @@ function createNarsilFromCore(core, config) {
|
|
|
24438
24134
|
const entry = requireIndex(indexName);
|
|
24439
24135
|
await withOpenIndexWrite(indexName, async () => {
|
|
24440
24136
|
if (entry.pendingAnalysis === null) return core.analysisRebuild.rebuild(indexName);
|
|
24441
|
-
return (await import('./analysis-change-
|
|
24137
|
+
return (await import('./analysis-change-M65AZQQG.mjs')).resumeAnalysisChange(core, indexName);
|
|
24442
24138
|
});
|
|
24443
24139
|
},
|
|
24444
24140
|
async changeAnalysis(indexName, change) {
|
|
@@ -24446,7 +24142,7 @@ function createNarsilFromCore(core, config) {
|
|
|
24446
24142
|
requireIndex(indexName);
|
|
24447
24143
|
const changed = withOpenIndex2(
|
|
24448
24144
|
indexName,
|
|
24449
|
-
async () => (await import('./analysis-change-
|
|
24145
|
+
async () => (await import('./analysis-change-M65AZQQG.mjs')).changeIndexAnalysis(core, indexName, change)
|
|
24450
24146
|
);
|
|
24451
24147
|
await emitWriteEventAfter(core, indexName, changed);
|
|
24452
24148
|
},
|
|
@@ -24484,7 +24180,7 @@ function createNarsilFromCore(core, config) {
|
|
|
24484
24180
|
}
|
|
24485
24181
|
rebalancesStarting.set(indexName, started);
|
|
24486
24182
|
const rebalanced = withOpenIndex2(indexName, async () => {
|
|
24487
|
-
const { executeRebalance } = await import('./analysis-change-
|
|
24183
|
+
const { executeRebalance } = await import('./analysis-change-M65AZQQG.mjs');
|
|
24488
24184
|
const running = executeRebalance(requireManager(indexName), indexName, targetPartitionCount, rebalanceCtx);
|
|
24489
24185
|
releaseWrites();
|
|
24490
24186
|
return running;
|
|
@@ -24553,6 +24249,7 @@ function createNarsilFromCore(core, config) {
|
|
|
24553
24249
|
async compactVectors(indexName, fieldName) {
|
|
24554
24250
|
guardShutdown();
|
|
24555
24251
|
requireIndex(indexName);
|
|
24252
|
+
const { compactVectors } = await loadVectorCode();
|
|
24556
24253
|
await withOpenIndexWrite(indexName, async () => {
|
|
24557
24254
|
compactVectors(requireManager(indexName), indexName, fieldName);
|
|
24558
24255
|
});
|
|
@@ -24560,13 +24257,15 @@ function createNarsilFromCore(core, config) {
|
|
|
24560
24257
|
async optimizeVectors(indexName, fieldName) {
|
|
24561
24258
|
guardShutdown();
|
|
24562
24259
|
requireIndex(indexName);
|
|
24260
|
+
const { optimizeVectors } = await loadVectorCode();
|
|
24563
24261
|
await withOpenIndexWrite(indexName, () => optimizeVectors(requireManager(indexName), indexName, fieldName));
|
|
24564
24262
|
},
|
|
24565
24263
|
vectorMaintenanceStatus(indexName) {
|
|
24566
24264
|
guardShutdown();
|
|
24567
24265
|
requireIndex(indexName);
|
|
24568
24266
|
const manager = executor.getManager(indexName);
|
|
24569
|
-
|
|
24267
|
+
const vectorCode = loadedVectorCode();
|
|
24268
|
+
return manager === void 0 || vectorCode === null ? [] : vectorCode.getVectorMaintenanceStatus(manager);
|
|
24570
24269
|
},
|
|
24571
24270
|
on(event, handler) {
|
|
24572
24271
|
const key = event;
|
|
@@ -24608,4 +24307,4 @@ async function createNarsil(config) {
|
|
|
24608
24307
|
// src/index.ts
|
|
24609
24308
|
var VERSION = "0.1.0";
|
|
24610
24309
|
|
|
24611
|
-
export { ARRAY_POSITION_GAP, DEFAULT_BM25_B, DEFAULT_BM25_K1, DEFAULT_WRITE_AHEAD_QUEUE_MAX_SIZE, HEADER_SIZE, MAX_DOCUMENT_NESTING_DEPTH, REBALANCE_CHUNK_SIZE, VECTOR_PATTERN, VERSION, arrayPositionsAreStale, assemblePagedFrozenSegment, buildPartialWordTableFrom, buildSegmentPayload, checksumOfChunks, clearNormalizationCache, configureNormalizationCache, crc32, crc32Final, crc32Init, crc32Update, createCompositePartition, createEncodedDocumentSource, createFrozenSegment, createNarsil, createPartitionIndex, createPartitionManager, createPartitionRouter,
|
|
24310
|
+
export { ARRAY_POSITION_GAP, DEFAULT_BM25_B, DEFAULT_BM25_K1, DEFAULT_WRITE_AHEAD_QUEUE_MAX_SIZE, HEADER_SIZE, MAX_DOCUMENT_NESTING_DEPTH, REBALANCE_CHUNK_SIZE, VECTOR_PATTERN, VERSION, arrayPositionsAreStale, assemblePagedFrozenSegment, buildPartialWordTableFrom, buildSegmentPayload, checksumOfChunks, clearNormalizationCache, configureNormalizationCache, crc32, crc32Final, crc32Init, crc32Update, createCompositePartition, createEncodedDocumentSource, createFrozenSegment, createNarsil, createPartitionIndex, createPartitionManager, createPartitionRouter, createSharedFrozenSegment, decodeEveryStoredDocument, decodeIndexConfiguration, decodeMapWithoutFields, decodeStoredDocument, decodeSurfaceTable, deleteNestedValue, emitEngineEvent, encodeDocument, encodeIndexConfiguration, encodeSurfaceTable, endOfValue, engineVersionParts, extractVectorFieldsFromSchema, extractVectorFromDoc, fieldIndexRemapOf, flattenSchema, freezeSegmentShared, generateId, getLanguage, getNestedValue, getNormalizationCacheSize, getStopWords, getTokenizer, hasNrslMagic, hasStopWords, hasTokenizer, holdsADiscardedField, insertDocumentVectors, isCompositePartition, isQuantizationMode, isStorageMode, loadVectorCodeFor, mergeDocFrequencies, mergeFieldIndexes2 as mergeFieldIndexes, mergeFieldLengths, mergePartialWords, mergeSegmentContents, mergeSurfaceForms2 as mergeSurfaceForms, messagePackUpperBoundBytes, openChecksummedEnvelope, packChecksummedEnvelope, packEnvelopeWithChecksum, parseVectorDimension, partialFieldsOf, partitionStateOf, prepareConfiguredSynonyms, prepareDocumentVectors, prepareStoredSynonyms, raiseEarlierReleaseGraphSetting, readHeader, readHeapStatistics, readResidentMemory, rebuildTextIndexes, reconstructSchemaFromMetadata, registerLanguage, registerPartialWordSearch, registerPatternSearch, registerStopWords, registerSynonyms, registerTokenizer, removeDocumentVectors, requireConfigurationShape, requireConfigurationWithinSizeLimit, requireSurfaceFormsForPartialFields, requireValidFieldTypes, requireWithinFileLimit, resetNormalizationCache, resolveIndexAnalysis, resolvePartialWordAnalysis, resolvePartitionInsertOptions, rewriteSpillOf, rulesOfStoredSynonyms, scanPostingBlocks, segmentArraysOf, selectionKeeps, shareSegmentArrays, storedArrayPositionGap, survivorDocumentsOf, textRebuildTargetOf, toError2 as toError, validateEmbeddingConfig, validatePatternValueLimit, validateRequiredFieldsInSchema, validateSchema, validateTextStorage, validateVectorPromotion, validateVectorStorage, vectorsEqual, wrapFrozenTokenTable, writeHeader, yieldToEventLoop2 as yieldToEventLoop };
|