Expand description

eyros

eyros (εύρος) is a multi-dimensional interval database.

eyros logo

The database is based on bkd and interval trees.

eyros operates on scalar (x) or interval (min,max) coordinates for each dimension. There are 2 operations: batched write (for inserting and deleting) and query by bounding box. All features that intersect the bounding box are returned in the query results.

example

This example inserts 5000 records, writes the data to disk, then queries and prints records inside the bounding box ((-120.0,20.0,10_000),(-100.0,35.0,20_000)).

The bounding box is of the form ((min_x,min_y,min_z),(max_x,max_y,max_z)).

use eyros::{Row,Coord};
use rand::random;
use async_std::prelude::*;

type P = (Coord<f32>,Coord<f32>,Coord<u16>);
type V = u64;
type E = Box<dyn std::error::Error+Sync+Send>;

#[async_std::main]
async fn main() -> Result<(),E> {
  let mut db = eyros::open_from_path3(
    &std::path::PathBuf::from("/tmp/eyros.db")
  ).await?;
  let batch: Vec<Row<P,V>> = (0..5_000).map(|i| {
    let xmin = (random::<f32>()*2.0-1.0)*180.0;
    let xmax = xmin + random::<f32>().powf(16.0)*(180.0-xmin);
    let ymin = (random::<f32>()*2.0-1.0)*90.0;
    let ymax = ymin + random::<f32>().powf(16.0)*(90.0-ymin);
    let z = random::<u16>();
    let point = (
      Coord::Interval(xmin,xmax),
      Coord::Interval(ymin,ymax),
      Coord::Scalar(z)
    );
    Row::Insert(point, i)
  }).collect();
  db.batch(&batch).await?;
  db.sync().await?;

  let bbox = ((-120.0,20.0,10_000),(-100.0,35.0,20_000));
  let mut stream = db.query(&bbox).await?;
  while let Some(result) = stream.next().await {
    println!("{:?}", result?);
  }
  Ok(())
}

The output from this program is of the form (coords, value):

$ cargo run --example polygons -q
((Interval(-100.94689, -100.94689), Interval(20.108843, 20.109331), Scalar(16522)), 4580)
((Interval(-111.62768, -110.40406), Interval(-7.519809, 86.154755), Scalar(12384)), 2603)
((Interval(-114.46505, -31.340988), Interval(-57.901405, 20.235504), Scalar(11360)), 1245)
((Interval(-159.97859, 121.304184), Interval(32.35743, 32.35743), Scalar(10164)), 3294)
((Interval(-150.29192, -35.475517), Interval(-39.97779, 29.163605), Scalar(15333)), 2336)
((Interval(-162.45879, -92.46166), Interval(31.187943, 31.187975), Scalar(12221)), 2826)
((Interval(-160.53441, -88.66396), Interval(10.031784, 21.852394), Scalar(11711)), 2366)
((Interval(-132.39021, -98.14838), Interval(-0.06010294, 53.88453), Scalar(10685)), 3441)

license

bsd

Re-exports

pub use tree::Tree2;
pub use tree::Tree3;
pub use tree::Tree4;

Modules

Structs

Top-level database API.

Builder to configure and instantiate an eyros database.

Struct for reading database properties.

Enums

The Coord enum represents the value for a dimension instead of a Point tuple. Use Coord::Scalar(x) to represent a single value and Coord::Interval(min,max) to represent a range of values from min to max, inclusive.

Enum container for batch operations on the database.

Traits

Intersection tests used by Point and Point::Bounds.

The Point trait represents the geometric coordinates of a feature. Each Point defines a Bounds that represents how to express bounding boxes. Points and Bounds are converted between each other with the to_bounds() and from_bounds() methods.

All coordinate values must implement this collection of traits.

Return random access storage adaptors for files by a string name

Define the payload stored at a given geometry point. Value types must define an Id that uniquely identify them so they can be deleted.

Functions

Open a database from a path in N dimensions. This function helps in selecting the appropriate Tree{N} type.

Open a database from a path in N dimensions. This function helps in selecting the appropriate Tree{N} type.

Open a database from a path in N dimensions. This function helps in selecting the appropriate Tree{N} type.

Type Definitions