21 #include "caffe2/core/db.h" 22 #include "caffe2/core/init.h" 23 #include "caffe2/core/logging.h" 24 #include "caffe2/utils/zmq_helper.h" 26 C10_DEFINE_string(server,
"tcp://*:5555",
"The server address.");
27 C10_DEFINE_string(input_db,
"",
"The input db.");
28 C10_DEFINE_string(input_db_type,
"",
"The input db type.");
34 int main(
int argc,
char** argv) {
37 LOG(INFO) <<
"Opening DB...";
38 auto in_db = caffe2::db::CreateDB(
39 FLAGS_input_db_type, FLAGS_input_db, caffe2::db::READ);
42 "Cannot load input db " + FLAGS_input_db +
" of expected type " +
44 auto cursor = in_db->NewCursor();
45 LOG(INFO) <<
"DB opened.";
47 LOG(INFO) <<
"Starting ZeroMQ server...";
51 sender.Bind(FLAGS_server);
52 LOG(INFO) <<
"Server created at " << FLAGS_server;
55 VLOG(1) <<
"Sending " << cursor->key();
56 sender.SendTillSuccess(cursor->key(), ZMQ_SNDMORE);
57 sender.SendTillSuccess(cursor->value(), 0);
59 if (!cursor->Valid()) {
60 cursor->SeekToFirst();
An abstract class for the cursor of the database while reading.
An abstract class for accessing a database of key-value pairs.
bool GlobalInit(int *pargc, char ***pargv)
Initialize the global environment of caffe2.