From 66ac3a7d9d9518d88eb6a072c120d5eb2cb88e26 Mon Sep 17 00:00:00 2001 From: orbiter Date: Fri, 20 Aug 2010 23:33:56 +0000 Subject: [PATCH] corrected database row iteration git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7055 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../net/yacy/kelondro/blob/BEncodedHeap.java | 26 ++++++++++--------- source/net/yacy/kelondro/blob/Heap.java | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/source/net/yacy/kelondro/blob/BEncodedHeap.java b/source/net/yacy/kelondro/blob/BEncodedHeap.java index 00b2eae53..5ce9f4493 100644 --- a/source/net/yacy/kelondro/blob/BEncodedHeap.java +++ b/source/net/yacy/kelondro/blob/BEncodedHeap.java @@ -184,23 +184,25 @@ public class BEncodedHeap implements Iterable>> 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>> 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>> 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; + } } } diff --git a/source/net/yacy/kelondro/blob/Heap.java b/source/net/yacy/kelondro/blob/Heap.java index 483217253..2ff14fa04 100755 --- a/source/net/yacy/kelondro/blob/Heap.java +++ b/source/net/yacy/kelondro/blob/Heap.java @@ -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> i = this.buffer.entrySet().iterator(); int l = 0;