mirror of
https://github.com/yacy/yacy_search_server.git
synced 2025-07-17 08:26:08 -04:00
- more asserts
- better memory usage during remove in kelondroRowSet git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3022 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
@ -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++;
|
||||
}
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -154,8 +154,8 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
|
||||
if (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);
|
||||
|
Reference in New Issue
Block a user