|
|
|
@ -558,28 +558,23 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSet
|
|
|
|
|
public static final TreeMap<String, String> decompressIndex(ByteBuffer ci, final String peerhash) {
|
|
|
|
|
TreeMap<String, String> target = new TreeMap<String, String>();
|
|
|
|
|
// 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() - 2);
|
|
|
|
|
String dom, url, peers;
|
|
|
|
|
while ((ci.length() >= 13) && (ci.byteAt(6) == ':')) {
|
|
|
|
|
if (ci.byteAt(0) != '{' || ci.byteAt(ci.length() - 1) != '}') return target;
|
|
|
|
|
//System.out.println("DEBUG-DECOMPRESS: input is " + ci.toString());
|
|
|
|
|
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();
|
|
|
|
|
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 = target.get(url);
|
|
|
|
|
if (peers == null) {
|
|
|
|
|
target.put(url, peerhash);
|
|
|
|
|
} else {
|
|
|
|
|
target.put(url, peers + peerhash);
|
|
|
|
|
}
|
|
|
|
|
//System.out.println("DEBUG-DECOMPRESS: " + url + ":" + target.get(url));
|
|
|
|
|
}
|
|
|
|
|
if (ci.byteAt(0) == ',') ci.trim(1);
|
|
|
|
|
url = ci.toString(0, 6) + dom;
|
|
|
|
|
ci.trim(6);
|
|
|
|
|
peers = target.put(url, peerhash);
|
|
|
|
|
if (peers != null) target.put(url, peers + peerhash);
|
|
|
|
|
//System.out.println("DEBUG-DECOMPRESS: " + url + ":" + target.get(url));
|
|
|
|
|
}
|
|
|
|
|
if (ci.byteAt(0) == ',') ci.trim(1);
|
|
|
|
|
}
|
|
|
|
|
return target;
|
|
|
|
|
}
|
|
|
|
|