From 395edec6f1469e32dea60737e6f65aac06fa5201 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Fri, 5 Sep 2014 14:50:22 +0200 Subject: [PATCH] changed strategy to count the number of documents: get the max of solr+buffer and the hit cache. This shall help during first crawls to see a running document counter even if there was no commit meanwhile to solr. To support that strategy, the hit cache must be written earlier. --- .../solr/connector/ConcurrentUpdateSolrConnector.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java b/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java index 5cb6331b4..1d7489ca3 100644 --- a/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java +++ b/source/net/yacy/cora/federate/solr/connector/ConcurrentUpdateSolrConnector.java @@ -117,10 +117,6 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector { } catch (final IOException e) { ConcurrentLog.logException(e); } - // move documents to metadata cache - for (Map.Entry entry: this.docBuffer.entrySet()) { - updateCache(entry.getKey(), AbstractSolrConnector.getLoadTimeURL(entry.getValue())); - } this.docBuffer.clear(); } } @@ -162,7 +158,7 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector { @Override public long getSize() { - return this.connector.getSize() + this.docBuffer.size(); + return Math.max(this.metadataCache.size(), this.connector.getSize() + this.docBuffer.size()); } @Override @@ -266,13 +262,12 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector { @Override public void add(SolrInputDocument solrdoc) throws IOException, SolrException { String id = (String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName()); - this.metadataCache.remove(id); // remove the id from the metadata cache because it will be overwritten by the update process anyway + updateCache(id, AbstractSolrConnector.getLoadTimeURL(solrdoc)); ensureAliveProcessHandler(); if (this.processHandler.isAlive()) { synchronized (this.docBuffer) {this.docBuffer.put(id, solrdoc);} } else { this.connector.add(solrdoc); - updateCache(id, AbstractSolrConnector.getLoadTimeURL(solrdoc)); } if (MemoryControl.shortStatus() || this.docBuffer.size() > this.updateCapacity) { commitDocBuffer(); @@ -285,6 +280,7 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector { synchronized (this.docBuffer) { for (SolrInputDocument solrdoc: solrdocs) { String id = (String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName()); + updateCache(id, AbstractSolrConnector.getLoadTimeURL(solrdoc)); if (this.processHandler.isAlive()) { this.docBuffer.put(id, solrdoc); } else {