dan-s1 commented on code in PR #10334:
URL: https://github.com/apache/nifi/pull/10334#discussion_r2379424428
##########
nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/main/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecord.java:
##########
@@ -773,6 +770,47 @@ private Object coerceStringToLong(final String fieldName,
final String stringVal
: stringValue;
}
+ private Record cloneRecord(final Record record) {
+ final Map<String, Object> valuesCopy = cloneValues(record.toMap());
+ return new MapRecord(record.getSchema(), valuesCopy,
record.isTypeChecked(), record.isDropUnknownFields());
+ }
+
+ private Map<String, Object> cloneValues(final Map<String, Object> values) {
+ final Map<String, Object> cloned = new LinkedHashMap<>(values.size());
+ for (final Map.Entry<String, Object> entry : values.entrySet()) {
+ cloned.put(entry.getKey(), cloneValue(entry.getValue()));
+ }
+ return cloned;
+ }
+
+ private Object cloneValue(final Object value) {
Review Comment:
Thanks for clarifying that. Could this cloning be reused? In other words
would it make sense to have a clone/deepClone method in the `Record` interface
and implemented in the implementations.
##########
nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/main/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecord.java:
##########
@@ -773,6 +770,47 @@ private Object coerceStringToLong(final String fieldName,
final String stringVal
: stringValue;
}
+ private Record cloneRecord(final Record record) {
+ final Map<String, Object> valuesCopy = cloneValues(record.toMap());
+ return new MapRecord(record.getSchema(), valuesCopy,
record.isTypeChecked(), record.isDropUnknownFields());
+ }
+
+ private Map<String, Object> cloneValues(final Map<String, Object> values) {
+ final Map<String, Object> cloned = new LinkedHashMap<>(values.size());
+ for (final Map.Entry<String, Object> entry : values.entrySet()) {
+ cloned.put(entry.getKey(), cloneValue(entry.getValue()));
+ }
+ return cloned;
+ }
+
+ private Object cloneValue(final Object value) {
Review Comment:
Thanks for clarifying that. Could this cloning be reused? In other words
would it make sense to have a clone/deepClone method in the `Record` interface
and implemented in the implementations?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]