You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/03/24 05:59:18 UTC

[GitHub] [nifi] timeabarna opened a new pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

timeabarna opened a new pull request #4931:
URL: https://github.com/apache/nifi/pull/4931


   Added value to record schema in order to displaying it in the scan result.
   https://issues.apache.org/jira/browse/NIFI-8283
   
   #### Description of PR
   
   Added value to record schema in order to displaying it in the scan result.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [ ] Does your PR title start with **NIFI-XXXX** where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically `main`)?
   
   - [ ] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
   
   ### For code changes:
   - [ ] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
   - [ ] Have you written or updated unit tests to verify your changes?
   - [ ] Have you verified that the full build is successful on JDK 8?
   - [ ] Have you verified that the full build is successful on JDK 11?
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
   - [ ] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
   - [ ] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
   - [ ] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] timeabarna commented on pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
timeabarna commented on pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#issuecomment-806425096


   @phrocker Thanks for your recommendation, I've updated the code accordingly


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] phrocker edited a comment on pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
phrocker edited a comment on pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#issuecomment-805981714


   Hi @timeabarna  May want to add this as an option that is true by default. Thanks for the change.
   
   There are cases where people do not want values and want to only get the keys, so an option can facilitate those cases as well. 
   
   Apologies for forgetting about that change.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] timeabarna commented on a change in pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
timeabarna commented on a change in pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#discussion_r600516907



##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -254,7 +258,12 @@ public void process(final InputStream in, final OutputStream out) throws IOExcep
 
                             try{
                                 final RecordSchema writeSchema = writerFactory.getSchema(flowAttributes, new KeySchema());
-                                try (final RecordSetWriter writer = writerFactory.createWriter(getLogger(), writeSchema, out)) {
+                                List<RecordField> fieldList = new ArrayList<>();
+                                fieldList.addAll(writeSchema.getFields());
+                                fieldList.add(new RecordField("value", RecordFieldType.STRING.getDataType()));

Review comment:
       Thanks for your help exceptionfactory, String will cover most cases




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] asfgit closed pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #4931:
URL: https://github.com/apache/nifi/pull/4931


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] markap14 commented on a change in pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
markap14 commented on a change in pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#discussion_r600483300



##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -270,8 +279,9 @@ public void process(final InputStream in, final OutputStream out) throws IOExcep
                                         data.put("columnQualifier", key.getColumnQualifier().toString());
                                         data.put("columnVisibility", key.getColumnVisibility().toString());
                                         data.put("timestamp", key.getTimestamp());
+                                        data.put("value", kv.getValue());

Review comment:
       The schema here indicates that this field is to be a `String` type. That means that the value added into the map needs to be a String also, but it's of type `Value`. Need to ensure that it's properly converted to a `String` before putting into the Map.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] pvillard31 commented on pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
pvillard31 commented on pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#issuecomment-806604948


   Merged to main, thanks @timeabarna 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] timeabarna commented on a change in pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
timeabarna commented on a change in pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#discussion_r600517501



##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -254,7 +258,12 @@ public void process(final InputStream in, final OutputStream out) throws IOExcep
 
                             try{
                                 final RecordSchema writeSchema = writerFactory.getSchema(flowAttributes, new KeySchema());
-                                try (final RecordSetWriter writer = writerFactory.createWriter(getLogger(), writeSchema, out)) {
+                                List<RecordField> fieldList = new ArrayList<>();

Review comment:
       renamed variable to recordSchemaFields




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] timeabarna commented on a change in pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
timeabarna commented on a change in pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#discussion_r600515517



##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -270,8 +279,9 @@ public void process(final InputStream in, final OutputStream out) throws IOExcep
                                         data.put("columnQualifier", key.getColumnQualifier().toString());
                                         data.put("columnVisibility", key.getColumnVisibility().toString());
                                         data.put("timestamp", key.getTimestamp());
+                                        data.put("value", kv.getValue());

Review comment:
       Thanks Mark for your help, modified to kv.getValue().toString()




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] timeabarna commented on a change in pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
timeabarna commented on a change in pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#discussion_r600644024



##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -270,8 +281,9 @@ public void process(final InputStream in, final OutputStream out) throws IOExcep
                                         data.put("columnQualifier", key.getColumnQualifier().toString());
                                         data.put("columnVisibility", key.getColumnVisibility().toString());
                                         data.put("timestamp", key.getTimestamp());
+                                        data.put("value", kv.getValue().toString());

Review comment:
       To be on the safe side I've added the null check




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] pvillard31 commented on a change in pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
pvillard31 commented on a change in pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#discussion_r601403451



##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -143,6 +150,16 @@
             .addValidator(Validator.VALID)
             .build();
 
+    static final PropertyDescriptor VALUE_INCLUDED_IN_RESULT = new PropertyDescriptor.Builder()
+            .displayName("Value Included in Result")
+            .name("accumulo-value-inclusive")
+            .description("Beside keys and their values, accumulo value field will also be included in the result as UTF-8 Encoded String.")
+            .required(false)
+            .defaultValue("True")

Review comment:
       ```suggestion
               .defaultValue("true")
   ```

##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -143,6 +150,16 @@
             .addValidator(Validator.VALID)
             .build();
 
+    static final PropertyDescriptor VALUE_INCLUDED_IN_RESULT = new PropertyDescriptor.Builder()
+            .displayName("Value Included in Result")
+            .name("accumulo-value-inclusive")
+            .description("Beside keys and their values, accumulo value field will also be included in the result as UTF-8 Encoded String.")
+            .required(false)
+            .defaultValue("True")
+            .allowableValues("True", "False")

Review comment:
       ```suggestion
               .allowableValues("true", "false")
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] markap14 commented on a change in pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
markap14 commented on a change in pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#discussion_r600590158



##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -270,8 +281,9 @@ public void process(final InputStream in, final OutputStream out) throws IOExcep
                                         data.put("columnQualifier", key.getColumnQualifier().toString());
                                         data.put("columnVisibility", key.getColumnVisibility().toString());
                                         data.put("timestamp", key.getTimestamp());
+                                        data.put("value", kv.getValue().toString());

Review comment:
       Is it possible here for the value to be null? I don't know much about accumulo, but i would guess so. If so, we need to check if null and if so avoid calling `toString()` on the null reference




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] phrocker commented on pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
phrocker commented on pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#issuecomment-805981714


   Hi @timeabarna  May want to add this as an option that is true by default. Thanks for the change.
   
   There are cases where people do not want values and want to only get the keys. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] timeabarna commented on a change in pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
timeabarna commented on a change in pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#discussion_r601419176



##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -143,6 +150,16 @@
             .addValidator(Validator.VALID)
             .build();
 
+    static final PropertyDescriptor VALUE_INCLUDED_IN_RESULT = new PropertyDescriptor.Builder()
+            .displayName("Value Included in Result")
+            .name("accumulo-value-inclusive")
+            .description("Beside keys and their values, accumulo value field will also be included in the result as UTF-8 Encoded String.")
+            .required(false)
+            .defaultValue("True")
+            .allowableValues("True", "False")

Review comment:
         @pvillard31 thanks for your comment however within this processor all boolean type properties start with capital letters, so I followed the pattern to stay consistent.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #4931: NIFI-8283 Value handling in ScanAccumulo processor

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #4931:
URL: https://github.com/apache/nifi/pull/4931#discussion_r600474873



##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -254,7 +258,12 @@ public void process(final InputStream in, final OutputStream out) throws IOExcep
 
                             try{
                                 final RecordSchema writeSchema = writerFactory.getSchema(flowAttributes, new KeySchema());
-                                try (final RecordSetWriter writer = writerFactory.createWriter(getLogger(), writeSchema, out)) {
+                                List<RecordField> fieldList = new ArrayList<>();

Review comment:
       Recommend declaring this variable and other variables as `final` following the general pattern of the Processor.  Renaming the variable to something like `writeSchemaFields` or `recordSchemaFields` would also be helpful.

##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -254,7 +258,12 @@ public void process(final InputStream in, final OutputStream out) throws IOExcep
 
                             try{
                                 final RecordSchema writeSchema = writerFactory.getSchema(flowAttributes, new KeySchema());
-                                try (final RecordSetWriter writer = writerFactory.createWriter(getLogger(), writeSchema, out)) {
+                                List<RecordField> fieldList = new ArrayList<>();
+                                fieldList.addAll(writeSchema.getFields());
+                                fieldList.add(new RecordField("value", RecordFieldType.STRING.getDataType()));

Review comment:
       The Accumulo `Value` object contains a byte array which can be converted to UTF-8 String, but does conversion to String cover all use cases?

##########
File path: nifi-nar-bundles/nifi-accumulo-bundle/nifi-accumulo-processors/src/main/java/org/apache/nifi/accumulo/processors/ScanAccumulo.java
##########
@@ -270,8 +279,9 @@ public void process(final InputStream in, final OutputStream out) throws IOExcep
                                         data.put("columnQualifier", key.getColumnQualifier().toString());
                                         data.put("columnVisibility", key.getColumnVisibility().toString());
                                         data.put("timestamp", key.getTimestamp());
+                                        data.put("value", kv.getValue());

Review comment:
       As mentioned in the RecordField definition, `Value.toString()` converts the underlying byte array to a UTF-8 encoded String.  If that covers all use cases, this should be changed to `kv.getValue().toString()`.  Alternatively, if the underlying byte array should be represented, this should be changed to `kv.getValue().get()` and the RecordFieldType should be changed,




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org