diff --git a/source/de/anomic/kelondro/io/records/Records.java b/source/de/anomic/kelondro/io/records/Records.java index 21cc72deb..b5b4a4431 100644 --- a/source/de/anomic/kelondro/io/records/Records.java +++ b/source/de/anomic/kelondro/io/records/Records.java @@ -34,8 +34,9 @@ import de.anomic.kelondro.util.FileUtils; import de.anomic.kelondro.util.MemoryControl; /** - * The EcoFS is a flat file with records of fixed length. The file does not contain - * any meta information and the first record starts right at file position 0 + * The Records data structure is a flat file with records of fixed length. + * The file does not contain any meta information and the first record starts + * right at file position 0. * The access rules are in such a way that a minimum of IO operations are necessary * Two caches provide a mirror to content in the file: a read cache and a write buffer * The read cache contains a number of entries from the file; a mirror that moves @@ -126,10 +127,10 @@ public class Records { * @param recordsize * @return number of records in table */ - public static long tableSize(final File tablefile, final long recordsize) { + public static long tableSize(final File tablefile, final long recordsize) throws IOException { if (!tablefile.exists()) return 0; final long size = tablefile.length(); - assert size % recordsize == 0; + if (size % recordsize != 0) throw new IOException("wrong file size: file = " + tablefile + ", size = " + size + ", recordsize = " + recordsize); return size / recordsize; } diff --git a/source/de/anomic/kelondro/table/SplitTable.java b/source/de/anomic/kelondro/table/SplitTable.java index c2abc477c..8a77edcbc 100644 --- a/source/de/anomic/kelondro/table/SplitTable.java +++ b/source/de/anomic/kelondro/table/SplitTable.java @@ -162,10 +162,14 @@ public class SplitTable implements ObjectIndex { maxtime = time; } - ram = Table.staticRAMIndexNeed(f, rowdef); - if (ram > 0) { - t.put(tablefile[i], Long.valueOf(ram)); - sum += ram; + try { + ram = Table.staticRAMIndexNeed(f, rowdef); + if (ram > 0) { + t.put(tablefile[i], Long.valueOf(ram)); + sum += ram; + } + } catch (IOException e) { + Log.logWarning("SplitTable", "file " + f.toString() + " appears to be corrupted: " + e.getMessage()); } } } diff --git a/source/de/anomic/kelondro/table/Table.java b/source/de/anomic/kelondro/table/Table.java index d9e04d78a..c1c7649d7 100644 --- a/source/de/anomic/kelondro/table/Table.java +++ b/source/de/anomic/kelondro/table/Table.java @@ -243,7 +243,7 @@ public class Table implements ObjectIndex { return MemoryControl.available() < minmemremaining; } - public static long tableSize(final File tablefile, final int recordsize) { + public static long tableSize(final File tablefile, final int recordsize) throws IOException { // returns number of records in table return Records.tableSize(tablefile, recordsize); } @@ -277,7 +277,7 @@ public class Table implements ObjectIndex { return this.table != null; } - public static int staticRAMIndexNeed(final File f, final Row rowdef) { + public static int staticRAMIndexNeed(final File f, final Row rowdef) throws IOException { return (int) (((long)(rowdef.primaryKeyLength + 4)) * tableSize(f, rowdef.objectsize) * RowCollection.growfactor100 / 100L); }