corrected database row iteration

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7055 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent dfd416e3fb
commit 66ac3a7d9d

@ -184,23 +184,25 @@ public class BEncodedHeap implements Iterable<Map.Entry<byte[], Map<String, byte
/**
* iterate all rows of the table.
* Be aware that this first closes the table to force flushing of all elements in
* the write buffer. After that an iterator on the closed file is generated and then
* the file is opened again.
*/
public Iterator<Map.Entry<byte[], Map<String, byte[]>>> iterator() {
File location = this.table.location();
int keylen = this.table.keylength();
ByteOrder order = this.table.ordering();
int buffermax = this.table.getBuffermax();
this.table.close();
try {
Iterator<Map.Entry<byte[], Map<String, byte[]>>> iter = new EntryIter(location, keylen);
this.table = new Heap(location, keylen, order, buffermax);
return iter;
} catch (IOException e) {
Log.logSevere("PropertiesTable", e.getMessage(), e);
return null;
this.table.flushBuffer();
return new EntryIter(location, keylen);
} catch (IOException e1) {
ByteOrder order = this.table.ordering();
int buffermax = this.table.getBuffermax();
this.table.close();
try {
Iterator<Map.Entry<byte[], Map<String, byte[]>>> iter = new EntryIter(location, keylen);
this.table = new Heap(location, keylen, order, buffermax);
return iter;
} catch (IOException e) {
Log.logSevere("PropertiesTable", e.getMessage(), e);
return null;
}
}
}

@ -158,7 +158,7 @@ public final class Heap extends HeapModifier implements BLOB {
* @throws IOException
* @throws RowSpaceExceededException
*/
private void flushBuffer() throws IOException {
public void flushBuffer() throws IOException {
// check size of buffer
Iterator<Map.Entry<byte[], byte[]>> i = this.buffer.entrySet().iterator();
int l = 0;

Loading…
Cancel
Save