Skip to content

Commit

Permalink
Fix binary search bug. Release 0.0.10.
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradHoeffner committed Jan 5, 2023
1 parent c0ad4be commit 2f03915
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hdt"
version = "0.0.9"
version = "0.0.10"
repository = "https://github.com/konradhoeffner/hdt"
authors = ["Tim Baccaert <tbaccaer@vub.be>", "Konrad Höffner"]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ If you need any of the those features, consider using a SPARQL endpoint instead.

```toml
[dependencies]
hdt = "0.0.9"
hdt = "0.0.10"
```

```rust
Expand Down Expand Up @@ -61,5 +61,5 @@ If you don't want to pull in the Sophia dependency, you can exclude the adapter:

```toml
[dependencies]
hdt = { version = "0.0.9", default-features = false }
hdt = { version = "0.0.10", default-features = false }
```
6 changes: 4 additions & 2 deletions src/triples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl TriplesBitmap {
let mut low = begin;
let mut high = end;

while low <= high {
while low < high {
let mid = (low + high) / 2;
match self.wavelet_y.get(mid).cmp(&element) {
Ordering::Less => low = mid + 1,
Expand All @@ -168,7 +168,7 @@ impl TriplesBitmap {

/// Search the wavelet matrix for the position of a given subject, predicate pair.
pub fn search_y(&self, subject_id: usize, property_id: usize) -> Option<usize> {
self.bin_search_y(property_id, self.find_y(subject_id), self.last_y(subject_id))
self.bin_search_y(property_id, self.find_y(subject_id), self.last_y(subject_id)+1)
}

fn build_wavelet(mut sequence: Sequence) -> WaveletMatrix {
Expand Down Expand Up @@ -511,5 +511,7 @@ mod tests {
}
// ??? (all triples)
assert_eq!(v, BitmapIter::with_pattern(&triples, &TripleId::new(0, 0, 0)).collect::<Vec<_>>());
// SP? where S and P are in the graph, but not together
assert_eq!(0,BitmapIter::with_pattern(&triples, &TripleId::new(12, 14, 154)).count());
}
}

0 comments on commit 2f03915

Please sign in to comment.