distinct keepOrder strategy, more discrete implementation of enhancement introduced in SVN 4158

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4176 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 9a7b093eed
commit 7d57b80598

@ -140,7 +140,7 @@ public class dbtest {
final STEntry entry = new STEntry(this.getSource()); final STEntry entry = new STEntry(this.getSource());
System.out.println("remove: " + serverLog.arrayList(entry.getKey(), 0, entry.getKey().length)); System.out.println("remove: " + serverLog.arrayList(entry.getKey(), 0, entry.getKey().length));
try { try {
getTable().remove(entry.getKey()); getTable().remove(entry.getKey(), false);
} catch (IOException e) { } catch (IOException e) {
System.err.println(e); System.err.println(e);
e.printStackTrace(); e.printStackTrace();
@ -338,7 +338,7 @@ public class dbtest {
start = System.currentTimeMillis(); start = System.currentTimeMillis();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
key = randomHash(random); key = randomHash(random);
table.remove(key); table.remove(key, false);
} }
remove = System.currentTimeMillis() - start; remove = System.currentTimeMillis() - start;

@ -149,7 +149,7 @@ public class indexContainer extends kelondroRowSet {
} }
public indexRWIEntry remove(String urlHash) { public indexRWIEntry remove(String urlHash) {
kelondroRow.Entry entry = this.remove(urlHash.getBytes()); kelondroRow.Entry entry = remove(urlHash.getBytes(), true);
if (entry == null) return null; if (entry == null) return null;
return new indexRWIEntry(entry); return new indexRWIEntry(entry);
} }
@ -384,7 +384,7 @@ public class indexContainer extends kelondroRowSet {
if ((ie0 != null) && (ie1 != null)) { if ((ie0 != null) && (ie1 != null)) {
assert (ie0.urlHash().length() == keylength) : "ie0.urlHash() = " + ie0.urlHash(); assert (ie0.urlHash().length() == keylength) : "ie0.urlHash() = " + ie0.urlHash();
assert (ie1.urlHash().length() == keylength) : "ie1.urlHash() = " + ie1.urlHash(); assert (ie1.urlHash().length() == keylength) : "ie1.urlHash() = " + ie1.urlHash();
if (iterate_pivot) se.remove(); pivot.remove(ie0.urlHash().getBytes()); if (iterate_pivot) se.remove(); pivot.remove(ie0.urlHash().getBytes(), true);
} }
} }
return pivot; return pivot;

@ -145,9 +145,9 @@ public class kelondroBytesIntMap {
//System.out.println("finished initialization phase at size = " + index0.size() + " in removei"); //System.out.println("finished initialization phase at size = " + index0.size() + " in removei");
} }
// if the new entry is within the initialization part, just overwrite it // if the new entry is within the initialization part, just overwrite it
kelondroRow.Entry indexentry = index0.remove(key); kelondroRow.Entry indexentry = index0.remove(key, true);
if (indexentry != null) { if (indexentry != null) {
assert index0.remove(key) == null; // check if remove worked assert index0.remove(key, true) == null; // check if remove worked
//assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis(); //assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis();
return (int) indexentry.getColLong(1); return (int) indexentry.getColLong(1);
} }
@ -156,9 +156,9 @@ public class kelondroBytesIntMap {
// at this point index1 cannot be null // at this point index1 cannot be null
assert (index1 != null); assert (index1 != null);
if (index1.size() == 0) return -1; if (index1.size() == 0) return -1;
kelondroRow.Entry indexentry = index1.remove(key); kelondroRow.Entry indexentry = index1.remove(key, true);
if (indexentry == null) return -1; if (indexentry == null) return -1;
assert index1.remove(key) == null; // check if remove worked assert index1.remove(key, true) == null; // check if remove worked
//assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis(); //assert consistencyAnalysis0() : "consistency problem: " + consistencyAnalysis();
return (int) indexentry.getColLong(1); return (int) indexentry.getColLong(1);
} }

@ -190,7 +190,7 @@ public class kelondroCache implements kelondroIndex {
} }
i = delete.rows(); i = delete.rows();
while (i.hasNext()) { while (i.hasNext()) {
writeBufferUnique.remove(((kelondroRow.Entry) i.next()).getColBytes(0)); writeBufferUnique.remove(((kelondroRow.Entry) i.next()).getColBytes(0), true);
} }
delete = null; delete = null;
writeBufferUnique.trim(true); writeBufferUnique.trim(true);
@ -223,7 +223,7 @@ public class kelondroCache implements kelondroIndex {
this.cacheFlush++; this.cacheFlush++;
} }
i = delete.rows(); i = delete.rows();
while (i.hasNext()) writeBufferDoubles.remove(((kelondroRow.Entry) i.next()).getColBytes(0)); while (i.hasNext()) writeBufferDoubles.remove(((kelondroRow.Entry) i.next()).getColBytes(0), true);
delete = null; delete = null;
writeBufferDoubles.trim(true); writeBufferDoubles.trim(true);
} }
@ -369,7 +369,7 @@ public class kelondroCache implements kelondroIndex {
// remove entry from miss- and hit-cache // remove entry from miss- and hit-cache
if (readMissCache != null) { if (readMissCache != null) {
if (readMissCache.remove(key) != null) { if (readMissCache.remove(key, true) != null) {
this.hasnotHit++; this.hasnotHit++;
// the entry does not exist before // the entry does not exist before
if (writeBufferUnique != null) { if (writeBufferUnique != null) {
@ -396,7 +396,7 @@ public class kelondroCache implements kelondroIndex {
// since we know that the entry was in the read cache, it cannot be in any write cache // since we know that the entry was in the read cache, it cannot be in any write cache
if (writeBufferDoubles != null) { if (writeBufferDoubles != null) {
// because the entry exists, it must be written in the doubles buffer // because the entry exists, it must be written in the doubles buffer
readHitCache.remove(key); readHitCache.remove(key, true);
this.cacheDelete++; this.cacheDelete++;
writeBufferDoubles.put(row); writeBufferDoubles.put(row);
return entry; return entry;
@ -467,7 +467,7 @@ public class kelondroCache implements kelondroIndex {
// remove entry from miss- and hit-cache // remove entry from miss- and hit-cache
if (readMissCache != null) { if (readMissCache != null) {
this.readMissCache.remove(key); this.readMissCache.remove(key, true);
this.hasnotDelete++; this.hasnotDelete++;
// the entry does not exist before // the entry does not exist before
if (writeBufferUnique != null) { if (writeBufferUnique != null) {
@ -519,7 +519,7 @@ public class kelondroCache implements kelondroIndex {
// remove entry from miss- and hit-cache // remove entry from miss- and hit-cache
if (readMissCache != null) { if (readMissCache != null) {
this.readMissCache.remove(key); this.readMissCache.remove(key, true);
this.hasnotDelete++; this.hasnotDelete++;
} }
@ -536,8 +536,7 @@ public class kelondroCache implements kelondroIndex {
while (i.hasNext()) addUnique((Entry) i.next()); while (i.hasNext()) addUnique((Entry) i.next());
} }
public synchronized Entry remove(byte[] key) throws IOException { public synchronized Entry remove(byte[] key, boolean keepOrder) throws IOException {
checkMissSpace(); checkMissSpace();
// add entry to miss-cache // add entry to miss-cache
@ -554,7 +553,7 @@ public class kelondroCache implements kelondroIndex {
// remove entry from hit-cache // remove entry from hit-cache
if (readHitCache != null) { if (readHitCache != null) {
Entry entry = readHitCache.remove(key); Entry entry = readHitCache.remove(key, true);
if (entry == null) { if (entry == null) {
this.readMiss++; this.readMiss++;
} else { } else {
@ -565,18 +564,18 @@ public class kelondroCache implements kelondroIndex {
// if the key already exists in one buffer, remove that buffer // if the key already exists in one buffer, remove that buffer
if (writeBufferUnique != null) { if (writeBufferUnique != null) {
Entry entry = writeBufferUnique.remove(key); Entry entry = writeBufferUnique.remove(key, true);
if (entry != null) return entry; if (entry != null) return entry;
} }
if (writeBufferDoubles != null) { if (writeBufferDoubles != null) {
Entry entry = writeBufferDoubles.remove(key); Entry entry = writeBufferDoubles.remove(key, true);
if (entry != null) { if (entry != null) {
index.remove(key); index.remove(key, false);
return entry; return entry;
} }
} }
return index.remove(key); return index.remove(key, false);
} }
public synchronized Entry removeOne() throws IOException { public synchronized Entry removeOne() throws IOException {
@ -599,7 +598,7 @@ public class kelondroCache implements kelondroIndex {
kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key)); kelondroRow.Entry dummy = readMissCache.put(readMissCache.row().newEntry(key));
if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++; if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;
} }
index.remove(key); index.remove(key, false);
return entry; return entry;
} }
@ -611,7 +610,7 @@ public class kelondroCache implements kelondroIndex {
if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++; if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;
} }
if (readHitCache != null) { if (readHitCache != null) {
kelondroRow.Entry dummy = readHitCache.remove(key); kelondroRow.Entry dummy = readHitCache.remove(key, true);
if (dummy != null) this.cacheDelete++; if (dummy != null) this.cacheDelete++;
} }
return entry; return entry;

@ -835,8 +835,8 @@ public class kelondroCollectionIndex {
Object k; Object k;
while (i.hasNext()) { while (i.hasNext()) {
k = i.next(); k = i.next();
if ((k instanceof byte[]) && (oldcollection.remove((byte[]) k) != null)) removed++; if ((k instanceof byte[]) && (oldcollection.remove((byte[]) k, false) != null)) removed++;
if ((k instanceof String) && (oldcollection.remove(((String) k).getBytes()) != null)) removed++; if ((k instanceof String) && (oldcollection.remove(((String) k).getBytes(), false) != null)) removed++;
} }
oldcollection.sort(); oldcollection.sort();
oldcollection.trim(false); oldcollection.trim(false);
@ -893,7 +893,7 @@ public class kelondroCollectionIndex {
public synchronized kelondroRowSet delete(byte[] key) throws IOException { public synchronized kelondroRowSet delete(byte[] key) throws IOException {
// find an entry, if one exists // find an entry, if one exists
kelondroRow.Entry indexrow = index.remove(key); kelondroRow.Entry indexrow = index.remove(key, false);
if (indexrow == null) return null; if (indexrow == null) return null;
kelondroRowSet removedCollection = getdelete(indexrow, true); kelondroRowSet removedCollection = getdelete(indexrow, true);
assert (removedCollection != null); assert (removedCollection != null);
@ -925,7 +925,7 @@ public class kelondroCollectionIndex {
byte[] arraykey = arrayrow.getColBytes(0); byte[] arraykey = arrayrow.getColBytes(0);
if (!(index.row().objectOrder.wellformed(arraykey))) { if (!(index.row().objectOrder.wellformed(arraykey))) {
// cleanup for a bad bug that corrupted the database // cleanup for a bad bug that corrupted the database
index.remove(indexkey); // the RowCollection must be considered lost index.remove(indexkey, false); // the RowCollection must be considered lost
array.remove(rownumber); // loose the RowCollection (we don't know how much is lost) array.remove(rownumber); // loose the RowCollection (we don't know how much is lost)
serverLog.logSevere("kelondroCollectionIndex." + array.filename, "lost a RowCollection because of a bad arraykey"); serverLog.logSevere("kelondroCollectionIndex." + array.filename, "lost a RowCollection because of a bad arraykey");
return new kelondroRowSet(this.payloadrow, 0); return new kelondroRowSet(this.payloadrow, 0);
@ -933,7 +933,7 @@ public class kelondroCollectionIndex {
kelondroRowSet collection = new kelondroRowSet(this.payloadrow, arrayrow, 1); // FIXME: this does not yet work with different rowdef in case of several rowdef.objectsize() kelondroRowSet collection = new kelondroRowSet(this.payloadrow, arrayrow, 1); // FIXME: this does not yet work with different rowdef in case of several rowdef.objectsize()
if ((!(index.row().objectOrder.wellformed(indexkey))) || (index.row().objectOrder.compare(arraykey, indexkey) != 0)) { if ((!(index.row().objectOrder.wellformed(indexkey))) || (index.row().objectOrder.compare(arraykey, indexkey) != 0)) {
// check if we got the right row; this row is wrong. Fix it: // check if we got the right row; this row is wrong. Fix it:
index.remove(indexkey); // the wrong row cannot be fixed index.remove(indexkey, true); // the wrong row cannot be fixed
// store the row number in the index; this may be a double-entry, but better than nothing // store the row number in the index; this may be a double-entry, but better than nothing
kelondroRow.Entry indexEntry = index.row().newEntry(); kelondroRow.Entry indexEntry = index.row().newEntry();
indexEntry.setCol(idx_col_key, arrayrow.getColBytes(0)); indexEntry.setCol(idx_col_key, arrayrow.getColBytes(0));

@ -332,7 +332,7 @@ public class kelondroDyn {
int recpos = 0; int recpos = 0;
byte[] k; byte[] k;
while (index.get(k = dynKey(key, recpos)) != null) { while (index.get(k = dynKey(key, recpos)) != null) {
index.remove(k); index.remove(k, true);
buffer.remove(k); buffer.remove(k);
recpos++; recpos++;
} }

@ -260,13 +260,13 @@ public class kelondroFlexSplitTable implements kelondroIndex {
while (i.hasNext()) addUnique((kelondroRow.Entry) i.next(), entryDate); while (i.hasNext()) addUnique((kelondroRow.Entry) i.next(), entryDate);
} }
public synchronized kelondroRow.Entry remove(byte[] key) throws IOException { public synchronized kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException {
Iterator i = tables.values().iterator(); Iterator i = tables.values().iterator();
kelondroIndex table; kelondroIndex table;
kelondroRow.Entry entry; kelondroRow.Entry entry;
while (i.hasNext()) { while (i.hasNext()) {
table = (kelondroIndex) i.next(); table = (kelondroIndex) i.next();
entry = table.remove(key); entry = table.remove(key, keepOrder);
if (entry != null) return entry; if (entry != null) return entry;
} }
return null; return null;

@ -311,7 +311,8 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
} }
public synchronized kelondroRow.Entry remove(byte[] key) throws IOException { public synchronized kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException {
assert keepOrder == false; // the underlying data structure is a file, where the order cannot be maintained. Gaps are filled with new values.
int i = index.removei(key); int i = index.removei(key);
assert (index.geti(key) < 0); // must be deleted assert (index.geti(key) < 0); // must be deleted
if (i < 0) { if (i < 0) {

@ -67,7 +67,7 @@ public interface kelondroIndex {
public void putMultiple(List /* of kelondroRow.Entry*/ rows) throws IOException; // for R/W head path optimization public void putMultiple(List /* of kelondroRow.Entry*/ rows) throws IOException; // for R/W head path optimization
public void addUnique(kelondroRow.Entry row) throws IOException; // no double-check public void addUnique(kelondroRow.Entry row) throws IOException; // no double-check
public void addUniqueMultiple(List /* of kelondroRow.Entry*/ rows) throws IOException; // no double-check public void addUniqueMultiple(List /* of kelondroRow.Entry*/ rows) throws IOException; // no double-check
public kelondroRow.Entry remove(byte[] key) throws IOException; public kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException;
public kelondroRow.Entry removeOne() throws IOException; public kelondroRow.Entry removeOne() throws IOException;
public kelondroCloneableIterator rows(boolean up, byte[] firstKey) throws IOException; public kelondroCloneableIterator rows(boolean up, byte[] firstKey) throws IOException;
public void close(); public void close();

@ -130,7 +130,7 @@ public class kelondroIntBytesMap {
index0.uniq(10000); index0.uniq(10000);
index1 = new kelondroRowSet(rowdef, 0); index1 = new kelondroRowSet(rowdef, 0);
} }
kelondroRow.Entry indexentry = index0.remove(key); kelondroRow.Entry indexentry = index0.remove(key, true);
if (indexentry != null) { if (indexentry != null) {
return indexentry.getColBytes(1); return indexentry.getColBytes(1);
} }
@ -139,7 +139,7 @@ public class kelondroIntBytesMap {
// at this point index1 cannot be null // at this point index1 cannot be null
assert (index1 != null); assert (index1 != null);
if (index1.size() == 0) return null; if (index1.size() == 0) return null;
kelondroRow.Entry indexentry = index1.remove(key); kelondroRow.Entry indexentry = index1.remove(key, true);
if (indexentry == null) return null; if (indexentry == null) return null;
return indexentry.getColBytes(1); return indexentry.getColBytes(1);
} }

@ -156,7 +156,7 @@ public class kelondroMapTable {
if (table != null) {table.remove(key); mTables.put(tablename, table); return;} if (table != null) {table.remove(key); mTables.put(tablename, table); return;}
kelondroIndex Tree = (kelondroIndex) tTables.get(tablename); kelondroIndex Tree = (kelondroIndex) tTables.get(tablename);
if (Tree != null) {Tree.remove(key.getBytes()); tTables.put(tablename, Tree); return;} if (Tree != null) {Tree.remove(key.getBytes(), false); tTables.put(tablename, Tree); return;}
throw new RuntimeException("kelondroTables.delete: table '" + tablename + "' does not exist."); throw new RuntimeException("kelondroTables.delete: table '" + tablename + "' does not exist.");
} }

@ -119,12 +119,12 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
return oldentry; return oldentry;
} }
private synchronized kelondroRow.Entry remove(byte[] a, int start, int length) { private synchronized kelondroRow.Entry remove(byte[] a, int start, int length, boolean keepOrder) {
int index = find(a, start, length); int index = find(a, start, length);
if (index < 0) return null; if (index < 0) return null;
//System.out.println("remove: chunk found at index position (before remove) " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * index, length + 10) + ", searchkey=" + serverLog.arrayList(a, start, length)); //System.out.println("remove: chunk found at index position (before remove) " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * index, length + 10) + ", searchkey=" + serverLog.arrayList(a, start, length));
kelondroRow.Entry entry = super.get(index); kelondroRow.Entry entry = super.get(index);
super.removeRow(index, false); super.removeRow(index, keepOrder);
//System.out.println("remove: chunk found at index position (after remove) " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * index, length) + ", searchkey=" + serverLog.arrayList(a, start, length)); //System.out.println("remove: chunk found at index position (after remove) " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * index, length) + ", searchkey=" + serverLog.arrayList(a, start, length));
int findagainindex = find(a, start, length); int findagainindex = find(a, start, length);
//System.out.println("kelondroRowSet.remove"); //System.out.println("kelondroRowSet.remove");
@ -132,8 +132,8 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
return entry; return entry;
} }
public kelondroRow.Entry remove(byte[] a) { public kelondroRow.Entry remove(byte[] a, boolean keepOrder) {
return remove(a, 0, a.length); return remove(a, 0, a.length, keepOrder);
} }
private int find(byte[] a, int astart, int alength) { private int find(byte[] a, int astart, int alength) {
@ -293,7 +293,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes()); for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes());
for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes()); for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes());
d.sort(); d.sort();
d.remove("fuenf".getBytes(), 0, 5); d.remove("fuenf".getBytes(), 0, 5, false);
Iterator ii = d.rows(); Iterator ii = d.rows();
String s; String s;
System.out.print("INPUT-ITERATOR: "); System.out.print("INPUT-ITERATOR: ");
@ -391,11 +391,11 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
key = randomHash(random); key = randomHash(random);
c.put(c.rowdef.newEntry(new byte[][]{key, key})); c.put(c.rowdef.newEntry(new byte[][]{key, key}));
if (i % 1000 == 0) { if (i % 1000 == 0) {
for (int j = 0; j < delkeys.length; j++) c.remove(delkeys[j]); for (int j = 0; j < delkeys.length; j++) c.remove(delkeys[j], true);
c.sort(); c.sort();
} }
} }
for (int j = 0; j < delkeys.length; j++) c.remove(delkeys[j]); for (int j = 0; j < delkeys.length; j++) c.remove(delkeys[j], true);
c.sort(); c.sort();
random = new Random(0); random = new Random(0);
for (int i = 0; i < testsize; i++) { for (int i = 0; i < testsize; i++) {

@ -179,7 +179,7 @@ public class kelondroSQLTable implements kelondroIndex {
public kelondroRow.Entry put(kelondroRow.Entry row) throws IOException { public kelondroRow.Entry put(kelondroRow.Entry row) throws IOException {
try { try {
kelondroRow.Entry oldEntry = remove(row.getColBytes(0)); kelondroRow.Entry oldEntry = remove(row.getColBytes(0), false);
String sqlQuery = new String String sqlQuery = new String
( (
@ -216,7 +216,7 @@ public class kelondroSQLTable implements kelondroIndex {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public kelondroRow.Entry remove(byte[] key) throws IOException { public kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException {
try { try {
kelondroRow.Entry entry = this.get(key); kelondroRow.Entry entry = this.get(key);

@ -150,8 +150,8 @@ public class kelondroSplittedTree implements kelondroIndex {
return ktfs[partition(row.getColBytes(0))].put(row); return ktfs[partition(row.getColBytes(0))].put(row);
} }
public kelondroRow.Entry remove(byte[] key) throws IOException { public kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException {
return ktfs[partition(key)].remove(key); return ktfs[partition(key)].remove(key, keepOrder);
} }
public kelondroRow.Entry removeOne() throws IOException { public kelondroRow.Entry removeOne() throws IOException {

@ -618,7 +618,10 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
} }
// Removes the mapping for this key from this map if present (optional operation). // Removes the mapping for this key from this map if present (optional operation).
public kelondroRow.Entry remove(byte[] key) throws IOException { public kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException {
// keepOrder cannot have any effect: the order inside the database file cannot be maintained, but iteration over objects will always maintain the object order
// therefore keepOrder should be true, because the effect is always given, while the data structure does not maintain order
assert keepOrder == true;
// delete from database // delete from database
synchronized(writeSearchObj) { synchronized(writeSearchObj) {
writeSearchObj.process(key); writeSearchObj.process(key);
@ -1090,7 +1093,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
public void remove() { public void remove() {
if (lastKey != null) try { if (lastKey != null) try {
kelondroTree.this.remove(lastKey); kelondroTree.this.remove(lastKey, true);
} catch (IOException e) { } catch (IOException e) {
// do nothing // do nothing
} }
@ -1241,9 +1244,9 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
fm.put("abc3".getBytes(), dummy); fm.put("bcd3".getBytes(), dummy); fm.put("abc3".getBytes(), dummy); fm.put("bcd3".getBytes(), dummy);
fm.put("def3".getBytes(), dummy); fm.put("bab3".getBytes(), dummy); fm.put("def3".getBytes(), dummy); fm.put("bab3".getBytes(), dummy);
fm.print(); fm.print();
fm.remove("def1".getBytes()); fm.remove("bab1".getBytes()); fm.remove("def1".getBytes(), true); fm.remove("bab1".getBytes(), true);
fm.remove("abc2".getBytes()); fm.remove("bcd2".getBytes()); fm.remove("abc2".getBytes(), true); fm.remove("bcd2".getBytes(), true);
fm.remove("def2".getBytes()); fm.remove("bab2".getBytes()); fm.remove("def2".getBytes(), true); fm.remove("bab2".getBytes(), true);
fm.put("def1".getBytes(), dummy); fm.put("bab1".getBytes(), dummy); fm.put("def1".getBytes(), dummy); fm.put("bab1".getBytes(), dummy);
fm.put("abc2".getBytes(), dummy); fm.put("bcd2".getBytes(), dummy); fm.put("abc2".getBytes(), dummy); fm.put("bcd2".getBytes(), dummy);
fm.put("def2".getBytes(), dummy); fm.put("bab2".getBytes(), dummy); fm.put("def2".getBytes(), dummy); fm.put("bab2".getBytes(), dummy);
@ -1261,7 +1264,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
} else if (args.length == 3) { } else if (args.length == 3) {
if (args[0].equals("-d")) { if (args[0].equals("-d")) {
kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0)); kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
fm.remove(args[2].getBytes()); fm.remove(args[2].getBytes(), true);
fm.close(); fm.close();
} else if (args[0].equals("-i")) { } else if (args[0].equals("-i")) {
kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0)); kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
@ -1386,7 +1389,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
// delete one // delete one
c = d.charAt((int) (System.currentTimeMillis() % d.length())); c = d.charAt((int) (System.currentTimeMillis() % d.length()));
b = testWord(c); b = testWord(c);
tt.remove(b); tt.remove(b, true);
d = d.substring(0, d.indexOf(c)) + d.substring(d.indexOf(c) + 1); d = d.substring(0, d.indexOf(c)) + d.substring(d.indexOf(c) + 1);
t = t + c; t = t + c;
System.out.println("removed " + new String(b)); System.out.println("removed " + new String(b));
@ -1440,8 +1443,8 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
b = testWord('C'); tt.put(b, b); //tt.print(); b = testWord('C'); tt.put(b, b); //tt.print();
b = testWord('D'); tt.put(b, b); //tt.print(); b = testWord('D'); tt.put(b, b); //tt.print();
b = testWord('A'); tt.put(b, b); //tt.print(); b = testWord('A'); tt.put(b, b); //tt.print();
b = testWord('D'); tt.remove(b); //tt.print(); b = testWord('D'); tt.remove(b, true); //tt.print();
b = testWord('B'); tt.remove(b); //tt.print(); b = testWord('B'); tt.remove(b, true); //tt.print();
b = testWord('B'); tt.put(b, b); //tt.print(); b = testWord('B'); tt.put(b, b); //tt.print();
b = testWord('D'); tt.put(b, b); b = testWord('D'); tt.put(b, b);
b = testWord('E'); tt.put(b, b); b = testWord('E'); tt.put(b, b);
@ -1530,7 +1533,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
//tt.print(); //tt.print();
// delete by permutation j // delete by permutation j
for (int elt = 0; elt < s[j].length(); elt++) { for (int elt = 0; elt < s[j].length(); elt++) {
tt.remove(testWord(s[j].charAt(elt))); tt.remove(testWord(s[j].charAt(elt)), true);
//tt.print(); //tt.print();
if (countElements(tt) != tt.size()) { if (countElements(tt) != tt.size()) {
System.out.println("ERROR! wrong size for probe tree " + s[i] + "; probe delete " + s[j] + "; position " + elt); System.out.println("ERROR! wrong size for probe tree " + s[i] + "; probe delete " + s[j] + "; position " + elt);

@ -171,7 +171,7 @@ public class plasmaCrawlBalancer {
// and it was implemented in the previous architecture // and it was implemented in the previous architecture
// however, usage is not recommendet // however, usage is not recommendet
int s = urlFileIndex.size(); int s = urlFileIndex.size();
kelondroRow.Entry entry = urlFileIndex.remove(urlhash.getBytes()); kelondroRow.Entry entry = urlFileIndex.remove(urlhash.getBytes(), false);
if (entry == null) return null; if (entry == null) return null;
assert urlFileIndex.size() + 1 == s : "urlFileIndex.size() = " + urlFileIndex.size() + ", s = " + s; assert urlFileIndex.size() + 1 == s : "urlFileIndex.size() = " + urlFileIndex.size() + ", s = " + s;
@ -446,7 +446,7 @@ public class plasmaCrawlBalancer {
long delta = lastAccessDelta(result); long delta = lastAccessDelta(result);
assert delta >= 0: "delta = " + delta; assert delta >= 0: "delta = " + delta;
int s = urlFileIndex.size(); int s = urlFileIndex.size();
kelondroRow.Entry rowEntry = urlFileIndex.remove(result.getBytes()); kelondroRow.Entry rowEntry = urlFileIndex.remove(result.getBytes(), false);
assert urlFileIndex.size() + 1 == s : "urlFileIndex.size() = " + urlFileIndex.size() + ", s = " + s + ", result = " + result; assert urlFileIndex.size() + 1 == s : "urlFileIndex.size() = " + urlFileIndex.size() + ", s = " + s + ", result = " + result;
if (rowEntry == null) { if (rowEntry == null) {
serverLog.logSevere("PLASMA BALANCER", "get() found a valid urlhash, but failed to fetch the corresponding url entry - total size = " + size() + ", fileStack.size() = " + urlFileStack.size() + ", ramStack.size() = " + urlRAMStack.size() + ", domainStacks.size() = " + domainStacks.size()); serverLog.logSevere("PLASMA BALANCER", "get() found a valid urlhash, but failed to fetch the corresponding url entry - total size = " + size() + ", fileStack.size() = " + urlFileStack.size() + ", ramStack.size() = " + urlRAMStack.size() + ", domainStacks.size() = " + domainStacks.size());

@ -281,7 +281,7 @@ public final class plasmaCrawlLURL {
public synchronized boolean remove(String urlHash) { public synchronized boolean remove(String urlHash) {
if (urlHash == null) return false; if (urlHash == null) return false;
try { try {
kelondroRow.Entry r = urlIndexFile.remove(urlHash.getBytes()); kelondroRow.Entry r = urlIndexFile.remove(urlHash.getBytes(), false);
if (r == null) return false; if (r == null) return false;
for (int stack = 1; stack <= 6; stack++) { for (int stack = 1; stack <= 6; stack++) {
for (int i = getStackSize(stack) - 1; i >= 0; i--) { for (int i = getStackSize(stack) - 1; i >= 0; i--) {

@ -584,7 +584,7 @@ public final class plasmaCrawlStacker {
synchronized(this.urlEntryHashCache) { synchronized(this.urlEntryHashCache) {
urlHash = (String) this.urlEntryHashCache.removeFirst(); urlHash = (String) this.urlEntryHashCache.removeFirst();
if (urlHash == null) throw new IOException("urlHash is null"); if (urlHash == null) throw new IOException("urlHash is null");
entry = this.urlEntryCache.remove(urlHash.getBytes()); entry = this.urlEntryCache.remove(urlHash.getBytes(), false);
} }
} finally { } finally {
this.writeSync.V(); this.writeSync.V();

@ -95,7 +95,7 @@ public class plasmaCrawlZURL {
public boolean remove(String hash) { public boolean remove(String hash) {
if (hash == null) return false; if (hash == null) return false;
try { try {
urlIndexFile.remove(hash.getBytes()); urlIndexFile.remove(hash.getBytes(), false);
return true; return true;
} catch (IOException e) { } catch (IOException e) {
return false; return false;

@ -90,7 +90,7 @@ public class yacyNewsDB {
} }
public void remove(String id) throws IOException { public void remove(String id) throws IOException {
news.remove(id.getBytes()); news.remove(id.getBytes(), false);
} }
public synchronized yacyNewsRecord put(yacyNewsRecord record) throws IOException { public synchronized yacyNewsRecord put(yacyNewsRecord record) throws IOException {

Loading…
Cancel
Save