Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
refactoring of IO access classes
orbiterfd6b9cb7dcde
diff --git a/htroot/Threaddump_p.java b/htroot/Threaddump_p.javaindex 364f57a07..b64344f39 100644--- a/htroot/Threaddump_p.java+++ b/htroot/Threaddump_p.java@@ -73,7 +73,7 @@ public class Threaddump_p {bufferappend(buffer, plain, "");bufferappend(buffer, plain, "");- int multipleCount = 1000;+ int multipleCount = 100;if (post != null && post.containsKey("multipleThreaddump")) {multipleCount = post.getInt("count", multipleCount);final ArrayList<Map<Thread,StackTraceElement[]>> traces = new ArrayList<Map<Thread,StackTraceElement[]>>();diff --git a/source/de/anomic/kelondro/blob/Heap.java b/source/de/anomic/kelondro/blob/Heap.javaindex 1318fd0f6..74b09e729 100755--- a/source/de/anomic/kelondro/blob/Heap.java+++ b/source/de/anomic/kelondro/blob/Heap.java@@ -32,7 +32,7 @@ import java.util.HashMap;import java.util.Iterator;import java.util.Map;-import de.anomic.kelondro.io.AbstractRandomAccess;+import de.anomic.kelondro.io.random.AbstractWriter;import de.anomic.kelondro.order.ByteOrder;import de.anomic.kelondro.order.CloneableIterator;import de.anomic.kelondro.order.NaturalOrder;@@ -181,7 +181,7 @@ public final class Heap extends HeapModifier implements BLOB {assert key.length == this.keylength : "key.length = " + key.length + ", this.keylength = " + this.keylength;blob = entry.getValue();index.put(key, posFile);- b = AbstractRandomAccess.int2array(key.length + blob.length);+ b = AbstractWriter.int2array(key.length + blob.length);assert b.length == 4;assert posBuffer + 4 < ba.length : "posBuffer = " + posBuffer + ", ba.length = " + ba.length;System.arraycopy(b, 0, ba, posBuffer, 4);diff --git a/source/de/anomic/kelondro/blob/HeapModifier.java b/source/de/anomic/kelondro/blob/HeapModifier.javaindex 8203f4b9a..410f65e90 100644--- a/source/de/anomic/kelondro/blob/HeapModifier.java+++ b/source/de/anomic/kelondro/blob/HeapModifier.java@@ -28,7 +28,7 @@ import java.io.File;import java.io.IOException;import java.util.SortedMap;-import de.anomic.kelondro.io.CachedRandomAccess;+import de.anomic.kelondro.io.random.CachedFileWriter;import de.anomic.kelondro.order.ByteOrder;import de.anomic.kelondro.util.FileUtils;import de.anomic.kelondro.util.MemoryControl;@@ -67,7 +67,7 @@ public class HeapModifier extends HeapReader implements BLOB {this.file.close();this.file = null;FileUtils.deletedelete(this.heapFile);- this.file = new CachedRandomAccess(heapFile);+ this.file = new CachedFileWriter(heapFile);}/**diff --git a/source/de/anomic/kelondro/blob/HeapReader.java b/source/de/anomic/kelondro/blob/HeapReader.javaindex c36be83fc..a5442fc58 100644--- a/source/de/anomic/kelondro/blob/HeapReader.java+++ b/source/de/anomic/kelondro/blob/HeapReader.java@@ -35,7 +35,7 @@ import java.util.Map.Entry;import java.util.concurrent.ExecutionException;import de.anomic.kelondro.index.HandleMap;-import de.anomic.kelondro.io.CachedRandomAccess;+import de.anomic.kelondro.io.random.CachedFileWriter;import de.anomic.kelondro.order.ByteOrder;import de.anomic.kelondro.order.CloneableIterator;import de.anomic.kelondro.order.RotateIterator;@@ -52,7 +52,7 @@ public class HeapReader {protected Gap free; // set of {seek, size} pairs denoting space and position of free recordsprotected File heapFile; // the file of the heapprotected final ByteOrder ordering; // the ordering on keys- protected CachedRandomAccess file; // a random access to the file+ protected CachedFileWriter file; // a random access to the filepublic HeapReader(final File heapFile,@@ -63,7 +63,7 @@ public class HeapReader {this.keylength = keylength;this.index = null; // will be created as result of initialization processthis.free = null; // will be initialized later depending on existing idx/gap file- this.file = new CachedRandomAccess(this.heapFile);+ this.file = new CachedFileWriter(this.heapFile);// read or initialize the indexif (initIndexReadDump()) {@@ -107,7 +107,7 @@ public class HeapReader {private boolean initIndexReadDump() {// look for an index dump and read it if it exist- // if this is successfull, return true; otherwise false+ // if this is successful, return true; otherwise falseString fingerprint = HeapWriter.fingerprintFileHash(this.heapFile);if (fingerprint == null) {Log.logSevere("HeapReader", "cannot generate a fingerprint for " + this.heapFile + ": null");diff --git a/source/de/anomic/kelondro/blob/HeapWriter.java b/source/de/anomic/kelondro/blob/HeapWriter.javaindex 02557e675..674738006 100644--- a/source/de/anomic/kelondro/blob/HeapWriter.java+++ b/source/de/anomic/kelondro/blob/HeapWriter.java@@ -39,7 +39,7 @@ import de.anomic.yacy.logging.Log;public final class HeapWriter {private int keylength; // the length of the primary key- private HandleMap index; // key/seek relation for used records+ private HandleMap index; // key/seek relation for used recordsprivate final File heapFileTMP; // the temporary file of the heap during writingprivate final File heapFileREADY; // the final file of the heap when the file is closedprivate DataOutputStream os; // the output stream where the BLOB is writtendiff --git a/source/de/anomic/kelondro/io/AbstractIOChunks.java b/source/de/anomic/kelondro/io/chunks/AbstractIOChunks.javasimilarity index 99%rename from source/de/anomic/kelondro/io/AbstractIOChunks.javarename to source/de/anomic/kelondro/io/chunks/AbstractIOChunks.javaindex a4415ae51..134c53468 100644--- a/source/de/anomic/kelondro/io/AbstractIOChunks.java+++ b/source/de/anomic/kelondro/io/chunks/AbstractIOChunks.java@@ -20,11 +20,12 @@// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-package de.anomic.kelondro.io;+package de.anomic.kelondro.io.chunks;import java.io.IOException;+public abstract class AbstractIOChunks implements IOChunksInterface {// logging supportdiff --git a/source/de/anomic/kelondro/io/IOChunksInterface.java b/source/de/anomic/kelondro/io/chunks/IOChunksInterface.javasimilarity index 95%rename from source/de/anomic/kelondro/io/IOChunksInterface.javarename to source/de/anomic/kelondro/io/chunks/IOChunksInterface.javaindex 4af232cee..c0e3cf8ad 100644--- a/source/de/anomic/kelondro/io/IOChunksInterface.java+++ b/source/de/anomic/kelondro/io/chunks/IOChunksInterface.java@@ -20,10 +20,12 @@// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-package de.anomic.kelondro.io;+package de.anomic.kelondro.io.chunks;import java.io.IOException;+import de.anomic.kelondro.io.random.Writer;+public interface IOChunksInterface {@@ -31,7 +33,7 @@ public interface IOChunksInterface {public String name();// reference handling- public RandomAccessInterface getRA();+ public Writer getRA();// pseudo-native methods:public long length() throws IOException;diff --git a/source/de/anomic/kelondro/io/RandomAccessIOChunks.java b/source/de/anomic/kelondro/io/chunks/RandomAccessIOChunks.javasimilarity index 91%rename from source/de/anomic/kelondro/io/RandomAccessIOChunks.javarename to source/de/anomic/kelondro/io/chunks/RandomAccessIOChunks.javaindex 668cf061f..ff6e3bef8 100644--- a/source/de/anomic/kelondro/io/RandomAccessIOChunks.java+++ b/source/de/anomic/kelondro/io/chunks/RandomAccessIOChunks.java@@ -20,21 +20,23 @@// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-package de.anomic.kelondro.io;+package de.anomic.kelondro.io.chunks;import java.io.IOException;+import de.anomic.kelondro.io.random.Writer;+public final class RandomAccessIOChunks extends AbstractIOChunks implements IOChunksInterface {- protected RandomAccessInterface ra;+ protected Writer ra;- public RandomAccessIOChunks(final RandomAccessInterface ra, final String name) {+ public RandomAccessIOChunks(final Writer ra, final String name) {this.name = name;this.ra = ra;}- public RandomAccessInterface getRA() {+ public Writer getRA() {return this.ra;}diff --git a/source/de/anomic/kelondro/io/random/AbstractReader.java b/source/de/anomic/kelondro/io/random/AbstractReader.javanew file mode 100644index 000000000..5a27f656e--- /dev/null+++ b/source/de/anomic/kelondro/io/random/AbstractReader.java@@ -0,0 +1,79 @@+// AbstractRandomAccessWriter.java+// -------------------------------+// (C) 2009 by Michael Peter Christen; [email protected]+// first published on http://www.anomic.de+// Frankfurt, Germany, 09.09.2009+//+// $LastChangedDate: 2009-01-30 15:48:11 +0100 (Fr, 30 Jan 2009) $+// $LastChangedRevision: 5539 $+// $LastChangedBy: orbiter $+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.kelondro.io.random;++import java.io.File;+import java.io.IOException;+++public abstract class AbstractReader implements Reader {++ // logging support+ protected String name = null;+ protected File file = null;+ public String name() {+ return name;+ }+ public File file() {+ return file;+ }++ // pseudo-native methods:+ abstract public void readFully(byte[] b, int off, int len) throws IOException;+ abstract public long length() throws IOException;+ abstract public long available() throws IOException;+ abstract public void seek(long pos) throws IOException;+ abstract public void close() throws IOException;+++ // derived methods:+ public byte[] readFully() throws IOException {+ long a = this.available();+ if (a <= 0) return null;+ if (a > Integer.MAX_VALUE) throw new IOException("available too large for a single array");+ final byte[] buffer = new byte[(int) a];+ this.readFully(buffer, 0, (int) a);+ return buffer;+ }++ public short readShort() throws IOException {+ byte[] b = new byte[2];+ this.readFully(b, 0, 2);+ //if ((b[0] | b[1]) < 0) throw new IOException("kelondroAbstractRA.readInt: wrong values; ch1=" + (b[0] & 0xFF) + ", ch2=" + (b[1] & 0xFF));+ return (short) (((b[0] & 0xFF) << 8) | (b[1] & 0xFF));+ }++ public int readInt() throws IOException {+ byte[] b = new byte[4];+ this.readFully(b, 0, 4);+ //if ((b[0] | b[1] | b[2] | b[3]) < 0) throw new IOException("kelondroAbstractRA.readInt: wrong values; ch1=" + (b[0] & 0xFF) + ", ch2=" + (b[1] & 0xFF) + ", ch3=" + (b[2] & 0xFF) + ", ch4=" + (b[3] & 0xFF));+ return (((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16) | ((b[2] & 0xFF) << 8) | (b[3] & 0xFF));+ }++ public long readLong() throws IOException {+ return ((long) (readInt()) << 32) | (readInt() & 0xFFFFFFFFL);+ }++}diff --git a/source/de/anomic/kelondro/io/AbstractRandomAccess.java b/source/de/anomic/kelondro/io/random/AbstractWriter.javasimilarity index 68%rename from source/de/anomic/kelondro/io/AbstractRandomAccess.javarename to source/de/anomic/kelondro/io/random/AbstractWriter.javaindex 3dfecd58f..26095c839 100644--- a/source/de/anomic/kelondro/io/AbstractRandomAccess.java+++ b/source/de/anomic/kelondro/io/random/AbstractWriter.java@@ -1,7 +1,6 @@-// kelondroAbstractRA.java-// ------------------------// part of The Kelondro Database-// (C) by Michael Peter Christen; [email protected]+// AbstractRandomAccessWriter.java+// -------------------------------+// (C) 2004 by Michael Peter Christen; [email protected]// first published on http://www.anomic.de// Frankfurt, Germany, 2004//@@ -23,11 +22,10 @@// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-package de.anomic.kelondro.io;+package de.anomic.kelondro.io.random;import java.io.BufferedReader;import java.io.ByteArrayInputStream;-import java.io.File;import java.io.IOException;import java.io.InputStreamReader;import java.util.HashMap;@@ -36,43 +34,15 @@ import java.util.Map;import de.anomic.kelondro.util.ByteBuffer;-public abstract class AbstractRandomAccess implements RandomAccessInterface {-- // logging support- protected String name = null;- protected File file = null;- public String name() {- return name;- }- public File file() {- return file;- }+public abstract class AbstractWriter extends AbstractReader implements Writer {+// pseudo-native methods:- abstract public void readFully(byte[] b, int off, int len) throws IOException;- abstract public long length() throws IOException;abstract public void setLength(long length) throws IOException;- abstract public long available() throws IOException;abstract public void write(byte[] b, int off, int len) throws IOException;- abstract public void seek(long pos) throws IOException;- abstract public void close() throws IOException;-+// derived methods:- public byte[] readFully() throws IOException {- long a = this.available();- if (a <= 0) return null;- if (a > Integer.MAX_VALUE) throw new IOException("available too large for a single array");- final byte[] buffer = new byte[(int) a];- this.readFully(buffer, 0, (int) a);- return buffer;- }- public short readShort() throws IOException {- byte[] b = new byte[2];- this.readFully(b, 0, 2);- //if ((b[0] | b[1]) < 0) throw new IOException("kelondroAbstractRA.readInt: wrong values; ch1=" + (b[0] & 0xFF) + ", ch2=" + (b[1] & 0xFF));- return (short) (((b[0] & 0xFF) << 8) | (b[1] & 0xFF));- }public void writeShort(final int v) throws IOException {byte[] b = new byte[2];@@ -81,13 +51,6 @@ public abstract class AbstractRandomAccess implements RandomAccessInterface {this.write(b);}- public int readInt() throws IOException {- byte[] b = new byte[4];- this.readFully(b, 0, 4);- //if ((b[0] | b[1] | b[2] | b[3]) < 0) throw new IOException("kelondroAbstractRA.readInt: wrong values; ch1=" + (b[0] & 0xFF) + ", ch2=" + (b[1] & 0xFF) + ", ch3=" + (b[2] & 0xFF) + ", ch4=" + (b[3] & 0xFF));- return (((b[0] & 0xFF) << 24) | ((b[1] & 0xFF) << 16) | ((b[2] & 0xFF) << 8) | (b[3] & 0xFF));- }-public void writeInt(final int v) throws IOException {this.write(int2array(v));}@@ -101,10 +64,6 @@ public abstract class AbstractRandomAccess implements RandomAccessInterface {return b;}- public long readLong() throws IOException {- return ((long) (readInt()) << 32) | (readInt() & 0xFFFFFFFFL);- }-public void writeLong(final long v) throws IOException {byte[] b = new byte[8];b[0] = (byte) ((v >>> 56) & 0xFF);diff --git a/source/de/anomic/kelondro/io/CachedRandomAccess.java b/source/de/anomic/kelondro/io/random/CachedFileWriter.javasimilarity index 93%rename from source/de/anomic/kelondro/io/CachedRandomAccess.javarename to source/de/anomic/kelondro/io/random/CachedFileWriter.javaindex 7d54aa7d1..daafaebbb 100644--- a/source/de/anomic/kelondro/io/CachedRandomAccess.java+++ b/source/de/anomic/kelondro/io/random/CachedFileWriter.java@@ -1,5 +1,5 @@-// kelondroCachedFileRA.java-// -----------------------+// CachedRandomAccessFileWriter.java+// ---------------------------------// part of The Kelondro Database// (C) by Michael Peter Christen; [email protected]// first published on http://yacy.net@@ -20,7 +20,7 @@// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-package de.anomic.kelondro.io;+package de.anomic.kelondro.io.random;import java.io.File;import java.io.FileNotFoundException;@@ -28,14 +28,15 @@ import java.io.IOException;import java.io.RandomAccessFile;-public final class CachedRandomAccess extends AbstractRandomAccess implements RandomAccessInterface {++public final class CachedFileWriter extends AbstractWriter implements Writer {private RandomAccessFile RAFile;private byte[] cache;private long cachestart;private int cachelen;- public CachedRandomAccess(final File file) throws IOException, FileNotFoundException {+ public CachedFileWriter(final File file) throws IOException, FileNotFoundException {this.name = file.getName();this.file = file;this.RAFile = new RandomAccessFile(this.file, "rw");diff --git a/source/de/anomic/kelondro/io/FileRandomAccess.java b/source/de/anomic/kelondro/io/random/FileWriter.javasimilarity index 83%rename from source/de/anomic/kelondro/io/FileRandomAccess.javarename to source/de/anomic/kelondro/io/random/FileWriter.javaindex d25a53655..0b837005f 100644--- a/source/de/anomic/kelondro/io/FileRandomAccess.java+++ b/source/de/anomic/kelondro/io/random/FileWriter.java@@ -1,10 +1,8 @@-// kelondroFileRA.java+// RandomAccessFileWriter.java// ------------------------// part of The Kelondro Database-// (C) by Michael Peter Christen; [email protected]+// (C) 2004-2008 by Michael Peter Christen; [email protected]// first published on http://yacy.net-// Frankfurt, Germany, 2004-2008-// last major change: 09.12.2008+// Frankfurt, Germany, 09.12.2008//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by@@ -20,7 +18,7 @@// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-package de.anomic.kelondro.io;+package de.anomic.kelondro.io.random;import java.io.File;import java.io.FileNotFoundException;@@ -29,11 +27,12 @@ import java.io.RandomAccessFile;import java.util.Map;-public final class FileRandomAccess extends AbstractRandomAccess implements RandomAccessInterface {++public final class FileWriter extends AbstractWriter implements Writer {private RandomAccessFile RAFile;- public FileRandomAccess(final File file) throws IOException, FileNotFoundException {+ public FileWriter(final File file) throws IOException, FileNotFoundException {this.name = file.getName();this.file = file;RAFile = new RandomAccessFile(file, "rw");@@ -79,9 +78,9 @@ public final class FileRandomAccess extends AbstractRandomAccess implements Randpublic static void writeMap(final File f, final Map<String, String> map, final String comment) throws IOException {final File fp = f.getParentFile();if (fp != null) fp.mkdirs();- RandomAccessInterface kra = null;+ Writer kra = null;try {- kra = new CachedRandomAccess(f);+ kra = new CachedFileWriter(f);kra.writeMap(map, comment);kra.close();} finally {@@ -90,9 +89,9 @@ public final class FileRandomAccess extends AbstractRandomAccess implements Rand}public static Map<String, String> readMap(final File f) throws IOException {- RandomAccessInterface kra = null;+ Writer kra = null;try {- kra = new CachedRandomAccess(f);+ kra = new CachedFileWriter(f);final Map<String, String> map = kra.readMap();kra.close();return map;diff --git a/source/de/anomic/kelondro/io/random/Reader.java b/source/de/anomic/kelondro/io/random/Reader.javanew file mode 100644index 000000000..520cf4d1c--- /dev/null+++ b/source/de/anomic/kelondro/io/random/Reader.java@@ -0,0 +1,48 @@+// RandomAccessReader.java+// -----------------------+// (C) 2009 by Michael Peter Christen; [email protected]+// first published on http://yacy.net+// Frankfurt, Germany, 09.09.2009+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.kelondro.io.random;++import java.io.File;+import java.io.IOException;++public interface Reader {++ // logging support+ public String name();+ public File file();++ // pseudo-native methods:+ public long length() throws IOException;+ public long available() throws IOException;++ public void readFully(byte[] b, int off, int len) throws IOException;++ public void seek(long pos) throws IOException;+ public void close() throws IOException;++ // derived methods:+ public byte[] readFully() throws IOException;++ public short readShort() throws IOException;+ public int readInt() throws IOException;+ public long readLong() throws IOException;++}diff --git a/source/de/anomic/kelondro/io/RandomAccessInterface.java b/source/de/anomic/kelondro/io/random/Writer.javasimilarity index 56%rename from source/de/anomic/kelondro/io/RandomAccessInterface.javarename to source/de/anomic/kelondro/io/random/Writer.javaindex 2aae66c5e..edf177bbb 100644--- a/source/de/anomic/kelondro/io/RandomAccessInterface.java+++ b/source/de/anomic/kelondro/io/random/Writer.java@@ -1,10 +1,8 @@-// kelondroRA.java+// RandomAccessWriter.java// ------------------------// part of The Kelondro Database-// (C) by Michael Peter Christen; [email protected]+// (C) 2004 by Michael Peter Christen; [email protected]// first published on http://www.anomic.de-// Frankfurt, Germany, 2004-// last major change: 09.02.2004+// Frankfurt, Germany, 09.02.2004//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by@@ -20,53 +18,24 @@// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-/*- The random access interface for the kelondro database.- kelondro stores data always through the kelondroRecords class,- which in turn also needs a random access file or similar- to store the database structure. To provide more than- ony file - random-access, we need an abstract interface.-*/+package de.anomic.kelondro.io.random;-package de.anomic.kelondro.io;--import java.io.File;import java.io.IOException;import java.util.HashMap;import java.util.Map;-public interface RandomAccessInterface {- // logging support- public String name();- public File file();-+public interface Writer extends Reader {+// pseudo-native methods:- public long length() throws IOException;public void setLength(long length) throws IOException;- public long available() throws IOException;-- public void readFully(byte[] b, int off, int len) throws IOException;-public void write(byte[] b, int off, int len) throws IOException;- public void seek(long pos) throws IOException;- public void close() throws IOException;-// derived methods:- public byte[] readFully() throws IOException;-- public short readShort() throws IOException;public void writeShort(int v) throws IOException;-- public int readInt() throws IOException;public void writeInt(int v) throws IOException;-- public long readLong() throws IOException;public void writeLong(long v) throws IOException;-public void write(byte[] b) throws IOException;-public void writeLine(String line) throws IOException;public void writeMap(Map<String, String> props, String comment) throws IOException;diff --git a/source/de/anomic/kelondro/io/BufferedEcoFS.java b/source/de/anomic/kelondro/io/records/BufferedRecords.javasimilarity index 96%rename from source/de/anomic/kelondro/io/BufferedEcoFS.javarename to source/de/anomic/kelondro/io/records/BufferedRecords.javaindex 08fb73edc..a5bf2d8a0 100644--- a/source/de/anomic/kelondro/io/BufferedEcoFS.java+++ b/source/de/anomic/kelondro/io/records/BufferedRecords.java@@ -1,4 +1,4 @@-// kelondroBufferedEcoFS.java+// BufferedRecords.java// (C) 2008 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany// first published 14.01.2008 on http://yacy.net//@@ -22,7 +22,7 @@// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-package de.anomic.kelondro.io;+package de.anomic.kelondro.io.records;import java.io.File;import java.io.IOException;@@ -39,13 +39,13 @@ import de.anomic.kelondro.util.FileUtils;* That means, each time, an entry is written to the end of the file, it is NOT buffered here,* but possibly buffered in the enclosed kelondroEcoFS*/-public class BufferedEcoFS {+public class BufferedRecords {- private EcoFS efs;+ private Records efs;private final int maxEntries;private final TreeMap<Long, byte[]> buffer;- public BufferedEcoFS(final EcoFS efs, final int maxEntries) {+ public BufferedRecords(final Records efs, final int maxEntries) {this.efs = efs;this.maxEntries = maxEntries;this.buffer = new TreeMap<Long, byte[]>();@@ -144,7 +144,7 @@ public class BufferedEcoFS {final File f = new File(args[0]);if (f.exists()) FileUtils.deletedelete(f);try {- final EcoFS t = new EcoFS(f, 8);+ final Records t = new Records(f, 8);final byte[] b = new byte[8];t.add("01234567".getBytes(), 0);t.add("ABCDEFGH".getBytes(), 0);diff --git a/source/de/anomic/kelondro/io/EcoFS.java b/source/de/anomic/kelondro/io/records/Records.javasimilarity index 99%rename from source/de/anomic/kelondro/io/EcoFS.javarename to source/de/anomic/kelondro/io/records/Records.javaindex 4767a1cce..21cc72deb 100644--- a/source/de/anomic/kelondro/io/EcoFS.java+++ b/source/de/anomic/kelondro/io/records/Records.java@@ -1,4 +1,4 @@-// kelondroEcoFS.java+// Records.java// (C) 2008 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany// first published 14.01.2008 on http://yacy.net//@@ -22,7 +22,7 @@// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA-package de.anomic.kelondro.io;+package de.anomic.kelondro.io.records;import java.io.File;import java.io.FileNotFoundException;@@ -49,7 +49,7 @@ import de.anomic.kelondro.util.MemoryControl;* All access to the file is made with byte[] that are generated outside of this class* This class only references byte[] that are handed over to methods of this class.*/-public class EcoFS {+public class Records {private RandomAccessFile raf;private final File tablefile;@@ -72,7 +72,7 @@ public class EcoFS {private static final int maxWriteBuffer = 16 * 1024;- public EcoFS(final File tablefile, final int recordsize) throws IOException {+ public Records(final File tablefile, final int recordsize) throws IOException {this.tablefile = tablefile;this.recordsize = recordsize;@@ -580,7 +580,7 @@ public class EcoFS {final File f = new File(args[0]);if (f.exists()) FileUtils.deletedelete(f);try {- final EcoFS t = new EcoFS(f, 8);+ final Records t = new Records(f, 8);final byte[] b = new byte[8];t.add("01234567".getBytes(), 0);t.add("ABCDEFGH".getBytes(), 0);diff --git a/source/de/anomic/kelondro/table/Records.java b/source/de/anomic/kelondro/table/Records.javaindex b6ce1a529..159fe9a30 100644--- a/source/de/anomic/kelondro/table/Records.java+++ b/source/de/anomic/kelondro/table/Records.java@@ -41,10 +41,10 @@ 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.FileRandomAccess;-import de.anomic.kelondro.io.IOChunksInterface;-import de.anomic.kelondro.io.RandomAccessInterface;-import de.anomic.kelondro.io.RandomAccessIOChunks;+import de.anomic.kelondro.io.chunks.IOChunksInterface;+import de.anomic.kelondro.io.chunks.RandomAccessIOChunks;+import de.anomic.kelondro.io.random.FileWriter;+import de.anomic.kelondro.io.random.Writer;import de.anomic.kelondro.order.ByteOrder;import de.anomic.kelondro.order.NaturalOrder;import de.anomic.kelondro.util.FileUtils;@@ -351,7 +351,7 @@ public class Records {public static int staticsize(final File file) {if (!(file.exists())) return 0;try {- final RandomAccessInterface ra = new FileRandomAccess(new File(file.getCanonicalPath()));+ final Writer ra = new FileWriter(new File(file.getCanonicalPath()));final IOChunksInterface entryFile = new RandomAccessIOChunks(ra, ra.name());final int used = entryFile.readInt(POS_USEDC); // works only if consistency with file size is given@@ -385,7 +385,7 @@ public class Records {if (file.exists()) {// opens an existing treethis.filename = file.getCanonicalPath();- RandomAccessInterface raf = new FileRandomAccess(new File(this.filename));+ Writer raf = new FileWriter(new File(this.filename));//kelondroRA raf = new kelondroBufferedRA(new kelondroFileRA(this.filename), 1024, 100);//kelondroRA raf = new kelondroCachedRA(new kelondroFileRA(this.filename), 5000000, 1000);//kelondroRA raf = new kelondroNIOFileRA(this.filename, (file.length() < 4000000), 10000);@@ -393,7 +393,7 @@ public class Records {initExistingFile(raf);} else {this.filename = file.getCanonicalPath();- final RandomAccessInterface raf = new FileRandomAccess(new File(this.filename));+ final Writer raf = new FileWriter(new File(this.filename));// kelondroRA raf = new kelondroBufferedRA(new kelondroFileRA(this.filename), 1024, 100);// kelondroRA raf = new kelondroNIOFileRA(this.filename, false, 10000);initNewFile(raf, FHandles, txtProps);@@ -412,16 +412,16 @@ public class Records {}public void clear() throws IOException {- RandomAccessInterface ra = this.entryFile.getRA();+ Writer ra = this.entryFile.getRA();final File f = ra.file();assert f != null;this.entryFile.close();FileUtils.deletedelete(f);- ra = new FileRandomAccess(f);+ ra = new FileWriter(f);initNewFile(ra, this.HANDLES.length, this.TXTPROPS.length);}- private void initNewFile(final RandomAccessInterface ra, final int FHandles, final int txtProps) throws IOException {+ private void initNewFile(final Writer ra, final int FHandles, final int txtProps) throws IOException {// create new Chunked IOthis.entryFile = new RandomAccessIOChunks(ra, ra.name());@@ -518,7 +518,7 @@ public class Records {this.theLogger.fine("KELONDRO DEBUG " + this.filename + ": " + message);}- private void initExistingFile(final RandomAccessInterface ra) throws IOException {+ private void initExistingFile(final Writer ra) throws IOException {// read from Chunked IO//useBuffer = false;/*if (useBuffer) {diff --git a/source/de/anomic/kelondro/table/Table.java b/source/de/anomic/kelondro/table/Table.javaindex 5bdd58adb..4ffe434a0 100644--- a/source/de/anomic/kelondro/table/Table.java+++ b/source/de/anomic/kelondro/table/Table.java@@ -45,8 +45,8 @@ import de.anomic.kelondro.index.RowCollection;import de.anomic.kelondro.index.RowSet;import de.anomic.kelondro.index.ObjectIndex;import de.anomic.kelondro.index.Row.Entry;-import de.anomic.kelondro.io.BufferedEcoFS;-import de.anomic.kelondro.io.EcoFS;+import de.anomic.kelondro.io.records.BufferedRecords;+import de.anomic.kelondro.io.records.Records;import de.anomic.kelondro.order.CloneableIterator;import de.anomic.kelondro.order.NaturalOrder;import de.anomic.kelondro.util.FileUtils;@@ -74,7 +74,7 @@ public class Table implements ObjectIndex {private int fail;private final int buffersize;protected HandleMap index;- protected BufferedEcoFS file;+ protected BufferedRecords file;protected Row rowdef;protected File tablefile;protected RowSet table;@@ -180,7 +180,7 @@ public class Table implements ObjectIndex {}// open the file- this.file = new BufferedEcoFS(new EcoFS(tablefile, rowdef.objectsize), this.buffersize);+ this.file = new BufferedRecords(new Records(tablefile, rowdef.objectsize), this.buffersize);// clean up the file by cleaning badly formed entriesint errorc = errors.size();@@ -245,7 +245,7 @@ public class Table implements ObjectIndex {public static long tableSize(final File tablefile, final int recordsize) {// returns number of records in table- return EcoFS.tableSize(tablefile, recordsize);+ return Records.tableSize(tablefile, recordsize);}public static final Iterator<String> filenames() {@@ -611,7 +611,7 @@ public class Table implements ObjectIndex {// open an existing table filetry {- this.file = new BufferedEcoFS(new EcoFS(f, rowdef.objectsize), this.buffersize);+ this.file = new BufferedRecords(new Records(f, rowdef.objectsize), this.buffersize);} catch (final FileNotFoundException e) {// should never happene.printStackTrace();