- fix for LOG path generation when the DATA/LOG does not exists (fix for bug introduced in SVN 4923)

- some more/better asserts
- slight performance enhancements in remove method in index management. Works for all who do not run using asserts (the majority)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4928 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 877299cc74
commit 31efb8fbee

@ -137,11 +137,13 @@ public class kelondroRAMIndex implements kelondroIndex {
// if the new entry is within the initialization part, just delete it // if the new entry is within the initialization part, just delete it
kelondroRow.Entry indexentry = index0.remove(key, keepOrder); kelondroRow.Entry indexentry = index0.remove(key, keepOrder);
if (indexentry != null) { if (indexentry != null) {
assert index0.remove(key, true) == null; // check if remove worked assert index0.get(key) == null; // check if remove worked
return indexentry; return indexentry;
} }
// else remove it from the index1 // else remove it from the index1
return index1.remove(key, keepOrder); kelondroRow.Entry removed = index1.remove(key, keepOrder);
assert index1.get(key) == null : "removed " + ((removed == null) ? " is null" : " is not null") + ", and index entry still exists"; // check if remove worked
return removed;
} }
public synchronized kelondroRow.Entry removeOne() { public synchronized kelondroRow.Entry removeOne() {

@ -269,6 +269,7 @@ public class kelondroRowCollection {
assert (index >= 0) : "get: access with index " + index + " is below zero"; assert (index >= 0) : "get: access with index " + index + " is below zero";
assert (index < chunkcount) : "get: access with index " + index + " is above chunkcount " + chunkcount + "; sortBound = " + sortBound; assert (index < chunkcount) : "get: access with index " + index + " is above chunkcount " + chunkcount + "; sortBound = " + sortBound;
assert (index * rowdef.objectsize < chunkcache.length); assert (index * rowdef.objectsize < chunkcache.length);
assert sortBound <= chunkcount : "sortBound = " + sortBound + ", chunkcount = " + chunkcount;
if ((chunkcache == null) || (rowdef == null)) return null; // case may appear during shutdown if ((chunkcache == null) || (rowdef == null)) return null; // case may appear during shutdown
kelondroRow.Entry entry; kelondroRow.Entry entry;
int addr = index * rowdef.objectsize; int addr = index * rowdef.objectsize;
@ -341,19 +342,6 @@ public class kelondroRowCollection {
this.lastTimeWrote = System.currentTimeMillis(); this.lastTimeWrote = System.currentTimeMillis();
return true; return true;
} }
/*
private static boolean bugappearance(byte[] a, int astart, int alength) {
// check strange appearances of '@[B', which is not a b64-value or any other hash fragment
if (astart + 3 > alength) return false;
loop: for (int i = astart; i <= alength - 3; i++) {
if (a[i ] != 64) continue loop;
if (a[i + 1] != 91) continue loop;
if (a[i + 2] != 66) continue loop;
return true;
}
return false;
}
*/
public synchronized final void addAllUnique(kelondroRowCollection c) { public synchronized final void addAllUnique(kelondroRowCollection c) {
if (c == null) return; if (c == null) return;
@ -380,11 +368,12 @@ public class kelondroRowCollection {
assert sortBound <= chunkcount : "sortBound = " + sortBound + ", chunkcount = " + chunkcount; assert sortBound <= chunkcount : "sortBound = " + sortBound + ", chunkcount = " + chunkcount;
if (keepOrder && (p < sortBound)) { if (keepOrder && (p < sortBound)) {
// remove by shift (quite expensive for big collections) // remove by shift (quite expensive for big collections)
int addr = p * this.rowdef.objectsize;
System.arraycopy( System.arraycopy(
chunkcache, (p + 1) * this.rowdef.objectsize, chunkcache, addr + this.rowdef.objectsize,
chunkcache, p * this.rowdef.objectsize, chunkcache, addr,
(chunkcount - p - 1) * this.rowdef.objectsize); (chunkcount - p - 1) * this.rowdef.objectsize);
sortBound--; sortBound--; // this is only correct if p < sortBound, but this was already checked above
} else { } else {
// remove by copying the top-element to the remove position // remove by copying the top-element to the remove position
if (p != chunkcount - 1) { if (p != chunkcount - 1) {
@ -395,7 +384,7 @@ public class kelondroRowCollection {
} }
// we moved the last element to the remove position: (p+1)st element // we moved the last element to the remove position: (p+1)st element
// only the first p elements keep their order (element p is already outside the order) // only the first p elements keep their order (element p is already outside the order)
if (sortBound >= p) sortBound = p; if (sortBound > p) sortBound = p;
} }
chunkcount--; chunkcount--;
this.lastTimeWrote = System.currentTimeMillis(); this.lastTimeWrote = System.currentTimeMillis();
@ -944,9 +933,9 @@ public class kelondroRowCollection {
System.out.println("uniq d : " + (t6 - t5) + " nanoseconds, " + d(testsize, (t6 - t5)) + " entries/nanoseconds"); System.out.println("uniq d : " + (t6 - t5) + " nanoseconds, " + d(testsize, (t6 - t5)) + " entries/nanoseconds");
random = new Random(0); random = new Random(0);
kelondroRowSet e = new kelondroRowSet(r, testsize); kelondroRowSet e = new kelondroRowSet(r, testsize);
/*for (int i = 0; i < testsize; i++) { for (int i = 0; i < testsize; i++) {
//e.put(r.newEntry(randomHash().getBytes())); e.put(r.newEntry(randomHash().getBytes()));
}*/ }
long t7 = System.nanoTime(); long t7 = System.nanoTime();
System.out.println("create e : " + (t7 - t6) + " nanoseconds, " + d(testsize, (t7 - t6)) + " entries/nanoseconds"); System.out.println("create e : " + (t7 - t6) + " nanoseconds, " + d(testsize, (t7 - t6)) + " entries/nanoseconds");
e.sort(); e.sort();
@ -967,13 +956,15 @@ public class kelondroRowCollection {
random = new Random(0); random = new Random(0);
boolean allfound = true; boolean allfound = true;
for (int i = 0; i < testsize; i++) { for (int i = 0; i < testsize; i++) {
if (e.get(randomHash().getBytes()) == null) { String rh = randomHash();
if (e.get(rh.getBytes()) == null) {
allfound = false; allfound = false;
System.out.println("not found hash " + rh + " at attempt " + i);
break; break;
} }
} }
long t13 = System.currentTimeMillis(); long t13 = System.nanoTime();
System.out.println("e allfound = " + ((allfound) ? "true" : "false") + ": " + (t13 - t12) + " milliseconds"); System.out.println("e allfound = " + ((allfound) ? "true" : "false") + ": " + (t13 - t12) + " nanoseconds");
boolean noghosts = true; boolean noghosts = true;
for (int i = 0; i < testsize; i++) { for (int i = 0; i < testsize; i++) {
if (e.get(randomHash().getBytes()) != null) { if (e.get(randomHash().getBytes()) != null) {
@ -981,8 +972,8 @@ public class kelondroRowCollection {
break; break;
} }
} }
long t14 = System.currentTimeMillis(); long t14 = System.nanoTime();
System.out.println("e noghosts = " + ((noghosts) ? "true" : "false") + ": " + (t14 - t13) + " milliseconds"); System.out.println("e noghosts = " + ((noghosts) ? "true" : "false") + ": " + (t14 - t13) + " nanoseconds");
System.out.println("Result size: c = " + c.size() + ", d = " + d.size() + ", e = " + e.size()); System.out.println("Result size: c = " + c.size() + ", d = " + d.size() + ", e = " + e.size());
System.out.println(); System.out.println();
if (sortingthreadexecutor != null) sortingthreadexecutor.shutdown(); if (sortingthreadexecutor != null) sortingthreadexecutor.shutdown();

@ -162,9 +162,9 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
kelondroRow.Entry entry = super.get(index, true); kelondroRow.Entry entry = super.get(index, true);
super.removeRow(index, keepOrder); super.removeRow(index, keepOrder);
//System.out.println("remove: chunk found at index position (after remove) " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * index, length) + ", searchkey=" + serverLog.arrayList(a, start, length)); //System.out.println("remove: chunk found at index position (after remove) " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * index, length) + ", searchkey=" + serverLog.arrayList(a, start, length));
int findagainindex = find(a, start, length); int findagainindex = 0;
//System.out.println("kelondroRowSet.remove"); //System.out.println("kelondroRowSet.remove");
assert findagainindex < 0 : "remove: chunk found again at index position (after remove) " + findagainindex + ", index(before) = " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize * findagainindex, length) + ", searchkey=" + serverLog.arrayList(a, start, length); // check if the remove worked assert (findagainindex = find(a, start, length)) < 0 : "remove: chunk found again at index position (after remove) " + findagainindex + ", index(before) = " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize * findagainindex, length) + ", searchkey=" + serverLog.arrayList(a, start, length); // check if the remove worked
return entry; return entry;
} }

@ -198,16 +198,16 @@ public final class yacy {
} }
// setting up logging // setting up logging
f = new File(homePath, "DATA/LOG/");
if (!f.exists()) f.mkdirs();
f = new File(homePath, "DATA/LOG/yacy.logging"); f = new File(homePath, "DATA/LOG/yacy.logging");
final File logPath =new File(f.getPath());
if (!logPath.exists()) logPath.mkdirs();
if (!f.exists()) try { if (!f.exists()) try {
serverFileUtils.copy(new File(homePath, "yacy.logging"), f); serverFileUtils.copy(new File(homePath, "yacy.logging"), f);
}catch (IOException e){ } catch (IOException e){
System.out.println("could not copy yacy.logging"); System.out.println("could not copy yacy.logging");
} }
try{ try{
serverLog.configureLogging(homePath, f); serverLog.configureLogging(homePath, new File(homePath, "DATA/LOG/yacy.logging"));
} catch (IOException e) { } catch (IOException e) {
System.out.println("could not find logging properties in homePath=" + homePath); System.out.println("could not find logging properties in homePath=" + homePath);
e.printStackTrace(); e.printStackTrace();

Loading…
Cancel
Save