tried to fix another eco bug

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4429 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 08a12e9bb5
commit cd3e0d6f03

@ -60,7 +60,7 @@ public class LogStatistics_p {
private static final String RESULTS = "results_"; private static final String RESULTS = "results_";
@SuppressWarnings("unchecked") @SuppressWarnings({ "unchecked", "boxing" })
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
@ -89,7 +89,7 @@ public class LogStatistics_p {
prop.put("results", "1"); prop.put("results", "1");
String[] t; String[] t;
float l; float l;
prop.put(RESULTS + LogParserPLASMA.DHT_DISTANCE_AVERAGE, (String) r.get(LogParserPLASMA.DHT_DISTANCE_AVERAGE)); prop.put(RESULTS + LogParserPLASMA.DHT_DISTANCE_AVERAGE, (Double) r.get(LogParserPLASMA.DHT_DISTANCE_AVERAGE));
prop.put(RESULTS + LogParserPLASMA.DHT_DISTANCE_MAX, (String) r.get(LogParserPLASMA.DHT_DISTANCE_MAX)); prop.put(RESULTS + LogParserPLASMA.DHT_DISTANCE_MAX, (String) r.get(LogParserPLASMA.DHT_DISTANCE_MAX));
prop.put(RESULTS + LogParserPLASMA.DHT_DISTANCE_MIN, (String) r.get(LogParserPLASMA.DHT_DISTANCE_MIN)); prop.put(RESULTS + LogParserPLASMA.DHT_DISTANCE_MIN, (String) r.get(LogParserPLASMA.DHT_DISTANCE_MIN));
prop.put(RESULTS + LogParserPLASMA.DHT_REJECTED, (String) r.get(LogParserPLASMA.DHT_REJECTED)); prop.put(RESULTS + LogParserPLASMA.DHT_REJECTED, (String) r.get(LogParserPLASMA.DHT_REJECTED));

@ -93,7 +93,7 @@ public class kelondroBufferedEcoFS {
public synchronized void put(long index, byte[] b, int start) throws IOException { public synchronized void put(long index, byte[] b, int start) throws IOException {
assert b.length - start >= efs.recordsize; assert b.length - start >= efs.recordsize;
if (index > size()) throw new IndexOutOfBoundsException("kelondroEcoFS.put(" + index + ") outside bounds (" + this.size() + ")"); if (index > size()) throw new IndexOutOfBoundsException("kelondroBufferedEcoFS.put(" + index + ") outside bounds (" + this.size() + ")");
if (index == efs.size()) { if (index == efs.size()) {
efs.put(index, b, start); efs.put(index, b, start);
} else { } else {
@ -107,7 +107,7 @@ public class kelondroBufferedEcoFS {
public synchronized void add(byte[] b, int start) throws IOException { public synchronized void add(byte[] b, int start) throws IOException {
put(size(), b, start); put(size(), b, start);
} }
/*
public synchronized void clean(long index, byte[] b, int start) throws IOException { public synchronized void clean(long index, byte[] b, int start) throws IOException {
assert b.length - start >= efs.recordsize; assert b.length - start >= efs.recordsize;
if (index >= size()) throw new IndexOutOfBoundsException("kelondroBufferedEcoFS.clean(" + index + ") outside bounds (" + this.size() + ")"); if (index >= size()) throw new IndexOutOfBoundsException("kelondroBufferedEcoFS.clean(" + index + ") outside bounds (" + this.size() + ")");
@ -126,24 +126,23 @@ public class kelondroBufferedEcoFS {
buffer.remove(new Long(index)); buffer.remove(new Long(index));
efs.clean(index); efs.clean(index);
} }
*/
public synchronized void cleanLast(byte[] b, int start) throws IOException { public synchronized void cleanLast(byte[] b, int start) throws IOException {
assert b.length - start >= efs.recordsize; assert b.length - start >= efs.recordsize;
Long i = new Long(size() - 1); Long i = new Long(size() - 1);
byte[] bb = buffer.get(i); byte[] bb = buffer.remove(i);
if (bb == null) { if (bb == null) {
efs.clean(i.intValue(), b, start); efs.cleanLast(b, start);
} else { } else {
System.arraycopy(bb, 0, b, start, efs.recordsize); System.arraycopy(bb, 0, b, start, efs.recordsize);
buffer.remove(i); efs.cleanLast();
efs.clean(i.intValue());
} }
} }
public synchronized void cleanLast() throws IOException { public synchronized void cleanLast() throws IOException {
Long i = new Long(size() - 1); Long i = new Long(size() - 1);
buffer.remove(i); buffer.remove(i);
efs.clean(i.intValue()); efs.cleanLast();
} }
} }

@ -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;

@ -375,7 +375,7 @@ public class kelondroEcoTable implements kelondroIndex {
byte[] p = new byte[rowdef.objectsize]; byte[] p = new byte[rowdef.objectsize];
if (table == null) { if (table == null) {
if (i == index.size() - 1) { if (i == index.size() - 1) {
file.clean(i); file.cleanLast();
} else { } else {
file.cleanLast(p, 0); file.cleanLast(p, 0);
file.put(i, p, 0); file.put(i, p, 0);
@ -387,7 +387,7 @@ public class kelondroEcoTable implements kelondroIndex {
if (i == index.size() - 1) { if (i == index.size() - 1) {
// special handling if the entry is the last entry in the file // special handling if the entry is the last entry in the file
table.removeRow(i, false); table.removeRow(i, false);
file.clean(i); file.cleanLast();
} else { } else {
// switch values // switch values
kelondroRow.Entry te = table.removeOne(); kelondroRow.Entry te = table.removeOne();
@ -413,12 +413,17 @@ public class kelondroEcoTable implements kelondroIndex {
byte[] b = new byte[rowdef.objectsize]; byte[] b = new byte[rowdef.objectsize];
byte[] p = new byte[rowdef.objectsize]; byte[] p = new byte[rowdef.objectsize];
int sb = index.size(); int sb = index.size();
int ix;
assert i < index.size();
if (table == null) { if (table == null) {
if (i == index.size() - 1) { if (i == index.size() - 1) {
index.removei(key); ix = index.removei(key);
file.clean(i, b, 0); assert ix == i;
file.cleanLast(b, 0);
} else { } else {
index.removei(key); assert i < index.size() - 1;
ix = index.removei(key);
assert ix == i;
file.get(i, b, 0); file.get(i, b, 0);
file.cleanLast(p, 0); file.cleanLast(p, 0);
file.put(i, p, 0); file.put(i, p, 0);
@ -437,7 +442,7 @@ public class kelondroEcoTable implements kelondroIndex {
// special handling if the entry is the last entry in the file // special handling if the entry is the last entry in the file
index.removei(key); index.removei(key);
table.removeRow(i, false); table.removeRow(i, false);
file.clean(i); file.cleanLast();
} else { } else {
// switch values // switch values
index.removei(key); index.removei(key);

Loading…
Cancel
Save