A reader wrapper for DB that also allows us to serialize it.
More...
#include <db.h>
|
| DBReader (const string &db_type, const string &source, const int32_t num_shards=1, const int32_t shard_id=0) |
|
| DBReader (const DBReaderProto &proto) |
|
| DBReader (std::unique_ptr< DB > db) |
|
void | Open (const string &db_type, const string &source, const int32_t num_shards=1, const int32_t shard_id=0) |
|
void | Open (unique_ptr< DB > &&db, const int32_t num_shards=1, const int32_t shard_id=0) |
|
void | Read (string *key, string *value) const |
| Read a set of key and value from the db and move to next. More...
|
|
void | SeekToFirst () const |
| Seeks to the first key. More...
|
|
Cursor * | cursor () const |
| Returns the underlying cursor of the db reader. More...
|
|
A reader wrapper for DB that also allows us to serialize it.
Definition at line 144 of file db.h.
Cursor* caffe2::db::DBReader::cursor |
( |
| ) |
const |
|
inline |
Returns the underlying cursor of the db reader.
Note that 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.
Definition at line 260 of file db.h.
void caffe2::db::DBReader::Read |
( |
string * |
key, |
|
|
string * |
value |
|
) |
| const |
|
inline |
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.
Definition at line 228 of file db.h.
void caffe2::db::DBReader::SeekToFirst |
( |
| ) |
const |
|
inline |
Seeks to the first key.
Thread safe.
Definition at line 247 of file db.h.
The documentation for this class was generated from the following file: