[−][src]Struct eyros::DB
Top-level database API.
Fields
trees: Vec<Rc<RefCell<Tree<S, P, V>>>>
staging: Staging<S, P, V>
data_store: Rc<RefCell<DataStore<S, P, V>>>
fields: SetupFields
bincode: Rc<Config>
Methods
impl<S, U, P, V> DB<S, U, P, V> where
S: RandomAccess<Error = Error>,
U: Fn(&str) -> Result<S, Error>,
P: Point,
V: Value,
[src]
S: RandomAccess<Error = Error>,
U: Fn(&str) -> Result<S, Error>,
P: Point,
V: Value,
pub fn open(open_store: U) -> Result<Self, Error>
[src]
Create a new database instance from open_store
, a function that receives
a string path as an argument and returns a Result with a RandomAccess
store. The database will be created with the default configuration.
For example:
use eyros::DB; use random_access_disk::RandomAccessDisk; use std::path::PathBuf; use failure::Error; type P = ((f32,f32),(f32,f32)); type V = u32; fn main () -> Result<(),Error> { let mut db: DB<_,_,P,V> = DB::open(storage)?; // ... Ok(()) } fn storage (name: &str) -> Result<RandomAccessDisk,Error> { let mut p = PathBuf::from("/tmp/eyros-db/"); p.push(name); Ok(RandomAccessDisk::builder(p).auto_sync(false).build()?) }
pub fn open_from_setup(setup: Setup<S, U>) -> Result<Self, Error>
[src]
Create a new database instance from setup
, a configuration builder.
let mut db: DB<_,_,P,V> = DB::open_from_setup( Setup::new(storage) .branch_factor(5) .max_data_size(3_000) .base_size(1_000) )?;
You can also use Setup
's .build()?
method to get a DB
instance:
use eyros::{DB,Setup}; let mut db: DB<_,_,P,V> = Setup::new(storage) .branch_factor(5) .max_data_size(3_000) .base_size(1_000) .build()?;
Always open a database with the same settings. Things will break if you change . There is no runtime check yet to ensure a database is opened with the same configuration that it was created with.
pub fn batch(&mut self, rows: &[Row<P, V>]) -> Result<(), Error>
[src]
Write a collection of updates to the database. Each update can be a
Row::Insert(point,value)
or a Row::Delete(location)
.
pub fn query<'b>(
&mut self,
bbox: &'b P::Bounds
) -> Result<QueryIterator<'b, S, P, V>, Error>
[src]
&mut self,
bbox: &'b P::Bounds
) -> Result<QueryIterator<'b, S, P, V>, Error>
Query the database for all records that intersect the bounding box.
The bounding box is a 2-tuple of n-tuples (for an n-dimensional point
type) representing the (min,max)
coordinates. In 2d with a conventional
x-y cartesian grid, the first bbox point would be the "bottom-left" (or
west-south) and the second point would be the "top-right" (or east-north).
You will receive an iterator of Result<(P,V,Location),Error>
results
that you can step through like this:
let bbox = ((-0.5,-0.8),(0.3,-0.5)); for result in db.query(&bbox)? { let (point,value,location) = result?; // ... }
If you want to delete records, you will need to use the Location
records
you get from a query. However, these locations are only valid until the
next .batch()
.
Auto Trait Implementations
impl<S, U, P, V> !RefUnwindSafe for DB<S, U, P, V>
impl<S, U, P, V> !Send for DB<S, U, P, V>
impl<S, U, P, V> !Sync for DB<S, U, P, V>
impl<S, U, P, V> Unpin for DB<S, U, P, V> where
S: Unpin,
U: Unpin,
S: Unpin,
U: Unpin,
impl<S, U, P, V> !UnwindSafe for DB<S, U, P, V>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,