Repository: camel
Updated Branches:
  refs/heads/camel-2.12.x 24d46af39 -> 8a5fe8e99


CAMEL-7296 Fixed the hbase consumer issue of pulling the data with family and 
qualifier options


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8a5fe8e9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8a5fe8e9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8a5fe8e9

Branch: refs/heads/camel-2.12.x
Commit: 8a5fe8e995a25d7dcec5f15e540cee499e60dfc6
Parents: 24d46af
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Thu Mar 20 16:12:02 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Thu Mar 20 16:31:37 2014 +0800

----------------------------------------------------------------------
 .../camel/component/hbase/HBaseConsumer.java    | 32 +++++++++++++++-----
 1 file changed, 24 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8a5fe8e9/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConsumer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConsumer.java
 
b/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConsumer.java
index 7040072..67a3050 100644
--- 
a/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConsumer.java
+++ 
b/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseConsumer.java
@@ -106,15 +106,31 @@ public class HBaseConsumer extends 
ScheduledBatchPollingConsumer {
 
                 List<KeyValue> keyValues = result.list();
                 if (keyValues != null) {
-                    for (KeyValue keyValue : keyValues) {
-                        String qualifier = new String(keyValue.getQualifier());
-                        String family = new String(keyValue.getFamily());
-                        HBaseCell resultCell = new HBaseCell();
-                        resultCell.setFamily(family);
-                        resultCell.setQualifier(qualifier);
-                        
resultCell.setValue(endpoint.getCamelContext().getTypeConverter().convertTo(String.class,
 keyValue.getValue()));
-                        resultRow.getCells().add(resultCell);
+                    Set<HBaseCell> cellModels = rowModel.getCells();
+                    if (cellModels.size() > 0) {
+                        for (HBaseCell modelCell : cellModels) {
+                            HBaseCell resultCell = new HBaseCell();
+                            String family = modelCell.getFamily();
+                            String column = modelCell.getQualifier();
+                            
resultCell.setValue(endpoint.getCamelContext().getTypeConverter().convertTo(modelCell.getValueType(),
+                                    
result.getValue(HBaseHelper.getHBaseFieldAsBytes(family), 
HBaseHelper.getHBaseFieldAsBytes(column))));
+                            resultCell.setFamily(modelCell.getFamily());
+                            resultCell.setQualifier(modelCell.getQualifier());
+                            resultRow.getCells().add(resultCell);
+                        }
+                    } else {
+                        // just need to put every key value into the result 
Cells
+                        for (KeyValue keyValue : keyValues) {
+                            String qualifier = new 
String(keyValue.getQualifier());
+                            String family = new String(keyValue.getFamily());
+                            HBaseCell resultCell = new HBaseCell();
+                            resultCell.setFamily(family);
+                            resultCell.setQualifier(qualifier);
+                            
resultCell.setValue(endpoint.getCamelContext().getTypeConverter().convertTo(String.class,
 keyValue.getValue()));
+                            resultRow.getCells().add(resultCell); 
+                        }
                     }
+               
                     data.getRows().add(resultRow);
                     exchange = endpoint.createExchange();
                     // Probably overkill but kept it here for consistency.

Reply via email to