fixed bug with decompression of index abstracts

this fixes a problem that occurred when searching for several words

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3968 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 924ae39170
commit 5444b07674

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

@ -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) {

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

Loading…
Cancel
Save