java.lang.NullPointerException
	at net.yacy.kelondro.index.RowCollection.<init>(RowCollection.java:97)
	at net.yacy.kelondro.index.RowSet.<init>(RowSet.java:48)
	at net.yacy.kelondro.rwi.ReferenceContainer.<init>(ReferenceContainer.java:58)
	at net.yacy.kelondro.rwi.ReferenceIterator.next(ReferenceIterator.java:69)
	at net.yacy.kelondro.rwi.ReferenceIterator.next(ReferenceIterator.java:43)
	at net.yacy.kelondro.blob.ArrayStack.merge(ArrayStack.java:1023)
	at net.yacy.kelondro.blob.ArrayStack.mergeWorker(ArrayStack.java:922)
	at net.yacy.kelondro.blob.ArrayStack.mergeMount(ArrayStack.java:869)
	at net.yacy.kelondro.rwi.IODispatcher$MergeJob.merge(IODispatcher.java:267)
	at net.yacy.kelondro.rwi.IODispatcher$MergeJob.access$300(IODispatcher.java:239)
	at net.yacy.kelondro.rwi.IODispatcher.run(IODispatcher.java:180)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7822 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 719777b2a7
commit 6d2e252bcf

@ -76,29 +76,29 @@ public class RowSet extends RowCollection implements Index, Iterable<Row.Entry>
public final static RowSet importRowSet(final byte[] b, final Row rowdef) throws RowSpaceExceededException {
assert b.length >= exportOverheadSize : "b.length = " + b.length;
if (b.length < exportOverheadSize) return new RowSet(rowdef);
if (b.length < exportOverheadSize) return new RowSet(rowdef, 0);
final int size = (int) NaturalOrder.decodeLong(b, 0, 4);
assert size >= 0 : "size = " + size;
if (size < 0) return new RowSet(rowdef);
if (size < 0) return new RowSet(rowdef, 0);
final int orderbound = (int) NaturalOrder.decodeLong(b, 10, 4);
assert orderbound >= 0 : "orderbound = " + orderbound;
if (orderbound < 0) return new RowSet(rowdef); // error
if (orderbound < 0) return new RowSet(rowdef, 0); // error
final long alloc = ((long) size) * ((long) rowdef.objectsize);
assert alloc <= Integer.MAX_VALUE : "alloc = " + alloc;
if (alloc > Integer.MAX_VALUE) return null;
if (alloc > Integer.MAX_VALUE) throw new RowSpaceExceededException((int) alloc, "importRowSet: alloc > Integer.MAX_VALUE");
assert alloc == b.length - exportOverheadSize;
if (alloc != b.length - exportOverheadSize) return null;
if (alloc != b.length - exportOverheadSize) throw new RowSpaceExceededException((int) alloc, "importRowSet: alloc != b.length - exportOverheadSize");
MemoryControl.request((int) alloc, true);
final byte[] chunkcache;
try {
chunkcache = new byte[(int) alloc];
} catch (final OutOfMemoryError e) {
throw new RowSpaceExceededException((int) alloc, "importRowSet");
throw new RowSpaceExceededException((int) alloc, "importRowSet: OutOfMemoryError");
}
//assert b.length - exportOverheadSize == size * rowdef.objectsize : "b.length = " + b.length + ", size * rowdef.objectsize = " + size * rowdef.objectsize;
if (b.length - exportOverheadSize != alloc) {
Log.logSevere("RowSet", "exportOverheadSize wrong: b.length = " + b.length + ", size * rowdef.objectsize = " + size * rowdef.objectsize);
return new RowSet(rowdef);
return new RowSet(rowdef, 0);
}
System.arraycopy(b, (int) exportOverheadSize, chunkcache, 0, chunkcache.length);
return new RowSet(rowdef, size, chunkcache, orderbound);

@ -28,7 +28,6 @@ package net.yacy.kelondro.rwi;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import net.yacy.kelondro.blob.HeapReader;
@ -36,62 +35,59 @@ import net.yacy.kelondro.index.RowSet;
import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.order.CloneableIterator;
import net.yacy.kelondro.util.LookAheadIterator;
/**
* iterator of BLOBHeap files: is used to import heap dumps into a write-enabled index heap
*/
public class ReferenceIterator <ReferenceType extends Reference> implements CloneableIterator<ReferenceContainer<ReferenceType>>, Iterable<ReferenceContainer<ReferenceType>> {
public class ReferenceIterator <ReferenceType extends Reference> extends LookAheadIterator<ReferenceContainer<ReferenceType>> implements CloneableIterator<ReferenceContainer<ReferenceType>>, Iterable<ReferenceContainer<ReferenceType>> {
HeapReader.entries blobs;
File blobFile;
ReferenceFactory<ReferenceType> factory;
public ReferenceIterator(final File blobFile, ReferenceFactory<ReferenceType> factory) throws IOException {
public ReferenceIterator(final File blobFile, final ReferenceFactory<ReferenceType> factory) throws IOException {
this.blobs = new HeapReader.entries(blobFile, factory.getRow().primaryKeyLength);
this.blobFile = blobFile;
this.factory = factory;
}
public boolean hasNext() {
if (blobs == null) return false;
if (blobs.hasNext()) return true;
close();
return false;
}
/**
* return an index container
* because they may get very large, it is wise to deallocate some memory before calling next()
*/
public ReferenceContainer<ReferenceType> next() {
Map.Entry<byte[], byte[]> entry = blobs.next();
byte[] payload = entry.getValue();
public ReferenceContainer<ReferenceType> next0() {
if (this.blobs == null) return null;
RowSet row;
Map.Entry<byte[], byte[]> entry;
while (this.blobs.hasNext()) {
entry = this.blobs.next();
try {
return new ReferenceContainer<ReferenceType>(factory, entry.getKey(), RowSet.importRowSet(payload, factory.getRow()));
} catch (RowSpaceExceededException e) {
Log.logSevere("ReferenceIterator", "lost entry '" + entry.getKey() + "' because of too low memory: " + e.toString());
return null;
row = RowSet.importRowSet(entry.getValue(), this.factory.getRow());
if (row == null) {
Log.logSevere("ReferenceIterator", "lost entry '" + entry.getKey() + "' because importRowSet returned null");
continue; // thats a fail but not as REALLY bad if the whole method would crash here
}
return new ReferenceContainer<ReferenceType>(this.factory, entry.getKey(), row);
} catch (final RowSpaceExceededException e) {
Log.logSevere("ReferenceIterator", "lost entry '" + entry.getKey() + "' because of too low memory: " + e.toString());
continue;
}
public void remove() {
throw new UnsupportedOperationException("heap dumps are read-only");
}
public Iterator<ReferenceContainer<ReferenceType>> iterator() {
return this;
close();
return null;
}
public void close() {
if (blobs != null) this.blobs.close();
blobs = null;
if (this.blobs != null) this.blobs.close();
this.blobs = null;
}
public CloneableIterator<ReferenceContainer<ReferenceType>> clone(Object modifier) {
if (blobs != null) this.blobs.close();
blobs = null;
public CloneableIterator<ReferenceContainer<ReferenceType>> clone(final Object modifier) {
if (this.blobs != null) this.blobs.close();
this.blobs = null;
try {
return new ReferenceIterator<ReferenceType>(this.blobFile, factory);
} catch (IOException e) {
return new ReferenceIterator<ReferenceType>(this.blobFile, this.factory);
} catch (final IOException e) {
Log.logException(e);
return null;
}

@ -43,7 +43,7 @@ public abstract class LookAheadIterator<A> implements Iterator<A>, Iterable<A> {
public LookAheadIterator() {
}
public Iterator<A> iterator() {
public final Iterator<A> iterator() {
return this;
}
@ -54,21 +54,21 @@ public abstract class LookAheadIterator<A> implements Iterator<A>, Iterable<A> {
protected abstract A next0() ;
private final void checkInit() {
if (fresh) {
next = next0();
fresh = false;
if (this.fresh) {
this.next = next0();
this.fresh = false;
}
}
public final boolean hasNext() {
checkInit();
return next != null;
return this.next != null;
}
public final A next() {
checkInit();
A n = next;
next = next0();
final A n = this.next;
this.next = next0();
return n;
}

Loading…
Cancel
Save