lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject svn commit: r796334 - in /lucene/solr/trunk/contrib/dataimporthandler: ./ src/main/java/org/apache/solr/handler/dataimport/ src/test/java/org/apache/solr/handler/dataimport/
Date Tue, 21 Jul 2009 15:07:59 GMT
Author: ehatcher
Date: Tue Jul 21 15:07:59 2009
New Revision: 796334

URL: http://svn.apache.org/viewvc?rev=796334&view=rev
Log:
SOLR-1286: Fix the commit parameter always defaulting to "true" even if "false" is explicitly
passed in.


Modified:
    lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt
    lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/AbstractDataImportHandlerTest.java
    lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java
    lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java
    lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java

Modified: lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt?rev=796334&r1=796333&r2=796334&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt (original)
+++ lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt Tue Jul 21 15:07:59 2009
@@ -248,6 +248,9 @@
 
 27.SOLR-1229: Fixes for deletedPkQuery, particularly when using transformed Solr unique id's
               (Lance Norskog, Noble Paul via ehatcher)
+              
+28.SOLR-1286: Fix the commit parameter always defaulting to "true" even if "false" is explicitly
passed in.
+              (Jay Hill, Noble Paul via ehatcher)
              
 
 Documentation

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/AbstractDataImportHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/AbstractDataImportHandlerTest.java?rev=796334&r1=796333&r2=796334&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/AbstractDataImportHandlerTest.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/AbstractDataImportHandlerTest.java
Tue Jul 21 15:07:59 2009
@@ -19,6 +19,7 @@
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.util.AbstractSolrTestCase;
+import org.apache.solr.common.util.NamedList;
 
 import java.io.IOException;
 import java.util.HashMap;
@@ -72,6 +73,17 @@
             dataConfig);
     h.query("/dataimport", request);
   }
+  protected void runFullImport(String dataConfig, Map<String ,String > extraParams)
throws Exception {
+    NamedList l = new NamedList();
+    l.add("command", "full-import");
+    l.add("debug", "on");
+    l.add("dataConfig", dataConfig);
+    for (Map.Entry<String, String> e : extraParams.entrySet()) {
+      l.add(e.getKey(),e.getValue());
+    }
+    LocalSolrQueryRequest request = new LocalSolrQueryRequest(h.getCore(), l);  
+    h.query("/dataimport", request);
+  }
 
   /**
    * Helper for creating a Context instance. Useful for testing Transformers

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java?rev=796334&r1=796333&r2=796334&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java
Tue Jul 21 15:07:59 2009
@@ -515,8 +515,11 @@
         rows = Integer.parseInt((String) requestParams.get("rows"));
       if (requestParams.containsKey("clean"))
         clean = Boolean.parseBoolean((String) requestParams.get("clean"));
-      if (requestParams.containsKey("optimize"))
+      if (requestParams.containsKey("optimize")) {
         optimize = Boolean.parseBoolean((String) requestParams.get("optimize"));
+        if (optimize)
+          commit = true;
+      }
 
       Object o = requestParams.get("entity");
 

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java?rev=796334&r1=796333&r2=796334&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java
Tue Jul 21 15:07:59 2009
@@ -182,11 +182,11 @@
       // Do not commit unnecessarily if this is a delta-import and no documents were created
or deleted
       if (!requestParameters.clean) {
         if (importStatistics.docCount.get() > 0 || importStatistics.deletedDocCount.get()
> 0) {
-          commit(lastIndexTimeProps);
+          finish(lastIndexTimeProps);
         }
       } else {
         // Finished operation normally, commit now
-        commit(lastIndexTimeProps);
+        finish(lastIndexTimeProps);
       }
       if (document.onImportEnd != null) {
         invokeEventListener(document.onImportEnd);
@@ -199,17 +199,18 @@
   }
 
   @SuppressWarnings("unchecked")
-  private void commit(Properties lastIndexTimeProps) {
-    LOG.info("Full Import completed successfully");
+  private void finish(Properties lastIndexTimeProps) {
+    LOG.info("Import completed successfully");
     statusMessages.put("", "Indexing completed. Added/Updated: "
             + importStatistics.docCount + " documents. Deleted "
             + importStatistics.deletedDocCount + " documents.");
-    writer.commit(requestParameters.optimize);
-    addStatusMessage("Committed");
-    if (requestParameters.optimize)
-      addStatusMessage("Optimized");
-    if (requestParameters.commit)
-      writer.persist(lastIndexTimeProps);
+    if(requestParameters.commit) {
+      writer.commit(requestParameters.optimize);
+      addStatusMessage("Committed");
+      if (requestParameters.optimize)
+        addStatusMessage("Optimized");
+    }
+    writer.persist(lastIndexTimeProps);
   }
 
   void rollback() {

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java?rev=796334&r1=796333&r2=796334&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestSqlEntityProcessor2.java
Tue Jul 21 15:07:59 2009
@@ -20,6 +20,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -72,6 +73,24 @@
 
   @Test
   @SuppressWarnings("unchecked")
+  public void testCompositePk_FullImportNoCommit() throws Exception {
+    List parentRow = new ArrayList();
+    parentRow.add(createMap("id", "10"));
+    MockDataSource.setIterator("select * from x", parentRow.iterator());
+
+    List childRow = new ArrayList();
+    childRow.add(createMap("desc", "hello"));
+
+    MockDataSource.setIterator("select * from y where y.A=10", childRow
+            .iterator());
+
+
+    super.runFullImport(dataConfig,createMap("commit","false"));
+    assertQ(req("id:10"), "//*[@numFound='0']");
+  }
+
+  @Test
+  @SuppressWarnings("unchecked")
   public void testCompositePk_DeltaImport() throws Exception {
     List deltaRow = new ArrayList();
     deltaRow.add(createMap("id", "5"));



Mime
View raw message