serializable-bptree 8.4.2 → 9.0.1
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.md +8 -2
- package/dist/cjs/index.cjs +2843 -1661
- package/dist/esm/index.mjs +2843 -1661
- package/dist/types/BPTreePureAsync.d.ts +38 -0
- package/dist/types/BPTreePureSync.d.ts +44 -0
- package/dist/types/base/BPTreeAlgorithmAsync.d.ts +33 -0
- package/dist/types/base/BPTreeAlgorithmSync.d.ts +47 -0
- package/dist/types/base/BPTreeNodeOps.d.ts +34 -0
- package/dist/types/base/BPTreeTransaction.d.ts +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/transaction/BPTreeAsyncTransaction.d.ts +8 -5
- package/dist/types/transaction/BPTreeSyncTransaction.d.ts +8 -5
- package/package.json +2 -2
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { BPTreeCondition, BPTreeConstructorOption, BPTreePair, BPTreeSearchOption, SerializableData } from './types';
|
|
2
|
+
import { SerializeStrategyAsync } from './SerializeStrategyAsync';
|
|
3
|
+
import { ValueComparator } from './base/ValueComparator';
|
|
4
|
+
import { BPTreeTransaction } from './base/BPTreeTransaction';
|
|
5
|
+
import { Ryoiki } from 'ryoiki';
|
|
6
|
+
export declare class BPTreePureAsync<K, V> {
|
|
7
|
+
protected readonly strategy: SerializeStrategyAsync<K, V>;
|
|
8
|
+
protected readonly comparator: ValueComparator<V>;
|
|
9
|
+
protected readonly option: BPTreeConstructorOption;
|
|
10
|
+
protected readonly lock: Ryoiki;
|
|
11
|
+
private readonly _cachedRegexp;
|
|
12
|
+
private _ctx;
|
|
13
|
+
private _ops;
|
|
14
|
+
private readonly _verifierMap;
|
|
15
|
+
private readonly _searchConfigs;
|
|
16
|
+
constructor(strategy: SerializeStrategyAsync<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
|
|
17
|
+
private _ensureValues;
|
|
18
|
+
private _createOps;
|
|
19
|
+
private _createBufferedOps;
|
|
20
|
+
protected writeLock<T>(fn: () => Promise<T>): Promise<T>;
|
|
21
|
+
init(): Promise<void>;
|
|
22
|
+
getRootId(): string;
|
|
23
|
+
getOrder(): number;
|
|
24
|
+
verify(nodeValue: V, condition: BPTreeCondition<V>): boolean;
|
|
25
|
+
get(key: K): Promise<V | undefined>;
|
|
26
|
+
exists(key: K, value: V): Promise<boolean>;
|
|
27
|
+
keysStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): AsyncGenerator<K>;
|
|
28
|
+
whereStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): AsyncGenerator<[K, V]>;
|
|
29
|
+
keys(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Promise<Set<K>>;
|
|
30
|
+
where(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Promise<BPTreePair<K, V>>;
|
|
31
|
+
insert(key: K, value: V): Promise<void>;
|
|
32
|
+
delete(key: K, value?: V): Promise<void>;
|
|
33
|
+
batchInsert(entries: [K, V][]): Promise<void>;
|
|
34
|
+
bulkLoad(entries: [K, V][]): Promise<void>;
|
|
35
|
+
getHeadData(): Promise<SerializableData>;
|
|
36
|
+
setHeadData(data: SerializableData): Promise<void>;
|
|
37
|
+
static ChooseDriver: typeof BPTreeTransaction.ChooseDriver;
|
|
38
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { BPTreeCondition, BPTreeConstructorOption, BPTreePair, BPTreeSearchOption, SerializableData } from './types';
|
|
2
|
+
import { SerializeStrategySync } from './SerializeStrategySync';
|
|
3
|
+
import { ValueComparator } from './base/ValueComparator';
|
|
4
|
+
import { BPTreeTransaction } from './base/BPTreeTransaction';
|
|
5
|
+
export declare class BPTreePureSync<K, V> {
|
|
6
|
+
protected readonly strategy: SerializeStrategySync<K, V>;
|
|
7
|
+
protected readonly comparator: ValueComparator<V>;
|
|
8
|
+
protected readonly option: BPTreeConstructorOption;
|
|
9
|
+
private readonly _cachedRegexp;
|
|
10
|
+
private _ctx;
|
|
11
|
+
private _ops;
|
|
12
|
+
private readonly _verifierMap;
|
|
13
|
+
private readonly _searchConfigs;
|
|
14
|
+
constructor(strategy: SerializeStrategySync<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
|
|
15
|
+
private _ensureValues;
|
|
16
|
+
private _createOps;
|
|
17
|
+
private _createBufferedOps;
|
|
18
|
+
init(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the ID of the root node.
|
|
21
|
+
*/
|
|
22
|
+
getRootId(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the order of the B+Tree.
|
|
25
|
+
*/
|
|
26
|
+
getOrder(): number;
|
|
27
|
+
/**
|
|
28
|
+
* Verified if the value satisfies the condition.
|
|
29
|
+
*/
|
|
30
|
+
verify(nodeValue: V, condition: BPTreeCondition<V>): boolean;
|
|
31
|
+
get(key: K): V | undefined;
|
|
32
|
+
exists(key: K, value: V): boolean;
|
|
33
|
+
keysStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Generator<K>;
|
|
34
|
+
whereStream(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Generator<[K, V]>;
|
|
35
|
+
keys(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): Set<K>;
|
|
36
|
+
where(condition: BPTreeCondition<V>, options?: BPTreeSearchOption<K>): BPTreePair<K, V>;
|
|
37
|
+
insert(key: K, value: V): void;
|
|
38
|
+
delete(key: K, value?: V): void;
|
|
39
|
+
batchInsert(entries: [K, V][]): void;
|
|
40
|
+
bulkLoad(entries: [K, V][]): void;
|
|
41
|
+
getHeadData(): SerializableData;
|
|
42
|
+
setHeadData(data: SerializableData): void;
|
|
43
|
+
static ChooseDriver: typeof BPTreeTransaction.ChooseDriver;
|
|
44
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BPTreeCondition, BPTreeLeafNode, BPTreeNodeKey, BPTreeUnknownNode, BPTreeSearchOption, SerializableData, SerializeStrategyHead } from '../types';
|
|
2
|
+
import type { BPTreeNodeOpsAsync, BPTreeAlgoContext } from './BPTreeNodeOps';
|
|
3
|
+
import { ValueComparator } from './ValueComparator';
|
|
4
|
+
import { cloneNode, binarySearchValues, insertValueIntoLeaf, createVerifierMap, resolveStartEndConfigs, verify } from './BPTreeAlgorithmSync';
|
|
5
|
+
export { cloneNode, binarySearchValues, insertValueIntoLeaf, createVerifierMap, resolveStartEndConfigs, verify };
|
|
6
|
+
type AsyncSearchConfigEntry<K, V> = {
|
|
7
|
+
start: (rootId: string, ops: BPTreeNodeOpsAsync<K, V>, v: V[]) => Promise<BPTreeLeafNode<K, V> | null>;
|
|
8
|
+
end: (rootId: string, ops: BPTreeNodeOpsAsync<K, V>, v: V[]) => Promise<BPTreeLeafNode<K, V> | null>;
|
|
9
|
+
direction: 1 | -1;
|
|
10
|
+
earlyTerminate: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function createSearchConfigsAsync<K, V>(comparator: ValueComparator<V>, ensureValues: (v: V | V[]) => V[]): Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', AsyncSearchConfigEntry<K, V>>>;
|
|
13
|
+
export declare function locateLeafAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): Promise<BPTreeLeafNode<K, V>>;
|
|
14
|
+
export declare function findLowerBoundLeafAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): Promise<BPTreeLeafNode<K, V>>;
|
|
15
|
+
export declare function findUpperBoundLeafAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): Promise<BPTreeLeafNode<K, V>>;
|
|
16
|
+
export declare function findOuterBoundaryLeafAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, value: V, direction: 1 | -1, comparator: ValueComparator<V>): Promise<BPTreeLeafNode<K, V> | null>;
|
|
17
|
+
export declare function leftestNodeAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string): Promise<BPTreeLeafNode<K, V>>;
|
|
18
|
+
export declare function rightestNodeAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string): Promise<BPTreeLeafNode<K, V>>;
|
|
19
|
+
export declare function getPairsGeneratorAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, direction: 1 | -1): AsyncGenerator<[K, V]>;
|
|
20
|
+
export declare function insertAtLeafAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V, comparator: ValueComparator<V>): Promise<BPTreeUnknownNode<K, V>>;
|
|
21
|
+
export declare function insertInParentAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, node: BPTreeUnknownNode<K, V>, value: V, newSiblingNode: BPTreeUnknownNode<K, V>): Promise<void>;
|
|
22
|
+
export declare function insertOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, key: K, value: V, comparator: ValueComparator<V>): Promise<void>;
|
|
23
|
+
export declare function deleteEntryAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, comparator: ValueComparator<V>): Promise<BPTreeUnknownNode<K, V>>;
|
|
24
|
+
export declare function deleteOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, key: K, comparator: ValueComparator<V>, value?: V): Promise<void>;
|
|
25
|
+
export declare function batchInsertOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, entries: [K, V][], comparator: ValueComparator<V>): Promise<void>;
|
|
26
|
+
export declare function bulkLoadOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, entries: [K, V][], comparator: ValueComparator<V>): Promise<void>;
|
|
27
|
+
export declare function existsOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, key: K, value: V, comparator: ValueComparator<V>): Promise<boolean>;
|
|
28
|
+
export declare function getOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, key: K): Promise<V | undefined>;
|
|
29
|
+
export declare function whereStreamOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, condition: BPTreeCondition<V>, comparator: ValueComparator<V>, verifierMap: Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>, searchConfigs: Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', AsyncSearchConfigEntry<K, V>>>, ensureValues: (v: V | V[]) => V[], options?: BPTreeSearchOption<K>): AsyncGenerator<[K, V]>;
|
|
30
|
+
export declare function keysStreamOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, rootId: string, condition: BPTreeCondition<V>, comparator: ValueComparator<V>, verifierMap: Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>, searchConfigs: Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', AsyncSearchConfigEntry<K, V>>>, ensureValues: (v: V | V[]) => V[], options?: BPTreeSearchOption<K>): AsyncGenerator<K>;
|
|
31
|
+
export declare function initOpAsync<K, V>(ops: BPTreeNodeOpsAsync<K, V>, ctx: BPTreeAlgoContext<K, V>, strategyOrder: number, strategyHead: {
|
|
32
|
+
data: SerializableData;
|
|
33
|
+
}, setStrategyHead: (head: SerializeStrategyHead) => void): Promise<void>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { BPTreeCondition, BPTreeLeafNode, BPTreeNodeKey, BPTreeUnknownNode, BPTreeSearchOption, SerializableData, SerializeStrategyHead } from '../types';
|
|
2
|
+
import type { BPTreeNodeOps, BPTreeAlgoContext } from './BPTreeNodeOps';
|
|
3
|
+
import { ValueComparator } from './ValueComparator';
|
|
4
|
+
export declare function cloneNode<K, V, T extends BPTreeUnknownNode<K, V>>(node: T): T;
|
|
5
|
+
export declare function binarySearchValues<V>(values: V[], target: V, comparator: ValueComparator<V>, usePrimary?: boolean, upperBound?: boolean): {
|
|
6
|
+
index: number;
|
|
7
|
+
found: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function insertValueIntoLeaf<K, V>(leaf: BPTreeLeafNode<K, V>, key: K, value: V, comparator: ValueComparator<V>): boolean;
|
|
10
|
+
export declare function createVerifierMap<V>(comparator: ValueComparator<V>, cachedRegexp: Map<string, RegExp>, ensureValues: (v: V | V[]) => V[]): Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>;
|
|
11
|
+
type SearchConfigEntry<K, V> = {
|
|
12
|
+
start: (rootId: string, ops: BPTreeNodeOps<K, V>, v: V[]) => BPTreeLeafNode<K, V> | null;
|
|
13
|
+
end: (rootId: string, ops: BPTreeNodeOps<K, V>, v: V[]) => BPTreeLeafNode<K, V> | null;
|
|
14
|
+
direction: 1 | -1;
|
|
15
|
+
earlyTerminate: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function createSearchConfigs<K, V>(comparator: ValueComparator<V>, ensureValues: (v: V | V[]) => V[]): Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', SearchConfigEntry<K, V>>>;
|
|
18
|
+
export declare function resolveStartEndConfigs<V>(condition: BPTreeCondition<V>, order: 'asc' | 'desc', comparator: ValueComparator<V>, ensureValues: (v: V | V[]) => V[]): {
|
|
19
|
+
startKey: keyof BPTreeCondition<V> | null;
|
|
20
|
+
endKey: keyof BPTreeCondition<V> | null;
|
|
21
|
+
startValues: V[];
|
|
22
|
+
endValues: V[];
|
|
23
|
+
direction: 1 | -1;
|
|
24
|
+
};
|
|
25
|
+
export declare function verify<V>(nodeValue: V, condition: BPTreeCondition<V>, verifierMap: Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>): boolean;
|
|
26
|
+
export declare function locateLeaf<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): BPTreeLeafNode<K, V>;
|
|
27
|
+
export declare function findLowerBoundLeaf<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): BPTreeLeafNode<K, V>;
|
|
28
|
+
export declare function findUpperBoundLeaf<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, value: V, comparator: ValueComparator<V>): BPTreeLeafNode<K, V>;
|
|
29
|
+
export declare function findOuterBoundaryLeaf<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, value: V, direction: 1 | -1, comparator: ValueComparator<V>): BPTreeLeafNode<K, V> | null;
|
|
30
|
+
export declare function leftestNode<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string): BPTreeLeafNode<K, V>;
|
|
31
|
+
export declare function rightestNode<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string): BPTreeLeafNode<K, V>;
|
|
32
|
+
export declare function getPairsGenerator<K, V>(ops: BPTreeNodeOps<K, V>, startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, direction: 1 | -1): Generator<[K, V]>;
|
|
33
|
+
export declare function insertAtLeaf<K, V>(ops: BPTreeNodeOps<K, V>, node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, value: V, comparator: ValueComparator<V>): BPTreeUnknownNode<K, V>;
|
|
34
|
+
export declare function insertInParent<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, node: BPTreeUnknownNode<K, V>, value: V, newSiblingNode: BPTreeUnknownNode<K, V>): void;
|
|
35
|
+
export declare function insertOp<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, key: K, value: V, comparator: ValueComparator<V>): void;
|
|
36
|
+
export declare function deleteEntry<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, node: BPTreeUnknownNode<K, V>, key: BPTreeNodeKey<K>, comparator: ValueComparator<V>): BPTreeUnknownNode<K, V>;
|
|
37
|
+
export declare function deleteOp<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, key: K, comparator: ValueComparator<V>, value?: V): void;
|
|
38
|
+
export declare function batchInsertOp<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, entries: [K, V][], comparator: ValueComparator<V>): void;
|
|
39
|
+
export declare function bulkLoadOp<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, entries: [K, V][], comparator: ValueComparator<V>): void;
|
|
40
|
+
export declare function existsOp<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, key: K, value: V, comparator: ValueComparator<V>): boolean;
|
|
41
|
+
export declare function getOp<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, key: K): V | undefined;
|
|
42
|
+
export declare function whereStreamOp<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, condition: BPTreeCondition<V>, comparator: ValueComparator<V>, verifierMap: Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>, searchConfigs: Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', SearchConfigEntry<K, V>>>, ensureValues: (v: V | V[]) => V[], options?: BPTreeSearchOption<K>): Generator<[K, V]>;
|
|
43
|
+
export declare function keysStreamOp<K, V>(ops: BPTreeNodeOps<K, V>, rootId: string, condition: BPTreeCondition<V>, comparator: ValueComparator<V>, verifierMap: Record<keyof BPTreeCondition<V>, (nodeValue: V, value: V | V[]) => boolean>, searchConfigs: Record<keyof BPTreeCondition<V>, Record<'asc' | 'desc', SearchConfigEntry<K, V>>>, ensureValues: (v: V | V[]) => V[], options?: BPTreeSearchOption<K>): Generator<K>;
|
|
44
|
+
export declare function initOp<K, V>(ops: BPTreeNodeOps<K, V>, ctx: BPTreeAlgoContext<K, V>, strategyOrder: number, strategyHead: {
|
|
45
|
+
data: SerializableData;
|
|
46
|
+
}, setStrategyHead: (head: SerializeStrategyHead) => void): void;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { BPTreeUnknownNode, SerializableData, SerializeStrategyHead } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Abstraction for B+Tree node access operations.
|
|
4
|
+
* Both MVCC-based (BPTreeSyncTransaction) and strategy-direct (BPTreePure)
|
|
5
|
+
* implementations provide this interface to the shared algorithm functions.
|
|
6
|
+
*/
|
|
7
|
+
export interface BPTreeNodeOps<K, V> {
|
|
8
|
+
getNode(id: string): BPTreeUnknownNode<K, V>;
|
|
9
|
+
createNode(leaf: boolean, keys: string[] | K[][], values: V[], parent?: string | null, next?: string | null, prev?: string | null): BPTreeUnknownNode<K, V>;
|
|
10
|
+
updateNode(node: BPTreeUnknownNode<K, V>): void;
|
|
11
|
+
deleteNode(node: BPTreeUnknownNode<K, V>): void;
|
|
12
|
+
readHead(): SerializeStrategyHead | null;
|
|
13
|
+
writeHead(head: SerializeStrategyHead): void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Mutable algorithm context passed to B+Tree algorithm functions.
|
|
17
|
+
* `rootId` is mutable because tree mutations (insert, delete) may change the root.
|
|
18
|
+
*/
|
|
19
|
+
export interface BPTreeAlgoContext<K, V> {
|
|
20
|
+
rootId: string;
|
|
21
|
+
order: number;
|
|
22
|
+
readonly headData: () => SerializableData;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Async version of BPTreeNodeOps for async B+Tree operations.
|
|
26
|
+
*/
|
|
27
|
+
export interface BPTreeNodeOpsAsync<K, V> {
|
|
28
|
+
getNode(id: string): Promise<BPTreeUnknownNode<K, V>>;
|
|
29
|
+
createNode(leaf: boolean, keys: string[] | K[][], values: V[], parent?: string | null, next?: string | null, prev?: string | null): Promise<BPTreeUnknownNode<K, V>>;
|
|
30
|
+
updateNode(node: BPTreeUnknownNode<K, V>): Promise<void>;
|
|
31
|
+
deleteNode(node: BPTreeUnknownNode<K, V>): Promise<void>;
|
|
32
|
+
readHead(): Promise<SerializeStrategyHead | null>;
|
|
33
|
+
writeHead(head: SerializeStrategyHead): Promise<void>;
|
|
34
|
+
}
|
|
@@ -3,7 +3,7 @@ import type { BPTreeCondition, BPTreeConstructorOption, BPTreeUnknownNode, Defer
|
|
|
3
3
|
import { ValueComparator } from './ValueComparator';
|
|
4
4
|
import { SerializeStrategy } from './SerializeStrategy';
|
|
5
5
|
export declare abstract class BPTreeTransaction<K, V> {
|
|
6
|
-
|
|
6
|
+
protected readonly _cachedRegexp: Map<string, RegExp>;
|
|
7
7
|
protected readonly rootTx: BPTreeTransaction<K, V>;
|
|
8
8
|
protected readonly mvccRoot: BPTreeMVCC<K, V>;
|
|
9
9
|
protected readonly mvcc: BPTreeMVCC<K, V>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export { BPTreeSync } from './BPTreeSync';
|
|
|
4
4
|
export { BPTreeSyncTransaction } from './transaction/BPTreeSyncTransaction';
|
|
5
5
|
export { BPTreeAsync } from './BPTreeAsync';
|
|
6
6
|
export { BPTreeAsyncTransaction } from './transaction/BPTreeAsyncTransaction';
|
|
7
|
+
export { BPTreePureSync } from './BPTreePureSync';
|
|
8
|
+
export { BPTreePureAsync } from './BPTreePureAsync';
|
|
7
9
|
export { SerializeStrategySync, InMemoryStoreStrategySync } from './SerializeStrategySync';
|
|
8
10
|
export { SerializeStrategyAsync, InMemoryStoreStrategyAsync } from './SerializeStrategyAsync';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TransactionResult } from 'mvcc-api';
|
|
2
|
-
import type { AsyncBPTreeMVCC, BPTreeCondition, BPTreeConstructorOption,
|
|
2
|
+
import type { AsyncBPTreeMVCC, BPTreeCondition, BPTreeConstructorOption, BPTreeNode, BPTreeNodeKey, BPTreePair, BPTreeUnknownNode, SerializableData, SerializeStrategyHead, BPTreeSearchOption, BPTreeLeafNode } from '../types';
|
|
3
3
|
import { Ryoiki } from 'ryoiki';
|
|
4
|
+
import { getPairsGeneratorAsync } from '../base/BPTreeAlgorithmAsync';
|
|
4
5
|
import { BPTreeTransaction } from '../base/BPTreeTransaction';
|
|
5
6
|
import { SerializeStrategyAsync } from '../SerializeStrategyAsync';
|
|
6
7
|
import { ValueComparator } from '../base/ValueComparator';
|
|
@@ -12,12 +13,14 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeTransaction<K, V
|
|
|
12
13
|
protected readonly comparator: ValueComparator<V>;
|
|
13
14
|
protected readonly option: BPTreeConstructorOption;
|
|
14
15
|
protected readonly lock: Ryoiki;
|
|
16
|
+
private _ops;
|
|
17
|
+
private _ctx;
|
|
18
|
+
private _verifierMapCached;
|
|
19
|
+
private _searchConfigsCached;
|
|
15
20
|
constructor(rootTx: BPTreeAsyncTransaction<K, V> | null, mvccRoot: AsyncBPTreeMVCC<K, V>, mvcc: AsyncBPTreeMVCC<K, V>, strategy: SerializeStrategyAsync<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
|
|
21
|
+
private _initAlgoContext;
|
|
16
22
|
protected writeLock<T>(id: number, fn: () => Promise<T>): Promise<T>;
|
|
17
23
|
protected getNode(id: string): Promise<BPTreeUnknownNode<K, V>>;
|
|
18
|
-
/**
|
|
19
|
-
* Create a new node with a unique ID.
|
|
20
|
-
*/
|
|
21
24
|
protected _createNode(leaf: boolean, keys: string[] | K[][], values: V[], parent?: string | null, next?: string | null, prev?: string | null): Promise<BPTreeUnknownNode<K, V>>;
|
|
22
25
|
protected _updateNode(node: BPTreeUnknownNode<K, V>): Promise<void>;
|
|
23
26
|
protected _deleteNode(node: BPTreeUnknownNode<K, V>): Promise<void>;
|
|
@@ -31,7 +34,7 @@ export declare class BPTreeAsyncTransaction<K, V> extends BPTreeTransaction<K, V
|
|
|
31
34
|
protected findOuterBoundaryLeaf(value: V, direction: 1 | -1): Promise<BPTreeLeafNode<K, V> | null>;
|
|
32
35
|
protected leftestNode(): Promise<BPTreeLeafNode<K, V>>;
|
|
33
36
|
protected rightestNode(): Promise<BPTreeLeafNode<K, V>>;
|
|
34
|
-
protected getPairsGenerator(startNode:
|
|
37
|
+
protected getPairsGenerator(startNode: Parameters<typeof getPairsGeneratorAsync<K, V>>[1], endNode: Parameters<typeof getPairsGeneratorAsync<K, V>>[2], direction: 1 | -1): AsyncGenerator<[BPTreeNodeKey<K>, V], void, unknown>;
|
|
35
38
|
init(): Promise<void>;
|
|
36
39
|
protected _initInternal(): Promise<void>;
|
|
37
40
|
reload(): Promise<void>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TransactionResult } from 'mvcc-api';
|
|
2
|
-
import type { BPTreeCondition, BPTreeConstructorOption,
|
|
2
|
+
import type { BPTreeCondition, BPTreeConstructorOption, BPTreeNode, BPTreeNodeKey, BPTreePair, BPTreeUnknownNode, SerializableData, SerializeStrategyHead, SyncBPTreeMVCC, BPTreeSearchOption, BPTreeLeafNode } from '../types';
|
|
3
|
+
import { getPairsGenerator } from '../base/BPTreeAlgorithmSync';
|
|
3
4
|
import { BPTreeTransaction } from '../base/BPTreeTransaction';
|
|
4
5
|
import { SerializeStrategySync } from '../SerializeStrategySync';
|
|
5
6
|
import { ValueComparator } from '../base/ValueComparator';
|
|
@@ -10,11 +11,13 @@ export declare class BPTreeSyncTransaction<K, V> extends BPTreeTransaction<K, V>
|
|
|
10
11
|
protected readonly strategy: SerializeStrategySync<K, V>;
|
|
11
12
|
protected readonly comparator: ValueComparator<V>;
|
|
12
13
|
protected readonly option: BPTreeConstructorOption;
|
|
14
|
+
private _ops;
|
|
15
|
+
private _ctx;
|
|
16
|
+
private _verifierMapCached;
|
|
17
|
+
private _searchConfigsCached;
|
|
13
18
|
constructor(rootTx: BPTreeSyncTransaction<K, V>, mvccRoot: SyncBPTreeMVCC<K, V>, mvcc: SyncBPTreeMVCC<K, V>, strategy: SerializeStrategySync<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
|
|
19
|
+
private _initAlgoContext;
|
|
14
20
|
protected getNode(id: string): BPTreeUnknownNode<K, V>;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new node with a unique ID.
|
|
17
|
-
*/
|
|
18
21
|
protected _createNode(leaf: boolean, keys: string[] | K[][], values: V[], parent?: string | null, next?: string | null, prev?: string | null): BPTreeUnknownNode<K, V>;
|
|
19
22
|
protected _updateNode(node: BPTreeUnknownNode<K, V>): void;
|
|
20
23
|
protected _deleteNode(node: BPTreeUnknownNode<K, V>): void;
|
|
@@ -28,7 +31,7 @@ export declare class BPTreeSyncTransaction<K, V> extends BPTreeTransaction<K, V>
|
|
|
28
31
|
protected findOuterBoundaryLeaf(value: V, direction: 1 | -1): BPTreeLeafNode<K, V> | null;
|
|
29
32
|
protected leftestNode(): BPTreeLeafNode<K, V>;
|
|
30
33
|
protected rightestNode(): BPTreeLeafNode<K, V>;
|
|
31
|
-
protected getPairsGenerator(startNode:
|
|
34
|
+
protected getPairsGenerator(startNode: Parameters<typeof getPairsGenerator<K, V>>[1], endNode: Parameters<typeof getPairsGenerator<K, V>>[2], direction: 1 | -1): Generator<[BPTreeNodeKey<K>, V], void, unknown>;
|
|
32
35
|
init(): void;
|
|
33
36
|
protected _initInternal(): void;
|
|
34
37
|
reload(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serializable-bptree",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "Store the B+tree flexibly, not only in-memory.",
|
|
5
5
|
"types": "./dist/types/index.d.ts",
|
|
6
6
|
"main": "./dist/cjs/index.cjs",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"typescript": "^5.9.3"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"mvcc-api": "^1.3.
|
|
47
|
+
"mvcc-api": "^1.3.7",
|
|
48
48
|
"ryoiki": "^1.2.0"
|
|
49
49
|
}
|
|
50
50
|
}
|