Commit 614b8d34 authored by Rob Latham's avatar Rob Latham
Browse files

honor 'max_keys'

we were previously just returning all keys
parent ecc461f1
......@@ -220,7 +220,10 @@ std::vector<ds_bulk_t> BerkeleyDBDataStore::BerkeleyDBDataStore::list(const ds_b
Dbc * cursorp;
Dbt key, data;
_dbm->cursor(NULL, &cursorp, 0);
while (cursorp->get(&key, &data, DB_NEXT) == 0) {
for (size_t i=0; i< count; i++) {
int ret = cursorp->get(&key, &data, DB_NEXT);
if (ret !=0 ) break;
ds_bulk_t k(key.get_size() );
memcpy(k.data(), key.get_data(), key.get_size() );
/* I hope this is a deep copy! */
......
......@@ -132,10 +132,12 @@ std::vector<ds_bulk_t> LevelDBDataStore::LevelDBDataStore::list(const ds_bulk_t
std::vector<ds_bulk_t> keys;
leveldb::Iterator *it = _dbm->NewIterator(leveldb::ReadOptions());
size_t i=0;
for (it->SeekToFirst(); it->Valid(); it->Next() ) {
ds_bulk_t k(it->key().size());
memcpy(k.data(), it->key().data(), it->key().size() );
keys.push_back(k);
if (i++ > count) break;
}
delete it;
return keys;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment