Skip to content

Instantly share code, notes, and snippets.

@vertexclique
Created December 20, 2020 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vertexclique/5f23d3cf7eb0130936fa412096b6d591 to your computer and use it in GitHub Desktop.
Save vertexclique/5f23d3cf7eb0130936fa412096b6d591 to your computer and use it in GitHub Desktop.
Simple zone map usage
use lever::index::zonemap::ZoneMap;
fn main() {
let customers: Vec<i32> = vec![
vec![1, 0, -1, -2].repeat(500),
vec![1, 2, 3, 4].repeat(250)
].concat();
let ingestion_data = vec![
("customers", customers.as_slice()),
];
let zm = ZoneMap::from(ingestion_data);
let (l, r) = zm.scan_range("customers", 4, 4, &*customers);
customers[l..=r].iter().filter(|x| **x >= 4).sum::<i32>()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment