Created
December 7, 2015 05:13
-
-
Save qiaohaijun/9611dea4d29471662a16 to your computer and use it in GitHub Desktop.
检查caffe做的leveldb格式的数据的正确性
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <iostream> | |
#include "leveldb/db.h" | |
#include "gflags/gflags.h" | |
#include "time.h" | |
DEFINE_string(leveldbname, "", "leveldb name"); | |
int main(int argc, char** argv) { | |
::google::ParseCommandLineFlags(&argc, &argv, true); | |
leveldb::DB* db; | |
leveldb::Options options; | |
options.create_if_missing = false; | |
leveldb::Status status = leveldb::DB::Open(options, FLAGS_leveldbname, &db); | |
if(!status.ok()) { | |
std::cerr << status.ToString() << std::endl; | |
} else { | |
std::cout << status.ToString() << std::endl; | |
} | |
assert(status.ok()); | |
leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions()); | |
int i=0; | |
for (it->SeekToFirst(); it->Valid(); it->Next()) { | |
//std::cout << it->key().ToString() << std::endl; | |
++i; | |
if(i>=10000) { | |
break; | |
} | |
} | |
assert(it->status().ok()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment