pigeonhole-db 1.2.2 → 1.3.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 (132) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +16 -16
  3. data/Cargo.toml +5 -5
  4. data/lib/pigeonhole/version.rb +1 -1
  5. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/io-event-1.22.3/IO_Event.so +0 -0
  6. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/io-event-1.22.3/gem_make.out +6 -6
  7. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/io-event-1.22.3/mkmf.log +26 -26
  8. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/gem_make.out +6 -6
  9. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/json/ext/generator.so +0 -0
  10. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/json/ext/parser.so +0 -0
  11. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/json-3.1.0/mkmf.log +19 -19
  12. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/prism-1.9.0/gem_make.out +9 -9
  13. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/prism-1.9.0/mkmf.log +6 -6
  14. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/prism-1.9.0/prism/prism.so +0 -0
  15. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/rbs-4.2.0/gem_make.out +6 -6
  16. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/rbs-4.2.0/mkmf.log +7 -7
  17. data/vendor/bundle/ruby/3.4.0/extensions/x86_64-linux/3.4.0/rbs-4.2.0/rbs_extension.so +0 -0
  18. data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/ext/Makefile +3 -3
  19. data/vendor/bundle/ruby/3.4.0/gems/io-event-1.22.3/lib/IO_Event.so +0 -0
  20. data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/generator/Makefile +3 -3
  21. data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/ext/json/ext/parser/Makefile +3 -3
  22. data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json/ext/generator.so +0 -0
  23. data/vendor/bundle/ruby/3.4.0/gems/json-3.1.0/lib/json/ext/parser.so +0 -0
  24. data/vendor/bundle/ruby/3.4.0/gems/prism-1.9.0/ext/prism/Makefile +3 -3
  25. data/vendor/bundle/ruby/3.4.0/gems/prism-1.9.0/lib/prism/prism.so +0 -0
  26. data/vendor/bundle/ruby/3.4.0/gems/rbs-4.2.0/ext/rbs_extension/Makefile +3 -3
  27. data/vendor/bundle/ruby/3.4.0/gems/rbs-4.2.0/lib/rbs_extension.so +0 -0
  28. data/vendor/cache/Cargo.toml +2 -2
  29. data/vendor/cache/src/lib.rs +37 -0
  30. data/vendor/cache/src/loom_tests.rs +32 -0
  31. data/vendor/cache/src/s3fifo.rs +239 -11
  32. data/vendor/cache/src/sync.rs +4 -4
  33. data/vendor/compaction/Cargo.toml +6 -6
  34. data/vendor/compaction/src/cursor.rs +86 -4
  35. data/vendor/compaction/src/job.rs +24 -2
  36. data/vendor/engine/Cargo.toml +11 -11
  37. data/vendor/engine/src/admission.rs +3 -1
  38. data/vendor/engine/src/catalog.rs +39 -4
  39. data/vendor/engine/src/check.rs +59 -20
  40. data/vendor/engine/src/compact.rs +2 -2
  41. data/vendor/engine/src/engine/hooks.rs +144 -2
  42. data/vendor/engine/src/engine/info.rs +6 -0
  43. data/vendor/engine/src/engine.rs +1492 -50
  44. data/vendor/engine/src/external_registry.rs +447 -0
  45. data/vendor/engine/src/feed.rs +313 -84
  46. data/vendor/engine/src/feed_reader/catalog.rs +490 -0
  47. data/vendor/engine/src/feed_reader/history.rs +236 -0
  48. data/vendor/engine/src/feed_reader/read_ahead.rs +241 -0
  49. data/vendor/engine/src/feed_reader/token.rs +232 -0
  50. data/vendor/engine/src/feed_reader.rs +970 -852
  51. data/vendor/engine/src/feed_stop_loom.rs +73 -0
  52. data/vendor/engine/src/flush.rs +29 -4
  53. data/vendor/engine/src/io_count.rs +190 -0
  54. data/vendor/engine/src/large.rs +4 -1
  55. data/vendor/engine/src/lib.rs +16 -2
  56. data/vendor/engine/src/maintenance.rs +2 -2
  57. data/vendor/engine/src/manifest.rs +38 -6
  58. data/vendor/engine/src/nonblocking.rs +3 -3
  59. data/vendor/engine/src/options.rs +26 -0
  60. data/vendor/engine/src/punch.rs +282 -0
  61. data/vendor/engine/src/range_copy.rs +365 -0
  62. data/vendor/engine/src/read/keys.rs +37 -5
  63. data/vendor/engine/src/read/reduce.rs +1 -0
  64. data/vendor/engine/src/read.rs +7 -0
  65. data/vendor/engine/src/row_cache.rs +24 -0
  66. data/vendor/engine/src/shard/tablets.rs +127 -31
  67. data/vendor/engine/src/shard.rs +1006 -33
  68. data/vendor/engine/src/source.rs +105 -12
  69. data/vendor/engine/src/write.rs +310 -4
  70. data/vendor/format/Cargo.toml +1 -1
  71. data/vendor/format/src/shm.rs +10 -0
  72. data/vendor/format/src/superblock.rs +9 -2
  73. data/vendor/format/src/wal.rs +818 -16
  74. data/vendor/io/Cargo.toml +3 -3
  75. data/vendor/io/src/count.rs +76 -0
  76. data/vendor/io/src/file.rs +70 -0
  77. data/vendor/io/src/lib.rs +2 -0
  78. data/vendor/io/src/os/unix.rs +124 -0
  79. data/vendor/io/src/os/windows.rs +51 -0
  80. data/vendor/io/src/pread.rs +26 -0
  81. data/vendor/io/src/sim.rs +81 -9
  82. data/vendor/io/src/sys.rs +53 -0
  83. data/vendor/io/src/uring.rs +28 -0
  84. data/vendor/io/src/vfs.rs +4 -0
  85. data/vendor/memory/Cargo.toml +4 -4
  86. data/vendor/memory/src/hooks.rs +6 -0
  87. data/vendor/memory/src/ivf.rs +67 -1
  88. data/vendor/memory/src/lib.rs +4 -1
  89. data/vendor/memory/src/recall/pool.rs +872 -0
  90. data/vendor/memory/src/recall.rs +351 -273
  91. data/vendor/memory/src/store.rs +15 -0
  92. data/vendor/memtable/Cargo.toml +3 -3
  93. data/vendor/pager/Cargo.toml +3 -3
  94. data/vendor/pager/src/alloc.rs +430 -0
  95. data/vendor/pager/src/lib.rs +114 -0
  96. data/vendor/pigeonhole/Cargo.toml +6 -5
  97. data/vendor/pigeonhole/src/db.rs +91 -2
  98. data/vendor/pigeonhole/src/error.rs +2 -1
  99. data/vendor/pigeonhole/src/feed.rs +210 -6
  100. data/vendor/pigeonhole/src/lib.rs +3 -0
  101. data/vendor/pigeonhole/src/metrics.rs +37 -0
  102. data/vendor/pigeonhole/src/nonblocking.rs +94 -111
  103. data/vendor/pigeonhole/src/options.rs +69 -0
  104. data/vendor/pigeonhole/src/replication.rs +601 -11
  105. data/vendor/pigeonhole/src/write.rs +81 -0
  106. data/vendor/runtime/Cargo.toml +2 -2
  107. data/vendor/shm/Cargo.toml +3 -3
  108. data/vendor/shm/src/region.rs +20 -2
  109. data/vendor/sst/Cargo.toml +4 -4
  110. data/vendor/sst/src/blob.rs +85 -7
  111. data/vendor/sst/src/iter.rs +98 -2
  112. data/vendor/sst/src/lib.rs +11 -2
  113. data/vendor/sst/src/writer.rs +12 -2
  114. data/vendor/text/Cargo.toml +2 -2
  115. data/vendor/text/src/block.rs +638 -0
  116. data/vendor/text/src/error.rs +8 -3
  117. data/vendor/text/src/fuzzy.rs +1 -1
  118. data/vendor/text/src/index.rs +1055 -80
  119. data/vendor/text/src/layout.rs +63 -2
  120. data/vendor/text/src/lib.rs +5 -1
  121. data/vendor/text/src/maxscore.rs +481 -94
  122. data/vendor/text/src/merged.rs +470 -0
  123. data/vendor/text/src/search.rs +1278 -341
  124. data/vendor/text/src/stats.rs +431 -0
  125. data/vendor/vector/Cargo.toml +2 -2
  126. data/vendor/vector/src/hooks.rs +33 -4
  127. data/vendor/vector/src/index.rs +498 -69
  128. data/vendor/wal/Cargo.toml +3 -3
  129. data/vendor/wal/src/feed.rs +313 -19
  130. data/vendor/wal/src/recovery.rs +31 -1
  131. data/vendor/wal/src/stream.rs +28 -0
  132. metadata +15 -1
@@ -15,6 +15,10 @@ pub(crate) const GLOBAL: &[u8] = b"G";
15
15
  pub(crate) const POST: &str = "post";
16
16
  /// `P{t}`: one column per document, its positions as ascending LEB128 deltas.
17
17
  pub(crate) const POS: &str = "pos";
18
+ /// `P{t}`, in a version 2 index: one column per packed block of postings, the qualifier the
19
+ /// block's last document id, the value the block ([`crate::block`]). Added to the table by
20
+ /// the first [`Index::pack`](crate::Index::pack).
21
+ pub(crate) const POSTB: &str = "postb";
18
22
  /// `P{t}`: a counter, the term's document frequency, at [`N`].
19
23
  pub(crate) const DF: &str = "df";
20
24
  /// `P{t}`: a `max` aggregate, the largest term frequency any posting had (MaxScore, M1).
@@ -44,10 +48,67 @@ pub(crate) const TOKENIZER: &[u8] = b"tokenizer";
44
48
  pub(crate) const FINGERPRINT: &[u8] = b"fingerprint";
45
49
  /// The normaliser's Unicode version, for diagnostics (D309 rev 6 §A.9).
46
50
  pub(crate) const NORMALIZER_UNICODE: &[u8] = b"normalizer-unicode";
47
- /// Present while [`Index::repair`](crate::Index::repair) runs.
51
+ /// The index's state, which every search and every write through the index reads:
52
+ /// - **absent:** layout version 1, and no repair running;
53
+ /// - **[`PACKED`]:** layout version 2, and no repair running;
54
+ /// - **anything else** (it is written empty): [`Index::repair`](crate::Index::repair) is
55
+ /// running, and the read fails with `Busy`.
56
+ ///
57
+ /// One cell for both, so a search learns the layout from the read it already made for the
58
+ /// repair flag (#1585), and a handle opened before the first pack needs no reopen. A 1.2
59
+ /// build, which knows only "present means a repair", fails with `Busy` on a packed index it
60
+ /// had open, where it would otherwise search past the packed postings without knowing.
48
61
  pub(crate) const REPAIR: &[u8] = b"repair";
49
-
62
+ /// [`REPAIR`]'s value in a version 2 index with no repair running.
63
+ pub(crate) const PACKED: &[u8] = b"v2";
64
+ /// A stopped pack's cursor (#1585): [`pack_cursor`] of the last posting cell its last chunk
65
+ /// took, or empty before its first chunk. Absent when no pack is part way.
66
+ pub(crate) const PACK_AFTER: &[u8] = b"pack-after";
67
+ /// A stopped rebuild's cursor (#1756): the last source row it reconciled, which
68
+ /// [`Index::resume_rebuild_with`](crate::Index::resume_rebuild_with) continues after. Absent
69
+ /// when no rebuild is pending.
70
+ pub(crate) const REBUILD_AFTER: &[u8] = b"rebuild-after";
71
+ /// An index created unfilled (#1722 PR 2c): present from
72
+ /// [`Index::create_unfilled`](crate::Index::create_unfilled) until a walk of the whole
73
+ /// source (its fill, or a rebuild or repair that reaches the end) finishes. Unlike
74
+ /// [`REBUILD_AFTER`], a client's rebuild never sets it: until it goes, the index lacks
75
+ /// source rows rather than holding stale postings for some.
76
+ pub(crate) const UNFILLED: &[u8] = b"unfilled";
77
+
78
+ /// The layout an index is created with: postings as one cell a document.
50
79
  pub(crate) const LAYOUT_VERSION: u64 = 1;
80
+ /// The layout after the first [`Index::pack`](crate::Index::pack) (#1585, ICR 0143): packed
81
+ /// blocks ([`POSTB`]) under the cells, and tombstones ([`TOMBSTONE`]) where a posting is
82
+ /// deleted.
83
+ pub(crate) const LAYOUT_PACKED: u64 = 2;
84
+
85
+ /// A deleted posting's [`POST`] value in a version 2 index (its [`POS`] value is empty): it
86
+ /// hides the document's posting in a packed block until the next pack removes both. A real
87
+ /// posting has a frequency of at least 1, and a real position list is never empty.
88
+ pub(crate) const TOMBSTONE: u64 = 0;
89
+
90
+ /// A pack cursor: the term's length (`u32` LE), the term, then the document id.
91
+ pub(crate) fn pack_cursor(term: &[u8], doc: &[u8]) -> Vec<u8> {
92
+ let mut v = Vec::with_capacity(4 + term.len() + doc.len());
93
+ v.extend_from_slice(&(term.len() as u32).to_le_bytes());
94
+ v.extend_from_slice(term);
95
+ v.extend_from_slice(doc);
96
+ v
97
+ }
98
+
99
+ /// A pack cursor's term and document id; `None` for the empty cursor (from the top).
100
+ pub(crate) fn unpack_cursor(b: &[u8]) -> Result<Option<(&[u8], &[u8])>> {
101
+ if b.is_empty() {
102
+ return Ok(None);
103
+ }
104
+ let bad = || Error::Corruption("a pack cursor doesn't parse".into());
105
+ let n = u32::from_le_bytes(b.get(..4).ok_or_else(bad)?.try_into().expect("4 bytes")) as usize;
106
+ let rest = &b[4..];
107
+ if rest.len() < n {
108
+ return Err(bad());
109
+ }
110
+ Ok(Some(rest.split_at(n)))
111
+ }
51
112
 
52
113
  pub(crate) fn post_row(term: &str) -> Vec<u8> {
53
114
  [POST_PREFIX, term.as_bytes()].concat()
@@ -46,23 +46,27 @@
46
46
 
47
47
  #![forbid(unsafe_code)]
48
48
 
49
+ mod block;
49
50
  mod error;
50
51
  mod fuzzy;
51
52
  mod highlight;
52
53
  mod index;
53
54
  mod layout;
54
55
  mod maxscore;
56
+ mod merged;
55
57
  mod query;
56
58
  mod search;
57
59
  mod sloppy;
60
+ mod stats;
58
61
  mod tokenizer;
59
62
 
60
63
  pub use error::{Error, QueryErrorKind, Result};
61
64
  pub use highlight::{Match, Snippet, snippet};
62
- pub use index::{Index, IndexStats, ReadIndex, RebuildStats};
65
+ pub use index::{Index, IndexStats, PackOptions, PackStats, ReadIndex, RebuildStats};
63
66
  pub use layout::{IndexOptions, Normalization, Source};
64
67
  pub use query::{Clause, Fuzziness, Query};
65
68
  pub use search::{FuzzyStats, Hit, Search, SearchStats};
69
+ pub use stats::QueryStats;
66
70
  pub use tokenizer::{Token, Tokenizer};
67
71
 
68
72
  /// The user guide's text-search page and the crate README, compiled and run as doctests.