-
Notifications
You must be signed in to change notification settings - Fork 11
Switch to serde and clean warnings #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
erg
wants to merge
1
commit into
master
Choose a base branch
from
update-to-serde
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [build] | ||
| rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"] | ||
|
|
||
| [env] | ||
| CXXFLAGS = "-std=c++11 -Wno-unused-parameter" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| use noise_search::index::{Batch, Index, OpenOptions}; | ||
| extern crate rocksdb; | ||
| use std::convert::TryInto; | ||
|
|
||
| fn main() { | ||
| // Clean start | ||
| let dbname = "target/tests/debug_bbox_db"; | ||
| let _ = Index::drop(dbname); | ||
|
|
||
| // Create index | ||
| let mut index = Index::open(dbname, Some(OpenOptions::Create)).unwrap(); | ||
| let mut batch = Batch::new(); | ||
|
|
||
| // Add a point | ||
| println!("Adding point at [10.9, 48.4]"); | ||
| index.add(r#"{"_id": "point1", "geometry": {"type": "Point", "coordinates": [10.9, 48.4]}}"#, &mut batch).unwrap(); | ||
| index.flush(batch).unwrap(); | ||
|
|
||
| println!("\nChecking what's stored in rtree:"); | ||
| let rtree_cf = index.rocks.cf_handle("rtree").unwrap(); | ||
| let iter = index.rocks.iterator_cf(rtree_cf, rocksdb::IteratorMode::Start).unwrap(); | ||
|
|
||
| for (key, _value) in iter { | ||
| println!("Key length: {}", key.len()); | ||
|
|
||
| // Parse the key | ||
| let mut offset = 0; | ||
|
|
||
| // Read keypath length (varint) | ||
| let keypath_len = key[offset] as usize; | ||
| offset += 1; | ||
|
|
||
| // Read keypath | ||
| let keypath = &key[offset..offset + keypath_len]; | ||
| let keypath_str = String::from_utf8_lossy(keypath); | ||
| println!("Keypath: '{}'", keypath_str); | ||
| offset += keypath_len; | ||
|
|
||
| // Read IID (u64) | ||
| let iid_bytes: [u8; 8] = key[offset..offset + 8] | ||
| .try_into() | ||
| .expect("iid bytes"); | ||
| let iid = u64::from_le_bytes(iid_bytes); | ||
| println!("IID: {}", iid); | ||
| offset += 8; | ||
|
|
||
| // Read bounding box (4 f64 values) | ||
| if key.len() >= offset + 32 { | ||
| let mut bbox = [0.0_f64; 4]; | ||
| for (idx, value) in bbox.iter_mut().enumerate() { | ||
| let start = offset + (idx * 8); | ||
| let bytes: [u8; 8] = key[start..start + 8] | ||
| .try_into() | ||
| .expect("bbox bytes"); | ||
| *value = f64::from_le_bytes(bytes); | ||
| } | ||
| println!("Bounding box: [{}, {}, {}, {}]", bbox[0], bbox[1], bbox[2], bbox[3]); | ||
|
|
||
| // Check if point [10.9, 48.4] should be inside various test bboxes | ||
| println!("\nChecking query matches:"); | ||
| let test_bboxes = vec![ | ||
| ([-1000.0, -1000.0, 99.0, 1000.0], "[-1000, -1000, 99, 1000]"), | ||
| ([0.0, 0.0, 20.0, 50.0], "[0, 0, 20, 50]"), | ||
| ([10.0, 48.0, 11.0, 49.0], "[10, 48, 11, 49]"), | ||
| ]; | ||
|
|
||
| for (query_bbox, desc) in test_bboxes { | ||
| let intersects = bbox[0] <= query_bbox[2] && bbox[2] >= query_bbox[0] && | ||
| bbox[1] <= query_bbox[3] && bbox[3] >= query_bbox[1]; | ||
| println!(" Query {}: intersects = {}", desc, intersects); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| use noise_search::index::{Batch, Index, OpenOptions}; | ||
| extern crate rocksdb; | ||
| use std::convert::TryInto; | ||
|
|
||
| fn main() { | ||
| let dbname = "target/tests/debug_bind_filter"; | ||
| let _ = Index::drop(dbname); | ||
|
|
||
| let mut index = Index::open(dbname, Some(OpenOptions::Create)).unwrap(); | ||
| let mut batch = Batch::new(); | ||
|
|
||
| // Add document with array of points | ||
| index.add(r#"{"_id": "arraypoint", "area": [{"type": "Point", "coordinates": [10.9, 48.4]}, {"type": "Point", "coordinates": [-5.0, -20.1]}]}"#, &mut batch).unwrap(); | ||
| index.flush(batch).unwrap(); | ||
|
|
||
| // Check what's in the rtree | ||
| println!("=== RTree entries ==="); | ||
| let rtree_cf = index.rocks.cf_handle("rtree").unwrap(); | ||
| let iter = index.rocks.iterator_cf(rtree_cf, rocksdb::IteratorMode::Start).unwrap(); | ||
|
|
||
| for (key, value) in iter { | ||
| // Parse key | ||
| let mut offset = 0; | ||
| let keypath_len = key[offset] as usize; | ||
| offset += 1; | ||
| let keypath = String::from_utf8_lossy(&key[offset..offset + keypath_len]); | ||
| offset += keypath_len; | ||
|
|
||
| let iid_bytes: [u8; 8] = key[offset..offset + 8] | ||
| .try_into() | ||
| .expect("iid bytes"); | ||
| let iid = u64::from_le_bytes(iid_bytes); | ||
| offset += 8; | ||
|
|
||
| let mut bbox = [0.0_f64; 4]; | ||
| for (idx, value) in bbox.iter_mut().enumerate() { | ||
| let start = offset + (idx * 8); | ||
| let bytes: [u8; 8] = key[start..start + 8] | ||
| .try_into() | ||
| .expect("bbox bytes"); | ||
| *value = f64::from_le_bytes(bytes); | ||
| } | ||
|
|
||
| // Parse value (arraypath) | ||
| let arraypath = if value.len() >= 8 { | ||
| let bytes: [u8; 8] = value[..8].try_into().expect("array path bytes"); | ||
| vec![u64::from_le_bytes(bytes)] | ||
| } else { | ||
| vec![] | ||
| }; | ||
|
|
||
| println!("Keypath: '{}', IID: {}, BBox: {:?}, ArrayPath: {:?}", keypath, iid, bbox, arraypath); | ||
| } | ||
|
|
||
| // Check main CF entries for area | ||
| println!("\n=== Main CF area entries ==="); | ||
| let main_iter = index.rocks.iterator(rocksdb::IteratorMode::Start); | ||
| for (key, _value) in main_iter { | ||
| let key_str = String::from_utf8_lossy(&key); | ||
| if key_str.contains(".area") && key_str.contains("coordinates") { | ||
| println!(" {}", key_str); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| use noise_search::index::{Batch, Index, OpenOptions}; | ||
| extern crate rocksdb; | ||
| use rocksdb::IteratorMode; | ||
| use std::convert::TryInto; | ||
|
|
||
| fn decode_rtree_key(key: &[u8]) -> (String, u64) { | ||
| let mut offset = 0; | ||
|
|
||
| // Read keypath length (varint) | ||
| let keypath_len = key[offset] as usize; | ||
| offset += 1; | ||
|
|
||
| // Read keypath | ||
| let keypath = &key[offset..offset + keypath_len]; | ||
| let keypath_str = String::from_utf8_lossy(keypath).to_string(); | ||
| offset += keypath_len; | ||
|
|
||
| // Read IID (u64) | ||
| let iid_bytes: [u8; 8] = key[offset..offset + 8] | ||
| .try_into() | ||
| .expect("iid bytes"); | ||
| let iid = u64::from_le_bytes(iid_bytes); | ||
|
|
||
| (keypath_str, iid) | ||
| } | ||
|
|
||
| fn main() { | ||
| let dbname = "target/tests/test_rtree_raw"; | ||
| let _ = Index::drop(dbname); | ||
|
|
||
| let mut index = Index::open(dbname, Some(OpenOptions::Create)).unwrap(); | ||
| let mut batch = Batch::new(); | ||
|
|
||
| // Add test documents | ||
| println!("Adding documents..."); | ||
| index.add(r#"{"_id": "point1", "geometry": {"type": "Point", "coordinates": [10.9, 48.4]}}"#, &mut batch).unwrap(); | ||
| index.add(r#"{"_id": "point2", "geometry": {"type": "Point", "coordinates": [50.0, 50.0]}}"#, &mut batch).unwrap(); | ||
| index.add(r#"{"_id": "point3", "other": {"type": "Point", "coordinates": [10.0, 10.0]}}"#, &mut batch).unwrap(); | ||
| index.flush(batch).unwrap(); | ||
|
|
||
| // Test 1: List all rtree entries | ||
| println!("\n=== All RTree entries ==="); | ||
| let rtree_cf = index.rocks.cf_handle("rtree").unwrap(); | ||
| let iter = index.rocks.iterator_cf(rtree_cf, IteratorMode::Start).unwrap(); | ||
| for (key, _value) in iter { | ||
| let (keypath, iid) = decode_rtree_key(&key); | ||
| println!(" Keypath: '{}', IID: {}", keypath, iid); | ||
| } | ||
|
|
||
| // Test 2: Test RTree iterator with query | ||
| println!("\n=== Testing RTree spatial query ==="); | ||
| let snapshot = index.rocks.snapshot(); | ||
|
|
||
| // Build a query bbox that should match point1 | ||
| let query_bbox = vec![ | ||
| 0.0f64.to_le_bytes().to_vec(), // west | ||
| 0.0f64.to_le_bytes().to_vec(), // south | ||
| 20.0f64.to_le_bytes().to_vec(), // east | ||
| 50.0f64.to_le_bytes().to_vec(), // north | ||
| ].concat(); | ||
|
|
||
| println!("Query bbox: [0, 0, 20, 50] (should match point1)"); | ||
|
|
||
| // Create the full query key | ||
| let keypath = ".geometry"; | ||
| let mut query = Vec::new(); | ||
| query.push(keypath.len() as u8); | ||
| query.extend_from_slice(keypath.as_bytes()); | ||
| query.extend_from_slice(&0u64.to_le_bytes()); // min IID | ||
| query.extend_from_slice(&u64::MAX.to_le_bytes()); // max IID | ||
| query.extend_from_slice(&query_bbox); | ||
|
|
||
| println!("Query key length: {}", query.len()); | ||
|
|
||
| let rtree_iter = snapshot.rtree_iterator(&query); | ||
| let mut count = 0; | ||
| for (key, _value) in rtree_iter { | ||
| count += 1; | ||
| let (keypath, iid) = decode_rtree_key(&key); | ||
| println!(" Result {}: Keypath: '{}', IID: {}", count, keypath, iid); | ||
| } | ||
|
|
||
| if count == 0 { | ||
| println!(" No results returned by RTree iterator!"); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't compile for me with those settings. I'm on Linux (Debian testing). So maybe those shouldn't be checked in?