From 7256bea45fd5ba2e274cd37165a6935af7be40f5 Mon Sep 17 00:00:00 2001 From: theli Date: Wed, 19 Oct 2005 05:38:04 +0000 Subject: [PATCH] *) Bugfix for nameLookup parameter handling *) Bugfix for Received xx Words [xxxxxxx .. null] Bug git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@953 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Connections_p.java | 2 +- htroot/yacy/transferRWI.java | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htroot/Connections_p.java b/htroot/Connections_p.java index e611411f7..2350cb251 100644 --- a/htroot/Connections_p.java +++ b/htroot/Connections_p.java @@ -73,7 +73,7 @@ public final class Connections_p { // determines if name lookup should be done or not boolean doNameLookup = true; - if (post.containsKey("nameLookup") && post.get("nameLookup","true").equals("false")) { + if ((post != null) && post.containsKey("nameLookup") && post.get("nameLookup","true").equals("false")) { doNameLookup = false; } diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java index 323d74b6b..04d583a85 100644 --- a/htroot/yacy/transferRWI.java +++ b/htroot/yacy/transferRWI.java @@ -66,20 +66,18 @@ public final class transferRWI { public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) throws InterruptedException { if (post == null || ss == null) { return null; } - long start = System.currentTimeMillis(); - // return variable that accumulates replacements final plasmaSwitchboard sb = (plasmaSwitchboard) ss; final serverObjects prop = new serverObjects(); if (prop == null || sb == null) { return null; } // request values - final String iam = (String) post.get("iam", ""); // seed hash of requester -// final String youare = (String) post.get("youare", ""); // seed hash of the target peer, needed for network stability -// final String key = (String) post.get("key", ""); // transmission key - final int wordc = Integer.parseInt((String) post.get("wordc", "")); // number of different words - final int entryc = Integer.parseInt((String) post.get("entryc", "")); // number of entries in indexes - byte[] indexes = ((String) post.get("indexes", "")).getBytes(); // the indexes, as list of word entries + final String iam = post.get("iam", ""); // seed hash of requester +// final String youare = (String) post.get("youare", ""); // seed hash of the target peer, needed for network stability +// final String key = (String) post.get("key", ""); // transmission key + final int wordc = Integer.parseInt(post.get("wordc", "")); // number of different words + final int entryc = Integer.parseInt(post.get("entryc", "")); // number of entries in indexes + byte[] indexes = post.get("indexes", "").getBytes(); // the indexes, as list of word entries final boolean granted = sb.getConfig("allowReceiveIndex", "false").equals("true"); // response values @@ -115,17 +113,18 @@ public final class transferRWI { String wordHash; String urlHash; plasmaWordIndexEntry entry; + int wordhashesSize = v.size(); final HashSet unknownURL = new HashSet(); String[] wordhashes = new String[v.size()]; int received = 0; - for (int i = 0; i < v.size(); i++) { + for (int i = 0; i < wordhashesSize; i++) { serverCore.checkInterruption(); estring = (String) v.removeFirst(); p = estring.indexOf("{"); if (p > 0) { wordHash = estring.substring(0, p); - wordhashes[i] = wordHash; + wordhashes[received] = wordHash; entry = new plasmaWordIndexEntry(estring.substring(p)); sb.wordIndex.addEntries(plasmaWordIndexEntryContainer.instantContainer(wordHash, System.currentTimeMillis(), entry), true); serverCore.checkInterruption(); @@ -141,7 +140,8 @@ public final class transferRWI { yacyCore.seedDB.mySeed.incRI(received); // finally compose the unknownURL hash list - final Iterator it = unknownURL.iterator(); + final Iterator it = unknownURL.iterator(); + unknownURLs.ensureCapacity(unknownURL.size()*13); while (it.hasNext()) { unknownURLs.append(",").append((String) it.next()); } @@ -149,8 +149,8 @@ public final class transferRWI { if (wordhashes.length == 0) { sb.getLog().logInfo("Received 0 RWIs from " + otherPeerName + ", processed in " + (System.currentTimeMillis() - startProcess) + " milliseconds, requesting " + unknownURL.size() + " URLs"); } else { - final double avdist = (yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, wordhashes[0]) + yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, wordhashes[wordhashes.length - 1])) / 2.0; - sb.getLog().logInfo("Received " + received + " Words [" + wordhashes[0] + " .. " + wordhashes[wordhashes.length - 1] + "]/" + avdist + " from " + otherPeerName + ", processed in " + (System.currentTimeMillis() - startProcess) + " milliseconds, requesting " + unknownURL.size() + " URLs"); + final double avdist = (yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, wordhashes[0]) + yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, wordhashes[received - 1])) / 2.0; + sb.getLog().logInfo("Received " + received + " Words [" + wordhashes[0] + " .. " + wordhashes[received - 1] + "]/" + avdist + " from " + otherPeerName + ", processed in " + (System.currentTimeMillis() - startProcess) + " milliseconds, requesting " + unknownURL.size() + " URLs"); } result = "ok"; } else {