added a fast mass-deletion method

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7933 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent a70dbce41c
commit 28f5b79deb

@ -25,8 +25,10 @@
package net.yacy.kelondro.index;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TreeMap;
@ -234,6 +236,21 @@ public class RowSet extends RowCollection implements Index, Iterable<Row.Entry>
}
}
public final synchronized void delete(final List<byte[]> keys) {
final int[] indexes = new int[keys.size()];
for (int i = 0; i < keys.size(); i++) {
indexes[i] = find(keys.get(i), 0);
}
// we will delete the entries in backward order
// That means it is necessary that the order below the indexes is stable
// therefore we can delete without keeping the order (since it still is stable below the deleted index)
Arrays.sort(indexes);
for (int i = indexes.length - 1; i >= 0; i--) {
if (indexes[i] < 0) break;
super.removeRow(indexes[i], false);
}
}
public final synchronized Row.Entry remove(final byte[] a) {
Row.Entry entry = null;
int index;

Loading…
Cancel
Save