Skip to content

Commit

Permalink
fixed a bug in rwi storage data size allocation
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6843 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
orbiter committed Apr 27, 2010
1 parent 90c3e5d commit b6cce08
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion source/net/yacy/kelondro/index/ObjectIndexCache.java
Expand Up @@ -92,7 +92,7 @@ protected final void finishInitialization() {
// finish initialization phase
index0.sort();
index0.uniq();
index0.trim(false);
index0.trim();
index1 = new RowSet(rowdef); //new RowSetArray(rowdef, spread);
}
}
Expand Down
16 changes: 8 additions & 8 deletions source/net/yacy/kelondro/index/RowCollection.java
Expand Up @@ -220,11 +220,12 @@ private static Row exportRow(final int chunkcachelength) {

public synchronized byte[] exportCollection() {
// returns null if the collection is empty
trim(false);
sort(); // experimental; supervise CPU load
//uniq();
//trim();
assert this.sortBound == this.chunkcount; // on case the collection is sorted
assert this.size() * this.rowdef.objectsize == this.chunkcache.length : "this.size() = " + this.size() + ", objectsize = " + this.rowdef.objectsize + ", chunkcache.length = " + this.chunkcache.length;
final Row row = exportRow(chunkcache.length);
assert this.size() * this.rowdef.objectsize <= this.chunkcache.length : "this.size() = " + this.size() + ", objectsize = " + this.rowdef.objectsize + ", chunkcache.length = " + this.chunkcache.length;
final Row row = exportRow(this.size() * this.rowdef.objectsize);
final Row.Entry entry = row.newEntry();
assert (sortBound <= chunkcount) : "sortBound = " + sortBound + ", chunkcount = " + chunkcount;
assert (this.chunkcount <= chunkcache.length / rowdef.objectsize) : "chunkcount = " + this.chunkcount + ", chunkcache.length = " + chunkcache.length + ", rowdef.objectsize = " + rowdef.objectsize;
Expand Down Expand Up @@ -296,10 +297,10 @@ protected final long memoryNeededForGrow() {
return neededSpaceForEnsuredSize(chunkcount + 1, false);
}

protected synchronized void trim(final boolean plusGrowFactor) {
protected synchronized void trim() {
if (chunkcache.length == 0) return;
long needed = chunkcount * rowdef.objectsize;
if (plusGrowFactor) needed = neededSpaceForEnsuredSize(chunkcount, false);
assert needed <= chunkcache.length;
if (needed >= chunkcache.length)
return; // in case that the growfactor causes that the cache would
// grow instead of shrink, simply ignore the growfactor
Expand All @@ -308,8 +309,7 @@ protected synchronized void trim(final boolean plusGrowFactor) {
// This is not critical. Otherwise we provoke a serious
// problem with OOM
final byte[] newChunkcache = new byte[(int) needed];
System.arraycopy(chunkcache, 0, newChunkcache, 0, Math.min(
chunkcache.length, newChunkcache.length));
System.arraycopy(chunkcache, 0, newChunkcache, 0, Math.min(chunkcache.length, newChunkcache.length));
chunkcache = newChunkcache;
}

Expand Down Expand Up @@ -945,7 +945,7 @@ public synchronized ArrayList<RowCollection> removeDoubles() throws RowSpaceExce
collection.addUnique(get(i + 1, false));
removeRow(i + 1, false);
if (i + 1 < chunkcount - 1) u = false;
collection.trim(false);
collection.trim();
report.add(collection);
collection = new RowSet(this.rowdef, 2);
}
Expand Down
2 changes: 1 addition & 1 deletion source/net/yacy/kelondro/index/RowSet.java
Expand Up @@ -515,7 +515,7 @@ public static void main(final String[] args) {
System.out.println("SORTED : " + d.toString());
d.uniq();
System.out.println("UNIQ : " + d.toString());
d.trim(false);
d.trim();
System.out.println("TRIM : " + d.toString());


Expand Down

0 comments on commit b6cce08

Please sign in to comment.