Skip to content
Snippets Groups Projects
Commit f261d44e authored by Jason Volk's avatar Jason Volk
Browse files

add method to iterate opened database columns


Signed-off-by: default avatarJason Volk <jason@zemos.net>
parent 849cfdcd
No related branches found
No related tags found
2 merge requests!544Database properties query,!545Admin command tracing capture
...@@ -2,7 +2,12 @@ ...@@ -2,7 +2,12 @@
use conduit::{Result, Server}; use conduit::{Result, Server};
use crate::{cork::Cork, maps, maps::Maps, Engine, Map}; use crate::{
cork::Cork,
maps,
maps::{Maps, MapsKey, MapsVal},
Engine, Map,
};
pub struct Database { pub struct Database {
pub db: Arc<Engine>, pub db: Arc<Engine>,
...@@ -30,6 +35,9 @@ pub fn cork_and_flush(&self) -> Cork { Cork::new(&self.db, true, false) } ...@@ -30,6 +35,9 @@ pub fn cork_and_flush(&self) -> Cork { Cork::new(&self.db, true, false) }
#[inline] #[inline]
#[must_use] #[must_use]
pub fn cork_and_sync(&self) -> Cork { Cork::new(&self.db, true, true) } pub fn cork_and_sync(&self) -> Cork { Cork::new(&self.db, true, true) }
#[inline]
pub fn iter_maps(&self) -> impl Iterator<Item = (&MapsKey, &MapsVal)> + '_ { self.map.iter() }
} }
impl Index<&str> for Database { impl Index<&str> for Database {
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
use crate::{Engine, Map}; use crate::{Engine, Map};
pub type Maps = BTreeMap<String, Arc<Map>>; pub type Maps = BTreeMap<MapsKey, MapsVal>;
pub(crate) type MapsVal = Arc<Map>;
pub(crate) type MapsKey = String;
pub(crate) fn open(db: &Arc<Engine>) -> Result<Maps> { open_list(db, MAPS) } pub(crate) fn open(db: &Arc<Engine>) -> Result<Maps> { open_list(db, MAPS) }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment