fix for "negative seek offset" error during extension of heap files.

This would have always happend when a heap file exceeds 2GB.
should fix https://github.com/yacy/yacy_search_server/issues/372
pull/607/head
Michael Peter Christen 1 year ago
parent 9c8fb97985
commit 4a54b24703

@ -117,7 +117,6 @@ public final class Heap extends HeapModifier implements BLOB {
return super.size() + ((this.buffer == null) ? 0 : this.buffer.size());
}
/**
* test if a key is in the heap file. This does not need any IO, because it uses only the ram index
* @param key
@ -147,7 +146,7 @@ public final class Heap extends HeapModifier implements BLOB {
private void add(byte[] key, final byte[] blob) throws IOException {
assert blob.length > 0;
if ((blob == null) || (blob.length == 0)) return;
final int pos = (int) this.file.length();
final long pos = this.file.length();
try {
this.index.put(key, pos);
this.file.seek(pos);
@ -283,7 +282,7 @@ public final class Heap extends HeapModifier implements BLOB {
ConcurrentLog.info("Heap", "clearing heap " + this.name());
assert this.buffer != null;
if (this.buffer == null) this.buffer = new TreeMap<byte[], byte[]>(this.ordering);
this.buffer.clear();
this.buffer.clear();
this.buffersize = 0;
super.clear();
}
@ -294,16 +293,16 @@ public final class Heap extends HeapModifier implements BLOB {
@Override
public synchronized void close(final boolean writeIDX) {
ConcurrentLog.info("Heap", "closing heap " + this.name());
if (this.file != null && this.buffer != null) {
if (this.file != null && this.buffer != null) {
try {
flushBuffer();
} catch (final IOException e) {
ConcurrentLog.logException(e);
}
}
this.buffer = null;
super.close(writeIDX);
assert this.file == null;
this.buffer = null;
super.close(writeIDX);
assert this.file == null;
}
@Override

Loading…
Cancel
Save