Class RowCounter
java.lang.Object
org.apache.hadoop.hbase.util.AbstractHBaseTool
org.apache.hadoop.hbase.mapreduce.RowCounter
- All Implemented Interfaces:
org.apache.hadoop.conf.Configurable
,org.apache.hadoop.util.Tool
A job with a just a map phase to count rows. Map outputs table rows IF the input row has columns
that have content.
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
(package private) static class
Mapper that runs the count.Nested classes/interfaces inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
AbstractHBaseTool.OptionsOrderComparator
-
Field Summary
Modifier and TypeFieldDescriptionprivate long
private static final String
private long
private static final String
private static final org.slf4j.Logger
(package private) static final String
Name of this 'program'.private static final String
private static final String
private static final String
private static final String
private List<MultiRowRangeFilter.RowRange>
private long
private String
Fields inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
cmdLineArgs, conf, EXIT_FAILURE, EXIT_SUCCESS, LONG_HELP_OPTION, options, SHORT_HELP_OPTION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Override this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)
and similar methods.org.apache.hadoop.mapreduce.Job
createSubmittableJob
(org.apache.hadoop.conf.Configuration conf) Sets up the actual job.static org.apache.hadoop.mapreduce.Job
createSubmittableJob
(org.apache.hadoop.conf.Configuration conf, String[] args) Deprecated.as of release 2.3.0.protected int
doWork()
The "main function" of the toolstatic void
Main entry point.protected org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParser
Create the parser to use for parsing and validating the command line.private static List<MultiRowRangeFilter.RowRange>
protected void
private static void
printUsage
(String errorMessage) Prints usage without error message.protected void
printUsage
(String usageStr, String usageHeader, String usageFooter) protected void
processOldArgs
(List<String> args) For backward compatibility.protected void
processOptions
(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd) This method is called to process the options after they have been parsed.private static void
setScanFilter
(Scan scan, List<MultiRowRangeFilter.RowRange> rowRangeList) Sets filterFilterBase
to theScan
instance.Methods inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
addOption, addOptNoArg, addOptNoArg, addOptWithArg, addOptWithArg, addRequiredOption, addRequiredOptWithArg, addRequiredOptWithArg, doStaticMain, getConf, getOptionAsDouble, getOptionAsInt, getOptionAsInt, getOptionAsLong, getOptionAsLong, parseArgs, parseInt, parseLong, run, setConf
-
Field Details
-
LOG
-
NAME
Name of this 'program'.- See Also:
-
JOB_NAME_CONF_KEY
- See Also:
-
EXPECTED_COUNT_KEY
-
OPT_START_TIME
- See Also:
-
OPT_END_TIME
- See Also:
-
OPT_RANGE
- See Also:
-
OPT_EXPECTED_COUNT
- See Also:
-
tableName
-
rowRangeList
-
startTime
-
endTime
-
expectedCount
-
columns
-
-
Constructor Details
-
RowCounter
public RowCounter()
-
-
Method Details
-
createSubmittableJob
public org.apache.hadoop.mapreduce.Job createSubmittableJob(org.apache.hadoop.conf.Configuration conf) throws IOException Sets up the actual job.- Parameters:
conf
- The current configuration.- Returns:
- The newly created job.
- Throws:
IOException
- When setting up the job fails.
-
createSubmittableJob
@Deprecated public static org.apache.hadoop.mapreduce.Job createSubmittableJob(org.apache.hadoop.conf.Configuration conf, String[] args) throws IOException Deprecated.as of release 2.3.0. Will be removed on 4.0.0. Please use main method instead.Sets up the actual job.- Parameters:
conf
- The current configuration.args
- The command line parameters.- Returns:
- The newly created job.
- Throws:
IOException
- When setting up the job fails.
-
printUsage
Prints usage without error message. Note that we don't document --expected-count, because it's intended for test. -
parseRowRangeParameter
-
setScanFilter
Sets filterFilterBase
to theScan
instance. If provided rowRangeList contains more than one element, method sets filter which is instance ofMultiRowRangeFilter
. Otherwise, method sets filter which is instance ofFirstKeyOnlyFilter
. If rowRangeList contains exactly one element, startRow and stopRow are set to the scan. -
printUsage
- Overrides:
printUsage
in classAbstractHBaseTool
-
printUsage
- Overrides:
printUsage
in classAbstractHBaseTool
-
addOptions
Description copied from class:AbstractHBaseTool
Override this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)
and similar methods.- Specified by:
addOptions
in classAbstractHBaseTool
-
processOptions
protected void processOptions(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd) throws IllegalArgumentException Description copied from class:AbstractHBaseTool
This method is called to process the options after they have been parsed.- Specified by:
processOptions
in classAbstractHBaseTool
- Throws:
IllegalArgumentException
-
processOldArgs
Description copied from class:AbstractHBaseTool
For backward compatibility. DO NOT use it for new tools. We have options in existing tools which can't be ported to Apache CLI'sOption
. (because they don't pass validation, for e.g. "-copy-to". "-" means short name which doesn't allow '-' in name). This function is to allow tools to have, for time being, parameters which can't be parsed usingOption
. Overrides should consume all valid legacy arguments. If the param 'args' is not empty on return, it means there were invalid options, in which case we'll exit from the tool. Note that it's called beforeAbstractHBaseTool.processOptions(CommandLine)
, which means new options' values will override old ones'.- Overrides:
processOldArgs
in classAbstractHBaseTool
-
doWork
Description copied from class:AbstractHBaseTool
The "main function" of the tool- Specified by:
doWork
in classAbstractHBaseTool
- Throws:
Exception
-
main
Main entry point.- Parameters:
args
- The command line parameters.- Throws:
Exception
- When running the job fails.
-
newParser
Description copied from class:AbstractHBaseTool
Create the parser to use for parsing and validating the command line. Since commons-cli lacks the capability to validate arbitrary combination of options, it may be helpful to bake custom logic into a specialized parser implementation. See LoadTestTool for examples.- Overrides:
newParser
in classAbstractHBaseTool
- Returns:
- a new parser specific to the current tool
-