[ 
https://issues.apache.org/jira/browse/HADOOP-10544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14649174#comment-14649174
 ] 

Akira AJISAKA commented on HADOOP-10544:
----------------------------------------

Thanks [~jonallen] for updating the patch. The failed test (TestHDFSCLI) looks 
related.  I'm thinking the following code should be fixed.
{code}
+        // split the arg to find any brackets without spaces
+        String[] expandedArg = 
arg.split("((?<=\\()|(?=\\()|(?<=\\))|(?=\\)))");
{code}
String.split will remove the string from the output if it matches the regular 
expression, so we should use {{arg.startsWith("(")}} and {{arg.endsWith(")")}} 
instead.
{code}
      if (!isPath) {
        brackets += splitParenthesis(expressionArgs, arg);
        if (brackets < 0) {
          throw new IOException("Unexpected ')'");
        }
        it.remove();
      }
{code}
{code}
  private int splitParenthesis(List<String> args, String arg) {
    int brackets = 0;
    if (arg.startsWith("(")) {
      brackets++;
      args.add("(");
      brackets += splitParenthesis(args, arg.substring(1));
    } else if (arg.endsWith(")")) {
      brackets--;
      brackets += splitParenthesis(args, arg.substring(0, arg.length() - 1));
      args.add(")");
    } else {
      if (arg.length() > 0) {
        args.add(arg);
      }
    }
    return brackets;
  }
{code}
I'm +1 for making the method recursive since we would like to deal with the 
argument such as {{((-name}}.

> Find command - add operator functions to find command
> -----------------------------------------------------
>
>                 Key: HADOOP-10544
>                 URL: https://issues.apache.org/jira/browse/HADOOP-10544
>             Project: Hadoop Common
>          Issue Type: Sub-task
>            Reporter: Jonathan Allen
>            Assignee: Jonathan Allen
>            Priority: Minor
>              Labels: BB2015-05-TBR
>         Attachments: HADOOP-10544.patch, HADOOP-10544.patch, 
> HADOOP-10544.patch, HADOOP-10544.patch, HADOOP-10544.patch, 
> HADOOP-10544.patch, HADOOP-10544.patch, HADOOP-10544.patch
>
>
> Add operator functions (OR, NOT) to the find command created under 
> HADOOP-8989.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to