From 96b0ebc980a9e9ba411cd220ed1ec2d8cf46e12d Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Fri, 31 Oct 2008 05:32:03 +0000 Subject: [PATCH] SOLR-832 -- Rows parameter is not honored in non-debug mode and can abort a running import in debug mode. git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@709352 13f79535-47bb-0310-9956-ffa450edef68 --- contrib/dataimporthandler/CHANGES.txt | 3 +++ .../handler/dataimport/DataImportHandler.java | 17 ++++++++--------- .../solr/handler/dataimport/DataImporter.java | 3 ++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/contrib/dataimporthandler/CHANGES.txt b/contrib/dataimporthandler/CHANGES.txt index caa8b080578..f7b516bd8b1 100644 --- a/contrib/dataimporthandler/CHANGES.txt +++ b/contrib/dataimporthandler/CHANGES.txt @@ -43,6 +43,9 @@ Bug Fixes 4. SOLR-742: Add ability to create dynamic fields with custom DataImportHandler transformers (Wojtek Piaseczny, Noble Paul, shalin) +5. SOLR-832: Rows parameter is not honored in non-debug mode and can abort a running import in debug mode. + (Akshay Ukey, shalin) + Documentation ---------------------- diff --git a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java index 0b0b9dcd364..000202c7c94 100644 --- a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java +++ b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImportHandler.java @@ -74,8 +74,6 @@ public class DataImportHandler extends RequestHandlerBase implements private Map dataSources = new HashMap(); - private DataImporter.RequestParams requestParams; - private List debugDocuments; private boolean debugEnabled = true; @@ -119,7 +117,7 @@ public class DataImportHandler extends RequestHandlerBase implements throws Exception { rsp.setHttpCaching(false); SolrParams params = req.getParams(); - requestParams = new DataImporter.RequestParams(getParamsMap(params)); + DataImporter.RequestParams requestParams = new DataImporter.RequestParams(getParamsMap(params)); String command = requestParams.command; if (DataImporter.SHOW_CONF_CMD.equals(command)) { @@ -178,7 +176,7 @@ public class DataImportHandler extends RequestHandlerBase implements req.getCore().getUpdateProcessingChain(params.get(UpdateParams.UPDATE_PROCESSOR)); UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp); SolrResourceLoader loader = req.getCore().getResourceLoader(); - SolrWriter sw = getSolrWriter(processor, loader); + SolrWriter sw = getSolrWriter(processor, loader, requestParams); if (requestParams.debug) { if (debugEnabled) { @@ -261,7 +259,7 @@ public class DataImportHandler extends RequestHandlerBase implements } private SolrWriter getSolrWriter(final UpdateRequestProcessor processor, - final SolrResourceLoader loader) { + final SolrResourceLoader loader, final DataImporter.RequestParams requestParams) { return new SolrWriter(processor, loader.getConfigDir()) { @@ -272,10 +270,11 @@ public class DataImportHandler extends RequestHandlerBase implements if (debugDocuments == null) debugDocuments = new ArrayList(); debugDocuments.add(document); - if (debugDocuments.size() >= requestParams.rows) { - // Abort this operation now - importer.getDocBuilder().abort(); - } + } + if (importer.getDocBuilder().importStatistics.docCount.get() >= requestParams.rows) { + // Abort this operation now + importer.getDocBuilder().abort(); + LOG.info("Indexing stopped at docCount = " + importer.getDocBuilder().importStatistics.docCount); } return super.upload(document); } catch (RuntimeException e) { diff --git a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java index bca6d2b23cb..88907803d34 100644 --- a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java +++ b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java @@ -474,7 +474,7 @@ public class DataImporter { public int start = 0; - public int rows = 10; + public int rows = Integer.MAX_VALUE; public boolean clean = true; @@ -493,6 +493,7 @@ public class DataImporter { if ("on".equals(requestParams.get("debug"))) { debug = true; + rows = 10; // Set default values suitable for debug mode commit = false; clean = false;