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/01/31 22:15:37 UTC

[GitHub] [nifi] jfrazee opened a new pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language

jfrazee opened a new pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language
URL: https://github.com/apache/nifi/pull/4031
 
 
   Thank you for submitting a contribution to Apache NiFi.
   
   Please provide a short description of the PR here:
   
   #### Description of PR
   
   This adds type 3 and type 5 namespace and name-based UUID functions to the Expression Language.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [X] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [X] 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.
   
   - [X] Has your PR been rebased against the latest commit within the target branch (typically `master`)?
   
   - [X] 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:
   - [X] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
   - [X] Have you written or updated unit tests to verify your changes?
   - [X] Have you verified that the full build is successful on both JDK 8 and JDK 11?
   - [X] 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`?
   - [X] 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:
   - [X] 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 travis-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


With regards,
Apache Git Services

[GitHub] [nifi] sburges commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language

Posted by GitBox <gi...@apache.org>.
sburges commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language
URL: https://github.com/apache/nifi/pull/4031#discussion_r376099727
 
 

 ##########
 File path: nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/Uuid3Evaluator.java
 ##########
 @@ -0,0 +1,64 @@
+/*
+ * 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.attribute.expression.language.evaluation.functions;
+
+import org.apache.nifi.attribute.expression.language.EvaluationContext;
+import org.apache.nifi.attribute.expression.language.evaluation.Evaluator;
+import org.apache.nifi.attribute.expression.language.evaluation.QueryResult;
+import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator;
+import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult;
+
+import java.nio.ByteBuffer;
+import java.util.Objects;
+import java.util.UUID;
+import org.apache.commons.lang3.ArrayUtils;
+
+public class Uuid3Evaluator extends StringEvaluator {
+
+    private final Evaluator<String> subject;
+    private final Evaluator<String> namespace;
+
+    public Uuid3Evaluator(final Evaluator<String> subject, final Evaluator<String> namespace) {
+        this.subject = subject;
+        this.namespace = namespace;
+    }
+
+    @Override
+    public QueryResult<String> evaluate(final EvaluationContext evaluationContext) {
+        final String subjectValue = subject.evaluate(evaluationContext).getValue();
+        final String nsValue = namespace.evaluate(evaluationContext).getValue();
+        final UUID nsUUID = UUID.fromString(Objects.requireNonNull(nsValue));
+
+        final byte[] nsBytes =
+            ByteBuffer.wrap(new byte[16])
+                .putLong(nsUUID.getMostSignificantBits())
+                .putLong(nsUUID.getLeastSignificantBits())
+                .array();
+
+        final byte[] subjectBytes = Objects.requireNonNull(subjectValue).getBytes();
 
 Review comment:
   I think this is throwing a NullRef when the attribute referenced doesn't exist

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


With regards,
Apache Git Services

[GitHub] [nifi] jfrazee commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language

Posted by GitBox <gi...@apache.org>.
jfrazee commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language
URL: https://github.com/apache/nifi/pull/4031#discussion_r376195035
 
 

 ##########
 File path: nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/Uuid3Evaluator.java
 ##########
 @@ -0,0 +1,64 @@
+/*
+ * 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.attribute.expression.language.evaluation.functions;
+
+import org.apache.nifi.attribute.expression.language.EvaluationContext;
+import org.apache.nifi.attribute.expression.language.evaluation.Evaluator;
+import org.apache.nifi.attribute.expression.language.evaluation.QueryResult;
+import org.apache.nifi.attribute.expression.language.evaluation.StringEvaluator;
+import org.apache.nifi.attribute.expression.language.evaluation.StringQueryResult;
+
+import java.nio.ByteBuffer;
+import java.util.Objects;
+import java.util.UUID;
+import org.apache.commons.lang3.ArrayUtils;
+
+public class Uuid3Evaluator extends StringEvaluator {
+
+    private final Evaluator<String> subject;
+    private final Evaluator<String> namespace;
+
+    public Uuid3Evaluator(final Evaluator<String> subject, final Evaluator<String> namespace) {
+        this.subject = subject;
+        this.namespace = namespace;
+    }
+
+    @Override
+    public QueryResult<String> evaluate(final EvaluationContext evaluationContext) {
+        final String subjectValue = subject.evaluate(evaluationContext).getValue();
+        final String nsValue = namespace.evaluate(evaluationContext).getValue();
+        final UUID nsUUID = UUID.fromString(Objects.requireNonNull(nsValue));
+
+        final byte[] nsBytes =
+            ByteBuffer.wrap(new byte[16])
+                .putLong(nsUUID.getMostSignificantBits())
+                .putLong(nsUUID.getLeastSignificantBits())
+                .array();
+
+        final byte[] subjectBytes = Objects.requireNonNull(subjectValue).getBytes();
 
 Review comment:
   Fixed. Returns `new StringQueryResult(null)` now if the subject is null.

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


With regards,
Apache Git Services

[GitHub] [nifi] joewitt commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language

Posted by GitBox <gi...@apache.org>.
joewitt commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language
URL: https://github.com/apache/nifi/pull/4031#discussion_r383034013
 
 

 ##########
 File path: nifi-commons/nifi-expression-language/pom.xml
 ##########
 @@ -93,5 +93,15 @@
             <artifactId>commons-text</artifactId>
             <version>1.8</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.8.1</version>
 
 Review comment:
   can we go to 3.9

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


With regards,
Apache Git Services

[GitHub] [nifi] joewitt commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language

Posted by GitBox <gi...@apache.org>.
joewitt commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language
URL: https://github.com/apache/nifi/pull/4031#discussion_r383034020
 
 

 ##########
 File path: nifi-commons/nifi-expression-language/pom.xml
 ##########
 @@ -93,5 +93,15 @@
             <artifactId>commons-text</artifactId>
             <version>1.8</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.8.1</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.13</version>
 
 Review comment:
   can we go to 1.14

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


With regards,
Apache Git Services

[GitHub] [nifi] MikeThomsen merged pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language

Posted by GitBox <gi...@apache.org>.
MikeThomsen merged pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language
URL: https://github.com/apache/nifi/pull/4031
 
 
   

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


With regards,
Apache Git Services

[GitHub] [nifi] jfrazee commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language

Posted by GitBox <gi...@apache.org>.
jfrazee commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language
URL: https://github.com/apache/nifi/pull/4031#discussion_r385402846
 
 

 ##########
 File path: nifi-commons/nifi-expression-language/pom.xml
 ##########
 @@ -93,5 +93,15 @@
             <artifactId>commons-text</artifactId>
             <version>1.8</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.8.1</version>
 
 Review comment:
   Bumped and re-tested. AFAICT nothing in the commons-lang3 release suggest a problem.

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


With regards,
Apache Git Services

[GitHub] [nifi] joewitt commented on issue #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language

Posted by GitBox <gi...@apache.org>.
joewitt commented on issue #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language
URL: https://github.com/apache/nifi/pull/4031#issuecomment-590110313
 
 
   would love to see @markap14 get some eyes on here but it looks good.  I'm just not quite comfortable merging myself as I dont feel confident enough in the EL world

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


With regards,
Apache Git Services

[GitHub] [nifi] jfrazee commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language

Posted by GitBox <gi...@apache.org>.
jfrazee commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language
URL: https://github.com/apache/nifi/pull/4031#discussion_r385402846
 
 

 ##########
 File path: nifi-commons/nifi-expression-language/pom.xml
 ##########
 @@ -93,5 +93,15 @@
             <artifactId>commons-text</artifactId>
             <version>1.8</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.8.1</version>
 
 Review comment:
   Bumped and re-tested. AFAICT nothing in the commons-lang3 release notes suggest a problem.

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


With regards,
Apache Git Services

[GitHub] [nifi] jfrazee commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language

Posted by GitBox <gi...@apache.org>.
jfrazee commented on a change in pull request #4031: NIFI-6791 Add UUID3 and UUID5 functions to Expression Language
URL: https://github.com/apache/nifi/pull/4031#discussion_r385403174
 
 

 ##########
 File path: nifi-commons/nifi-expression-language/pom.xml
 ##########
 @@ -93,5 +93,15 @@
             <artifactId>commons-text</artifactId>
             <version>1.8</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.8.1</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.13</version>
 
 Review comment:
   Bumped and re-tested. Similarly, AFAICT nothing in the commons-codec release notes suggest a problem.

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


With regards,
Apache Git Services