[
https://issues.apache.org/jira/browse/NIFI-1784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15775860#comment-15775860
]
ASF GitHub Bot commented on NIFI-1784:
--------------------------------------
Github user joshelser commented on a diff in the pull request:
https://github.com/apache/nifi/pull/1349#discussion_r93823487
--- Diff:
nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/io/JsonQualifierAndValueRowSerializer.java
---
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.hbase.io;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.nifi.hbase.scan.ResultCell;
+import org.apache.nifi.hbase.util.ResultCellUtil;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
+public class JsonQualifierAndValueRowSerializer implements RowSerializer {
+
+ private final Charset charset;
+ private final boolean base64encodeValues;
+
+ public JsonQualifierAndValueRowSerializer(final Charset charset) {
+ this(charset, false);
+ }
+
+ public JsonQualifierAndValueRowSerializer(final Charset charset, final
boolean base64encodeValues) {
+ this.charset = charset;
+ this.base64encodeValues = base64encodeValues;
+ }
+
+ @Override
+ public void serialize(final byte[] rowKey, final ResultCell[] cells,
final OutputStream out) throws IOException {
+ final StringBuilder jsonBuilder = new StringBuilder();
+ jsonBuilder.append("{");
+
+ int i = 0;
+ for (final ResultCell cell : cells) {
+ final String cellQualifier = new
String(cell.getQualifierArray(), cell.getQualifierOffset(),
cell.getQualifierLength(), charset);
+ final String cellValue = ResultCellUtil.getCellValue(cell,
charset, base64encodeValues);
+
+ if (i > 0) {
+ jsonBuilder.append(", ");
+ }
+
jsonBuilder.append("\"").append(StringEscapeUtils.escapeJson(cellQualifier)).append("\":");
--- End diff --
Might want to apply the same base64 encoding logic to the qualifier as you
would to the value.
I would think that if you base64 encode the value, you'd do all of the
other components as well. However, maybe I'm just being overly cautious. It's
probably fine to only do the value as a first-stab :)
> Create a FetchHBase Processor
> -----------------------------
>
> Key: NIFI-1784
> URL: https://issues.apache.org/jira/browse/NIFI-1784
> Project: Apache NiFi
> Issue Type: Improvement
> Reporter: Bryan Bende
> Assignee: Bryan Bende
> Priority: Minor
> Fix For: 1.2.0
>
>
> We should provide a processor to fetch a row from HBase. The processor should
> support receiving an incoming FlowFile and taking the row id to fetch from an
> attribute on the incoming, and should also be able to fetch a static row id.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)