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.append('}'); bb.append('}');
bb.trim();
return bb; return bb;
} }
@ -597,12 +596,14 @@ public class plasmaURL {
// target is a mapping from url-hashes to a string of peer-hashes // target is a mapping from url-hashes to a string of peer-hashes
if ((ci.byteAt(0) == '{') && (ci.byteAt(ci.length() - 1) == '}')) { if ((ci.byteAt(0) == '{') && (ci.byteAt(ci.length() - 1) == '}')) {
//System.out.println("DEBUG-DECOMPRESS: input is " + ci.toString()); //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; String dom, url, peers;
while ((ci.length() >= 13) && (ci.byteAt(6) == ':')) { while ((ci.length() >= 13) && (ci.byteAt(6) == ':')) {
assert ci.length() >= 6 : "ci.length() = " + ci.length();
dom = ci.toString(0, 6); dom = ci.toString(0, 6);
ci.trim(7); ci.trim(7);
while ((ci.length() > 0) && (ci.byteAt(0) != ',')) { while ((ci.length() > 0) && (ci.byteAt(0) != ',')) {
assert ci.length() >= 6 : "ci.length() = " + ci.length();
url = ci.toString(0, 6) + dom; url = ci.toString(0, 6) + dom;
ci.trim(6); ci.trim(6);
peers = (String) target.get(url); peers = (String) target.get(url);

@ -307,37 +307,25 @@ public final class serverByteBuffer extends OutputStream {
} }
public serverByteBuffer trim(int start) { public serverByteBuffer trim(int start) {
// the end value is outside (+1) of the wanted target array trim(start, this.length - start);
if (start > length) throw new IndexOutOfBoundsException("trim: start > length");
offset = offset + start;
length = length - start;
return this; return this;
} }
public serverByteBuffer trim(int start, int len) { public serverByteBuffer trim(int start, int len) {
// the end value is outside (+1) of the wanted target array if (start + len > this.length) throw new IndexOutOfBoundsException("trim: start + len > length; this.offset = " + this.offset + ", this.length = " + this.length + ", start = " + start + ", len = " + len);
if (start > length) throw new IndexOutOfBoundsException("trim: start > length"); this.offset = this.offset + start;
if (start + len > length) throw new IndexOutOfBoundsException("trim: start + len > length"); this.length = len;
offset = offset + start;
length = len;
return this; return this;
} }
public serverByteBuffer trim() { public serverByteBuffer trim() {
int l = 0; int l = 0;
while ((l < length) && (buffer[offset + l] <= 32)) l++; while ((l < length) && (buffer[offset + l] <= 32)) {
int r = length; l++;
int u;
while ((r > 0) && (buffer[offset + r - 1] <= 32)) {
u = isUTF8char(r - 1);
if (u > 0) {
r += u - 1;
break;
}
r--;
} }
if (l > r) r = l; int r = length - 1;
return trim(l, r - l); while ((r > l) && (buffer[offset + r] <= 32)) r--;
return trim(l, r - l + 1);
} }
public int isUTF8char(int start) { 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 singleAbstract = (TreeMap) abstractCache.get(wordhash); // a mapping from url-hashes to a string of peer-hashes
if (singleAbstract == null) singleAbstract = new TreeMap(); if (singleAbstract == null) singleAbstract = new TreeMap();
ci = new serverByteBuffer(((String) entry.getValue()).getBytes()); 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); plasmaURL.decompressIndex(singleAbstract, ci, target.hash);
abstractCache.put(wordhash, singleAbstract); abstractCache.put(wordhash, singleAbstract);
} }

Loading…
Cancel
Save