You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LevelDB does not support delete range; a delete is like an insert, you need to create a delete entry for each existing key.
You should do something like this to delete a key range:
final DB db = ...;
final byte[] firstKeyOrPreffix = ...;
final Predicate<byte[]> inRange = ...;
try(final DBIterator iterator = db.iterator(); final WriteBatch wb = db.createWriteBatch()) {
iterator.seek(firstKeyOrPreffix);
while (iterator.hasNext()) {
final Map.Entry<byte[], byte[]> next = iterator.next();
if (!inRange.test(next.getKey())) {
break;
}
wb.delete(next.getKey());
}
db.write(wb);
}
How to delete a range of keys
The text was updated successfully, but these errors were encountered: