From 30a1de41b32ec4340019ffff9c4ce52a01edfaff Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 11 Feb 2009 15:21:48 +0000 Subject: [PATCH] disabled the BufferedIOChunks, because I consider it as broken. I will try to fix that, but it is better to not use a buffer than using a broken buffer. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5600 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/kelondro/io/BufferedIOChunks.java | 9 ++++++++- source/de/anomic/kelondro/table/AbstractRecords.java | 10 ++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source/de/anomic/kelondro/io/BufferedIOChunks.java b/source/de/anomic/kelondro/io/BufferedIOChunks.java index 098352428..1759b42d3 100644 --- a/source/de/anomic/kelondro/io/BufferedIOChunks.java +++ b/source/de/anomic/kelondro/io/BufferedIOChunks.java @@ -93,7 +93,14 @@ public final class BufferedIOChunks extends AbstractIOChunks implements IOChunks return; } if (this.buffer == null) this.buffer = new byte[this.bufferSize]; - System.arraycopy(b, off, this.buffer, (int) (pos - this.ra.length()), len); + assert b != null; + assert off >= 0 : "off = " + off; + assert off + len <= b.length : "off = " + off + ", len = " + len + ", b.length = " + b.length; + assert this.buffer != null; + assert pos - this.ra.length() >= 0 : "pos = " + pos + ", this.ra.length() = " + this.ra.length(); + assert pos - this.ra.length() + len <= this.buffer.length : "pos = " + pos + ", this.ra.length() = " + this.ra.length() + ", len = " + len + ", buffer.length = " + buffer.length; + //pos = 1216, this.ra.length() = 1208, len = 386, buffer.length = 0 + System.arraycopy(b, off, this.buffer, (int) (pos - this.ra.length()), len); // OOB Exception :-( this.bufferSize = (int) Math.max(this.bufferSize, pos - this.ra.length() + len); return; } else if (pos + len >= this.ra.length()) { diff --git a/source/de/anomic/kelondro/table/AbstractRecords.java b/source/de/anomic/kelondro/table/AbstractRecords.java index 247f8811d..2caffc474 100644 --- a/source/de/anomic/kelondro/table/AbstractRecords.java +++ b/source/de/anomic/kelondro/table/AbstractRecords.java @@ -32,7 +32,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.HashSet; import java.util.Iterator; -import java.util.Random; import java.util.Set; import java.util.StringTokenizer; import java.util.TreeSet; @@ -42,7 +41,6 @@ import java.util.logging.Logger; import de.anomic.kelondro.index.Column; import de.anomic.kelondro.index.Row; import de.anomic.kelondro.index.Row.EntryIndex; -import de.anomic.kelondro.io.BufferedIOChunks; import de.anomic.kelondro.io.ChannelRandomAccess; import de.anomic.kelondro.io.FileRandomAccess; import de.anomic.kelondro.io.IOChunksInterface; @@ -112,7 +110,7 @@ public abstract class AbstractRecords implements RandomAccessRecords { protected boolean fileExisted; // Random. This is used to shift flush-times of write-buffers to differrent time - private static Random random = new Random(System.currentTimeMillis()); + //private static Random random = new Random(System.currentTimeMillis()); // check for debug mode public static boolean debugmode = false; @@ -554,11 +552,11 @@ public abstract class AbstractRecords implements RandomAccessRecords { private void initExistingFile(final RandomAccessInterface ra, boolean useBuffer) throws IOException { // read from Chunked IO //useBuffer = false; - if (useBuffer) { + /*if (useBuffer) { this.entryFile = new BufferedIOChunks(ra, ra.name(), 1024*1024, 30000 + random.nextLong() % 30000); - } else { + } else {*/ this.entryFile = new RandomAccessIOChunks(ra, ra.name()); - } + //} // read dynamic variables that are back-ups of stored values in file; // read/defined on instantiation