You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by JPercivall <gi...@git.apache.org> on 2016/10/26 20:34:06 UTC

[GitHub] nifi pull request #1161: NIFI-2950 Adding support for whole number hex value...

GitHub user JPercivall opened a pull request:

    https://github.com/apache/nifi/pull/1161

    NIFI-2950 Adding support for whole number hex values and a fromRadix function

    Thank you for submitting a contribution to Apache NiFi.
    
    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?
    
    ### 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] 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)? 
    - [X] 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?
    - [X] 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.
    
    \u2026

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/JPercivall/nifi NIFI-2950

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/1161.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1161
    
----
commit 3240d90cec85413cf62c2e13f76a4d797d14f9e3
Author: jpercivall <jo...@yahoo.com>
Date:   2016-10-26T20:34:14Z

    NIFI-2950 Adding support for whole number hex values and a fromRadix function

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1161: NIFI-2950 Adding support for whole number hex value...

Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1161#discussion_r85231591
  
    --- Diff: nifi-docs/src/main/asciidoc/expression-language-guide.adoc ---
    @@ -1645,6 +1649,34 @@ Divide. This is to preserve backwards compatibility and to not force rounding er
     |=======================================================================================
     
     [.function]
    +=== fromRadix
    +
    +*Description*: [.description]#Converts the Subject from a specified Radix (or number base) to a base ten whole number. The subject will converted as is, without interpretation, and all characters
    +must be valid for the base being converted from. For example converting "0xFF" from hex will not work due to it not x not being a valid hex character.
    --- End diff --
    
    I think there is a typo in "due to *it not x not* being a valid hex character". 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1161: NIFI-2950 Adding support for whole number hex value...

Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1161#discussion_r86192691
  
    --- Diff: nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/FromRadixEvaluator.java ---
    @@ -0,0 +1,58 @@
    +/*
    + * 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.evaluation.Evaluator;
    +import org.apache.nifi.attribute.expression.language.evaluation.QueryResult;
    +import org.apache.nifi.attribute.expression.language.evaluation.WholeNumberEvaluator;
    +import org.apache.nifi.attribute.expression.language.evaluation.WholeNumberQueryResult;
    +
    +import java.util.Map;
    +
    +public class FromRadixEvaluator extends WholeNumberEvaluator {
    +
    +    private final Evaluator<String> numberEvaluator;
    +    private final Evaluator<Long> radixEvaluator;
    +
    +    public FromRadixEvaluator(final Evaluator<String> subject, final Evaluator<Long> radixEvaluator) {
    +        this.numberEvaluator = subject;
    +        this.radixEvaluator = radixEvaluator;
    +    }
    +
    +    @Override
    +    public QueryResult<Long> evaluate(final Map<String, String> attributes) {
    +        final String result = numberEvaluator.evaluate(attributes).getValue();
    --- End diff --
    
    Given that this is a public method, consider null check on ```attributes``` to avoid NPE unless this class is not considered to be part of public API.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1161: NIFI-2950 Adding support for whole number hex value...

Posted by JPercivall <gi...@git.apache.org>.
Github user JPercivall commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1161#discussion_r85343844
  
    --- Diff: nifi-docs/src/main/asciidoc/expression-language-guide.adoc ---
    @@ -1645,6 +1649,34 @@ Divide. This is to preserve backwards compatibility and to not force rounding er
     |=======================================================================================
     
     [.function]
    +=== fromRadix
    +
    +*Description*: [.description]#Converts the Subject from a specified Radix (or number base) to a base ten whole number. The subject will converted as is, without interpretation, and all characters
    +must be valid for the base being converted from. For example converting "0xFF" from hex will not work due to it not x not being a valid hex character.
    --- End diff --
    
    Yup you're right, will fix.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi issue #1161: NIFI-2950 Adding support for whole number hex values and a...

Posted by olegz <gi...@git.apache.org>.
Github user olegz commented on the issue:

    https://github.com/apache/nifi/pull/1161
  
    +1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1161: NIFI-2950 Adding support for whole number hex value...

Posted by JPercivall <gi...@git.apache.org>.
Github user JPercivall commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1161#discussion_r86605783
  
    --- Diff: nifi-commons/nifi-expression-language/src/main/java/org/apache/nifi/attribute/expression/language/evaluation/functions/FromRadixEvaluator.java ---
    @@ -0,0 +1,58 @@
    +/*
    + * 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.evaluation.Evaluator;
    +import org.apache.nifi.attribute.expression.language.evaluation.QueryResult;
    +import org.apache.nifi.attribute.expression.language.evaluation.WholeNumberEvaluator;
    +import org.apache.nifi.attribute.expression.language.evaluation.WholeNumberQueryResult;
    +
    +import java.util.Map;
    +
    +public class FromRadixEvaluator extends WholeNumberEvaluator {
    +
    +    private final Evaluator<String> numberEvaluator;
    +    private final Evaluator<Long> radixEvaluator;
    +
    +    public FromRadixEvaluator(final Evaluator<String> subject, final Evaluator<Long> radixEvaluator) {
    +        this.numberEvaluator = subject;
    +        this.radixEvaluator = radixEvaluator;
    +    }
    +
    +    @Override
    +    public QueryResult<Long> evaluate(final Map<String, String> attributes) {
    +        final String result = numberEvaluator.evaluate(attributes).getValue();
    --- End diff --
    
    I highly doubt this is considered part of the Public API. 
    
    Also passing null to the evaluate() methods is expected but since I never explicitly use attributes (other than passing it to the next evaluator), it is safe from NPE.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] nifi pull request #1161: NIFI-2950 Adding support for whole number hex value...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/nifi/pull/1161


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---