| 180 | } |
| 181 | |
| 182 | bool RocksDBStorageProvider::enumerate(callback fn) const |
| 183 | { |
| 184 | std::unique_ptr<rocksdb::Iterator> it = std::unique_ptr<rocksdb::Iterator>(m_spdb->NewIterator(ReadOptions(), m_spcolfamily.get())); |
| 185 | size_t count = 0; |
| 186 | for (it->SeekToFirst(); it->Valid(); it->Next()) { |
| 187 | if (FInternalKey(it->key().data(), it->key().size())) |
| 188 | continue; |
| 189 | ++count; |
| 190 | bool fContinue = fn(it->key().data()+HASHSLOT_PREFIX_BYTES, it->key().size()-HASHSLOT_PREFIX_BYTES, it->value().data(), it->value().size()); |
| 191 | if (!fContinue) |
| 192 | break; |
| 193 | } |
| 194 | if (!it->Valid() && count != m_count) |
| 195 | { |
| 196 | if (const_cast<RocksDBStorageProvider*>(this)->m_count != count) |
| 197 | printf("WARNING: rocksdb count mismatch"); |
| 198 | const_cast<RocksDBStorageProvider*>(this)->m_count = count; |
| 199 | } |
| 200 | assert(it->status().ok()); // Check for any errors found during the scan |
| 201 | return !it->Valid(); |
| 202 | } |
| 203 | |
| 204 | bool RocksDBStorageProvider::enumerate_hashslot(callback fn, unsigned int hashslot) const |
| 205 | { |