:command:`list-crc [prefix]`
Print CRC of all KV pairs stored with the URL encoded prefix.
+:command:`dump [prefix]`
+ Print key and value of all KV pairs stored with the URL encoded prefix.
+
:command:`exists <prefix> [key]`
Check if there is any KV pair stored with the URL encoded prefix. If key
is also specified, check for the key with the prefix instead.
uint32_t traverse(const string &prefix,
const bool do_crc,
+ const bool do_value_dump,
ostream *out) {
KeyValueDB::WholeSpaceIterator iter = db->get_wholespace_iterator();
}
if (out)
*out << std::endl;
+ if (out && do_value_dump) {
+ bufferptr bp = iter->value_as_ptr();
+ bufferlist value;
+ value.append(bp);
+ ostringstream os;
+ value.hexdump(os);
+ std::cout << os.str() << std::endl;
+ }
iter->next();
}
return crc;
}
- void list(const string &prefix, const bool do_crc) {
- traverse(prefix, do_crc, &std::cout);
+ void list(const string &prefix, const bool do_crc, const bool do_value_dump) {
+ traverse(prefix, do_crc, do_value_dump, &std::cout);
}
bool exists(const string &prefix) {
<< "Commands:\n"
<< " list [prefix]\n"
<< " list-crc [prefix]\n"
+ << " dump [prefix]\n"
<< " exists <prefix> [key]\n"
<< " get <prefix> <key> [out <file>]\n"
<< " crc <prefix> <key>\n"
prefix = url_unescape(argv[4]);
bool do_crc = (cmd == "list-crc");
+ st.list(prefix, do_crc, false);
- st.list(prefix, do_crc);
+ } else if (cmd == "dump") {
+ string prefix;
+ if (argc > 4)
+ prefix = url_unescape(argv[4]);
+ st.list(prefix, false, true);
} else if (cmd == "exists") {
string key;
return 1;
}
std::ofstream fs(argv[4]);
- uint32_t crc = st.traverse(string(), true, &fs);
+ uint32_t crc = st.traverse(string(), true, false, &fs);
std::cout << "store at '" << argv[4] << "' crc " << crc << std::endl;
} else if (cmd == "compact") {