@frostpillar/frostpillar-btree 0.2.5 → 0.2.7
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/README-JA.md +117 -64
- package/README.md +117 -64
- package/dist/InMemoryBTree.d.ts +3 -3
- package/dist/btree/autoScale.d.ts +2 -0
- package/dist/btree/entry-lookup.d.ts +8 -0
- package/dist/btree/mutations.d.ts +1 -3
- package/dist/btree/node-ops.d.ts +15 -0
- package/dist/btree/rangeQuery.d.ts +5 -1
- package/dist/btree/rebalance-branch.d.ts +4 -0
- package/dist/btree/rebalance.d.ts +5 -2
- package/dist/btree/serialization.d.ts +3 -1
- package/dist/btree/split.d.ts +3 -0
- package/dist/btree/traversal.d.ts +7 -0
- package/dist/btree/types.d.ts +23 -26
- package/dist/{chunk-CZFRT2NN.js → chunk-UGGWGP4E.js} +823 -499
- package/dist/concurrency/ConcurrentInMemoryBTree.d.ts +22 -29
- package/dist/concurrency/coordinator.d.ts +21 -0
- package/dist/concurrency/helpers.d.ts +8 -2
- package/dist/concurrency/syncLogValidation.d.ts +2 -0
- package/dist/concurrency/types.d.ts +14 -1
- package/dist/concurrency/writeOps.d.ts +48 -0
- package/dist/core.cjs +823 -499
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -1
- package/dist/errors.d.ts +3 -0
- package/dist/frostpillar-btree-core.min.js +1 -1
- package/dist/frostpillar-btree.min.js +1 -1
- package/dist/index.cjs +1212 -670
- package/dist/index.d.ts +1 -1
- package/dist/index.js +397 -179
- package/package.json +1 -1
package/README-JA.md
CHANGED
|
@@ -399,6 +399,24 @@ tree.forEach((entry) => {
|
|
|
399
399
|
});
|
|
400
400
|
```
|
|
401
401
|
|
|
402
|
+
**`forEachRange(startKey, endKey, callback, options?)`** -- 配列を生成せずに範囲内のエントリを反復します。
|
|
403
|
+
|
|
404
|
+
```ts
|
|
405
|
+
tree.forEachRange(10, 20, (entry) => {
|
|
406
|
+
console.log(entry.key, entry.value);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// 排他的境界の指定
|
|
410
|
+
tree.forEachRange(
|
|
411
|
+
10,
|
|
412
|
+
20,
|
|
413
|
+
(entry) => {
|
|
414
|
+
/* ... */
|
|
415
|
+
},
|
|
416
|
+
{ lowerBound: 'exclusive' },
|
|
417
|
+
);
|
|
418
|
+
```
|
|
419
|
+
|
|
402
420
|
**`snapshot()`** -- 全エントリをソート順で取得します。
|
|
403
421
|
|
|
404
422
|
```ts
|
|
@@ -437,6 +455,8 @@ copy.put(99, 'new');
|
|
|
437
455
|
tree.hasKey(99); // false -- 元のツリーには影響しない
|
|
438
456
|
```
|
|
439
457
|
|
|
458
|
+
注意: `EntryId` の値はクローン内で再割り当てされます — 元のツリーの ID はクローンに対して有効ではありません。
|
|
459
|
+
|
|
440
460
|
**`toJSON()` / `fromJSON()`** -- ツリーをシリアライズ・復元します。
|
|
441
461
|
|
|
442
462
|
```ts
|
|
@@ -756,46 +776,66 @@ try {
|
|
|
756
776
|
|
|
757
777
|
---
|
|
758
778
|
|
|
779
|
+
#### 共有ストアのセキュリティ前提
|
|
780
|
+
|
|
781
|
+
`ConcurrentInMemoryBTree` は共有ストアが**信頼されている**ことを前提としています。悪意を持って細工されたミューテーションペイロードや、異常に大きなペイロードに対する防御機能はありません。
|
|
782
|
+
|
|
783
|
+
**信頼境界:**
|
|
784
|
+
|
|
785
|
+
- ストアはあなたのアプリケーションの管理下にあること。
|
|
786
|
+
- 同一ストアを共有するすべてのインスタンスは同一の設定を使用すること(最初の書き込み時に `init` ミューテーションの設定フィンガープリントで検証されますが、リプレイバッチに `init` が含まれている場合に限ります)。
|
|
787
|
+
- ミューテーションはリプレイ前に構造的に検証されますが、セマンティックな正確性(キー型の整合性など)は呼び出し側の責任です。
|
|
788
|
+
|
|
789
|
+
**共有・マルチテナントデプロイメントにおける堅牢化の推奨事項:**
|
|
790
|
+
|
|
791
|
+
- 認可レイヤーなしに `append` や `getLogEntriesSince` を信頼されていないクライアントに公開しないこと。
|
|
792
|
+
- 格納するミューテーションペイロードのサイズ制限をストアレベルで適用してから `ConcurrentInMemoryBTree` に渡すこと。
|
|
793
|
+
- `maxSyncMutationsPerBatch` を使用して、1回の sync 呼び出しで適用するミューテーション数を制限すること(デフォルト:100,000)。
|
|
794
|
+
- リプレイ失敗により `sync()` が `BTreeConcurrencyError` をスローした場合、インスタンスは永続的に汚染されます。そのインスタンスを破棄し、新しいインスタンスを作成してください。
|
|
795
|
+
|
|
796
|
+
---
|
|
797
|
+
|
|
759
798
|
## API リファレンス
|
|
760
799
|
|
|
761
800
|
### InMemoryBTree
|
|
762
801
|
|
|
763
|
-
| メソッド | シグネチャ
|
|
764
|
-
| -------------------- |
|
|
765
|
-
| `put` | `(key: TKey, value: TValue) => EntryId`
|
|
766
|
-
| `putMany` | `(entries: readonly { key: TKey; value: TValue }[]) => EntryId[]`
|
|
767
|
-
| `remove` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null`
|
|
768
|
-
| `removeById` | `(entryId: EntryId) => BTreeEntry<TKey, TValue> \| null`
|
|
769
|
-
| `peekById` | `(entryId: EntryId) => BTreeEntry<TKey, TValue> \| null`
|
|
770
|
-
| `updateById` | `(entryId: EntryId, value: TValue) => BTreeEntry<TKey, TValue> \| null`
|
|
771
|
-
| `popFirst` | `() => BTreeEntry<TKey, TValue> \| null`
|
|
772
|
-
| `popLast` | `() => BTreeEntry<TKey, TValue> \| null`
|
|
773
|
-
| `peekFirst` | `() => BTreeEntry<TKey, TValue> \| null`
|
|
774
|
-
| `peekLast` | `() => BTreeEntry<TKey, TValue> \| null`
|
|
775
|
-
| `findFirst` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null`
|
|
776
|
-
| `findLast` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null`
|
|
777
|
-
| `get` | `(key: TKey) => TValue \| null`
|
|
778
|
-
| `hasKey` | `(key: TKey) => boolean`
|
|
779
|
-
| `count` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => number`
|
|
780
|
-
| `range` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => BTreeEntry<TKey, TValue>[]`
|
|
781
|
-
| `nextHigherKey` | `(key: TKey) => TKey \| null`
|
|
782
|
-
| `nextLowerKey` | `(key: TKey) => TKey \| null`
|
|
783
|
-
| `getPairOrNextLower` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null`
|
|
784
|
-
| `deleteRange` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => number`
|
|
785
|
-
| `entries` | `() => IterableIterator<BTreeEntry<TKey, TValue>>`
|
|
786
|
-
| `entriesReversed` | `() => IterableIterator<BTreeEntry<TKey, TValue>>`
|
|
787
|
-
| `keys` | `() => IterableIterator<TKey>`
|
|
788
|
-
| `values` | `() => IterableIterator<TValue>`
|
|
789
|
-
| `[Symbol.iterator]` | `() => IterableIterator<BTreeEntry<TKey, TValue>>`
|
|
790
|
-
| `forEach` | `(callback: (entry) => void, thisArg?) => void`
|
|
791
|
-
| `
|
|
792
|
-
| `
|
|
793
|
-
| `
|
|
794
|
-
| `
|
|
795
|
-
| `
|
|
796
|
-
| `
|
|
797
|
-
| `
|
|
798
|
-
| `
|
|
802
|
+
| メソッド | シグネチャ | 説明 |
|
|
803
|
+
| -------------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------- |
|
|
804
|
+
| `put` | `(key: TKey, value: TValue) => EntryId` | キーバリューペアを挿入し、`EntryId` を返す。 |
|
|
805
|
+
| `putMany` | `(entries: readonly { key: TKey; value: TValue }[]) => EntryId[]` | ソート済みエントリの一括挿入。空のツリーでは O(n)。非空ツリーではカーソル最適化。 |
|
|
806
|
+
| `remove` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null` | 指定キーに一致する最初のエントリを削除する。 |
|
|
807
|
+
| `removeById` | `(entryId: EntryId) => BTreeEntry<TKey, TValue> \| null` | ID でエントリを削除する。 |
|
|
808
|
+
| `peekById` | `(entryId: EntryId) => BTreeEntry<TKey, TValue> \| null` | ID でエントリを削除せずに参照する。 |
|
|
809
|
+
| `updateById` | `(entryId: EntryId, value: TValue) => BTreeEntry<TKey, TValue> \| null` | ID でエントリの値を更新する。 |
|
|
810
|
+
| `popFirst` | `() => BTreeEntry<TKey, TValue> \| null` | 最小キーのエントリを削除して返す。 |
|
|
811
|
+
| `popLast` | `() => BTreeEntry<TKey, TValue> \| null` | 最大キーのエントリを削除して返す。 |
|
|
812
|
+
| `peekFirst` | `() => BTreeEntry<TKey, TValue> \| null` | 最小キーのエントリを削除せずに返す。 |
|
|
813
|
+
| `peekLast` | `() => BTreeEntry<TKey, TValue> \| null` | 最大のエントリを削除せずに返す。 |
|
|
814
|
+
| `findFirst` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null` | キーに一致する最初のエントリを返す。 |
|
|
815
|
+
| `findLast` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null` | キーに一致する最後のエントリを返す。 |
|
|
816
|
+
| `get` | `(key: TKey) => TValue \| null` | 指定キーの最初の値を返す。キーがない場合は null。 |
|
|
817
|
+
| `hasKey` | `(key: TKey) => boolean` | 指定キーのエントリが 1 件以上存在するか確認する。 |
|
|
818
|
+
| `count` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => number` | 配列割り当てなしで範囲内のエントリ数を返す。境界はデフォルトで包含。 |
|
|
819
|
+
| `range` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => BTreeEntry<TKey, TValue>[]` | startKey から endKey のエントリを返す。境界はデフォルトで包含。 |
|
|
820
|
+
| `nextHigherKey` | `(key: TKey) => TKey \| null` | 指定キーより大きい次のキーを返す。 |
|
|
821
|
+
| `nextLowerKey` | `(key: TKey) => TKey \| null` | 指定キーより小さい次のキーを返す。 |
|
|
822
|
+
| `getPairOrNextLower` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null` | 一致エントリまたはそれより小さい最大のエントリを返す。 |
|
|
823
|
+
| `deleteRange` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => number` | 範囲内のエントリを削除し、削除件数を返す。 |
|
|
824
|
+
| `entries` | `() => IterableIterator<BTreeEntry<TKey, TValue>>` | 昇順で全エントリを遅延イテレーションする。 |
|
|
825
|
+
| `entriesReversed` | `() => IterableIterator<BTreeEntry<TKey, TValue>>` | 降順で全エントリを遅延イテレーションする。 |
|
|
826
|
+
| `keys` | `() => IterableIterator<TKey>` | 昇順で全キーを遅延イテレーションする。 |
|
|
827
|
+
| `values` | `() => IterableIterator<TValue>` | 昇順で全値を遅延イテレーションする。 |
|
|
828
|
+
| `[Symbol.iterator]` | `() => IterableIterator<BTreeEntry<TKey, TValue>>` | `for...of` やスプレッドを有効にする。`entries()` に委譲。 |
|
|
829
|
+
| `forEach` | `(callback: (entry) => void, thisArg?) => void` | 昇順で各エントリを訪問する。 |
|
|
830
|
+
| `forEachRange` | `(startKey: TKey, endKey: TKey, callback: (entry) => void, options?: RangeBounds) => void` | 配列を生成せずに範囲内のエントリを反復する。 |
|
|
831
|
+
| `snapshot` | `() => BTreeEntry<TKey, TValue>[]` | 全エントリをソート順で返す。 |
|
|
832
|
+
| `clear` | `() => void` | 全エントリを削除し、空の状態に O(1) でリセットする。 |
|
|
833
|
+
| `size` | `() => number` | エントリ数を返す。 |
|
|
834
|
+
| `getStats` | `() => BTreeStats` | 構造統計を返す。 |
|
|
835
|
+
| `assertInvariants` | `() => void` | B+ tree の構造的な整合性を検証する。不正な場合はスローする。 |
|
|
836
|
+
| `clone` | `() => InMemoryBTree<TKey, TValue>` | 構造的に独立したコピーを返す(キー・値参照は共有)。 |
|
|
837
|
+
| `toJSON` | `() => BTreeJSON<TKey, TValue>` | バージョン付き JSON 互換ペイロードにシリアライズする。 |
|
|
838
|
+
| `fromJSON` (静的) | `(json, compareKeys) => InMemoryBTree<TKey, TValue>` | `toJSON` ペイロードからツリーを再構築する。 |
|
|
799
839
|
|
|
800
840
|
**コンストラクタ:**
|
|
801
841
|
|
|
@@ -805,33 +845,46 @@ new InMemoryBTree<TKey, TValue>(config: InMemoryBTreeConfig<TKey>)
|
|
|
805
845
|
|
|
806
846
|
### ConcurrentInMemoryBTree
|
|
807
847
|
|
|
808
|
-
`InMemoryBTree`
|
|
809
|
-
|
|
810
|
-
| メソッド
|
|
811
|
-
|
|
|
812
|
-
| `sync`
|
|
813
|
-
| `put`
|
|
814
|
-
| `
|
|
815
|
-
| `
|
|
816
|
-
| `
|
|
817
|
-
| `
|
|
818
|
-
| `
|
|
819
|
-
| `
|
|
820
|
-
| `
|
|
821
|
-
| `
|
|
822
|
-
| `
|
|
823
|
-
| `
|
|
824
|
-
| `
|
|
825
|
-
| `
|
|
826
|
-
| `
|
|
827
|
-
| `
|
|
828
|
-
| `
|
|
829
|
-
| `
|
|
830
|
-
| `
|
|
831
|
-
| `
|
|
832
|
-
| `
|
|
833
|
-
| `
|
|
834
|
-
| `
|
|
848
|
+
`InMemoryBTree` メソッドを `Promise` を返す非同期版として提供します。書き込みは shared store を介して協調し、`readMode` が `'strong'`(デフォルト)の場合は読み取り前に同期します。`readMode` が `'local'` の場合、読み取りは同期なしでローカルツリーに対して実行されます。
|
|
849
|
+
|
|
850
|
+
| メソッド | シグネチャ | 説明 |
|
|
851
|
+
| ------------------------ | -------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
|
|
852
|
+
| `sync` | `() => Promise<void>` | shared store の最新ログを取得して適用する。 |
|
|
853
|
+
| `put` | `(key: TKey, value: TValue) => Promise<EntryId>` | 楽観的並行制御で挿入する。 |
|
|
854
|
+
| `putMany` | `(entries: readonly { key: TKey; value: TValue }[]) => Promise<EntryId[]>` | 楽観的並行制御で一括挿入する。 |
|
|
855
|
+
| `remove` | `(key: TKey) => Promise<BTreeEntry<TKey, TValue> \| null>` | 指定キーに一致する最初のエントリを削除する。 |
|
|
856
|
+
| `removeById` | `(entryId: EntryId) => Promise<BTreeEntry<TKey, TValue> \| null>` | ID でエントリを削除する。 |
|
|
857
|
+
| `peekById` | `(entryId: EntryId) => Promise<BTreeEntry<TKey, TValue> \| null>` | ID でエントリを参照する(事前に同期)。 |
|
|
858
|
+
| `updateById` | `(entryId: EntryId, value: TValue) => Promise<BTreeEntry<TKey, TValue> \| null>` | 楽観的並行制御で ID のエントリ値を更新する。 |
|
|
859
|
+
| `popFirst` | `() => Promise<BTreeEntry<TKey, TValue> \| null>` | 最小キーのエントリを削除して返す。 |
|
|
860
|
+
| `popLast` | `() => Promise<BTreeEntry<TKey, TValue> \| null>` | 最大キーのエントリを削除して返す。 |
|
|
861
|
+
| `deleteRange` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => Promise<number>` | 楽観的並行制御で範囲内のエントリを削除する。 |
|
|
862
|
+
| `clear` | `() => Promise<void>` | 楽観的並行制御で全エントリを削除する。 |
|
|
863
|
+
| `peekFirst` | `() => Promise<BTreeEntry<TKey, TValue> \| null>` | 最小キーのエントリを返す(事前に同期)。 |
|
|
864
|
+
| `peekLast` | `() => Promise<BTreeEntry<TKey, TValue> \| null>` | 最大キーのエントリを返す(事前に同期)。 |
|
|
865
|
+
| `findFirst` | `(key: TKey) => Promise<BTreeEntry<TKey, TValue> \| null>` | キーに一致する最初のエントリを返す(事前に同期)。 |
|
|
866
|
+
| `findLast` | `(key: TKey) => Promise<BTreeEntry<TKey, TValue> \| null>` | キーに一致する最後のエントリを返す(事前に同期)。 |
|
|
867
|
+
| `get` | `(key: TKey) => Promise<TValue \| null>` | キーの値を取得する(事前に同期)。 |
|
|
868
|
+
| `hasKey` | `(key: TKey) => Promise<boolean>` | キーの存在を確認する(事前に同期)。 |
|
|
869
|
+
| `count` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => Promise<number>` | 範囲内のエントリ数を返す(事前に同期)。 |
|
|
870
|
+
| `range` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => Promise<BTreeEntry<TKey, TValue>[]>` | 範囲クエリ(事前に同期)。 |
|
|
871
|
+
| `nextHigherKey` | `(key: TKey) => Promise<TKey \| null>` | 指定キーより大きい次のキー(事前に同期)。 |
|
|
872
|
+
| `nextLowerKey` | `(key: TKey) => Promise<TKey \| null>` | 指定キーより小さい次のキー(事前に同期)。 |
|
|
873
|
+
| `getPairOrNextLower` | `(key: TKey) => Promise<BTreeEntry<TKey, TValue> \| null>` | 一致または次に小さいエントリ(事前に同期)。 |
|
|
874
|
+
| `entries` | `() => Promise<BTreeEntry<TKey, TValue>[]>` | 全エントリを配列で返す(事前に同期)。 |
|
|
875
|
+
| `entriesReversed` | `() => Promise<BTreeEntry<TKey, TValue>[]>` | 全エントリを逆順で配列として返す(事前に同期)。 |
|
|
876
|
+
| `keys` | `() => Promise<TKey[]>` | 全キーを配列で返す(事前に同期)。 |
|
|
877
|
+
| `values` | `() => Promise<TValue[]>` | 全値を配列で返す(事前に同期)。 |
|
|
878
|
+
| `forEach` | `(callback: (entry: BTreeEntry<TKey, TValue>) => void) => Promise<void>` | 全エントリを反復する(事前に同期)。 |
|
|
879
|
+
| `forEachRange` | `(startKey, endKey, callback, options?) => Promise<void>` | 範囲内のエントリを反復する(事前に同期)。 |
|
|
880
|
+
| `snapshot` | `() => Promise<BTreeEntry<TKey, TValue>[]>` | 全エントリを返す(事前に同期)。 |
|
|
881
|
+
| `size` | `() => Promise<number>` | エントリ数を返す(事前に同期)。 |
|
|
882
|
+
| `getStats` | `() => Promise<BTreeStats>` | 構造統計を返す(事前に同期)。 |
|
|
883
|
+
| `assertInvariants` | `() => Promise<void>` | 構造的な整合性を検証する(事前に同期)。 |
|
|
884
|
+
| `clone` | `() => Promise<InMemoryBTree<TKey, TValue>>` | 独立したローカルコピーを返す(事前に同期)。 |
|
|
885
|
+
| `toJSON` | `() => Promise<BTreeJSON<TKey, TValue>>` | JSON にシリアライズする(事前に同期)。 |
|
|
886
|
+
| `fromJSON` (static) | `(json: BTreeJSON<TKey, TValue>, compareKeys: KeyComparator<TKey>) => InMemoryBTree<TKey, TValue>` | JSON からデシリアライズする(ローカルツリーを返す)。 |
|
|
887
|
+
| `[Symbol.asyncIterator]` | `() => AsyncIterableIterator<BTreeEntry<TKey, TValue>>` | 全エントリを非同期反復する(事前に同期)。 |
|
|
835
888
|
|
|
836
889
|
**コンストラクタ:**
|
|
837
890
|
|
|
@@ -855,7 +908,7 @@ new ConcurrentInMemoryBTree<TKey, TValue>(config: ConcurrentInMemoryBTreeConfig<
|
|
|
855
908
|
| `ConcurrentInMemoryBTreeConfig<TKey, TValue>` | `InMemoryBTreeConfig<TKey>` を拡張し、`store: SharedTreeStore<TKey, TValue>`、`maxRetries?: number`、`maxSyncMutationsPerBatch?: number`、`readMode?: ReadMode` を追加。 |
|
|
856
909
|
| `SharedTreeStore<TKey, TValue>` | `getLogEntriesSince(version)` と `append(expectedVersion, mutations)` を持つインターフェース。 |
|
|
857
910
|
| `SharedTreeLog<TKey, TValue>` | `{ version: bigint; mutations: BTreeMutation<TKey, TValue>[] }` |
|
|
858
|
-
| `BTreeMutation<TKey, TValue>` | 判別共用体: `init`、`put`、`remove`、`removeById`、`updateById`、`popFirst`、`popLast`。
|
|
911
|
+
| `BTreeMutation<TKey, TValue>` | 判別共用体: `init`、`put`、`putMany`、`remove`、`removeById`、`updateById`、`popFirst`、`popLast`、`deleteRange`、`clear`。 |
|
|
859
912
|
| `BTreeValidationError` | コンパレータや設定の違反でスローされるエラー。 |
|
|
860
913
|
| `BTreeInvariantError` | ツリー構造の整合性違反でスローされるエラー。 |
|
|
861
914
|
| `BTreeConcurrencyError` | 並行処理コンフリクトやストア契約違反でスローされるエラー。 |
|
package/README.md
CHANGED
|
@@ -399,6 +399,24 @@ tree.forEach((entry) => {
|
|
|
399
399
|
});
|
|
400
400
|
```
|
|
401
401
|
|
|
402
|
+
**`forEachRange(startKey, endKey, callback, options?)`** -- iterate over entries in a range without allocating a result array:
|
|
403
|
+
|
|
404
|
+
```ts
|
|
405
|
+
tree.forEachRange(10, 20, (entry) => {
|
|
406
|
+
console.log(entry.key, entry.value);
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// With exclusive bounds
|
|
410
|
+
tree.forEachRange(
|
|
411
|
+
10,
|
|
412
|
+
20,
|
|
413
|
+
(entry) => {
|
|
414
|
+
/* ... */
|
|
415
|
+
},
|
|
416
|
+
{ lowerBound: 'exclusive' },
|
|
417
|
+
);
|
|
418
|
+
```
|
|
419
|
+
|
|
402
420
|
**`snapshot()`** -- get all entries in sorted order:
|
|
403
421
|
|
|
404
422
|
```ts
|
|
@@ -437,6 +455,8 @@ copy.put(99, 'new');
|
|
|
437
455
|
tree.hasKey(99); // false — original is unaffected
|
|
438
456
|
```
|
|
439
457
|
|
|
458
|
+
Note: `EntryId` values are reassigned in the clone — IDs from the source tree are not valid for the clone.
|
|
459
|
+
|
|
440
460
|
**`toJSON()` / `fromJSON()`** -- serialize and reconstruct:
|
|
441
461
|
|
|
442
462
|
```ts
|
|
@@ -756,46 +776,66 @@ try {
|
|
|
756
776
|
|
|
757
777
|
---
|
|
758
778
|
|
|
779
|
+
#### Shared Store Security Assumptions
|
|
780
|
+
|
|
781
|
+
`ConcurrentInMemoryBTree` assumes the shared store is **trusted**. It does not defend against a store that returns maliciously crafted or arbitrarily large mutation payloads.
|
|
782
|
+
|
|
783
|
+
**Trust boundary:**
|
|
784
|
+
|
|
785
|
+
- The store is under your control or the control of your application.
|
|
786
|
+
- All instances sharing a store must use identical configuration (enforced via config fingerprint on the first write, but only when an `init` mutation is present in the replayed batch).
|
|
787
|
+
- Mutations are structurally validated before replay, but semantic correctness (e.g., key type consistency) is the caller's responsibility.
|
|
788
|
+
|
|
789
|
+
**Hardening recommendations for shared or multi-tenant deployments:**
|
|
790
|
+
|
|
791
|
+
- Do not expose `append` or `getLogEntriesSince` to untrusted clients without an authorization layer.
|
|
792
|
+
- Apply size limits to stored mutation payloads at the store level before they reach `ConcurrentInMemoryBTree`.
|
|
793
|
+
- Use `maxSyncMutationsPerBatch` to cap the number of mutations applied per sync call (default: 100,000).
|
|
794
|
+
- If a `sync()` throws `BTreeConcurrencyError` due to a replay failure, the instance is permanently poisoned. Discard it and create a new one.
|
|
795
|
+
|
|
796
|
+
---
|
|
797
|
+
|
|
759
798
|
## API Reference
|
|
760
799
|
|
|
761
800
|
### InMemoryBTree
|
|
762
801
|
|
|
763
|
-
| Method | Signature
|
|
764
|
-
| -------------------- |
|
|
765
|
-
| `put` | `(key: TKey, value: TValue) => EntryId`
|
|
766
|
-
| `putMany` | `(entries: readonly { key: TKey; value: TValue }[]) => EntryId[]`
|
|
767
|
-
| `remove` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null`
|
|
768
|
-
| `removeById` | `(entryId: EntryId) => BTreeEntry<TKey, TValue> \| null`
|
|
769
|
-
| `peekById` | `(entryId: EntryId) => BTreeEntry<TKey, TValue> \| null`
|
|
770
|
-
| `updateById` | `(entryId: EntryId, value: TValue) => BTreeEntry<TKey, TValue> \| null`
|
|
771
|
-
| `popFirst` | `() => BTreeEntry<TKey, TValue> \| null`
|
|
772
|
-
| `popLast` | `() => BTreeEntry<TKey, TValue> \| null`
|
|
773
|
-
| `peekFirst` | `() => BTreeEntry<TKey, TValue> \| null`
|
|
774
|
-
| `peekLast` | `() => BTreeEntry<TKey, TValue> \| null`
|
|
775
|
-
| `findFirst` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null`
|
|
776
|
-
| `findLast` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null`
|
|
777
|
-
| `get` | `(key: TKey) => TValue \| null`
|
|
778
|
-
| `hasKey` | `(key: TKey) => boolean`
|
|
779
|
-
| `count` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => number`
|
|
780
|
-
| `range` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => BTreeEntry<TKey, TValue>[]`
|
|
781
|
-
| `nextHigherKey` | `(key: TKey) => TKey \| null`
|
|
782
|
-
| `nextLowerKey` | `(key: TKey) => TKey \| null`
|
|
783
|
-
| `getPairOrNextLower` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null`
|
|
784
|
-
| `deleteRange` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => number`
|
|
785
|
-
| `entries` | `() => IterableIterator<BTreeEntry<TKey, TValue>>`
|
|
786
|
-
| `entriesReversed` | `() => IterableIterator<BTreeEntry<TKey, TValue>>`
|
|
787
|
-
| `keys` | `() => IterableIterator<TKey>`
|
|
788
|
-
| `values` | `() => IterableIterator<TValue>`
|
|
789
|
-
| `[Symbol.iterator]` | `() => IterableIterator<BTreeEntry<TKey, TValue>>`
|
|
790
|
-
| `forEach` | `(callback: (entry) => void, thisArg?) => void`
|
|
791
|
-
| `
|
|
792
|
-
| `
|
|
793
|
-
| `
|
|
794
|
-
| `
|
|
795
|
-
| `
|
|
796
|
-
| `
|
|
797
|
-
| `
|
|
798
|
-
| `
|
|
802
|
+
| Method | Signature | Description |
|
|
803
|
+
| -------------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------- |
|
|
804
|
+
| `put` | `(key: TKey, value: TValue) => EntryId` | Insert a key-value pair. Returns an `EntryId`. |
|
|
805
|
+
| `putMany` | `(entries: readonly { key: TKey; value: TValue }[]) => EntryId[]` | Bulk insert pre-sorted entries. O(n) on empty tree; cursor-optimized on non-empty tree. |
|
|
806
|
+
| `remove` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null` | Remove the first matching entry by key. |
|
|
807
|
+
| `removeById` | `(entryId: EntryId) => BTreeEntry<TKey, TValue> \| null` | Remove a specific entry by ID. |
|
|
808
|
+
| `peekById` | `(entryId: EntryId) => BTreeEntry<TKey, TValue> \| null` | Look up an entry by ID without removing it. |
|
|
809
|
+
| `updateById` | `(entryId: EntryId, value: TValue) => BTreeEntry<TKey, TValue> \| null` | Update the value of an entry by ID. |
|
|
810
|
+
| `popFirst` | `() => BTreeEntry<TKey, TValue> \| null` | Remove and return the smallest entry. |
|
|
811
|
+
| `popLast` | `() => BTreeEntry<TKey, TValue> \| null` | Remove and return the largest entry. |
|
|
812
|
+
| `peekFirst` | `() => BTreeEntry<TKey, TValue> \| null` | Return the smallest entry without removing it. |
|
|
813
|
+
| `peekLast` | `() => BTreeEntry<TKey, TValue> \| null` | Return the largest entry without removing it. |
|
|
814
|
+
| `findFirst` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null` | Return the first entry matching key, or null. |
|
|
815
|
+
| `findLast` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null` | Return the last entry matching key, or null. |
|
|
816
|
+
| `get` | `(key: TKey) => TValue \| null` | Return the value of the first matching key, or null. |
|
|
817
|
+
| `hasKey` | `(key: TKey) => boolean` | Check if at least one entry exists for the key. |
|
|
818
|
+
| `count` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => number` | Count entries in range without array allocation. Bounds default to inclusive. |
|
|
819
|
+
| `range` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => BTreeEntry<TKey, TValue>[]` | Return entries between startKey and endKey. Bounds default to inclusive. |
|
|
820
|
+
| `nextHigherKey` | `(key: TKey) => TKey \| null` | Return the next key strictly greater than key. |
|
|
821
|
+
| `nextLowerKey` | `(key: TKey) => TKey \| null` | Return the next key strictly less than key. |
|
|
822
|
+
| `getPairOrNextLower` | `(key: TKey) => BTreeEntry<TKey, TValue> \| null` | Return exact match or next lower entry. |
|
|
823
|
+
| `deleteRange` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => number` | Remove entries in range, return count deleted. |
|
|
824
|
+
| `entries` | `() => IterableIterator<BTreeEntry<TKey, TValue>>` | Lazily iterate all entries in ascending key order. |
|
|
825
|
+
| `entriesReversed` | `() => IterableIterator<BTreeEntry<TKey, TValue>>` | Lazily iterate all entries in descending key order. |
|
|
826
|
+
| `keys` | `() => IterableIterator<TKey>` | Lazily iterate all keys in ascending order. |
|
|
827
|
+
| `values` | `() => IterableIterator<TValue>` | Lazily iterate all values in ascending key order. |
|
|
828
|
+
| `[Symbol.iterator]` | `() => IterableIterator<BTreeEntry<TKey, TValue>>` | Enables `for...of` and spread. Delegates to `entries()`. |
|
|
829
|
+
| `forEach` | `(callback: (entry) => void, thisArg?) => void` | Visit each entry in ascending key order. |
|
|
830
|
+
| `forEachRange` | `(startKey: TKey, endKey: TKey, callback: (entry) => void, options?: RangeBounds) => void` | Iterate entries in range without array allocation. |
|
|
831
|
+
| `snapshot` | `() => BTreeEntry<TKey, TValue>[]` | Return all entries in sorted order. |
|
|
832
|
+
| `clear` | `() => void` | Remove all entries and reset to empty state in O(1). |
|
|
833
|
+
| `size` | `() => number` | Return the total number of entries. |
|
|
834
|
+
| `getStats` | `() => BTreeStats` | Return structural statistics. |
|
|
835
|
+
| `assertInvariants` | `() => void` | Assert B+ tree structural integrity. Throws if invalid. |
|
|
836
|
+
| `clone` | `() => InMemoryBTree<TKey, TValue>` | Return a structurally independent copy (shared key/value refs). |
|
|
837
|
+
| `toJSON` | `() => BTreeJSON<TKey, TValue>` | Serialize to a versioned JSON-safe payload. |
|
|
838
|
+
| `fromJSON` (static) | `(json, compareKeys) => InMemoryBTree<TKey, TValue>` | Reconstruct a tree from a `toJSON` payload. |
|
|
799
839
|
|
|
800
840
|
**Constructor:**
|
|
801
841
|
|
|
@@ -805,33 +845,46 @@ new InMemoryBTree<TKey, TValue>(config: InMemoryBTreeConfig<TKey>)
|
|
|
805
845
|
|
|
806
846
|
### ConcurrentInMemoryBTree
|
|
807
847
|
|
|
808
|
-
Exposes
|
|
809
|
-
|
|
810
|
-
| Method
|
|
811
|
-
|
|
|
812
|
-
| `sync`
|
|
813
|
-
| `put`
|
|
814
|
-
| `
|
|
815
|
-
| `
|
|
816
|
-
| `
|
|
817
|
-
| `
|
|
818
|
-
| `
|
|
819
|
-
| `
|
|
820
|
-
| `
|
|
821
|
-
| `
|
|
822
|
-
| `
|
|
823
|
-
| `
|
|
824
|
-
| `
|
|
825
|
-
| `
|
|
826
|
-
| `
|
|
827
|
-
| `
|
|
828
|
-
| `
|
|
829
|
-
| `
|
|
830
|
-
| `
|
|
831
|
-
| `
|
|
832
|
-
| `
|
|
833
|
-
| `
|
|
834
|
-
| `
|
|
848
|
+
Exposes `InMemoryBTree` methods as async equivalents returning `Promise`. Writes coordinate through the shared store; reads sync before returning when `readMode` is `'strong'` (the default). When `readMode` is `'local'`, reads execute against the local tree without syncing.
|
|
849
|
+
|
|
850
|
+
| Method | Signature | Description |
|
|
851
|
+
| ------------------------ | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
852
|
+
| `sync` | `() => Promise<void>` | Fetch and apply the latest log entries from the shared store. |
|
|
853
|
+
| `put` | `(key: TKey, value: TValue) => Promise<EntryId>` | Insert with optimistic concurrency. |
|
|
854
|
+
| `putMany` | `(entries: readonly { key: TKey; value: TValue }[]) => Promise<EntryId[]>` | Batch insert with optimistic concurrency. |
|
|
855
|
+
| `remove` | `(key: TKey) => Promise<BTreeEntry<TKey, TValue> \| null>` | Remove the first matching entry by key. |
|
|
856
|
+
| `removeById` | `(entryId: EntryId) => Promise<BTreeEntry<TKey, TValue> \| null>` | Remove a specific entry by ID. |
|
|
857
|
+
| `peekById` | `(entryId: EntryId) => Promise<BTreeEntry<TKey, TValue> \| null>` | Look up an entry by ID (syncs first). |
|
|
858
|
+
| `updateById` | `(entryId: EntryId, value: TValue) => Promise<BTreeEntry<TKey, TValue> \| null>` | Update an entry by ID with optimistic concurrency. |
|
|
859
|
+
| `popFirst` | `() => Promise<BTreeEntry<TKey, TValue> \| null>` | Remove and return the smallest entry. |
|
|
860
|
+
| `popLast` | `() => Promise<BTreeEntry<TKey, TValue> \| null>` | Remove and return the largest entry. |
|
|
861
|
+
| `deleteRange` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => Promise<number>` | Delete entries in range with optimistic concurrency. |
|
|
862
|
+
| `clear` | `() => Promise<void>` | Remove all entries with optimistic concurrency. |
|
|
863
|
+
| `peekFirst` | `() => Promise<BTreeEntry<TKey, TValue> \| null>` | Return the smallest entry (syncs first). |
|
|
864
|
+
| `peekLast` | `() => Promise<BTreeEntry<TKey, TValue> \| null>` | Return the largest entry (syncs first). |
|
|
865
|
+
| `findFirst` | `(key: TKey) => Promise<BTreeEntry<TKey, TValue> \| null>` | Return the first entry matching key (syncs first). |
|
|
866
|
+
| `findLast` | `(key: TKey) => Promise<BTreeEntry<TKey, TValue> \| null>` | Return the last entry matching key (syncs first). |
|
|
867
|
+
| `get` | `(key: TKey) => Promise<TValue \| null>` | Return value by key (syncs first). |
|
|
868
|
+
| `hasKey` | `(key: TKey) => Promise<boolean>` | Check key existence (syncs first). |
|
|
869
|
+
| `count` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => Promise<number>` | Count entries in range (syncs first). |
|
|
870
|
+
| `range` | `(startKey: TKey, endKey: TKey, options?: RangeBounds) => Promise<BTreeEntry<TKey, TValue>[]>` | Range query (syncs first). |
|
|
871
|
+
| `nextHigherKey` | `(key: TKey) => Promise<TKey \| null>` | Next key strictly greater (syncs first). |
|
|
872
|
+
| `nextLowerKey` | `(key: TKey) => Promise<TKey \| null>` | Next key strictly less (syncs first). |
|
|
873
|
+
| `getPairOrNextLower` | `(key: TKey) => Promise<BTreeEntry<TKey, TValue> \| null>` | Exact match or next lower (syncs first). |
|
|
874
|
+
| `entries` | `() => Promise<BTreeEntry<TKey, TValue>[]>` | Return all entries as array (syncs first). |
|
|
875
|
+
| `entriesReversed` | `() => Promise<BTreeEntry<TKey, TValue>[]>` | Return all entries in reverse as array (syncs first). |
|
|
876
|
+
| `keys` | `() => Promise<TKey[]>` | Return all keys as array (syncs first). |
|
|
877
|
+
| `values` | `() => Promise<TValue[]>` | Return all values as array (syncs first). |
|
|
878
|
+
| `forEach` | `(callback: (entry: BTreeEntry<TKey, TValue>) => void) => Promise<void>` | Iterate all entries (syncs first). |
|
|
879
|
+
| `forEachRange` | `(startKey, endKey, callback, options?) => Promise<void>` | Iterate entries in range (syncs first). |
|
|
880
|
+
| `snapshot` | `() => Promise<BTreeEntry<TKey, TValue>[]>` | Return all entries (syncs first). |
|
|
881
|
+
| `size` | `() => Promise<number>` | Return entry count (syncs first). |
|
|
882
|
+
| `getStats` | `() => Promise<BTreeStats>` | Return structural statistics (syncs first). |
|
|
883
|
+
| `assertInvariants` | `() => Promise<void>` | Assert structural integrity (syncs first). |
|
|
884
|
+
| `clone` | `() => Promise<InMemoryBTree<TKey, TValue>>` | Return an independent local copy (syncs first). |
|
|
885
|
+
| `toJSON` | `() => Promise<BTreeJSON<TKey, TValue>>` | Serialize to JSON (syncs first). |
|
|
886
|
+
| `fromJSON` (static) | `(json: BTreeJSON<TKey, TValue>, compareKeys: KeyComparator<TKey>) => InMemoryBTree<TKey, TValue>` | Deserialize from JSON (returns local tree). |
|
|
887
|
+
| `[Symbol.asyncIterator]` | `() => AsyncIterableIterator<BTreeEntry<TKey, TValue>>` | Async iteration over all entries (syncs first). |
|
|
835
888
|
|
|
836
889
|
**Constructor:**
|
|
837
890
|
|
|
@@ -855,7 +908,7 @@ new ConcurrentInMemoryBTree<TKey, TValue>(config: ConcurrentInMemoryBTreeConfig<
|
|
|
855
908
|
| `ConcurrentInMemoryBTreeConfig<TKey, TValue>` | Extends `InMemoryBTreeConfig<TKey>` with `store: SharedTreeStore<TKey, TValue>`, `maxRetries?: number`, `maxSyncMutationsPerBatch?: number`, and `readMode?: ReadMode`. |
|
|
856
909
|
| `SharedTreeStore<TKey, TValue>` | Interface with `getLogEntriesSince(version)` and `append(expectedVersion, mutations)`. |
|
|
857
910
|
| `SharedTreeLog<TKey, TValue>` | `{ version: bigint; mutations: BTreeMutation<TKey, TValue>[] }` |
|
|
858
|
-
| `BTreeMutation<TKey, TValue>` | Discriminated union: `init`, `put`, `remove`, `removeById`, `updateById`, `popFirst`, `popLast`.
|
|
911
|
+
| `BTreeMutation<TKey, TValue>` | Discriminated union: `init`, `put`, `putMany`, `remove`, `removeById`, `updateById`, `popFirst`, `popLast`, `deleteRange`, `clear`. |
|
|
859
912
|
| `BTreeValidationError` | Error thrown for comparator or config violations. |
|
|
860
913
|
| `BTreeInvariantError` | Error thrown for tree structural integrity violations. |
|
|
861
914
|
| `BTreeConcurrencyError` | Error thrown for concurrency conflicts or store contract violations. |
|
package/dist/InMemoryBTree.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type BTreeJSON } from './btree/serialization.js';
|
|
2
|
-
import { type BTreeEntry, type BTreeStats, type DuplicateKeyPolicy, type EntryId, type InMemoryBTreeConfig, type KeyComparator, type RangeBounds } from './btree/types.js';
|
|
3
|
-
export type { BTreeJSON };
|
|
4
|
-
export type { BTreeEntry, BTreeStats, DuplicateKeyPolicy, EntryId, InMemoryBTreeConfig, RangeBounds };
|
|
2
|
+
import { type BTreeEntry, type BTreeStats, type DeleteRebalancePolicy, type DuplicateKeyPolicy, type EntryId, type InMemoryBTreeConfig, type KeyComparator, type RangeBounds } from './btree/types.js';
|
|
3
|
+
export type { BTreeEntry, BTreeJSON, BTreeStats, DeleteRebalancePolicy, DuplicateKeyPolicy, EntryId, InMemoryBTreeConfig, RangeBounds, };
|
|
5
4
|
export declare class InMemoryBTree<TKey, TValue> {
|
|
6
5
|
private readonly state;
|
|
7
6
|
constructor(config: InMemoryBTreeConfig<TKey>);
|
|
@@ -34,6 +33,7 @@ export declare class InMemoryBTree<TKey, TValue> {
|
|
|
34
33
|
keys(): IterableIterator<TKey>;
|
|
35
34
|
values(): IterableIterator<TValue>;
|
|
36
35
|
[Symbol.iterator](): IterableIterator<BTreeEntry<TKey, TValue>>;
|
|
36
|
+
forEachRange(startKey: TKey, endKey: TKey, callback: (entry: BTreeEntry<TKey, TValue>) => void, options?: RangeBounds): void;
|
|
37
37
|
forEach(callback: (entry: BTreeEntry<TKey, TValue>) => void, thisArg?: unknown): void;
|
|
38
38
|
snapshot(): BTreeEntry<TKey, TValue>[];
|
|
39
39
|
clone(): InMemoryBTree<TKey, TValue>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BTreeState, type InMemoryBTreeConfig } from './types.js';
|
|
2
|
+
export declare const minOccupancy: (max: number) => number;
|
|
2
3
|
export declare const computeAutoScaleTier: (entryCount: number) => {
|
|
3
4
|
readonly maxLeaf: number;
|
|
4
5
|
readonly maxBranch: number;
|
|
@@ -7,3 +8,4 @@ export declare const computeNextAutoScaleThreshold: (entryCount: number) => numb
|
|
|
7
8
|
export declare const createInitialState: <TKey, TValue>(config: InMemoryBTreeConfig<TKey>) => BTreeState<TKey, TValue>;
|
|
8
9
|
export declare const maybeAutoScale: <TKey, TValue>(state: BTreeState<TKey, TValue>) => void;
|
|
9
10
|
export declare const applyAutoScaleCapacitySnapshot: <TKey, TValue>(state: BTreeState<TKey, TValue>, maxLeafEntries: number, maxBranchChildren: number) => void;
|
|
11
|
+
export declare const resetAutoScaleToTier0: <TKey, TValue>(state: BTreeState<TKey, TValue>) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type BTreeEntry, type BTreeState, type EntryId, type LeafNode } from './types.js';
|
|
2
|
+
export declare const findLeafEntryBySequence: <TKey, TValue>(state: BTreeState<TKey, TValue>, userKey: TKey, sequence: number) => {
|
|
3
|
+
leaf: LeafNode<TKey, TValue>;
|
|
4
|
+
index: number;
|
|
5
|
+
} | null;
|
|
6
|
+
export declare const peekEntryById: <TKey, TValue>(state: BTreeState<TKey, TValue>, entryId: EntryId) => BTreeEntry<TKey, TValue> | null;
|
|
7
|
+
export declare const updateEntryById: <TKey, TValue>(state: BTreeState<TKey, TValue>, entryId: EntryId, newValue: TValue) => BTreeEntry<TKey, TValue> | null;
|
|
8
|
+
export declare const removeEntryById: <TKey, TValue>(state: BTreeState<TKey, TValue>, entryId: EntryId) => BTreeEntry<TKey, TValue> | null;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { type BTreeEntry, type BTreeState, type EntryId } from './types.js';
|
|
2
|
+
export { peekEntryById, removeEntryById, updateEntryById, } from './entry-lookup.js';
|
|
2
3
|
export declare const putEntry: <TKey, TValue>(state: BTreeState<TKey, TValue>, key: TKey, value: TValue) => EntryId;
|
|
3
4
|
export declare const popFirstEntry: <TKey, TValue>(state: BTreeState<TKey, TValue>) => BTreeEntry<TKey, TValue> | null;
|
|
4
5
|
export declare const popLastEntry: <TKey, TValue>(state: BTreeState<TKey, TValue>) => BTreeEntry<TKey, TValue> | null;
|
|
5
6
|
export declare const removeFirstMatchingEntry: <TKey, TValue>(state: BTreeState<TKey, TValue>, key: TKey) => BTreeEntry<TKey, TValue> | null;
|
|
6
|
-
export declare const removeEntryById: <TKey, TValue>(state: BTreeState<TKey, TValue>, entryId: EntryId) => BTreeEntry<TKey, TValue> | null;
|
|
7
|
-
export declare const peekEntryById: <TKey, TValue>(state: BTreeState<TKey, TValue>, entryId: EntryId) => BTreeEntry<TKey, TValue> | null;
|
|
8
|
-
export declare const updateEntryById: <TKey, TValue>(state: BTreeState<TKey, TValue>, entryId: EntryId, newValue: TValue) => BTreeEntry<TKey, TValue> | null;
|
|
9
7
|
export declare const putManyEntries: <TKey, TValue>(state: BTreeState<TKey, TValue>, entries: readonly {
|
|
10
8
|
key: TKey;
|
|
11
9
|
value: TValue;
|