Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

better handling of array files of length 0

orbiter65b66c2c18b5
diff --git a/source/de/anomic/kelondro/blob/ArrayStack.java b/source/de/anomic/kelondro/blob/ArrayStack.java
index 5f036702b..3568fbb73 100755
--- a/source/de/anomic/kelondro/blob/ArrayStack.java
+++ b/source/de/anomic/kelondro/blob/ArrayStack.java
@@ -149,9 +149,13 @@ public class ArrayStack implements BLOB {
deletions = false;
for (int i = 0; i < files.length; i++) {
if (files[i].length() >= 19 && files[i].endsWith(".blob")) {
- try {
+ File f = new File(heapLocation, files[i]);
+ if (f.length() == 0) {
+ f.delete();
+ deletions = true;
+ } else try {
d = DateFormatter.parseShortSecond(files[i].substring(0, 14));
- new File(heapLocation, files[i]).renameTo(newBLOB(d));
+ f.renameTo(newBLOB(d));
deletions = true;
} catch (ParseException e) {continue;}
}
@@ -649,6 +653,20 @@ public class ArrayStack implements BLOB {
return -1;
}
+ /**
+ * retrieve the sizes of all BLOB
+ * @param key
+ * @return the size of the BLOB or -1 if the BLOB does not exist
+ * @throws IOException
+ */
+ public synchronized long lengthAdd(byte[] key) throws IOException {
+ long l = 0;
+ for (blobItem bi: blobs) {
+ l += bi.blob.length(key);
+ }
+ return l;
+ }
+
/**
* write a whole byte array as BLOB to the table
* @param key the primary key