pub struct DBReader { /* private fields */ }
Expand description
| A reader wrapper for DB that also allows | us to serialize it. |
Implementations§
source§impl DBReader
impl DBReader
pub fn new( db_type: &String, source: &String, num_shards: i32, shard_id: i32 ) -> Self
pub fn open( &mut self, db_type: &String, source: &String, num_shards: Option<i32>, shard_id: Option<i32> )
pub fn open_with_db( &mut self, db: Box<dyn DB>, num_shards: Option<i32>, shard_id: Option<i32> )
sourcepub fn read(&self, key: *mut String, value: *mut String)
pub fn read(&self, key: *mut String, value: *mut String)
| Read a set of key and value from the db | and move to next. Thread safe. | | The string objects key and value must | be created by the caller and explicitly | passed in to this function. This saves | one additional object copy. | | If the cursor reaches its end, the reader | will go back to the head of the db. This | function can be used to enable multiple | input ops to read the same db. | | Note(jiayq): we loosen the definition | of a const function here a little bit: | the state of the cursor is actually changed. | However, this allows us to pass in a DBReader | to an Operator without the need of a duplicated | output blob. |
sourcepub fn seek_to_first(&self)
pub fn seek_to_first(&self)
| ———– | @brief | | Seeks to the first key. Thread safe. |
sourcepub fn cursor(&self) -> *mut dyn Cursor
pub fn cursor(&self) -> *mut dyn Cursor
| Returns the underlying cursor of the | db reader. | | ———– | @note | | if you directly use the cursor, the read | will not be thread safe, because there | is no mechanism to stop multiple threads | from accessing the same cursor. You | should consider using Read() explicitly. |
pub fn initialize_cursor(&mut self, num_shards: i32, shard_id: i32)
pub fn move_to_beginning(&self)
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for DBReader
impl !Send for DBReader
impl !Sync for DBReader
impl Unpin for DBReader
impl !UnwindSafe for DBReader
Blanket Implementations§
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.