mattyb149 commented on a change in pull request #3977: NIFI-7007 Add update 
functionality to the PutCassandraRecord processor.
URL: https://github.com/apache/nifi/pull/3977#discussion_r366566815
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-cassandra-bundle/nifi-cassandra-processors/src/main/java/org/apache/nifi/processors/cassandra/PutCassandraRecord.java
 ##########
 @@ -193,6 +231,74 @@ public void onTrigger(ProcessContext context, 
ProcessSession session) throws Pro
 
     }
 
+    private Statement generateUpdate(String cassandraTable, RecordSchema 
schema, String updateKeys, String updateMethod, Map<String, Object> 
recordContentMap) {
+        Update updateQuery;
+
+        // Split up the update key names separated by a comma, we need at 
least 1 key.
+        final Set<String> updateKeyNames;
+        updateKeyNames = new HashSet<>();
+        for (final String updateKey : updateKeys.split(",")) {
+            updateKeyNames.add(updateKey.trim());
 
 Review comment:
   You may want to check for the empty string here before adding to the set. 
There's a common pattern you see in NiFi, something like:
   
   ```
   updateKeyNames = Arrays.stream(updateKeys.split(","))
      .map(String::trim)
      .filter(StringUtils::isNotEmpty)
      collect(Collectors.toSet());
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to