pub struct TsDb {
pub data: HashMap<String, Trace>,
/* private fields */
}Expand description
A time series database which can be used as a library. Note that this struct is not usable in multiple threads. To make it accessible from multiple threads, use the TsDbHandle wrapper.
Fields§
§data: HashMap<String, Trace>Implementations§
Source§impl TsDb
Database for time series.
impl TsDb
Database for time series.
pub fn into_handle(self) -> TsDbHandle
Sourcepub fn add_values(&mut self, name: &str, samples: Vec<Observation<Sample>>)
pub fn add_values(&mut self, name: &str, samples: Vec<Observation<Sample>>)
Add a batch of values
Sourcepub fn new_trace(&mut self, name: &str)
pub fn new_trace(&mut self, name: &str)
Examples found in repository?
examples/perf.rs (line 22)
15fn insertions(db: &mut TsDb) {
16 let num_insertions = 1_000_000;
17 println!(
18 "Created database, now inserting {} data points into a signal.",
19 num_insertions
20 );
21
22 db.new_trace("fu");
23 let t1 = Instant::now();
24 for i in 0..num_insertions {
25 let ts = TimeStamp::new(i as f64);
26 let sample = Sample::new(i as f64);
27 let observation = Observation::new(ts, sample);
28 db.add_value("fu", observation);
29 }
30 let t2 = Instant::now();
31 let time_delta = t2 - t1;
32 let time_delta = time_delta.as_secs_f64();
33
34 println!(
35 "Inserted {} points in {} seconds.",
36 num_insertions, time_delta
37 );
38 let rate = num_insertions as f64 / time_delta;
39 println!("That means {} mega-points per second.", rate / 1.0e6);
40}Sourcepub fn add_value(&mut self, name: &str, observation: Observation<Sample>)
pub fn add_value(&mut self, name: &str, observation: Observation<Sample>)
Examples found in repository?
examples/perf.rs (line 28)
15fn insertions(db: &mut TsDb) {
16 let num_insertions = 1_000_000;
17 println!(
18 "Created database, now inserting {} data points into a signal.",
19 num_insertions
20 );
21
22 db.new_trace("fu");
23 let t1 = Instant::now();
24 for i in 0..num_insertions {
25 let ts = TimeStamp::new(i as f64);
26 let sample = Sample::new(i as f64);
27 let observation = Observation::new(ts, sample);
28 db.add_value("fu", observation);
29 }
30 let t2 = Instant::now();
31 let time_delta = t2 - t1;
32 let time_delta = time_delta.as_secs_f64();
33
34 println!(
35 "Inserted {} points in {} seconds.",
36 num_insertions, time_delta
37 );
38 let rate = num_insertions as f64 / time_delta;
39 println!("That means {} mega-points per second.", rate / 1.0e6);
40}Sourcepub fn query(&self, name: &str, query: Query) -> QueryResult
pub fn query(&self, name: &str, query: Query) -> QueryResult
Query the given trace for data.
Examples found in repository?
examples/perf.rs (line 50)
42fn do_query(db: &TsDb) {
43 // Query the data
44 println!("Querying the database!");
45
46 let query = Query::create()
47 .start(TimeStamp::new(0.0))
48 .end(TimeStamp::new(1000.0))
49 .build();
50 let result = db.query("fu", query);
51
52 println!("Got result: {:?}", result.query);
53 println!("Num result: {:?}", result.len());
54 // let raw_samples = result.into_vec();
55 // println!("Raw samples: {}", raw_samples.len());
56}Sourcepub fn summary(&self, name: &str) -> Option<Aggregation<Sample, SampleMetrics>>
pub fn summary(&self, name: &str) -> Option<Aggregation<Sample, SampleMetrics>>
Get a summary for the given trace.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TsDb
impl !RefUnwindSafe for TsDb
impl Send for TsDb
impl !Sync for TsDb
impl Unpin for TsDb
impl UnwindSafe for TsDb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more