hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daryn Sharp (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HADOOP-7494) Add -c option for FSshell -tail
Date Mon, 08 Aug 2011 16:28:27 GMT

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

Daryn Sharp commented on HADOOP-7494:
-------------------------------------

bq. And i think the pattern match is necessary because the error msg displayed by parseLong()
is strange if bytes specified like this -c+-10 or -c+10+.

I'm not sure what you mean... {{parseLong()}} seems to always throw {{java.lang.NumberFormatException:
For input string: "something"}} for bad input.  Wouldn't something like this do what you want?
{code}
try {
  startingOffset = Long.parseLong(arg);
} catch (NumberFormatException)
  throw new NumberFormatException(arg + ": invalid number of bytes"); // note no trailing
"." too
}
{code}

Other generally small issues:
# I generally like to see items in alphabetical order, in this case the usage options.
# I'd suggest changing {{processOffset()}} to {{preprocessOptions()}} and let it locate the
{{-c}}.
# Code removes the {{-c}} when a number is glued on.  May as well remove the {{-c}} too when
it has an argument.
# I think you can remove the pattern compile and use above snippet.
# Should set {{showLastBytes}} in both cases in the event the object is reused.
# {{arg.replace("+", "0")}} isn't right.  It's going to replace all occurrences of + with
0.  It also makes a lone + be a valid argument of 0.  Should use {{arg.substring(1)}} to strip
the leading +.
# You're right about subtracting 1!  The fact that both 0 & 1 are 0 offset is odd.

For the last few points, perhaps something like this might work:
{code}
if (arg.startsWith("+")) {
  arg = arg.substr(arg,1);
  isNegativeOffset = false; // you can leave this showLastBytes if you want
} else {
  if (!arg.startsWith("-")) {
    arg = "-".concat(arg);
  }
  isNegativeOffset = true;
}
// parseLong() with exception cited earlier
if (startingOffset != 0) {
  startingOffset += isNegativeOffset ? 1 : -1;
}
{code}

I hope this helps!

> Add -c option for FSshell -tail
> -------------------------------
>
>                 Key: HADOOP-7494
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7494
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: fs
>    Affects Versions: 0.23.0
>            Reporter: XieXianshan
>            Assignee: XieXianshan
>            Priority: Trivial
>             Fix For: 0.23.0
>
>         Attachments: HADOOP-7494-v0.2.patch, HADOOP-7494.patch
>
>
> Add the "-c" option for FSshell -tail to allow users to specify the output bytes(currently,it's
-1024 by default).
> For instance:
> $ hdfs dfs -tail -c -10 /user/hadoop/xiexs
> or
> $ hdfs dfs -tail -c+10 /user/hadoop/xiexs

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message