fixed a bug in rwi storage data size allocation

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6843 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 15 years ago
parent 90c3e5d6f6
commit b6cce08019

@ -92,7 +92,7 @@ public final class ObjectIndexCache implements ObjectIndex, Iterable<Row.Entry>
// finish initialization phase // finish initialization phase
index0.sort(); index0.sort();
index0.uniq(); index0.uniq();
index0.trim(false); index0.trim();
index1 = new RowSet(rowdef); //new RowSetArray(rowdef, spread); index1 = new RowSet(rowdef); //new RowSetArray(rowdef, spread);
} }
} }

@ -220,11 +220,12 @@ public class RowCollection implements Iterable<Row.Entry>, Cloneable {
public synchronized byte[] exportCollection() { public synchronized byte[] exportCollection() {
// returns null if the collection is empty // returns null if the collection is empty
trim(false);
sort(); // experimental; supervise CPU load sort(); // experimental; supervise CPU load
//uniq();
//trim();
assert this.sortBound == this.chunkcount; // on case the collection is sorted 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; 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); final Row row = exportRow(this.size() * this.rowdef.objectsize);
final Row.Entry entry = row.newEntry(); final Row.Entry entry = row.newEntry();
assert (sortBound <= chunkcount) : "sortBound = " + sortBound + ", chunkcount = " + chunkcount; 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; assert (this.chunkcount <= chunkcache.length / rowdef.objectsize) : "chunkcount = " + this.chunkcount + ", chunkcache.length = " + chunkcache.length + ", rowdef.objectsize = " + rowdef.objectsize;
@ -296,10 +297,10 @@ public class RowCollection implements Iterable<Row.Entry>, Cloneable {
return neededSpaceForEnsuredSize(chunkcount + 1, false); return neededSpaceForEnsuredSize(chunkcount + 1, false);
} }
protected synchronized void trim(final boolean plusGrowFactor) { protected synchronized void trim() {
if (chunkcache.length == 0) return; if (chunkcache.length == 0) return;
long needed = chunkcount * rowdef.objectsize; long needed = chunkcount * rowdef.objectsize;
if (plusGrowFactor) needed = neededSpaceForEnsuredSize(chunkcount, false); assert needed <= chunkcache.length;
if (needed >= chunkcache.length) if (needed >= chunkcache.length)
return; // in case that the growfactor causes that the cache would return; // in case that the growfactor causes that the cache would
// grow instead of shrink, simply ignore the growfactor // grow instead of shrink, simply ignore the growfactor
@ -308,8 +309,7 @@ public class RowCollection implements Iterable<Row.Entry>, Cloneable {
// This is not critical. Otherwise we provoke a serious // This is not critical. Otherwise we provoke a serious
// problem with OOM // problem with OOM
final byte[] newChunkcache = new byte[(int) needed]; final byte[] newChunkcache = new byte[(int) needed];
System.arraycopy(chunkcache, 0, newChunkcache, 0, Math.min( System.arraycopy(chunkcache, 0, newChunkcache, 0, Math.min(chunkcache.length, newChunkcache.length));
chunkcache.length, newChunkcache.length));
chunkcache = newChunkcache; chunkcache = newChunkcache;
} }
@ -945,7 +945,7 @@ public class RowCollection implements Iterable<Row.Entry>, Cloneable {
collection.addUnique(get(i + 1, false)); collection.addUnique(get(i + 1, false));
removeRow(i + 1, false); removeRow(i + 1, false);
if (i + 1 < chunkcount - 1) u = false; if (i + 1 < chunkcount - 1) u = false;
collection.trim(false); collection.trim();
report.add(collection); report.add(collection);
collection = new RowSet(this.rowdef, 2); collection = new RowSet(this.rowdef, 2);
} }

@ -515,7 +515,7 @@ public class RowSet extends RowCollection implements ObjectIndex, Iterable<Row.E
System.out.println("SORTED : " + d.toString()); System.out.println("SORTED : " + d.toString());
d.uniq(); d.uniq();
System.out.println("UNIQ : " + d.toString()); System.out.println("UNIQ : " + d.toString());
d.trim(false); d.trim();
System.out.println("TRIM : " + d.toString()); System.out.println("TRIM : " + d.toString());

Loading…
Cancel
Save