You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2012/07/18 18:58:48 UTC
svn commit: r1363018 - in /lucene/dev/branches/branch_4x: ./ solr/
solr/core/src/java/org/apache/solr/update/processor/
solr/core/src/test/org/apache/solr/
solr/solrj/src/java/org/apache/solr/common/
Author: markrmiller
Date: Wed Jul 18 16:58:47 2012
New Revision: 1363018
URL: http://svn.apache.org/viewvc?rev=1363018&view=rev
Log:
SOLR-3215: Clone SolrInputDocument when distrib indexing so that update processors after the distrib update process do not process the document twice.
Added:
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/TestDocumentBuilder.java
- copied unchanged from r1363013, lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDocumentBuilder.java
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1363018&r1=1363017&r2=1363018&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Wed Jul 18 16:58:47 2012
@@ -113,6 +113,9 @@ Other Changes
* SOLR-3600: Raise the default zkClientTimeout from 10 seconds to 15 seconds. (Mark Miller)
+* SOLR-3215: Clone SolrInputDocument when distrib indexing so that update processors after
+ the distrib update process do not process the document twice. (Mark Miller)
+
================== 4.0.0-ALPHA ==================
More information about this release, including any errata related to the
release notes, upgrade instructions, or other changes may be found online at:
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java?rev=1363018&r1=1363017&r2=1363018&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java Wed Jul 18 16:58:47 2012
@@ -285,7 +285,10 @@ public class DistributedUpdateProcessor
boolean dropCmd = false;
if (!forwardToLeader) {
- dropCmd = versionAdd(cmd);
+ // clone the original doc
+ SolrInputDocument clonedDoc = cmd.solrDoc.deepCopy();
+ dropCmd = versionAdd(cmd, clonedDoc);
+ cmd.solrDoc = clonedDoc;
}
if (dropCmd) {
@@ -393,10 +396,11 @@ public class DistributedUpdateProcessor
/**
* @param cmd
+ * @param cloneDoc needs the version if it's assigned
* @return whether or not to drop this cmd
* @throws IOException
*/
- private boolean versionAdd(AddUpdateCommand cmd) throws IOException {
+ private boolean versionAdd(AddUpdateCommand cmd, SolrInputDocument cloneDoc) throws IOException {
BytesRef idBytes = cmd.getIndexedId();
if (vinfo == null || idBytes == null) {
@@ -469,6 +473,7 @@ public class DistributedUpdateProcessor
long version = vinfo.getNewClock();
cmd.setVersion(version);
cmd.getSolrInputDocument().setField(VersionInfo.VERSION_FIELD, version);
+ cloneDoc.setField(VersionInfo.VERSION_FIELD, version);
bucket.updateHighest(version);
} else {
// The leader forwarded us this update.
Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java?rev=1363018&r1=1363017&r2=1363018&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java Wed Jul 18 16:58:47 2012
@@ -18,10 +18,10 @@
package org.apache.solr.common;
import java.io.Serializable;
+import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
-import java.util.Collection;
import java.util.Set;
/**
@@ -182,6 +182,15 @@ public class SolrInputDocument implement
return "SolrInputDocument" + _fields.values();
}
+ public SolrInputDocument deepCopy() {
+ SolrInputDocument clone = new SolrInputDocument();
+ Set<Entry<String,SolrInputField>> entries = _fields.entrySet();
+ for (Map.Entry<String,SolrInputField> fieldEntry : entries) {
+ clone._fields.put(fieldEntry.getKey(), fieldEntry.getValue().deepCopy());
+ }
+ clone._documentBoost = _documentBoost;
+ return clone;
+ }
//---------------------------------------------------
// MAP interface
Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java?rev=1363018&r1=1363017&r2=1363018&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java (original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/common/SolrInputField.java Wed Jul 18 16:58:47 2012
@@ -199,4 +199,19 @@ public class SolrInputField implements I
{
return name + ((boost == 1.0) ? "=" : ("("+boost+")=")) + value;
}
+
+ public SolrInputField deepCopy() {
+ SolrInputField clone = new SolrInputField(name);
+ clone.boost = boost;
+ // We can't clone here, so we rely on simple primitives
+ if (value instanceof Collection) {
+ Collection<Object> values = (Collection<Object>) value;
+ Collection<Object> cloneValues = new ArrayList<Object>(values.size());
+ cloneValues.addAll(values);
+ clone.value = cloneValues;
+ } else {
+ clone.value = value;
+ }
+ return clone;
+ }
}