Author: shalin
Date: Thu Dec 11 05:43:23 2008
New Revision: 725684
URL: http://svn.apache.org/viewvc?rev=725684&view=rev
Log:
SOLR-884 -- CachedSqlEntityProcessor should check if the cache key is present
in the query results
Modified:
lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt
lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorBase.java
Modified: lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt?rev=725684&r1=725683&r2=725684&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt (original)
+++ lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt Thu Dec 11 05:43:23
2008
@@ -76,6 +76,9 @@
11. SOLR-841: DataImportHandler should throw exception if a field does not
have column attribute
(Michael Henson, shalin)
+12. SOLR-884: CachedSqlEntityProcessor should check if the cache key is
present in the query results
+ (Noble Paul via shalin)
+
Documentation
----------------------
Modified:
lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorBase.java
URL:
http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorBase.java?rev=725684&r1=725683&r2=725684&view=diff
==============================================================================
---
lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorBase.java
(original)
+++
lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/EntityProcessorBase.java
Thu Dec 11 05:43:23 2008
@@ -341,6 +341,12 @@
.get(query);
List<Map<String, Object>> rows = null;
Object key = resolver.resolve(cacheVariableName);
+ if (key == null) {
+ throw new DataImportHandlerException(DataImportHandlerException.WARN,
+ "The cache lookup value : " + cacheVariableName + " is resolved
to be null in the entity :" +
+ context.getEntityAttribute("name"));
+
+ }
if (rowIdVsRows != null) {
rows = rowIdVsRows.get(key);
if (rows == null)
@@ -355,6 +361,17 @@
rowIdVsRows = new HashMap<Object, List<Map<String, Object>>>();
for (Map<String, Object> row : rows) {
Object k = row.get(cachePk);
+ if (k == null) {
+ throw new
DataImportHandlerException(DataImportHandlerException.WARN,
+ "No value available for the cache key : " + cachePk + " in
the entity : " +
+ context.getEntityAttribute("name"));
+ }
+ if (!k.getClass().equals(key.getClass())) {
+ throw new
DataImportHandlerException(DataImportHandlerException.WARN,
+ "The key in the cache type : " + k.getClass().getName() +
+ "is not same as the lookup value type " +
key.getClass().getName() + " in the entity " +
+ context.getEntityAttribute("name"));
+ }
if (rowIdVsRows.get(k) == null)
rowIdVsRows.put(k, new ArrayList<Map<String, Object>>());
rowIdVsRows.get(k).add(row);