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 2020/11/09 22:48:48 UTC

[GitHub] [nifi] jfrazee commented on a change in pull request #4570: NIFI-7879 Created record path function for UUID v5

jfrazee commented on a change in pull request #4570:
URL: https://github.com/apache/nifi/pull/4570#discussion_r520147752



##########
File path: nifi-docs/src/main/asciidoc/record-path-guide.adoc
##########
@@ -869,7 +869,42 @@ The following record path expression would append '@' characters to the input St
 | `padRight(/name, 15, '@')` | john smith@@@@@
 |==========================================================
 
+=== uuid5
 
+Inserts a UUID v5 into the target field.
+
+There are two ways to use this function: with or without a "namespace." A namespace is another UUID. Example usage without a namespace:
+
+`uuid5(/input)`
+
+Example usage with a namespace, given this schema
+
+----
+{
+  "type": "record",
+  "name": "events",
+  "fields": [
+    { "name": "input", "type": "string" },
+    { "name": "id_ns", "type": "string" }
+  ]
+}
+----
+
+and a record such as:
+
+----
+{
+  "input" : "john smith",
+  "id_ns": "02b317d3-7fec-421a-89c5-3ad0eb83c79e"
+}
+----
+
+`uuid5(/input, /id_ns)`
+
+Would result in a more complex and unique UUID salted with the value in id_ns being being generated. This is a very good

Review comment:
       ```suggestion
   Would result in a more complex and unique UUID salted with the value in id_ns being generated. This is a good
   ```

##########
File path: nifi-commons/nifi-commons-uuid5/pom.xml
##########
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.10</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.14</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+    <parent>
+        <groupId>org.apache.nifi</groupId>
+        <artifactId>nifi-commons</artifactId>
+        <version>1.13.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>nifi-commons-uuid5</artifactId>

Review comment:
       ```suggestion
       <artifactId>nifi-uuid5</artifactId>
   ```

##########
File path: nifi-docs/src/main/asciidoc/record-path-guide.adoc
##########
@@ -869,7 +869,42 @@ The following record path expression would append '@' characters to the input St
 | `padRight(/name, 15, '@')` | john smith@@@@@
 |==========================================================
 
+=== uuid5

Review comment:
       I find the doc a little confusing since the first case has example output and the second doesn't. Might also want to indicate the errors cases, which I think is just empty or invalid namespace strings and null names.

##########
File path: nifi-commons/nifi-record-path/src/test/java/org/apache/nifi/record/path/TestRecordPath.java
##########
@@ -1644,6 +1646,48 @@ public void testPadRight() {
         assertEquals("MyStringfewfewfewfew", RecordPath.compile("padRight(/someString, 20, \"few\")").evaluate(record).getSelectedFields().findFirst().get().getValue());
     }
 
+    @Test
+    public void testUuidV5() {
+        final List<RecordField> fields = new ArrayList<>();
+        fields.add(new RecordField("input", RecordFieldType.STRING.getDataType()));
+        fields.add(new RecordField("name", RecordFieldType.STRING.getDataType(), true));
+        final RecordSchema schema = new SimpleRecordSchema(fields);
+        final UUID name = UUID.fromString("67eb2232-f06e-406a-b934-e17f5fa31ae4");
+        final String input = "testing NiFi functionality";
+        final Map<String, Object> values = new HashMap<>();
+        values.put("input", input);
+        values.put("name", name.toString());

Review comment:
       Not a big deal but this is a little confusing since name usually refers to the input.




----------------------------------------------------------------
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