camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] git commit: CAMEL-7296 Fixed the hbase consumer issue of pulling the data with family and qualifier options
Date Thu, 20 Mar 2014 08:22:22 GMT
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/be1d9e41
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/be1d9e41
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/be1d9e41

Branch: refs/heads/master
Commit: be1d9e413e7d32f34f3b0945b4959c83111ec592
Parents: 6b6a387
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Thu Mar 20 16:12:02 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Thu Mar 20 16:21:19 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/be1d9e41/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.


Mime
View raw message