Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

refactoring to integrate indexCell data structures

orbiter209f25f5f5d6
diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.java
index 09065e811..d665199d8 100644
--- a/htroot/IndexControlRWIs_p.java
+++ b/htroot/IndexControlRWIs_p.java
@@ -120,7 +120,7 @@ public class IndexControlRWIs_p {
}
// delete word
- if (post.containsKey("keyhashdeleteall")) {
+ if (post.containsKey("keyhashdeleteall")) try {
if (delurl || delurlref) {
// generate an urlx array
ReferenceContainer index = null;
@@ -144,10 +144,12 @@ public class IndexControlRWIs_p {
sb.webIndex.index().deleteAllReferences(keyhash);
post.remove("keyhashdeleteall");
post.put("urllist", "generated");
+ } catch (IOException e) {
+ e.printStackTrace();
}
// delete selected URLs
- if (post.containsKey("keyhashdelete")) {
+ if (post.containsKey("keyhashdelete")) try {
if (delurlref) {
for (int i = 0; i < urlx.length; i++) sb.removeAllUrlReferences(urlx[i], true);
}
@@ -163,6 +165,8 @@ public class IndexControlRWIs_p {
// thinks that it was called for a list presentation
post.remove("keyhashdelete");
post.put("urllist", "generated");
+ } catch (IOException e) {
+ e.printStackTrace();
}
if (post.containsKey("urllist")) {
@@ -176,7 +180,7 @@ public class IndexControlRWIs_p {
}
// transfer to other peer
- if (post.containsKey("keyhashtransfer")) {
+ if (post.containsKey("keyhashtransfer")) try {
if (keystring.length() == 0 || !Word.word2hash(keystring).equals(keyhash)) {
prop.put("keystring", "&lt;not possible to compute word from hash&gt;");
}
@@ -233,6 +237,8 @@ public class IndexControlRWIs_p {
timeout);
prop.put("result", (error == null) ? ("Successfully transferred " + knownURLs.size() + " words in " + ((System.currentTimeMillis() - starttime) / 1000) + " seconds, " + unknownURLEntries + " URL not found") : "error: " + error);
index = null;
+ } catch (IOException e) {
+ e.printStackTrace();
}
// generate list
@@ -315,7 +321,11 @@ public class IndexControlRWIs_p {
} catch (final IOException e) {
}
}
- sb.webIndex.index().removeReferences(keyhash, urlHashes);
+ try {
+ sb.webIndex.index().removeReferences(keyhash, urlHashes);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
if (prop.getInt("searchresult", 0) == 3) plasmaSearchAPI.listHosts(prop, keyhash, sb);
diff --git a/htroot/PerformanceGraph.java b/htroot/PerformanceGraph.java
index cee7d2b7b..ff1556e0a 100644
--- a/htroot/PerformanceGraph.java
+++ b/htroot/PerformanceGraph.java
@@ -41,7 +41,7 @@ public class PerformanceGraph {
final int width = post.getInt("width", 660);
final int height = post.getInt("height", 240);
- return plasmaProfiling.performanceGraph(width, height, sb.webIndex.metadata().size() + " URLS / " + sb.webIndex.index().collectionsSize() + " WORDS IN COLLECTIONS / " + sb.webIndex.index().cacheSize() + " WORDS IN CACHE");
+ return plasmaProfiling.performanceGraph(width, height, sb.webIndex.metadata().size() + " URLS / " + sb.webIndex.index().backendSize() + " WORDS IN COLLECTIONS / " + sb.webIndex.index().cacheSize() + " WORDS IN CACHE");
}
}
\ No newline at end of file
diff --git a/htroot/yacy/query.java b/htroot/yacy/query.java
index d34566b8b..f1be181b1 100644
--- a/htroot/yacy/query.java
+++ b/htroot/yacy/query.java
@@ -27,6 +27,8 @@
// javac -classpath .:../../classes query.java
// if the shell's current path is HTROOT
+import java.io.IOException;
+
import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.util.DateFormatter;
import de.anomic.plasma.plasmaSwitchboard;
@@ -79,11 +81,13 @@ public final class query {
}
// requests about environment
- if (obj.equals("rwiurlcount")) {
+ if (obj.equals("rwiurlcount")) try {
// the total number of different urls in the rwi is returned
// <env> shall contain a word hash, the number of assigned lurls to this hash is returned
prop.put("response", sb.webIndex.index().getReferences(env, null).size());
return prop;
+ } catch (IOException e) {
+ e.printStackTrace();
}
if (obj.equals("rwicount")) {
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index 412cf178b..2f8aedd5e 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -27,6 +27,7 @@
// javac -classpath .:../classes yacysearch.java
// if the shell's current path is HTROOT
+import java.io.IOException;
import java.util.HashMap;
import java.util.TreeSet;
@@ -307,7 +308,7 @@ public class yacysearch {
}
// if a minus-button was hit, remove a special reference first
- if (post != null && post.containsKey("deleteref")) {
+ if (post != null && post.containsKey("deleteref")) try {
if (!sb.verifyAuthentication(header, true)) {
prop.put("AUTHENTICATE", "admin log-in"); // force log-in
return prop;
@@ -315,7 +316,7 @@ public class yacysearch {
// delete the index entry locally
final String delHash = post.get("deleteref", ""); // urlhash
- sb.webIndex.index().removeWordReferences(query[0], delHash);
+ sb.webIndex.index().removeEntryMultiple(Word.words2hashes(query[0]), delHash);
// make new news message with negative voting
final HashMap<String, String> map = new HashMap<String, String>();
@@ -323,6 +324,8 @@ public class yacysearch {
map.put("vote", "negative");
map.put("refid", "");
sb.webIndex.peers().newsPool.publishMyNews(yacyNewsRecord.newRecord(sb.webIndex.peers().mySeed(), yacyNewsPool.CATEGORY_SURFTIPP_VOTE_ADD, map));
+ } catch (IOException e) {
+ e.printStackTrace();
}
// if a plus-button was hit, create new voting message
diff --git a/source/de/anomic/kelondro/text/AbstractIndex.java b/source/de/anomic/kelondro/text/AbstractIndex.java
new file mode 100644
index 000000000..908ed7555
--- /dev/null
+++ b/source/de/anomic/kelondro/text/AbstractIndex.java
@@ -0,0 +1,57 @@
+// AbstractIndex.java
+// -----------------------------
+// (C) 2009 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
+// first published 15.3.2009 on http://yacy.net
+//
+// This is a part of YaCy, a peer-to-peer based web search engine
+//
+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
+// $LastChangedRevision: 1986 $
+// $LastChangedBy: orbiter $
+//
+// LICENSE
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+package de.anomic.kelondro.text;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+
+public abstract class AbstractIndex implements Index {
+
+ public int removeEntryMultiple(final Set<String> wordHashes, final String urlHash) throws IOException {
+ // remove the same url hashes for multiple words
+ // this is mainly used when correcting a index after a search
+ final Iterator<String> i = wordHashes.iterator();
+ int c = 0;
+ while (i.hasNext()) {
+ if (removeReference(i.next(), urlHash)) c++;
+ }
+ return c;
+ }
+
+ public void removeEntriesMultiple(final Set<String> wordHashes, final Set<String> urlHashes) throws IOException {
+ // remove the same url hashes for multiple words
+ // this is mainly used when correcting a index after a search
+ final Iterator<String> i = wordHashes.iterator();
+ while (i.hasNext()) {
+ removeReferences(i.next(), urlHashes);
+ }
+ }
+
+
+}
diff --git a/source/de/anomic/kelondro/text/CachedIndexCollection.java b/source/de/anomic/kelondro/text/CachedIndexCollection.java
index fb5f3c50b..56347d858 100644
--- a/source/de/anomic/kelondro/text/CachedIndexCollection.java
+++ b/source/de/anomic/kelondro/text/CachedIndexCollection.java
@@ -46,12 +46,11 @@ import de.anomic.kelondro.text.IndexCollection;
import de.anomic.kelondro.text.ReferenceContainer;
import de.anomic.kelondro.text.ReferenceContainerOrder;
import de.anomic.kelondro.text.ReferenceRow;
-import de.anomic.kelondro.text.Word;
import de.anomic.kelondro.util.MemoryControl;
import de.anomic.kelondro.util.Log;
import de.anomic.server.serverProfiling;
-public final class CachedIndexCollection implements Index {
+public final class CachedIndexCollection extends AbstractIndex implements Index, IndexPackage {
// environment constants
public static final long wCacheMaxAge = 1000 * 60 * 30; // milliseconds; 30 minutes
@@ -65,7 +64,7 @@ public final class CachedIndexCollection implements Index {
private final IndexCache indexCache;
private final IndexCollection collections; // new database structure to replace AssortmentCluster and FileCluster
- public CachedIndexCollection(
+ public CachedIndexCollection (
File indexPrimaryTextLocation,
final int entityCacheMaxSize,
final boolean useCommons,
@@ -100,6 +99,120 @@ public final class CachedIndexCollection implements Index {
useCommons);
}
+ /* methods for interface Index */
+
+ public void addReferences(final ReferenceContainer entries) {
+ assert (entries.row().objectsize == ReferenceRow.urlEntryRow.objectsize);
+
+ // add the entry
+ indexCache.addReferences(entries);
+ cacheFlushControl();
+ }
+
+ public boolean hasReferences(final String wordHash) {
+ if (indexCache.hasReferences(wordHash)) return true;
+ if (collections.hasReferences(wordHash)) return true;
+ return false;
+ }
+
+ public int countReferences(String key) {
+ return indexCache.countReferences(key) + collections.countReferences(key);
+ }
+
+ public ReferenceContainer getReferences(final String wordHash, final Set<String> urlselection) {
+ if (wordHash == null) {
+ // wrong input
+ return null;
+ }
+
+ // get from cache
+ ReferenceContainer container;
+ container = indexCache.getReferences(wordHash, urlselection);
+
+ // get from collection index
+ if (container == null) {
+ container = collections.getReferences(wordHash, urlselection);
+ } else {
+ container.addAllUnique(collections.getReferences(wordHash, urlselection));
+ }
+
+ if (container == null) return null;
+
+ // check doubles
+ final int beforeDouble = container.size();
+ container.sort();
+ final ArrayList<RowCollection> d = container.removeDoubles();
+ RowCollection set;
+ for (int i = 0; i < d.size(); i++) {
+ // for each element in the double-set, take that one that is the most recent one
+ set = d.get(i);
+ ReferenceRow e, elm = null;
+ long lm = 0;
+ for (int j = 0; j < set.size(); j++) {
+ e = new ReferenceRow(set.get(j, true));
+ if ((elm == null) || (e.lastModified() > lm)) {
+ elm = e;
+ lm = e.lastModified();
+ }
+ }
+ if(elm != null) {
+ container.addUnique(elm.toKelondroEntry());
+ }
+ }
+ if (container.size() < beforeDouble) System.out.println("*** DEBUG DOUBLECHECK - removed " + (beforeDouble - container.size()) + " index entries from word container " + container.getWordHash());
+
+ return container;
+ }
+
+ public ReferenceContainer deleteAllReferences(final String wordHash) {
+ final ReferenceContainer c = new ReferenceContainer(
+ wordHash,
+ ReferenceRow.urlEntryRow,
+ indexCache.countReferences(wordHash));
+ c.addAllUnique(indexCache.deleteAllReferences(wordHash));
+ c.addAllUnique(collections.deleteAllReferences(wordHash));
+ return c;
+ }
+
+ public boolean removeReference(final String wordHash, final String urlHash) {
+ boolean removed = false;
+ removed = removed | (indexCache.removeReference(wordHash, urlHash));
+ removed = removed | (collections.removeReference(wordHash, urlHash));
+ return removed;
+ }
+
+ public int removeReferences(final String wordHash, final Set<String> urlHashes) {
+ int removed = 0;
+ removed += indexCache.removeReferences(wordHash, urlHashes);
+ removed += collections.removeReferences(wordHash, urlHashes);
+ return removed;
+ }
+
+ public synchronized CloneableIterator<ReferenceContainer> referenceIterator(final String startHash, final boolean rot, final boolean ram) {
+ final CloneableIterator<ReferenceContainer> i = wordContainers(startHash, ram);
+ if (rot) {
+ return new RotateIterator<ReferenceContainer>(i, new String(Base64Order.zero(startHash.length())), indexCache.size() + ((ram) ? 0 : collections.size()));
+ }
+ return i;
+ }
+
+ private synchronized CloneableIterator<ReferenceContainer> wordContainers(final String startWordHash, final boolean ram) {
+ final Order<ReferenceContainer> containerOrder = new ReferenceContainerOrder(indexOrder.clone());
+ containerOrder.rotate(ReferenceContainer.emptyContainer(startWordHash, 0));
+ if (ram) {
+ return indexCache.referenceIterator(startWordHash, false, true);
+ }
+ return collections.referenceIterator(startWordHash, false, false);
+ /*
+ return new MergeIterator<ReferenceContainer>(
+ indexCache.referenceIterator(startWordHash, false, true),
+ collections.referenceIterator(startWordHash, false, false),
+ containerOrder,
+ ReferenceContainer.containerMergeMethod,
+ true);
+ */
+ }
+
public void clear() {
indexCache.clear();
try {
@@ -109,10 +222,24 @@ public final class CachedIndexCollection implements Index {
}
}
+ public void close() {
+ indexCache.close();
+ collections.close();
+ }
+
+ public int size() {
+ return java.lang.Math.max(collections.size(), indexCache.size());
+ }
+
public int minMem() {
return 1024*1024 /* indexing overhead */ + indexCache.minMem() + collections.minMem();
}
+
+ /*
+ * methods for cache management
+ */
+
public int maxURLinCache() {
return indexCache.maxURLinCache();
}
@@ -145,7 +272,7 @@ public final class CachedIndexCollection implements Index {
indexCache.setMaxWordCount(maxWords);
}
- public void cacheFlushControl(final IndexCache theCache) {
+ public void cacheFlushControl() {
// check for forced flush
int cs = cacheSize();
if (cs > 0) {
@@ -155,37 +282,19 @@ public final class CachedIndexCollection implements Index {
serverProfiling.update("wordcache", Long.valueOf(cs), true);
// To ensure termination an additional counter is used
int l = 0;
- while (theCache.size() > 0 && (l++ < 100) && (theCache.maxURLinCache() > wCacheMaxChunk)) {
- flushCacheOne(theCache);
+ while (this.indexCache.size() > 0 && (l++ < 100) && (this.indexCache.maxURLinCache() > wCacheMaxChunk)) {
+ flushCacheOne(this.indexCache);
}
// next flush more entries if the size exceeds the maximum size of the cache
- while (theCache.size() > 0 &&
- ((theCache.size() > theCache.getMaxWordCount()) ||
+ while (this.indexCache.size() > 0 &&
+ ((this.indexCache.size() > this.indexCache.getMaxWordCount()) ||
(MemoryControl.available() < collections.minMem()))) {
- flushCacheOne(theCache);
+ flushCacheOne(this.indexCache);
}
if (cacheSize() != cs) serverProfiling.update("wordcache", Long.valueOf(cacheSize()), true);
}
}
- public static ReferenceContainer emptyContainer(final String wordHash, final int elementCount) {
- return new ReferenceContainer(wordHash, ReferenceRow.urlEntryRow, elementCount);
- }
-
- public void addEntry(final String wordHash, final ReferenceRow entry, final long updateTime) {
- // add the entry
- indexCache.addEntry(wordHash, entry, updateTime, true);
- cacheFlushControl(this.indexCache);
- }
-
- public void addReferences(final ReferenceContainer entries) {
- assert (entries.row().objectsize == ReferenceRow.urlEntryRow.objectsize);
-
- // add the entry
- indexCache.addReferences(entries);
- cacheFlushControl(this.indexCache);
- }
-
public void flushCacheFor(int time) {
flushCacheUntil(System.currentTimeMillis() + time);
}
@@ -212,67 +321,56 @@ public final class CachedIndexCollection implements Index {
}
}
- public boolean hasReferences(final String wordHash) {
- if (indexCache.hasReferences(wordHash)) return true;
- if (collections.hasReferences(wordHash)) return true;
- return false;
+ public int backendSize() {
+ return collections.size();
}
- public ReferenceContainer getReferences(final String wordHash, final Set<String> urlselection) {
- if (wordHash == null) {
- // wrong input
- return null;
- }
-
- // get from cache
- ReferenceContainer container;
- container = indexCache.getReferences(wordHash, urlselection);
-
- // get from collection index
- if (container == null) {
- container = collections.getReferences(wordHash, urlselection);
- } else {
- container.addAllUnique(collections.getReferences(wordHash, urlselection));
- }
-
- if (container == null) return null;
-
- // check doubles
- final int beforeDouble = container.size();
- container.sort();
- final ArrayList<RowCollection> d = container.removeDoubles();
- RowCollection set;
- for (int i = 0; i < d.size(); i++) {
- // for each element in the double-set, take that one that is the most recent one
- set = d.get(i);
- ReferenceRow e, elm = null;
- long lm = 0;
- for (int j = 0; j < set.size(); j++) {
- e = new ReferenceRow(set.get(j, true));
- if ((elm == null) || (e.lastModified() > lm)) {
- elm = e;
- lm = e.lastModified();
- }
- }
- if(elm != null) {
- container.addUnique(elm.toKelondroEntry());
- }
- }
- if (container.size() < beforeDouble) System.out.println("*** DEBUG DOUBLECHECK - removed " + (beforeDouble - container.size()) + " index entries from word container " + container.getWordHash());
+ public int cacheSize() {
+ return indexCache.size();
+ }
- return container;
+
+ /*
+ * methods to update the index
+ */
+
+ public void addEntry(final String wordHash, final ReferenceRow entry, final long updateTime) {
+ // add the entry
+ indexCache.addEntry(wordHash, entry, updateTime, true);
+ cacheFlushControl();
}
+
+ /*
+ * methods to search the index
+ */
+
+ @SuppressWarnings("unchecked")
+ public HashMap<String, ReferenceContainer>[] localSearchContainers(
+ final TreeSet<String> queryHashes,
+ final TreeSet<String> excludeHashes,
+ final Set<String> urlselection) {
+ // search for the set of hashes and return a map of of wordhash:indexContainer containing the seach result
+
+ // retrieve entities that belong to the hashes
+ HashMap<String, ReferenceContainer> inclusionContainers = (queryHashes.size() == 0) ? new HashMap<String, ReferenceContainer>(0) : getContainers(
+ queryHashes,
+ urlselection);
+ if ((inclusionContainers.size() != 0) && (inclusionContainers.size() < queryHashes.size())) inclusionContainers = new HashMap<String, ReferenceContainer>(0); // prevent that only a subset is returned
+ final HashMap<String, ReferenceContainer> exclusionContainers = (inclusionContainers.size() == 0) ? new HashMap<String, ReferenceContainer>(0) : getContainers(
+ excludeHashes,
+ urlselection);
+ return new HashMap[]{inclusionContainers, exclusionContainers};
+ }
+
/**
- * return map of wordhash:indexContainer
- *
+ * collect containers for given word hashes. This collection stops if a single container does not contain any references.
+ * In that case only a empty result is returned.
* @param wordHashes
* @param urlselection
- * @param deleteIfEmpty
- * @param interruptIfEmpty
- * @return
+ * @return map of wordhash:indexContainer
*/
- public HashMap<String, ReferenceContainer> getContainers(final Set<String> wordHashes, final Set<String> urlselection, final boolean interruptIfEmpty) {
+ private HashMap<String, ReferenceContainer> getContainers(final Set<String> wordHashes, final Set<String> urlselection) {
// retrieve entities that belong to the hashes
final HashMap<String, ReferenceContainer> containers = new HashMap<String, ReferenceContainer>(wordHashes.size());
String singleHash;
@@ -287,118 +385,18 @@ public final class CachedIndexCollection implements Index {
singleContainer = getReferences(singleHash, urlselection);
// check result
- if (((singleContainer == null) || (singleContainer.size() == 0)) && (interruptIfEmpty)) return new HashMap<String, ReferenceContainer>(0);
+ if ((singleContainer == null || singleContainer.size() == 0)) return new HashMap<String, ReferenceContainer>(0);
containers.put(singleHash, singleContainer);
}
return containers;
}
- @SuppressWarnings("unchecked")
- public HashMap<String, ReferenceContainer>[] localSearchContainers(
- final TreeSet<String> queryHashes,
- final TreeSet<String> excludeHashes,
- final Set<String> urlselection) {
- // search for the set of hashes and return a map of of wordhash:indexContainer containing the seach result
-
- // retrieve entities that belong to the hashes
- HashMap<String, ReferenceContainer> inclusionContainers = (queryHashes.size() == 0) ? new HashMap<String, ReferenceContainer>(0) : getContainers(
- queryHashes,
- urlselection,
- true);
- if ((inclusionContainers.size() != 0) && (inclusionContainers.size() < queryHashes.size())) inclusionContainers = new HashMap<String, ReferenceContainer>(0); // prevent that only a subset is returned
- final HashMap<String, ReferenceContainer> exclusionContainers = (inclusionContainers.size() == 0) ? new HashMap<String, ReferenceContainer>(0) : getContainers(
- excludeHashes,
- urlselection,
- true);
- return new HashMap[]{inclusionContainers, exclusionContainers};
- }
-
- public int size() {
- return java.lang.Math.max(collections.size(), indexCache.size());
- }
-
- public int collectionsSize() {
- return collections.size();
- }
-
- public int cacheSize() {
- return indexCache.size();
- }
-
- public void close() {
- indexCache.close();
- collections.close();
- }
-
- public ReferenceContainer deleteAllReferences(final String wordHash) {
- final ReferenceContainer c = new ReferenceContainer(
- wordHash,
- ReferenceRow.urlEntryRow,
- indexCache.countReferences(wordHash));
- c.addAllUnique(indexCache.deleteAllReferences(wordHash));
- c.addAllUnique(collections.deleteAllReferences(wordHash));
- return c;
- }
-
- public boolean removeReference(final String wordHash, final String urlHash) {
- boolean removed = false;
- removed = removed | (indexCache.removeReference(wordHash, urlHash));
- removed = removed | (collections.removeReference(wordHash, urlHash));
- return removed;
- }
-
- public int removeEntryMultiple(final Set<String> wordHashes, final String urlHash) {
- // remove the same url hashes for multiple words
- // this is mainly used when correcting a index after a search
- final Iterator<String> i = wordHashes.iterator();
- int count = 0;
- while (i.hasNext()) {
- if (removeReference(i.next(), urlHash)) count++;
- }
- return count;
- }
-
- public int removeReferences(final String wordHash, final Set<String> urlHashes) {
- int removed = 0;
- removed += indexCache.removeReferences(wordHash, urlHashes);
- removed += collections.removeReferences(wordHash, urlHashes);
- return removed;
- }
-
- public String removeEntriesExpl(final String wordHash, final Set<String> urlHashes) {
- String removed = "";
- removed += indexCache.removeReferences(wordHash, urlHashes) + ", ";
- removed += collections.removeReferences(wordHash, urlHashes);
- return removed;
- }
-
- public void removeEntriesMultiple(final Set<String> wordHashes, final Set<String> urlHashes) {
- // remove the same url hashes for multiple words
- // this is mainly used when correcting a index after a search
- final Iterator<String> i = wordHashes.iterator();
- while (i.hasNext()) {
- removeReferences(i.next(), urlHashes);
- }
- }
-
- public int removeWordReferences(final Set<String> words, final String urlhash) {
- // sequentially delete all word references
- // returns number of deletions
- final Iterator<String> iter = words.iterator();
- int count = 0;
- while (iter.hasNext()) {
- // delete the URL reference in this word index
- if (removeReference(Word.word2hash(iter.next()), urlhash)) count++;
- }
- return count;
- }
-
public synchronized TreeSet<ReferenceContainer> indexContainerSet(final String startHash, final boolean ram, final boolean rot, int count) {
// creates a set of indexContainers
// this does not use the cache
final Order<ReferenceContainer> containerOrder = new ReferenceContainerOrder(indexOrder.clone());
- containerOrder.rotate(emptyContainer(startHash, 0));
+ containerOrder.rotate(ReferenceContainer.emptyContainer(startHash, 0));
final TreeSet<ReferenceContainer> containers = new TreeSet<ReferenceContainer>(containerOrder);
final Iterator<ReferenceContainer> i = referenceIterator(startHash, rot, ram);
if (ram) count = Math.min(indexCache.size(), count);
@@ -416,34 +414,5 @@ public final class CachedIndexCollection implements Index {
}
return containers; // this may return less containers as demanded
}
-
- public synchronized CloneableIterator<ReferenceContainer> referenceIterator(final String startHash, final boolean rot, final boolean ram) {
- final CloneableIterator<ReferenceContainer> i = wordContainers(startHash, ram);
- if (rot) {
- return new RotateIterator<ReferenceContainer>(i, new String(Base64Order.zero(startHash.length())), indexCache.size() + ((ram) ? 0 : collections.size()));
- }
- return i;
- }
-
- private synchronized CloneableIterator<ReferenceContainer> wordContainers(final String startWordHash, final boolean ram) {
- final Order<ReferenceContainer> containerOrder = new ReferenceContainerOrder(indexOrder.clone());
- containerOrder.rotate(emptyContainer(startWordHash, 0));
- if (ram) {
- return indexCache.referenceIterator(startWordHash, false, true);
- }
- return collections.referenceIterator(startWordHash, false, false);
- /*
- return new MergeIterator<ReferenceContainer>(
- indexCache.referenceIterator(startWordHash, false, true),
- collections.referenceIterator(startWordHash, false, false),
- containerOrder,
- ReferenceContainer.containerMergeMethod,
- true);
- */
- }
- public int countReferences(String key) {
- return indexCache.countReferences(key) + collections.countReferences(key);
- }
-
}
diff --git a/source/de/anomic/kelondro/text/Index.java b/source/de/anomic/kelondro/text/Index.java
index f13898293..c99b49115 100644
--- a/source/de/anomic/kelondro/text/Index.java
+++ b/source/de/anomic/kelondro/text/Index.java
@@ -98,6 +98,10 @@ public interface Index {
*/
public int removeReferences(String wordHash, Set<String> referenceHashes) throws IOException;
+ public int removeEntryMultiple(final Set<String> wordHashes, final String urlHash) throws IOException;
+
+ public void removeEntriesMultiple(final Set<String> wordHashes, final Set<String> urlHashes) throws IOException;
+
/**
* iterate all references from the beginning of a specific word hash
* @param startWordHash
diff --git a/source/de/anomic/kelondro/text/IndexCache.java b/source/de/anomic/kelondro/text/IndexCache.java
index ea877c058..ec5803270 100644
--- a/source/de/anomic/kelondro/text/IndexCache.java
+++ b/source/de/anomic/kelondro/text/IndexCache.java
@@ -1,4 +1,4 @@
-// ReverseIndexCache.java
+// IndexCache.java
// (C) 2005, 2006 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
// first published 2005 on http://yacy.net
//
@@ -38,7 +38,11 @@ import de.anomic.kelondro.util.MemoryControl;
import de.anomic.kelondro.util.ScoreCluster;
import de.anomic.kelondro.util.Log;
-public final class IndexCache implements Index, IndexReader, Iterable<ReferenceContainer> {
+/**
+ * A IndexCache is a ReferenceContainerCache with an attached cache flush logic
+ *
+ */
+public final class IndexCache extends AbstractIndex implements Index, IndexReader, Iterable<ReferenceContainer> {
// class variables
private final ScoreCluster<String> hashScore;
diff --git a/source/de/anomic/kelondro/text/IndexCell.java b/source/de/anomic/kelondro/text/IndexCell.java
index 26cf949ef..0a05ad96f 100644
--- a/source/de/anomic/kelondro/text/IndexCell.java
+++ b/source/de/anomic/kelondro/text/IndexCell.java
@@ -47,7 +47,7 @@ import de.anomic.kelondro.order.Order;
* another BLOB file in the index array.
*/
-public final class IndexCell implements Index {
+public final class IndexCell extends AbstractIndex implements Index {
// class variables
private ReferenceContainerArray array;
@@ -77,6 +77,7 @@ public final class IndexCell implements Index {
/**
* add entries to the cell: this adds the new entries always to the RAM part, never to BLOBs
* @throws IOException
+ * @throws IOException
*/
public synchronized void addReferences(ReferenceContainer newEntries) throws IOException {
this.ram.addReferences(newEntries);
@@ -85,6 +86,7 @@ public final class IndexCell implements Index {
/**
* clear the RAM and BLOB part, deletes everything in the cell
+ * @throws IOException
*/
public synchronized void clear() throws IOException {
this.ram.clear();
@@ -111,6 +113,7 @@ public final class IndexCell implements Index {
/**
* deleting a container affects the containers in RAM and all the BLOB files
* the deleted containers are merged and returned as result of the method
+ * @throws IOException
*/
public ReferenceContainer deleteAllReferences(String wordHash) throws IOException {
ReferenceContainer c0 = this.ram.deleteAllReferences(wordHash);
@@ -126,6 +129,7 @@ public final class IndexCell implements Index {
/**
* all containers in the BLOBs and the RAM are merged and returned
+ * @throws IOException
*/
public ReferenceContainer getReferences(String wordHash, Set<String> urlselection) throws IOException {
ReferenceContainer c0 = this.ram.getReferences(wordHash, null);
@@ -173,6 +177,7 @@ public final class IndexCell implements Index {
* new BLOBs. This returns the sum of all url references that have been removed
* @throws IOException
* @throws IOException
+ * @throws IOException
*/
public int removeReferences(String wordHash, Set<String> urlHashes) throws IOException {
int reduced = this.array.replace(wordHash, new RemoveRewriter(urlHashes));
@@ -188,7 +193,7 @@ public final class IndexCell implements Index {
return this.ram.size() + this.array.size();
}
- public CloneableIterator<ReferenceContainer> referenceIterator(String startWordHash, boolean rot, boolean ram) throws IOException {
+ public CloneableIterator<ReferenceContainer> referenceIterator(String startWordHash, boolean rot, boolean ram) {
final Order<ReferenceContainer> containerOrder = new ReferenceContainerOrder(this.ram.rowdef().getOrdering().clone());
containerOrder.rotate(new ReferenceContainer(startWordHash, this.ram.rowdef(), 0));
if (ram) {
diff --git a/source/de/anomic/kelondro/text/IndexCollection.java b/source/de/anomic/kelondro/text/IndexCollection.java
index 85c2c4fca..450c7f8a7 100644
--- a/source/de/anomic/kelondro/text/IndexCollection.java
+++ b/source/de/anomic/kelondro/text/IndexCollection.java
@@ -61,7 +61,7 @@ import de.anomic.kelondro.util.kelondroOutOfLimitsException;
import de.anomic.kelondro.util.Log;
import de.anomic.yacy.yacyURL;
-public class IndexCollection implements Index {
+public class IndexCollection extends AbstractIndex implements Index {
private static final int loadfactor = 4;
private static final int serialNumber = 0;
diff --git a/source/de/anomic/kelondro/text/IndexPackage.java b/source/de/anomic/kelondro/text/IndexPackage.java
new file mode 100644
index 000000000..5257b2bd5
--- /dev/null
+++ b/source/de/anomic/kelondro/text/IndexPackage.java
@@ -0,0 +1,91 @@
+// IndexPackage.java
+// -----------------------------
+// (C) 2009 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
+// first published 15.3.2009 on http://yacy.net
+//
+// This is a part of YaCy, a peer-to-peer based web search engine
+//
+// $LastChangedDate: 2006-04-02 22:40:07 +0200 (So, 02 Apr 2006) $
+// $LastChangedRevision: 1986 $
+// $LastChangedBy: orbiter $
+//
+// LICENSE
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+package de.anomic.kelondro.text;
+
+import java.util.HashMap;
+import java.util.Set;
+import java.util.TreeSet;
+
+/*
+ * an IndexPackage is an integration of different index types, i.e.
+ * - ReferenceContainerArray
+ * - ReferenceContainerCache
+ * - IndexCache (which is a wrapper of a ReferenceContainerCache)
+ * - IndexCollection
+ * This interface was created from the methods that are used in CachedIndexCollection
+ * (which integrates IndexCache and IndexCollection)
+ * and is applied to the new index integration class IndexCell
+ * (which integrates ReferenceContainerArray and ReferenceContainerCache)
+ * to make it possible to switch between the old and new index data structure
+ */
+public interface IndexPackage extends Index {
+
+ /*
+ * methods for monitoring of the cache
+ */
+
+ public int maxURLinCache();
+
+ public long minAgeOfCache();
+
+ public long maxAgeOfCache();
+
+ public int indexCacheSize();
+
+ public long indexCacheSizeBytes();
+
+ public void setMaxWordCount(final int maxWords);
+
+ public void cacheFlushControl();
+
+ public void flushCacheFor(int time);
+
+ public int backendSize();
+
+ public int cacheSize();
+
+
+ /*
+ * methods to update the index
+ */
+
+ public void addEntry(final String wordHash, final ReferenceRow entry, final long updateTime);
+
+ /*
+ * methods to search the index
+ */
+
+ public HashMap<String, ReferenceContainer>[] localSearchContainers(
+ final TreeSet<String> queryHashes,
+ final TreeSet<String> excludeHashes,
+ final Set<String> urlselection);
+
+ public TreeSet<ReferenceContainer> indexContainerSet(final String startHash, final boolean ram, final boolean rot, int count);
+
+
+}
diff --git a/source/de/anomic/kelondro/text/IndexReader.java b/source/de/anomic/kelondro/text/IndexReader.java
index 76ac4659e..c6d8add73 100644
--- a/source/de/anomic/kelondro/text/IndexReader.java
+++ b/source/de/anomic/kelondro/text/IndexReader.java
@@ -1,4 +1,4 @@
-// ReverseIndexReader.java
+// IndexReader.java
// (C) 2008 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany
// first published 2.4.2008 on http://yacy.net
//
diff --git a/source/de/anomic/kelondro/text/ReferenceContainer.java b/source/de/anomic/kelondro/text/ReferenceContainer.java
index 7df94010b..94814a819 100644
--- a/source/de/anomic/kelondro/text/ReferenceContainer.java
+++ b/source/de/anomic/kelondro/text/ReferenceContainer.java
@@ -39,6 +39,11 @@ import de.anomic.kelondro.index.RowSet;
import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.util.ByteBuffer;
+/**
+ * A ReferenceContainer is a set of ReferenceRows entries. Since ReferenceRow entries are special
+ * Row entries, a collection of ReferenceRows can be contained in a RowSet. This class extends
+ * the RowSet with methods for the handling of special ReferenceRow Row entry objects.
+ */
public class ReferenceContainer extends RowSet {
private String wordHash;
@@ -60,6 +65,10 @@ public class ReferenceContainer extends RowSet {
return newContainer;
}
+ public static ReferenceContainer emptyContainer(final String wordHash, final int elementCount) {
+ return new ReferenceContainer(wordHash, ReferenceRow.urlEntryRow, elementCount);
+ }
+
public void setWordHash(final String newWordHash) {
this.wordHash = newWordHash;
}
@@ -228,11 +237,11 @@ public class ReferenceContainer extends RowSet {
// join a search result and return the joincount (number of pages after join)
// since this is a conjunction we return an empty entity if any word is not known
- if (includeContainers == null) return CachedIndexCollection.emptyContainer(null, 0);
+ if (includeContainers == null) return ReferenceContainer.emptyContainer(null, 0);
// join the result
final ReferenceContainer rcLocal = ReferenceContainer.joinContainers(includeContainers, maxDistance);
- if (rcLocal == null) return CachedIndexCollection.emptyContainer(null, 0);
+ if (rcLocal == null) return ReferenceContainer.emptyContainer(null, 0);
excludeContainers(rcLocal, excludeContainers);
return rcLocal;
diff --git a/source/de/anomic/kelondro/text/ReferenceContainerArray.java b/source/de/anomic/kelondro/text/ReferenceContainerArray.java
index d403c2b8d..4c91a9d33 100644
--- a/source/de/anomic/kelondro/text/ReferenceContainerArray.java
+++ b/source/de/anomic/kelondro/text/ReferenceContainerArray.java
@@ -95,8 +95,13 @@ public final class ReferenceContainerArray {
* objects in the cache.
* @throws IOException
*/
- public synchronized CloneableIterator<ReferenceContainer> wordContainerIterator(final String startWordHash, final boolean rot, final boolean ram) throws IOException {
- return new heapCacheIterator(startWordHash, rot);
+ public synchronized CloneableIterator<ReferenceContainer> wordContainerIterator(final String startWordHash, final boolean rot, final boolean ram) {
+ try {
+ return new heapCacheIterator(startWordHash, rot);
+ } catch (IOException e) {
+ e.printStackTrace();
+ return null;
+ }
}
/**
diff --git a/source/de/anomic/kelondro/text/ReferenceContainerCache.java b/source/de/anomic/kelondro/text/ReferenceContainerCache.java
index 12a59ffbb..3b8f5bc8c 100644
--- a/source/de/anomic/kelondro/text/ReferenceContainerCache.java
+++ b/source/de/anomic/kelondro/text/ReferenceContainerCache.java
@@ -48,7 +48,7 @@ import de.anomic.kelondro.util.Log;
import de.anomic.kelondro.index.Row;
import de.anomic.kelondro.index.RowSet;
-public final class ReferenceContainerCache implements Iterable<ReferenceContainer>, Index {
+public final class ReferenceContainerCache extends AbstractIndex implements Index, IndexReader, Iterable<ReferenceContainer> {
private final Row payloadrow;
private SortedMap<String, ReferenceContainer> cache;
diff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.java
index 553a04fc4..07002dd04 100644
--- a/source/de/anomic/plasma/plasmaSearchEvent.java
+++ b/source/de/anomic/plasma/plasmaSearchEvent.java
@@ -26,6 +26,7 @@
package de.anomic.plasma;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
@@ -43,6 +44,7 @@ import de.anomic.kelondro.text.Reference;
import de.anomic.kelondro.text.ReferenceContainer;
import de.anomic.kelondro.text.ReferenceVars;
import de.anomic.kelondro.text.URLMetadata;
+import de.anomic.kelondro.text.Word;
import de.anomic.kelondro.util.MemoryControl;
import de.anomic.kelondro.util.SetTools;
import de.anomic.kelondro.util.SortStack;
@@ -248,7 +250,11 @@ public final class plasmaSearchEvent {
if (rw > 0) {
final Set<String> removeWords = cleanEvent.query.queryHashes;
removeWords.addAll(cleanEvent.query.excludeHashes);
- cleanEvent.wordIndex.index().removeEntriesMultiple(removeWords, cleanEvent.failedURLs.keySet());
+ try {
+ cleanEvent.wordIndex.index().removeEntriesMultiple(removeWords, cleanEvent.failedURLs.keySet());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
Log.logInfo("SearchEvents", "cleaning up event " + cleanEvent.query.id(true) + ", removed " + rw + " URL references on " + removeWords.size() + " words");
}
@@ -301,7 +307,7 @@ public final class plasmaSearchEvent {
(query.constraint.get(plasmaCondenser.flag_cat_indexof)) &&
(!(metadata.dc_title().startsWith("Index of")))) {
final Iterator<String> wi = query.queryHashes.iterator();
- while (wi.hasNext()) wordIndex.index().removeReference(wi.next(), page.hash());
+ while (wi.hasNext()) try { wordIndex.index().removeReference(wi.next(), page.hash()); } catch (IOException e) {}
registerFailure(page.hash(), "index-of constraint not fullfilled");
return null;
}
@@ -345,7 +351,12 @@ public final class plasmaSearchEvent {
} else {
// problems with snippet fetch
registerFailure(page.hash(), "no text snippet for URL " + metadata.url());
- if (!wordIndex.peers().mySeed().isVirgin()) plasmaSnippetCache.failConsequences(snippet, query.id(false));
+ if (!wordIndex.peers().mySeed().isVirgin())
+ try {
+ plasmaSnippetCache.failConsequences(snippet, query.id(false));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
return null;
}
} else {
@@ -824,13 +835,17 @@ public final class plasmaSearchEvent {
String address = null;
if ((seed == null) || ((address = seed.getPublicAddress()) == null)) {
// seed is not known from here
- wordIndex.index().removeWordReferences(
- plasmaCondenser.getWords(
- ("yacyshare " +
- filename.replace('?', ' ') +
- " " +
- urlcomps.dc_title())).keySet(),
- urlentry.hash());
+ try {
+ wordIndex.index().removeEntryMultiple(
+ Word.words2hashes(plasmaCondenser.getWords(
+ ("yacyshare " +
+ filename.replace('?', ' ') +
+ " " +
+ urlcomps.dc_title())).keySet()),
+ urlentry.hash());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
wordIndex.metadata().remove(urlentry.hash()); // clean up
throw new RuntimeException("index void");
}
diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.java
index 80f061853..c0c54270e 100644
--- a/source/de/anomic/plasma/plasmaSnippetCache.java
+++ b/source/de/anomic/plasma/plasmaSnippetCache.java
@@ -937,7 +937,7 @@ public class plasmaSnippetCache {
return new Object[]{resource, Long.valueOf(contentLength)};
}
- public static String failConsequences(final TextSnippet snippet, final String eventID) {
+ public static String failConsequences(final TextSnippet snippet, final String eventID) throws IOException {
// problems with snippet fetch
final String urlHash = snippet.getUrl().hash();
final String querystring = SetTools.setToString(snippet.getRemainingHashes(), ' ');
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index dbe02b9a5..dda627d8f 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -143,6 +143,7 @@ import de.anomic.kelondro.text.Document;
import de.anomic.kelondro.text.MetadataRowContainer;
import de.anomic.kelondro.text.URLMetadata;
import de.anomic.kelondro.text.Blacklist;
+import de.anomic.kelondro.text.Word;
import de.anomic.kelondro.util.DateFormatter;
import de.anomic.kelondro.util.FileUtils;
import de.anomic.kelondro.util.Log;
@@ -1772,7 +1773,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
// delete all word references
int count = 0;
- if (words != null) count = webIndex.index().removeWordReferences(words, urlhash);
+ if (words != null) count = webIndex.index().removeEntryMultiple(Word.words2hashes(words), urlhash);
// finally delete the url entry itself
webIndex.metadata().remove(urlhash);
@@ -1780,6 +1781,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
}
} catch (final ParserException e) {
return 0;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return 0;
} finally {
if (resourceContent != null) try { resourceContent.close(); } catch (final Exception e) {/* ignore this */}
}
diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.java
index f22ada707..e35afdb02 100644
--- a/source/de/anomic/plasma/plasmaWordIndex.java
+++ b/source/de/anomic/plasma/plasmaWordIndex.java
@@ -39,6 +39,7 @@ import de.anomic.crawler.IndexingStack;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.http.httpdProxyCacheEntry;
import de.anomic.kelondro.text.CachedIndexCollection;
+import de.anomic.kelondro.text.IndexPackage;
import de.anomic.kelondro.text.MetadataRowContainer;
import de.anomic.kelondro.text.ReferenceContainer;
import de.anomic.kelondro.text.ReferenceRow;
@@ -77,7 +78,7 @@ public final class plasmaWordIndex {
public static final long CRAWL_PROFILE_SNIPPET_GLOBAL_MEDIA_RECRAWL_CYCLE = 60L * 24L * 30L;
- private final CachedIndexCollection index;
+ private final IndexPackage index;
private final Log log;
private MetadataRepository metadata;
private final yacySeedDB peers;
@@ -211,13 +212,13 @@ public final class plasmaWordIndex {
return this.peers;
}
- public CachedIndexCollection index() {
+ public IndexPackage index() {
return this.index;
}
public void clear() {
- index.clear();
try {
+ index.clear();
metadata.clear();
} catch (final IOException e) {
e.printStackTrace();
@@ -559,13 +560,16 @@ public final class plasmaWordIndex {
}
}
}
- if (urlHashs.size() > 0) {
+ if (urlHashs.size() > 0) try {
final int removed = index.removeReferences(container.getWordHash(), urlHashs);
Log.logFine("INDEXCLEANER", container.getWordHash() + ": " + removed + " of " + container.size() + " URL-entries deleted");
lastWordHash = container.getWordHash();
lastDeletionCounter = urlHashs.size();
urlHashs.clear();
+ } catch (IOException e) {
+ e.printStackTrace();
}
+
if (!containerIterator.hasNext()) {
// We may not be finished yet, try to get the next chunk of wordHashes
final TreeSet<ReferenceContainer> containers = index.indexContainerSet(container.getWordHash(), false, false, 100);
diff --git a/source/de/anomic/yacy/dht/Transmission.java b/source/de/anomic/yacy/dht/Transmission.java
index 405a9bc9b..e7f4351fa 100644
--- a/source/de/anomic/yacy/dht/Transmission.java
+++ b/source/de/anomic/yacy/dht/Transmission.java
@@ -235,11 +235,7 @@ public class Transmission {
}
public void restore() {
- for (ReferenceContainer ic : this) try {
- backend.addReferences(ic);
- } catch (IOException e1) {
- e1.printStackTrace();
- }
+ for (ReferenceContainer ic : this) try { backend.addReferences(ic); } catch (IOException e) {}
}
}
}
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 2d4187006..449d26ee3 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -69,7 +69,6 @@ import de.anomic.http.httpRequestHeader;
import de.anomic.kelondro.order.Base64Order;
import de.anomic.kelondro.order.Bitfield;
import de.anomic.kelondro.order.Digest;
-import de.anomic.kelondro.text.CachedIndexCollection;
import de.anomic.kelondro.text.MetadataRowContainer;
import de.anomic.kelondro.text.Reference;
import de.anomic.kelondro.text.ReferenceContainer;
@@ -530,7 +529,7 @@ public final class yacyClient {
final int words = wordhashes.length() / yacySeedDB.commonHashLength;
final ReferenceContainer[] container = new ReferenceContainer[words];
for (int i = 0; i < words; i++) {
- container[i] = CachedIndexCollection.emptyContainer(wordhashes.substring(i * yacySeedDB.commonHashLength, (i + 1) * yacySeedDB.commonHashLength), count);
+ container[i] = ReferenceContainer.emptyContainer(wordhashes.substring(i * yacySeedDB.commonHashLength, (i + 1) * yacySeedDB.commonHashLength), count);
}
// insert results to containers
@@ -638,9 +637,11 @@ public final class yacyClient {
}
// insert the containers to the index
- for (int m = 0; m < words; m++) {
- wordIndex.index().addReferences(container[m]);
- }
+ for (int m = 0; m < words; m++) try {
+ wordIndex.index().addReferences(container[m]);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
// generate statistics
long searchtime;