Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- more asserts - better memory usage during remove in kelondroRowSet
orbiter4ce590622f6c
diff --git a/htroot/IndexControl_p.java b/htroot/IndexControl_p.javaindex 147863579..2e49bd0f8 100644--- a/htroot/IndexControl_p.java+++ b/htroot/IndexControl_p.java@@ -396,7 +396,7 @@ public class IndexControl_p {seed = (yacySeed) e.nextElement();if (seed != null) {prop.put("hosts_" + hc + "_hosthash", seed.hash);- prop.put("hosts_" + hc + "_hostname", /*seed.hash + " " +*/ seed.get(yacySeed.NAME, "nameless"));+ prop.put("hosts_" + hc + "_hostname", seed.hash + " " + seed.get(yacySeed.NAME, "nameless"));hc++;}}diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.javaindex 189e47e68..d0cfda72e 100644--- a/source/de/anomic/kelondro/kelondroRowCollection.java+++ b/source/de/anomic/kelondro/kelondroRowCollection.java@@ -269,17 +269,33 @@ public class kelondroRowCollection {}protected final void removeShift(int pos, int dist, int upBound) {+ assert ((pos + dist) * rowdef.objectsize() >= 0) : "pos = " + pos + ", dist = " + dist + ", rowdef.objectsize() = " + rowdef.objectsize;+ assert (pos * rowdef.objectsize() >= 0) : "pos = " + pos + ", rowdef.objectsize() = " + rowdef.objectsize;+ assert ((pos + dist) * rowdef.objectsize() + (upBound - pos - dist) * rowdef.objectsize() <= chunkcache.length) : "pos = " + pos + ", dist = " + dist + ", rowdef.objectsize() = " + rowdef.objectsize + ", upBound = " + upBound + ", chunkcache.length = " + chunkcache.length;+ assert (pos * rowdef.objectsize() + (upBound - pos - dist) * rowdef.objectsize() <= chunkcache.length) : "pos = " + pos + ", dist = " + dist + ", rowdef.objectsize() = " + rowdef.objectsize + ", upBound = " + upBound + ", chunkcache.length = " + chunkcache.length;System.arraycopy(chunkcache, (pos + dist) * rowdef.objectsize(),chunkcache, pos * rowdef.objectsize(),(upBound - pos - dist) * rowdef.objectsize());}- public final void removeShift(int p) {- assert ((p >= 0) && (p < chunkcount) && (chunkcount > 0));- //System.out.println("REMOVE at pos " + p + ", chunkcount=" + chunkcount + ", sortBound=" + sortBound);+ protected final void copytop(int i) {+ // copies the topmost row element to given position+ if (i == chunkcount - 1) return;+ System.arraycopy(chunkcache, this.rowdef.objectsize() * (chunkcount - 1), chunkcache, this.rowdef.objectsize() * i, this.rowdef.objectsize());+ }++ protected final void removeRow(int p) {+ assert ((p >= 0) && (p < chunkcount) && (chunkcount > 0)) : "p = " + p + ", chunkcount = " + chunkcount;synchronized (chunkcache) {- if (p < sortBound) sortBound--;- removeShift(p, 1, chunkcount--);+ if (p < sortBound) {+ sortBound--;+ removeShift(p, 1, chunkcount);+ chunkcount--;+ } else {+ copytop(p);+ chunkcount--;+ }+}this.lastTimeWrote = System.currentTimeMillis();}@@ -328,7 +344,7 @@ public class kelondroRowCollection {public void remove() {p--;- removeShift(p);+ removeRow(p);}}@@ -466,7 +482,7 @@ public class kelondroRowCollection {while (i < chunkcount - 1) {if (compare(i, i + 1) == 0) {//System.out.println("DOUBLE: " + new String(this.chunkcache, this.chunksize * i, this.chunksize));- removeShift(i);+ removeRow(i);} else {i++;}diff --git a/source/de/anomic/kelondro/kelondroRowSet.java b/source/de/anomic/kelondro/kelondroRowSet.javaindex f7b3f0128..662a54c56 100644--- a/source/de/anomic/kelondro/kelondroRowSet.java+++ b/source/de/anomic/kelondro/kelondroRowSet.java@@ -154,8 +154,8 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndif (removeMarker.size() > removeMaxSize) resolveMarkedRemoved();} else {// remove directly by swap- if (chunkcount == sortBound) sortBound--;- super.swap(p, --chunkcount, 0);+ super.copytop(p);+ chunkcount--;}profile.stopDelete(handle);