Skip to content

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

fixed bug with decompression of index abstracts this fixes a problem that occurred when searching for several words

orbiter5444b0767460
diff --git a/source/de/anomic/plasma/plasmaURL.java b/source/de/anomic/plasma/plasmaURL.java
index 4c7d7dffb..e4fc7b257 100644
--- a/source/de/anomic/plasma/plasmaURL.java
+++ b/source/de/anomic/plasma/plasmaURL.java
@@ -589,7 +589,6 @@ public class plasmaURL {
bb.append(',');
}
bb.append('}');
- bb.trim();
return bb;
}
@@ -597,12 +596,14 @@ public class plasmaURL {
// target is a mapping from url-hashes to a string of peer-hashes
if ((ci.byteAt(0) == '{') && (ci.byteAt(ci.length() - 1) == '}')) {
//System.out.println("DEBUG-DECOMPRESS: input is " + ci.toString());
- ci = ci.trim(1, ci.length() - 1);
+ ci = ci.trim(1, ci.length() - 2);
String dom, url, peers;
while ((ci.length() >= 13) && (ci.byteAt(6) == ':')) {
+ assert ci.length() >= 6 : "ci.length() = " + ci.length();
dom = ci.toString(0, 6);
ci.trim(7);
while ((ci.length() > 0) && (ci.byteAt(0) != ',')) {
+ assert ci.length() >= 6 : "ci.length() = " + ci.length();
url = ci.toString(0, 6) + dom;
ci.trim(6);
peers = (String) target.get(url);
diff --git a/source/de/anomic/server/serverByteBuffer.java b/source/de/anomic/server/serverByteBuffer.java
index a61408f2c..ed1c53f07 100644
--- a/source/de/anomic/server/serverByteBuffer.java
+++ b/source/de/anomic/server/serverByteBuffer.java
@@ -307,37 +307,25 @@ public final class serverByteBuffer extends OutputStream {
}
public serverByteBuffer trim(int start) {
- // the end value is outside (+1) of the wanted target array
- if (start > length) throw new IndexOutOfBoundsException("trim: start > length");
- offset = offset + start;
- length = length - start;
+ trim(start, this.length - start);
return this;
}
public serverByteBuffer trim(int start, int len) {
- // the end value is outside (+1) of the wanted target array
- if (start > length) throw new IndexOutOfBoundsException("trim: start > length");
- if (start + len > length) throw new IndexOutOfBoundsException("trim: start + len > length");
- offset = offset + start;
- length = len;
+ if (start + len > this.length) throw new IndexOutOfBoundsException("trim: start + len > length; this.offset = " + this.offset + ", this.length = " + this.length + ", start = " + start + ", len = " + len);
+ this.offset = this.offset + start;
+ this.length = len;
return this;
}
public serverByteBuffer trim() {
int l = 0;
- while ((l < length) && (buffer[offset + l] <= 32)) l++;
- int r = length;
- int u;
- while ((r > 0) && (buffer[offset + r - 1] <= 32)) {
- u = isUTF8char(r - 1);
- if (u > 0) {
- r += u - 1;
- break;
- }
- r--;
+ while ((l < length) && (buffer[offset + l] <= 32)) {
+ l++;
}
- if (l > r) r = l;
- return trim(l, r - l);
+ int r = length - 1;
+ while ((r > l) && (buffer[offset + r] <= 32)) r--;
+ return trim(l, r - l + 1);
}
public int isUTF8char(int start) {
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 473e95bb6..4e0b15462 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -529,7 +529,7 @@ public final class yacyClient {
singleAbstract = (TreeMap) abstractCache.get(wordhash); // a mapping from url-hashes to a string of peer-hashes
if (singleAbstract == null) singleAbstract = new TreeMap();
ci = new serverByteBuffer(((String) entry.getValue()).getBytes());
- System.out.println("DEBUG-ABSTRACTFETCH: for word hash " + wordhash + " received " + ci.toString());
+ //System.out.println("DEBUG-ABSTRACTFETCH: for word hash " + wordhash + " received " + ci.toString());
plasmaURL.decompressIndex(singleAbstract, ci, target.hash);
abstractCache.put(wordhash, singleAbstract);
}