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.
pull/1/head
Michael Peter Christen 11 years ago
parent e87dc08c0d
commit 395edec6f1

@ -117,10 +117,6 @@ public class ConcurrentUpdateSolrConnector implements SolrConnector {
} catch (final IOException e) {
ConcurrentLog.logException(e);
}
// move documents to metadata cache
for (Map.Entry<String, SolrInputDocument> 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 {

Loading…
Cancel
Save