diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java index 357d83b86..460a8927b 100644 --- a/htroot/yacy/search.java +++ b/htroot/yacy/search.java @@ -171,7 +171,7 @@ public final class search { sb.intermissionAllThreads(100); EventTracker.delete(EventTracker.EClass.SEARCH); - final HandleSet abstractSet = ((abstracts.length() == 0) || (abstracts.equals("auto"))) ? null : QueryParams.hashes2Set(abstracts); + final HandleSet abstractSet = (abstracts.length() == 0 || abstracts.equals("auto")) ? null : QueryParams.hashes2Set(abstracts); // store accessing peer final yacySeed remoteSeed = yacySeed.genRemoteSeed(oseed, key, false); @@ -283,10 +283,15 @@ public final class search { yacyChannel.channels(yacyChannel.REMOTESEARCH).addMessage(new RSSMessage("Remote Search Request from " + ((remoteSeed == null) ? "unknown" : remoteSeed.getName()), QueryParams.anonymizedQueryHashes(theQuery.queryHashes), "")); // make event - theSearch = SearchEventCache.getEvent(theQuery, sb.peers, sb.crawlResults, null, true, sb.loader); + theSearch = SearchEventCache.getEvent(theQuery, sb.peers, sb.crawlResults, null, abstracts.length() > 0, sb.loader); // set statistic details of search result and find best result index set - if (theSearch.getRankingResult().getLocalIndexCount() == 0) { + joincount = theSearch.getRankingResult().getLocalIndexCount(); + prop.put("joincount", Integer.toString(joincount)); + if (joincount != 0) { + accu = theSearch.result().completeResults(1000); + } + if (theSearch.getRankingResult().getLocalIndexCount() == 0 || abstracts.length() == 0) { prop.put("indexcount", ""); prop.put("joincount", "0"); } else { @@ -310,15 +315,6 @@ public final class search { } prop.put("indexcount", indexcount.toString()); - if (theSearch.getRankingResult().getLocalIndexCount() == 0) { - joincount = 0; - prop.put("joincount", "0"); - } else { - joincount = theSearch.getRankingResult().getLocalIndexCount(); - prop.put("joincount", Integer.toString(joincount)); - accu = theSearch.result().completeResults(3000); - } - // generate compressed index for maxcounthash // this is not needed if the search is restricted to specific // urls, because it is a re-search @@ -353,7 +349,7 @@ public final class search { prop.put("indexabstract", indexabstract.toString()); // prepare result - if ((joincount == 0) || (accu == null)) { + if (joincount == 0 || accu == null || accu.size() == 0) { // no results prop.put("links", ""); diff --git a/source/net/yacy/kelondro/io/BufferedRecords.java b/source/net/yacy/kelondro/io/BufferedRecords.java index c4d162657..8e7b0f163 100644 --- a/source/net/yacy/kelondro/io/BufferedRecords.java +++ b/source/net/yacy/kelondro/io/BufferedRecords.java @@ -92,14 +92,18 @@ public final class BufferedRecords { } public final synchronized void get(final long index, final byte[] b, final int start) throws IOException { - assert b.length - start >= efs.recordsize; - if (index >= size()) throw new IndexOutOfBoundsException("kelondroBufferedEcoFS.get(" + index + ") outside bounds (" + this.size() + ")"); - final byte[] bb = buffer.get(Long.valueOf(index)); - if (bb == null) { - efs.get(index, b, start); - } else { - System.arraycopy(bb, 0, b, start, efs.recordsize); + Long idx = Long.valueOf(index); + final byte[] bb; + synchronized (this) { + assert b.length - start >= efs.recordsize; + if (index >= size()) throw new IndexOutOfBoundsException("kelondroBufferedEcoFS.get(" + index + ") outside bounds (" + this.size() + ")"); + bb = buffer.get(idx); + if (bb == null) { + efs.get(index, b, start); + return; + } } + System.arraycopy(bb, 0, b, start, efs.recordsize); } public final synchronized void put(final long index, final byte[] b, final int start) throws IOException { diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainer.java b/source/net/yacy/kelondro/rwi/ReferenceContainer.java index debed495d..4ab8c8645 100644 --- a/source/net/yacy/kelondro/rwi/ReferenceContainer.java +++ b/source/net/yacy/kelondro/rwi/ReferenceContainer.java @@ -516,20 +516,21 @@ public class ReferenceContainer extends RowSet public static final ByteBuffer compressIndex(final ReferenceContainer inputContainer, final ReferenceContainer excludeContainer, final long maxtime) { // collect references according to domains final long timeout = (maxtime < 0) ? Long.MAX_VALUE : System.currentTimeMillis() + maxtime; - final TreeMap doms = new TreeMap(); + final TreeMap doms = new TreeMap(); synchronized (inputContainer) { final Iterator i = inputContainer.entries(); Reference iEntry; - String dom, mod, paths; + String dom, mod; + StringBuilder paths; while (i.hasNext()) { iEntry = i.next(); if ((excludeContainer != null) && (excludeContainer.getReference(iEntry.metadataHash()) != null)) continue; // do not include urls that are in excludeContainer dom = new String(iEntry.metadataHash(), 6, 6); mod = new String(iEntry.metadataHash(), 0, 6); if ((paths = doms.get(dom)) == null) { - doms.put(dom, mod); + doms.put(dom, new StringBuilder(30).append(mod)); } else { - doms.put(dom, paths + mod); + doms.put(dom, paths.append(mod)); } if (System.currentTimeMillis() > timeout) break; @@ -538,13 +539,13 @@ public class ReferenceContainer extends RowSet // construct a result string final ByteBuffer bb = new ByteBuffer(inputContainer.size() * 6); bb.append('{'); - final Iterator> i = doms.entrySet().iterator(); - Map.Entry entry; + final Iterator> i = doms.entrySet().iterator(); + Map.Entry entry; while (i.hasNext()) { entry = i.next(); bb.append(entry.getKey()); bb.append(':'); - bb.append(entry.getValue()); + bb.append(entry.getValue().toString()); if (System.currentTimeMillis() > timeout) break; if (i.hasNext())