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

ASF GitHub Bot commented on HADOOP-10579:
-----------------------------------------

LamiumAmplexicaule commented on code in PR #8259:
URL: https://github.com/apache/hadoop/pull/8259#discussion_r3347308579


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/shell/find/NumberExpression.java:
##########
@@ -0,0 +1,109 @@
+/**
+ * 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.hadoop.fs.shell.find;
+
+import java.io.IOException;
+import java.util.Deque;
+
+/**
+ * Base class for numeric {@link Expression}s.
+ * Implements helper methods for processing numeric arguments.
+ */
+public abstract class NumberExpression extends BaseExpression {
+  /**
+   * Number of milliseconds in a day.
+   */
+  protected static final long DAY_IN_MILLISECONDS = 86400000L;
+
+  /**
+   * Number of milliseconds in a minute.
+   */
+  protected static final long MINUTE_IN_MILLISECONDS = 60000L;
+
+  private long max = -1L;
+  private long min = -1L;
+  private long units = 1L;
+
+  /**
+   * Constructor specifying for size of units to used as the expression
+   * argument.
+   *
+   * @param units size of the expression argument compared to the item being
+   *              processed.
+   */
+  protected NumberExpression(long units) {
+    setUnits(units);
+  }
+
+  protected NumberExpression() {
+    this(1L);
+  }
+
+  protected void setUnits(long units) {
+    this.units = units;
+  }
+
+  @Override
+  public void prepare() throws IOException {
+    parseArgument(getArgument(1));
+  }
+
+  /**
+   * Parse the argument string to extract the numeric argument.
+   *
+   * @param arg String to be parsed
+   * @throws IllegalArgumentException if there is a problem parsing the 
argument
+   */
+  protected void parseArgument(String arg) throws IllegalArgumentException {
+    if (arg == null) {
+      throw new IllegalArgumentException("Invalid null argument");
+    } else if (arg.isEmpty()) {
+      throw new IllegalArgumentException("Invalid empty argument");
+    }
+    if (arg.startsWith("+")) {
+      min = (Long.parseLong(arg.substring(1)) * units) + units;
+    } else if (arg.startsWith("-")) {
+      max = (Long.parseLong(arg.substring(1)) * units) - 1L;

Review Comment:
   Thank you for your review.
   I fix it by using `Long.MIN_VALUE` as the sentinel value in 
https://github.com/apache/hadoop/pull/8259/changes/7770bd6296581013043fe9cbb2abfefbd3492e53.





> Find command - add match expressions to find command
> ----------------------------------------------------
>
>                 Key: HADOOP-10579
>                 URL: https://issues.apache.org/jira/browse/HADOOP-10579
>             Project: Hadoop Common
>          Issue Type: Sub-task
>            Reporter: Jonathan Allen
>            Assignee: Hiroki Egawa
>            Priority: Minor
>              Labels: pull-request-available
>         Attachments: HADOOP-10579.patch
>
>
> Add match expressions to the find command created under HADOOP-8989, e.g.:
> - atime
> - empty
> - group
> - mtime
> - newer
> - nogroup
> - nouser
> - perm
> - regex
> - size
> - user



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to