|
|
@ -225,10 +225,12 @@ public class kelondroEcoFS {
|
|
|
|
assert b.length - start >= this.recordsize;
|
|
|
|
assert b.length - start >= this.recordsize;
|
|
|
|
if (index > size()) throw new IndexOutOfBoundsException("kelondroEcoFS.put(" + index + ") outside bounds (" + this.size() + ")");
|
|
|
|
if (index > size()) throw new IndexOutOfBoundsException("kelondroEcoFS.put(" + index + ") outside bounds (" + this.size() + ")");
|
|
|
|
// check if this is an empty entry
|
|
|
|
// check if this is an empty entry
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (isClean(b , start, this.recordsize)) {
|
|
|
|
if (isClean(b , start, this.recordsize)) {
|
|
|
|
clean(index);
|
|
|
|
clean(index);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
// check if index is inside of cache
|
|
|
|
// check if index is inside of cache
|
|
|
|
int p = inCache(index);
|
|
|
|
int p = inCache(index);
|
|
|
|
int q = (p >= 0) ? -1 : inBuffer(index);
|
|
|
|
int q = (p >= 0) ? -1 : inBuffer(index);
|
|
|
@ -304,7 +306,7 @@ public class kelondroEcoFS {
|
|
|
|
assert false;
|
|
|
|
assert false;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
public synchronized void clean(long index, byte[] b, int start) throws IOException {
|
|
|
|
public synchronized void clean(long index, byte[] b, int start) throws IOException {
|
|
|
|
// removes an entry by cleaning (writing zero bytes to the file)
|
|
|
|
// removes an entry by cleaning (writing zero bytes to the file)
|
|
|
|
// the entry that had been at the specific place before is copied to the given array b
|
|
|
|
// the entry that had been at the specific place before is copied to the given array b
|
|
|
@ -376,7 +378,7 @@ public class kelondroEcoFS {
|
|
|
|
raf.seek((long) index * (long) this.recordsize);
|
|
|
|
raf.seek((long) index * (long) this.recordsize);
|
|
|
|
raf.write(zero, 0, this.recordsize);
|
|
|
|
raf.write(zero, 0, this.recordsize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
public synchronized void cleanLast(byte[] b, int start) throws IOException {
|
|
|
|
public synchronized void cleanLast(byte[] b, int start) throws IOException {
|
|
|
|
cleanLast0(b, start);
|
|
|
|
cleanLast0(b, start);
|
|
|
|
long i;
|
|
|
|
long i;
|
|
|
@ -472,7 +474,7 @@ public class kelondroEcoFS {
|
|
|
|
t.add("=======2".getBytes(), 0);
|
|
|
|
t.add("=======2".getBytes(), 0);
|
|
|
|
t.cleanLast(b, 0);
|
|
|
|
t.cleanLast(b, 0);
|
|
|
|
System.out.println(new String(b));
|
|
|
|
System.out.println(new String(b));
|
|
|
|
t.clean(2, b, 0);
|
|
|
|
//t.clean(2, b, 0);
|
|
|
|
System.out.println(new String(b));
|
|
|
|
System.out.println(new String(b));
|
|
|
|
t.get(1, b, 0);
|
|
|
|
t.get(1, b, 0);
|
|
|
|
System.out.println(new String(b));
|
|
|
|
System.out.println(new String(b));
|
|
|
@ -484,7 +486,7 @@ public class kelondroEcoFS {
|
|
|
|
t.get(4, b, 0);
|
|
|
|
t.get(4, b, 0);
|
|
|
|
System.out.println(new String(b));
|
|
|
|
System.out.println(new String(b));
|
|
|
|
System.out.println("size = " + t.size());
|
|
|
|
System.out.println("size = " + t.size());
|
|
|
|
t.clean(t.size() - 2);
|
|
|
|
//t.clean(t.size() - 2);
|
|
|
|
t.cleanLast();
|
|
|
|
t.cleanLast();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
long c = 0;
|
|
|
|
long c = 0;
|
|
|
|