xitdb 0.13.0 → 0.15.0

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.
Files changed (61) hide show
  1. package/README.md +129 -15
  2. package/dist/core-buffered-file.d.ts +2 -2
  3. package/dist/core-buffered-file.js +182 -0
  4. package/dist/core-file.d.ts +1 -1
  5. package/dist/core-file.js +105 -0
  6. package/dist/core-memory.d.ts +1 -1
  7. package/dist/core-memory.js +152 -0
  8. package/dist/core.js +1 -0
  9. package/dist/database.d.ts +174 -49
  10. package/dist/database.js +3047 -0
  11. package/dist/exceptions.d.ts +4 -0
  12. package/dist/exceptions.js +62 -0
  13. package/dist/hasher.js +49 -0
  14. package/dist/index.d.ts +30 -26
  15. package/dist/index.js +35 -3923
  16. package/dist/read-array-list.d.ts +4 -3
  17. package/dist/read-array-list.js +41 -0
  18. package/dist/read-counted-hash-map.d.ts +2 -2
  19. package/dist/read-counted-hash-map.js +19 -0
  20. package/dist/read-counted-hash-set.d.ts +2 -2
  21. package/dist/read-counted-hash-set.js +19 -0
  22. package/dist/read-cursor.d.ts +16 -5
  23. package/dist/read-cursor.js +678 -0
  24. package/dist/read-hash-map.d.ts +4 -4
  25. package/dist/read-hash-map.js +65 -0
  26. package/dist/read-hash-set.d.ts +4 -4
  27. package/dist/read-hash-set.js +47 -0
  28. package/dist/read-linked-array-list.d.ts +4 -3
  29. package/dist/read-linked-array-list.js +41 -0
  30. package/dist/read-sorted-map.d.ts +21 -0
  31. package/dist/read-sorted-map.js +73 -0
  32. package/dist/read-sorted-set.d.ts +19 -0
  33. package/dist/read-sorted-set.js +65 -0
  34. package/dist/slot-pointer.d.ts +1 -1
  35. package/dist/slot-pointer.js +11 -0
  36. package/dist/slot.d.ts +2 -2
  37. package/dist/slot.js +41 -0
  38. package/dist/slotted.d.ts +1 -1
  39. package/dist/slotted.js +1 -0
  40. package/dist/tag.d.ts +3 -1
  41. package/dist/tag.js +25 -0
  42. package/dist/write-array-list.d.ts +4 -4
  43. package/dist/write-array-list.js +42 -0
  44. package/dist/write-counted-hash-map.d.ts +2 -2
  45. package/dist/write-counted-hash-map.js +18 -0
  46. package/dist/write-counted-hash-set.d.ts +2 -2
  47. package/dist/write-counted-hash-set.js +18 -0
  48. package/dist/write-cursor.d.ts +5 -5
  49. package/dist/write-cursor.js +124 -0
  50. package/dist/write-hash-map.d.ts +4 -4
  51. package/dist/write-hash-map.js +90 -0
  52. package/dist/write-hash-set.d.ts +4 -4
  53. package/dist/write-hash-set.js +59 -0
  54. package/dist/write-linked-array-list.d.ts +4 -4
  55. package/dist/write-linked-array-list.js +52 -0
  56. package/dist/write-sorted-map.d.ts +12 -0
  57. package/dist/write-sorted-map.js +37 -0
  58. package/dist/write-sorted-set.d.ts +10 -0
  59. package/dist/write-sorted-set.js +29 -0
  60. package/dist/writeable-data.js +68 -0
  61. package/package.json +6 -6
@@ -1,6 +1,6 @@
1
- import { Slot } from './slot';
2
- import type { Slotted } from './slotted';
3
- import { ReadCursor, CursorIterator } from './read-cursor';
1
+ import { Slot } from './slot.js';
2
+ import type { Slotted } from './slotted.js';
3
+ import { ReadCursor, CursorIterator } from './read-cursor.js';
4
4
  export declare class ReadArrayList implements Slotted {
5
5
  cursor: ReadCursor;
6
6
  constructor();
@@ -8,6 +8,7 @@ export declare class ReadArrayList implements Slotted {
8
8
  slot(): Slot;
9
9
  count(): number;
10
10
  iterator(): CursorIterator;
11
+ iteratorFrom(index: number): CursorIterator;
11
12
  [Symbol.iterator](): Iterator<ReadCursor>;
12
13
  getCursor(index: number): ReadCursor | null;
13
14
  getSlot(index: number): Slot | null;
@@ -0,0 +1,41 @@
1
+ import { CursorIterator } from './read-cursor.js';
2
+ import { ArrayListGet } from './database.js';
3
+ import { UnexpectedTagException } from './exceptions.js';
4
+ export class ReadArrayList {
5
+ cursor;
6
+ constructor(cursor) {
7
+ if (cursor) {
8
+ switch (cursor.slotPtr.slot.tag) {
9
+ case 0 /* Tag.NONE */:
10
+ case 2 /* Tag.ARRAY_LIST */:
11
+ this.cursor = cursor;
12
+ break;
13
+ default:
14
+ throw new UnexpectedTagException();
15
+ }
16
+ }
17
+ }
18
+ slot() {
19
+ return this.cursor.slot();
20
+ }
21
+ count() {
22
+ return this.cursor.count();
23
+ }
24
+ iterator() {
25
+ return this.cursor.iterator();
26
+ }
27
+ // iterate starting at the given index, seeking straight to it instead of
28
+ // walking from the front. negative indexes count from the end.
29
+ iteratorFrom(index) {
30
+ return CursorIterator.initArrayListFromIndex(this.cursor, index);
31
+ }
32
+ *[Symbol.iterator]() {
33
+ yield* this.cursor;
34
+ }
35
+ getCursor(index) {
36
+ return this.cursor.readPath([new ArrayListGet(index)]);
37
+ }
38
+ getSlot(index) {
39
+ return this.cursor.readPathSlot([new ArrayListGet(index)]);
40
+ }
41
+ }
@@ -1,5 +1,5 @@
1
- import { ReadHashMap } from './read-hash-map';
2
- import { ReadCursor } from './read-cursor';
1
+ import { ReadHashMap } from './read-hash-map.js';
2
+ import { ReadCursor } from './read-cursor.js';
3
3
  export declare class ReadCountedHashMap extends ReadHashMap {
4
4
  constructor(cursor: ReadCursor);
5
5
  count(): number;
@@ -0,0 +1,19 @@
1
+ import { ReadHashMap } from './read-hash-map.js';
2
+ import { UnexpectedTagException } from './exceptions.js';
3
+ export class ReadCountedHashMap extends ReadHashMap {
4
+ constructor(cursor) {
5
+ super();
6
+ switch (cursor.slotPtr.slot.tag) {
7
+ case 0 /* Tag.NONE */:
8
+ case 12 /* Tag.COUNTED_HASH_MAP */:
9
+ case 13 /* Tag.COUNTED_HASH_SET */:
10
+ this.cursor = cursor;
11
+ break;
12
+ default:
13
+ throw new UnexpectedTagException();
14
+ }
15
+ }
16
+ count() {
17
+ return this.cursor.count();
18
+ }
19
+ }
@@ -1,5 +1,5 @@
1
- import { ReadHashSet } from './read-hash-set';
2
- import { ReadCursor } from './read-cursor';
1
+ import { ReadHashSet } from './read-hash-set.js';
2
+ import { ReadCursor } from './read-cursor.js';
3
3
  export declare class ReadCountedHashSet extends ReadHashSet {
4
4
  constructor(cursor: ReadCursor);
5
5
  count(): number;
@@ -0,0 +1,19 @@
1
+ import { ReadHashSet } from './read-hash-set.js';
2
+ import { UnexpectedTagException } from './exceptions.js';
3
+ export class ReadCountedHashSet extends ReadHashSet {
4
+ constructor(cursor) {
5
+ super();
6
+ switch (cursor.slotPtr.slot.tag) {
7
+ case 0 /* Tag.NONE */:
8
+ case 12 /* Tag.COUNTED_HASH_MAP */:
9
+ case 13 /* Tag.COUNTED_HASH_SET */:
10
+ this.cursor = cursor;
11
+ break;
12
+ default:
13
+ throw new UnexpectedTagException();
14
+ }
15
+ }
16
+ count() {
17
+ return this.cursor.count();
18
+ }
19
+ }
@@ -1,8 +1,8 @@
1
- import { Slot } from './slot';
2
- import { SlotPointer } from './slot-pointer';
3
- import type { Slotted } from './slotted';
4
- import { Database, type PathPart } from './database';
5
- import { Bytes } from './writeable-data';
1
+ import { Slot } from './slot.js';
2
+ import { SlotPointer } from './slot-pointer.js';
3
+ import type { Slotted } from './slotted.js';
4
+ import { Database, type PathPart } from './database.js';
5
+ import { Bytes } from './writeable-data.js';
6
6
  export declare class KeyValuePairCursor {
7
7
  valueCursor: ReadCursor;
8
8
  keyCursor: ReadCursor;
@@ -48,7 +48,18 @@ export declare class CursorIterator {
48
48
  private stack;
49
49
  private nextCursorMaybe;
50
50
  constructor(cursor: ReadCursor);
51
+ private static resolveStartIndex;
52
+ static initSortedFromIndex(cursor: ReadCursor, startIndex: number): CursorIterator;
53
+ static initArrayListFromIndex(cursor: ReadCursor, startIndex: number): CursorIterator;
54
+ static initLinkedArrayListFromIndex(cursor: ReadCursor, startIndex: number): CursorIterator;
55
+ static initSortedFromKey(cursor: ReadCursor, startKey: Uint8Array): CursorIterator;
56
+ private static sortedRootPtr;
57
+ private static sortedStackFromIndex;
58
+ private static arrayListStackFromIndex;
59
+ private static btreeStackFromIndex;
60
+ private static sortedStackFromKey;
51
61
  init(): void;
62
+ static readSlotBlock(cursor: ReadCursor, position: number): Slot[];
52
63
  private initStack;
53
64
  hasNext(): boolean;
54
65
  next(): ReadCursor | null;