Expand description
§BRK Query
A crate that searches for datasets from either brk_indexer
or brk_computer
according to given parameters.
It’s possible to search for one or multiple dataset if they have the same index and specify range with both the from
and to
being optional and supporting negative values.
The output will depend on the format choson which can be Markdown, Json, CSV or TSV and might vary if there is a one or mutiple datasets, and if one dataset one or multiple values.
In the future, it will support more features similar to a real query engine like in a Postgres databases and presets to fetch data grouped by address, transaction or blockhash/height.
§Example
use std::path::Path;
use brk_computer::Computer;
use brk_indexer::Indexer;
use brk_query::{Index, Query};
use brk_vec::{Computation, Format};
pub fn main() -> color_eyre::Result<()> {
color_eyre::install()?;
let outputs_dir = Path::new("../../_outputs");
let format = Format::Compressed;
let mut indexer = Indexer::new(outputs_dir, format, true)?;
indexer.import_vecs()?;
let mut computer = Computer::new(outputs_dir, None, format);
computer.import_vecs(&indexer, Computation::Lazy)?;
let query = Query::build(&indexer, &computer);
dbg!(query.search_and_format(Index::Height, &["date"], Some(-1), None, None)?);
dbg!(query.search_and_format(Index::Height, &["date"], Some(-10), None, None)?);
dbg!(query.search_and_format(Index::Height, &["date", "timestamp"], Some(-10), None, None)?);
Ok(())
}