@delali/narsil 0.3.1-next.111 → 0.3.1-next.113
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/browser/{chunk-6YUUEMQ4.mjs → chunk-3YPLBK4C.mjs} +2 -2
- package/dist/browser/{chunk-5BQPBG3G.mjs → chunk-4FVSBSXY.mjs} +1 -1
- package/dist/browser/{chunk-HQOYKRMB.mjs → chunk-DC2SZO4D.mjs} +183 -44
- package/dist/browser/{chunk-OVY4RPDS.mjs → chunk-YZPOBLAS.mjs} +35 -1
- package/dist/browser/{durability-wiring-CYAJBYCO.mjs → durability-wiring-2RG22WQJ.mjs} +3 -3
- package/dist/browser/{module-DYKR4INA.mjs → module-5EWHBKHZ.mjs} +102 -11
- package/dist/browser/{restore-queue-RTZGJT4D.mjs → restore-queue-WCFUB4NS.mjs} +1 -1
- package/dist/browser/{snapshot-BU6I25CW.mjs → snapshot-BE3F2PNC.mjs} +6 -5
- package/dist/browser/{write-RUPYHPBZ.mjs → write-MV7K7OCU.mjs} +2 -2
- package/dist/{capabilities-ByaX8Arf.d.ts → capabilities-DOgB3pPf.d.ts} +2 -2
- package/dist/{chunk-ZXZ26WSO.mjs → chunk-22YPZVMG.mjs} +5 -1
- package/dist/{chunk-6S7YRUPQ.mjs → chunk-27ZEY73B.mjs} +4 -4
- package/dist/{chunk-QI6JW4PM.mjs → chunk-4PFOOQFQ.mjs} +1 -1
- package/dist/{chunk-YIDSHBQS.mjs → chunk-4XWIW3F3.mjs} +29 -1
- package/dist/{chunk-R2MRMH6M.mjs → chunk-5QIRLJH4.mjs} +3 -3
- package/dist/{chunk-7JOONQ24.mjs → chunk-5WEBVYOA.mjs} +176 -38
- package/dist/{chunk-63HFWQEA.mjs → chunk-AOLD3LPV.mjs} +273 -102
- package/dist/{chunk-PT7VRWS7.mjs → chunk-CU4OB64V.mjs} +3 -2
- package/dist/{chunk-JBPYFYIU.mjs → chunk-DZXGNLK5.mjs} +3 -3
- package/dist/chunk-EBIHRL7B.mjs +21 -0
- package/dist/{chunk-UGKO3RG2.mjs → chunk-GLZI636G.mjs} +1 -1
- package/dist/{chunk-R2MRGYU5.mjs → chunk-H2GNWBLB.mjs} +22 -2
- package/dist/{chunk-V7G627TA.mjs → chunk-HFJXEFFV.mjs} +13 -62
- package/dist/chunk-IWVEG5CX.mjs +67 -0
- package/dist/{chunk-SXVDBHYJ.mjs → chunk-JUAFWJON.mjs} +3 -3
- package/dist/{chunk-PKE2PCTS.mjs → chunk-LVNBY2TS.mjs} +1 -1
- package/dist/{chunk-YLE75NQ5.mjs → chunk-OABTAUCW.mjs} +2 -2
- package/dist/{chunk-YSR5L3XJ.mjs → chunk-OM5G2J6X.mjs} +1 -1
- package/dist/{chunk-IW6UR3AF.mjs → chunk-PABYSTKO.mjs} +13 -10
- package/dist/chunk-PELHVTO7.mjs +24 -0
- package/dist/{chunk-CUVTRLA4.mjs → chunk-QGVMEMCG.mjs} +4 -4
- package/dist/{chunk-6OXNHLNZ.mjs → chunk-RIIUZJQ3.mjs} +1 -1
- package/dist/{chunk-C7SLA6CM.mjs → chunk-W55X2BYN.mjs} +5 -1
- package/dist/{chunk-SOADQINJ.mjs → chunk-ZATRDAYU.mjs} +31 -3
- package/dist/{client-BdnzDFtO.d.ts → client-BGzLNt78.d.ts} +2 -2
- package/dist/client.d.ts +6 -6
- package/dist/{config-ujZESkJz.d.ts → config-CS5ADSrx.d.ts} +18 -2
- package/dist/{config-CSgvApt0.d.ts → config-CSYMTTm1.d.ts} +1 -1
- package/dist/{direct-executor-QFAUKTCQ.mjs → direct-executor-R4HOSVPE.mjs} +6 -5
- package/dist/distribution.d.ts +5 -5
- package/dist/distribution.mjs +74 -37
- package/dist/{durability-wiring-NUHTYXHA.mjs → durability-wiring-XZI6355I.mjs} +15 -14
- package/dist/{engine-C_HSy3iz.d.ts → engine-CCBBGmMR.d.ts} +1 -1
- package/dist/{events-CJsXF1F9.d.ts → events-D8GPB1-H.d.ts} +5 -0
- package/dist/index.browser.mjs +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +8 -7
- package/dist/{module-WP4VVGV2.mjs → module-WVKSJL74.mjs} +67 -7
- package/dist/persistence/durability/checkpoint-worker.mjs +12 -11
- package/dist/react.d.ts +6 -6
- package/dist/{restore-queue-QSLGXZJB.mjs → restore-queue-JAZAB5IQ.mjs} +1 -1
- package/dist/server.d.ts +8 -8
- package/dist/server.mjs +20 -62
- package/dist/{snapshot-IV3S2TMI.mjs → snapshot-PDUGHQ25.mjs} +16 -15
- package/dist/{tasks-CI3Fvkxw.d.ts → tasks-5_LCFEzF.d.ts} +1 -1
- package/dist/{thread-THLCKMEB.mjs → thread-S4SUCV4Y.mjs} +10 -7
- package/dist/vector/search-worker.mjs +2 -2
- package/dist/workers/entry.mjs +6 -6
- package/dist/{write-VGRTOS7N.mjs → write-KVJ7YJJ6.mjs} +9 -8
- package/package.json +7 -7
|
@@ -597,6 +597,8 @@ function createDocumentStore() {
|
|
|
597
597
|
// src/core/constants.ts
|
|
598
598
|
var POSTING_LIST_COMPACTION_THRESHOLD = 0.3;
|
|
599
599
|
var MAX_TERM_FREQUENCY = 65535;
|
|
600
|
+
var PENDING_REMOVAL_MERGE_FLOOR = 64;
|
|
601
|
+
var PENDING_REMOVAL_MERGE_DIVISOR = 256;
|
|
600
602
|
|
|
601
603
|
// src/core/inverted-index/constants.ts
|
|
602
604
|
var TERM_TABLE_START_CAPACITY = 1 << 10;
|
|
@@ -2187,6 +2189,7 @@ function vincentyDistance(lat1, lon1, lat2, lon2) {
|
|
|
2187
2189
|
}
|
|
2188
2190
|
|
|
2189
2191
|
// src/geo/geo-index.ts
|
|
2192
|
+
var REMOVED_DOC_ID = -1;
|
|
2190
2193
|
function firstAtOrAfter(entries, code) {
|
|
2191
2194
|
let lo = 0;
|
|
2192
2195
|
let hi = entries.length;
|
|
@@ -2197,25 +2200,58 @@ function firstAtOrAfter(entries, code) {
|
|
|
2197
2200
|
}
|
|
2198
2201
|
return lo;
|
|
2199
2202
|
}
|
|
2203
|
+
function dropRemoved(entries) {
|
|
2204
|
+
let write = 0;
|
|
2205
|
+
for (let read = 0; read < entries.length; read++) {
|
|
2206
|
+
if (entries[read].docId !== REMOVED_DOC_ID) entries[write++] = entries[read];
|
|
2207
|
+
}
|
|
2208
|
+
entries.length = write;
|
|
2209
|
+
}
|
|
2210
|
+
function mergeSortedPending(entries, pending) {
|
|
2211
|
+
pending.sort((left2, right2) => left2.code - right2.code || left2.docId - right2.docId);
|
|
2212
|
+
const mainLength = entries.length;
|
|
2213
|
+
for (const entry of pending) entries.push(entry);
|
|
2214
|
+
let left = mainLength - 1;
|
|
2215
|
+
let right = pending.length - 1;
|
|
2216
|
+
let write = entries.length - 1;
|
|
2217
|
+
while (right >= 0) {
|
|
2218
|
+
const later = left >= 0 ? entries[left] : void 0;
|
|
2219
|
+
const next = pending[right];
|
|
2220
|
+
if (later !== void 0 && (later.code > next.code || later.code === next.code && later.docId > next.docId)) {
|
|
2221
|
+
entries[write--] = later;
|
|
2222
|
+
left--;
|
|
2223
|
+
} else {
|
|
2224
|
+
entries[write--] = next;
|
|
2225
|
+
right--;
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2200
2229
|
function createGeoIndex() {
|
|
2201
|
-
|
|
2230
|
+
let entries = [];
|
|
2231
|
+
let pending = [];
|
|
2202
2232
|
const byDocument = /* @__PURE__ */ new Map();
|
|
2203
|
-
let
|
|
2233
|
+
let removedCount = 0;
|
|
2204
2234
|
function ensureSorted() {
|
|
2205
|
-
if (
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
if (
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
entries.splice(at, 1);
|
|
2217
|
-
return;
|
|
2235
|
+
if (removedCount > 0) {
|
|
2236
|
+
dropRemoved(entries);
|
|
2237
|
+
dropRemoved(pending);
|
|
2238
|
+
removedCount = 0;
|
|
2239
|
+
}
|
|
2240
|
+
if (pending.length === 0) return;
|
|
2241
|
+
if (entries.length === 0) {
|
|
2242
|
+
pending.sort((left, right) => left.code - right.code || left.docId - right.docId);
|
|
2243
|
+
entries = pending;
|
|
2244
|
+
} else {
|
|
2245
|
+
mergeSortedPending(entries, pending);
|
|
2218
2246
|
}
|
|
2247
|
+
pending = [];
|
|
2248
|
+
}
|
|
2249
|
+
function removeEntry(entry) {
|
|
2250
|
+
byDocument.delete(entry.docId);
|
|
2251
|
+
entry.docId = REMOVED_DOC_ID;
|
|
2252
|
+
removedCount++;
|
|
2253
|
+
const held = entries.length + pending.length;
|
|
2254
|
+
if (removedCount >= Math.max(PENDING_REMOVAL_MERGE_FLOOR, held / PENDING_REMOVAL_MERGE_DIVISOR)) ensureSorted();
|
|
2219
2255
|
}
|
|
2220
2256
|
function matching(boxes, passes, inside) {
|
|
2221
2257
|
ensureSorted();
|
|
@@ -2234,14 +2270,15 @@ function createGeoIndex() {
|
|
|
2234
2270
|
}
|
|
2235
2271
|
const index = {
|
|
2236
2272
|
insert(internalId, lat, lon) {
|
|
2237
|
-
|
|
2273
|
+
const existing = byDocument.get(internalId);
|
|
2274
|
+
if (existing !== void 0) removeEntry(existing);
|
|
2238
2275
|
const entry = { lat, lon, docId: internalId, code: locationCode(lat, lon) };
|
|
2239
|
-
|
|
2276
|
+
pending.push(entry);
|
|
2240
2277
|
byDocument.set(internalId, entry);
|
|
2241
|
-
sorted = false;
|
|
2242
2278
|
},
|
|
2243
2279
|
remove(internalId) {
|
|
2244
|
-
|
|
2280
|
+
const existing = byDocument.get(internalId);
|
|
2281
|
+
if (existing !== void 0) removeEntry(existing);
|
|
2245
2282
|
},
|
|
2246
2283
|
radiusQuery(lat, lon, distanceMeters, inside, highPrecision) {
|
|
2247
2284
|
const distanceFn = highPrecision ? vincentyDistance : haversineDistance;
|
|
@@ -2257,13 +2294,14 @@ function createGeoIndex() {
|
|
|
2257
2294
|
},
|
|
2258
2295
|
documentsBitset(capacity) {
|
|
2259
2296
|
const bits = createBitSet(capacity);
|
|
2260
|
-
for (const
|
|
2297
|
+
for (const docId of byDocument.keys()) bitsetSet(bits, docId);
|
|
2261
2298
|
return bits;
|
|
2262
2299
|
},
|
|
2263
2300
|
clear() {
|
|
2264
|
-
entries
|
|
2301
|
+
entries = [];
|
|
2302
|
+
pending = [];
|
|
2265
2303
|
byDocument.clear();
|
|
2266
|
-
|
|
2304
|
+
removedCount = 0;
|
|
2267
2305
|
},
|
|
2268
2306
|
serialize() {
|
|
2269
2307
|
ensureSorted();
|
|
@@ -2591,29 +2629,126 @@ function collectDocIdsBitset(entries, from, to, capacity) {
|
|
|
2591
2629
|
}
|
|
2592
2630
|
return bs;
|
|
2593
2631
|
}
|
|
2632
|
+
function removalsFor(byDocument, docId, value) {
|
|
2633
|
+
const keys = byDocument.get(docId);
|
|
2634
|
+
if (keys === void 0) return void 0;
|
|
2635
|
+
for (const key of keys) {
|
|
2636
|
+
if (key.value === value) return key;
|
|
2637
|
+
}
|
|
2638
|
+
return void 0;
|
|
2639
|
+
}
|
|
2640
|
+
function groupRemovals(docIds, values, limits) {
|
|
2641
|
+
const byDocument = /* @__PURE__ */ new Map();
|
|
2642
|
+
for (let at = 0; at < docIds.length; at++) {
|
|
2643
|
+
const existing = removalsFor(byDocument, docIds[at], values[at]);
|
|
2644
|
+
if (existing !== void 0) {
|
|
2645
|
+
existing.limits.push(limits[at]);
|
|
2646
|
+
continue;
|
|
2647
|
+
}
|
|
2648
|
+
const key = { value: values[at], limits: [limits[at]], next: 0 };
|
|
2649
|
+
const keys = byDocument.get(docIds[at]);
|
|
2650
|
+
if (keys === void 0) byDocument.set(docIds[at], [key]);
|
|
2651
|
+
else keys.push(key);
|
|
2652
|
+
}
|
|
2653
|
+
return byDocument;
|
|
2654
|
+
}
|
|
2655
|
+
function markedDocuments(docIds) {
|
|
2656
|
+
let highest = 0;
|
|
2657
|
+
for (const docId of docIds) if (docId > highest) highest = docId;
|
|
2658
|
+
const marked = new Uint8Array(highest + 1);
|
|
2659
|
+
for (const docId of docIds) marked[docId] = 1;
|
|
2660
|
+
return marked;
|
|
2661
|
+
}
|
|
2662
|
+
function removeFromSorted(entries, from, marked, byDocument) {
|
|
2663
|
+
let write = from;
|
|
2664
|
+
for (let read = from; read < entries.length; read++) {
|
|
2665
|
+
const entry = entries[read];
|
|
2666
|
+
if (entry.docId < marked.length && marked[entry.docId] === 1) {
|
|
2667
|
+
const key = removalsFor(byDocument, entry.docId, entry.value);
|
|
2668
|
+
if (key !== void 0 && key.next < key.limits.length) {
|
|
2669
|
+
key.next++;
|
|
2670
|
+
continue;
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
entries[write++] = entry;
|
|
2674
|
+
}
|
|
2675
|
+
entries.length = write;
|
|
2676
|
+
}
|
|
2677
|
+
function removeFromPending(pending, marked, byDocument) {
|
|
2678
|
+
let write = 0;
|
|
2679
|
+
for (let read = 0; read < pending.length; read++) {
|
|
2680
|
+
const entry = pending[read];
|
|
2681
|
+
if (entry.docId < marked.length && marked[entry.docId] === 1) {
|
|
2682
|
+
const key = removalsFor(byDocument, entry.docId, entry.value);
|
|
2683
|
+
if (key !== void 0) {
|
|
2684
|
+
while (key.next < key.limits.length && key.limits[key.next] <= read) key.next++;
|
|
2685
|
+
if (key.next < key.limits.length) {
|
|
2686
|
+
key.next++;
|
|
2687
|
+
continue;
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
pending[write++] = entry;
|
|
2692
|
+
}
|
|
2693
|
+
pending.length = write;
|
|
2694
|
+
}
|
|
2695
|
+
function mergeSortedPending2(entries, pending) {
|
|
2696
|
+
pending.sort((a, b) => a.value - b.value);
|
|
2697
|
+
const mainLength = entries.length;
|
|
2698
|
+
for (const entry of pending) entries.push(entry);
|
|
2699
|
+
let left = mainLength - 1;
|
|
2700
|
+
let right = pending.length - 1;
|
|
2701
|
+
let write = entries.length - 1;
|
|
2702
|
+
while (right >= 0) {
|
|
2703
|
+
if (left >= 0 && entries[left].value > pending[right].value) entries[write--] = entries[left--];
|
|
2704
|
+
else entries[write--] = pending[right--];
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2594
2707
|
function createNumericIndex() {
|
|
2595
2708
|
let entries = [];
|
|
2596
|
-
let
|
|
2709
|
+
let pending = [];
|
|
2710
|
+
const removedDocIds = [];
|
|
2711
|
+
const removedValues = [];
|
|
2712
|
+
const removedLimits = [];
|
|
2713
|
+
function applyRemovals() {
|
|
2714
|
+
const byDocument = groupRemovals(removedDocIds, removedValues, removedLimits);
|
|
2715
|
+
const marked = markedDocuments(removedDocIds);
|
|
2716
|
+
let lowest = removedValues[0];
|
|
2717
|
+
for (const value of removedValues) if (value < lowest) lowest = value;
|
|
2718
|
+
removeFromSorted(entries, lowerBound(entries, lowest), marked, byDocument);
|
|
2719
|
+
if (pending.length > 0) removeFromPending(pending, marked, byDocument);
|
|
2720
|
+
removedDocIds.length = 0;
|
|
2721
|
+
removedValues.length = 0;
|
|
2722
|
+
removedLimits.length = 0;
|
|
2723
|
+
}
|
|
2597
2724
|
function ensureSorted() {
|
|
2598
|
-
if (
|
|
2599
|
-
|
|
2600
|
-
|
|
2725
|
+
if (removedDocIds.length > 0) applyRemovals();
|
|
2726
|
+
if (pending.length === 0) return;
|
|
2727
|
+
if (entries.length === 0) {
|
|
2728
|
+
pending.sort((a, b) => a.value - b.value);
|
|
2729
|
+
entries = pending;
|
|
2730
|
+
} else {
|
|
2731
|
+
mergeSortedPending2(entries, pending);
|
|
2601
2732
|
}
|
|
2733
|
+
pending = [];
|
|
2734
|
+
}
|
|
2735
|
+
function discardPending() {
|
|
2736
|
+
pending = [];
|
|
2737
|
+
removedDocIds.length = 0;
|
|
2738
|
+
removedValues.length = 0;
|
|
2739
|
+
removedLimits.length = 0;
|
|
2602
2740
|
}
|
|
2603
2741
|
return {
|
|
2604
2742
|
insert(internalId, value) {
|
|
2605
|
-
|
|
2606
|
-
sorted = false;
|
|
2743
|
+
pending.push({ value, docId: internalId });
|
|
2607
2744
|
},
|
|
2608
2745
|
remove(internalId, value) {
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
return;
|
|
2616
|
-
}
|
|
2746
|
+
removedDocIds.push(internalId);
|
|
2747
|
+
removedValues.push(value);
|
|
2748
|
+
removedLimits.push(pending.length);
|
|
2749
|
+
const held = entries.length + pending.length;
|
|
2750
|
+
if (removedDocIds.length >= Math.max(PENDING_REMOVAL_MERGE_FLOOR, held / PENDING_REMOVAL_MERGE_DIVISOR)) {
|
|
2751
|
+
ensureSorted();
|
|
2617
2752
|
}
|
|
2618
2753
|
},
|
|
2619
2754
|
queryEq(value) {
|
|
@@ -2650,6 +2785,7 @@ function createNumericIndex() {
|
|
|
2650
2785
|
return collectDocIds(entries, lowerBound(entries, min), upperBound(entries, max));
|
|
2651
2786
|
},
|
|
2652
2787
|
getAllDocIds() {
|
|
2788
|
+
ensureSorted();
|
|
2653
2789
|
return collectDocIds(entries, 0, entries.length);
|
|
2654
2790
|
},
|
|
2655
2791
|
queryEqBitset(value, capacity) {
|
|
@@ -2677,9 +2813,11 @@ function createNumericIndex() {
|
|
|
2677
2813
|
return collectDocIdsBitset(entries, lowerBound(entries, min), upperBound(entries, max), capacity);
|
|
2678
2814
|
},
|
|
2679
2815
|
getAllDocIdsBitset(capacity) {
|
|
2816
|
+
ensureSorted();
|
|
2680
2817
|
return collectDocIdsBitset(entries, 0, entries.length, capacity);
|
|
2681
2818
|
},
|
|
2682
2819
|
count() {
|
|
2820
|
+
ensureSorted();
|
|
2683
2821
|
return entries.length;
|
|
2684
2822
|
},
|
|
2685
2823
|
facetValueCounts(matched) {
|
|
@@ -2717,7 +2855,7 @@ function createNumericIndex() {
|
|
|
2717
2855
|
},
|
|
2718
2856
|
clear() {
|
|
2719
2857
|
entries = [];
|
|
2720
|
-
|
|
2858
|
+
discardPending();
|
|
2721
2859
|
},
|
|
2722
2860
|
serialize() {
|
|
2723
2861
|
ensureSorted();
|
|
@@ -2725,7 +2863,7 @@ function createNumericIndex() {
|
|
|
2725
2863
|
},
|
|
2726
2864
|
deserialize(data) {
|
|
2727
2865
|
entries = data.slice();
|
|
2728
|
-
|
|
2866
|
+
discardPending();
|
|
2729
2867
|
}
|
|
2730
2868
|
};
|
|
2731
2869
|
}
|