From e2e7f065e934c266e1a49b0792b69e68118dc784 Mon Sep 17 00:00:00 2001 From: orbiter Date: Thu, 24 Jan 2008 23:58:18 +0000 Subject: [PATCH] minor fixes, some generics git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4398 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/kelondro/kelondroRowSet.java | 6 +++- .../de/anomic/plasma/plasmaCrawlBalancer.java | 2 +- source/de/anomic/yacy/yacySearch.java | 34 +++++++++---------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/source/de/anomic/kelondro/kelondroRowSet.java b/source/de/anomic/kelondro/kelondroRowSet.java index 11296db64..412108f85 100644 --- a/source/de/anomic/kelondro/kelondroRowSet.java +++ b/source/de/anomic/kelondro/kelondroRowSet.java @@ -33,7 +33,7 @@ import de.anomic.server.logging.serverLog; public class kelondroRowSet extends kelondroRowCollection implements kelondroIndex { - private static final int collectionReSortLimit = 300; + private static final int collectionReSortLimit = 400; private kelondroProfile profile; @@ -144,6 +144,10 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd if (rowdef.objectOrder == null) return iterativeSearch(a, astart, alength, 0, this.chunkcount); + if ((this.chunkcount - this.sortBound) > (collectionReSortLimit << 1)) { + sort(); + } + if ((this.rowdef.objectOrder != null) && (this.rowdef.objectOrder instanceof kelondroBase64Order) && (this.sortBound > 4000)) { // first try to find in sorted area final byte[] compiledPivot = compilePivot(a, astart, alength); diff --git a/source/de/anomic/plasma/plasmaCrawlBalancer.java b/source/de/anomic/plasma/plasmaCrawlBalancer.java index bc29b019c..c64af7c18 100644 --- a/source/de/anomic/plasma/plasmaCrawlBalancer.java +++ b/source/de/anomic/plasma/plasmaCrawlBalancer.java @@ -465,7 +465,7 @@ public class plasmaCrawlBalancer { assert delta >= 0: "delta = " + delta; int s = urlFileIndex.size(); kelondroRow.Entry rowEntry = urlFileIndex.remove(result.getBytes(), false); - assert (rowEntry != null) && (urlFileIndex.size() + 1 == s) : "urlFileIndex.size() = " + urlFileIndex.size() + ", s = " + s + ", result = " + result; + assert (rowEntry == null) || (urlFileIndex.size() + 1 == s) : "urlFileIndex.size() = " + urlFileIndex.size() + ", s = " + s + ", result = " + result; if (rowEntry == null) { serverLog.logSevere("PLASMA BALANCER", "get() found a valid urlhash, but failed to fetch the corresponding url entry - total size = " + size() + ", fileStack.size() = " + urlFileStack.size() + ", ramStack.size() = " + urlRAMStack.size() + ", domainStacks.size() = " + domainStacks.size()); return null; diff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.java index 2b453dce0..04c448bce 100644 --- a/source/de/anomic/yacy/yacySearch.java +++ b/source/de/anomic/yacy/yacySearch.java @@ -120,9 +120,9 @@ public class yacySearch extends Thread { } } - public static String set2string(Set hashes) { + public static String set2string(Set hashes) { String wh = ""; - final Iterator iter = hashes.iterator(); + final Iterator iter = hashes.iterator(); while (iter.hasNext()) { wh = wh + (String) iter.next(); } return wh; } @@ -139,28 +139,28 @@ public class yacySearch extends Thread { return targetPeer; } - private static yacySeed[] selectClusterPeers(TreeMap peerhashes) { - Iterator i = peerhashes.entrySet().iterator(); - ArrayList l = new ArrayList(); - Map.Entry entry; + private static yacySeed[] selectClusterPeers(TreeMap peerhashes) { + Iterator> i = peerhashes.entrySet().iterator(); + ArrayList l = new ArrayList(); + Map.Entry entry; yacySeed s; while (i.hasNext()) { - entry = (Map.Entry) i.next(); - s = yacyCore.seedDB.get((String) entry.getKey()); // should be getConnected; get only during testing time + entry = i.next(); + s = yacyCore.seedDB.get(entry.getKey()); // should be getConnected; get only during testing time if (s != null) { - s.setAlternativeAddress((String) entry.getValue()); + s.setAlternativeAddress(entry.getValue()); l.add(s); } } yacySeed[] result = new yacySeed[l.size()]; for (int j = 0; j < l.size(); j++) { - result[j] = (yacySeed) l.get(j); + result[j] = l.get(j); } return result; //return (yacySeed[]) l.toArray(); } - private static yacySeed[] selectSearchTargets(Set wordhashes, int seedcount) { + private static yacySeed[] selectSearchTargets(Set wordhashes, int seedcount) { // find out a specific number of seeds, that would be relevant for the given word hash(es) // the result is ordered by relevance: [0] is most relevant // the seedcount is the maximum number of wanted results @@ -171,15 +171,15 @@ public class yacySearch extends Thread { // put in seeds according to dht final kelondroMScoreCluster ranking = new kelondroMScoreCluster(); - final HashMap seeds = new HashMap(); + final HashMap seeds = new HashMap(); yacySeed seed; - Iterator dhtEnum; + Iterator dhtEnum; int c; String wordhash; double distance; - Iterator iter = wordhashes.iterator(); + Iterator iter = wordhashes.iterator(); while (iter.hasNext()) { - wordhash = (String) iter.next(); + wordhash = iter.next(); dhtEnum = yacyCore.dhtAgent.getDHTSeeds(true, wordhash, (float) 0.0); c = seedcount; while (dhtEnum.hasNext() && c > 0) { @@ -200,7 +200,7 @@ public class yacySearch extends Thread { int score; if (c > yacyCore.seedDB.sizeConnected()) { c = yacyCore.seedDB.sizeConnected(); } while (dhtEnum.hasNext() && c > 0) { - seed = (yacySeed) dhtEnum.next(); + seed = dhtEnum.next(); if (seed == null) continue; if (!seed.getFlagAcceptRemoteIndex()) continue; // probably a robinson peer score = (int) Math.round(Math.random() * ((c / 3) + 3)); @@ -214,7 +214,7 @@ public class yacySearch extends Thread { // or seeds that are newbies to ensure that public demonstrations always work dhtEnum = yacyCore.seedDB.seedsConnected(true, false, null, (float) 0.50); while (dhtEnum.hasNext()) { - seed = (yacySeed) dhtEnum.next(); + seed = dhtEnum.next(); if (seed == null) continue; if (seed.matchPeerTags(wordhashes)) { // access robinson peers with matching tag serverLog.logInfo("PLASMA", "selectPeers/PeerTags: " + seed.hash + ":" + seed.getName() + ", is specialized peer for " + seed.getPeerTags().toString());