corrupted files are ignored

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6339 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent efa7fb34f0
commit e4797ebcde

@ -34,8 +34,9 @@ import de.anomic.kelondro.util.FileUtils;
import de.anomic.kelondro.util.MemoryControl; import de.anomic.kelondro.util.MemoryControl;
/** /**
* The EcoFS is a flat file with records of fixed length. The file does not contain * The Records data structure is a flat file with records of fixed length.
* any meta information and the first record starts right at file position 0 * 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 * 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 * 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 * The read cache contains a number of entries from the file; a mirror that moves
@ -126,10 +127,10 @@ public class Records {
* @param recordsize * @param recordsize
* @return number of records in table * @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; if (!tablefile.exists()) return 0;
final long size = tablefile.length(); 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; return size / recordsize;
} }

@ -162,10 +162,14 @@ public class SplitTable implements ObjectIndex {
maxtime = time; maxtime = time;
} }
ram = Table.staticRAMIndexNeed(f, rowdef); try {
if (ram > 0) { ram = Table.staticRAMIndexNeed(f, rowdef);
t.put(tablefile[i], Long.valueOf(ram)); if (ram > 0) {
sum += ram; t.put(tablefile[i], Long.valueOf(ram));
sum += ram;
}
} catch (IOException e) {
Log.logWarning("SplitTable", "file " + f.toString() + " appears to be corrupted: " + e.getMessage());
} }
} }
} }

@ -243,7 +243,7 @@ public class Table implements ObjectIndex {
return MemoryControl.available() < minmemremaining; 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 // returns number of records in table
return Records.tableSize(tablefile, recordsize); return Records.tableSize(tablefile, recordsize);
} }
@ -277,7 +277,7 @@ public class Table implements ObjectIndex {
return this.table != null; 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); return (int) (((long)(rowdef.primaryKeyLength + 4)) * tableSize(f, rowdef.objectsize) * RowCollection.growfactor100 / 100L);
} }

Loading…
Cancel
Save