public void run(InputBenchmarkCmd args) throws Exception {
HadoopNative.requireHadoopNative();
Timer allTime = Metrics.newTimer(InputBenchmark.class, "all-time", MILLISECONDS, MILLISECONDS);
TimerContext allTimerContext = allTime.time();
HiveInputDescription input = new HiveInputDescription();
input.setDbName(args.tableOpts.database);
input.setTableName(args.tableOpts.table);
input.setPartitionFilter(args.tableOpts.partitionFilter);
input.getMetastoreDesc().setHost(args.metastoreOpts.host);
input.getMetastoreDesc().setPort(args.metastoreOpts.port);
HiveConf hiveConf = HiveUtils.newHiveConf(InputBenchmark.class);
System.err.println("Initialize profile with input data");
HiveApiInputFormat.setProfileInputDesc(hiveConf, input, DEFAULT_PROFILE_ID);
HiveApiInputFormat defaultInputFormat = new HiveApiInputFormat();
if (args.trackMetrics) {
defaultInputFormat.setObserver(new MetricsObserver("default", args.recordPrintPeriod));
}
List<InputSplit> splits = defaultInputFormat.getSplits(new JobContext(hiveConf, new JobID()));
System.err.println("getSplits returned " + splits.size() + " splits");
long numRows = 0;
for (int i = 0; i < splits.size(); ++i) {
InputSplit split = splits.get(i);
TaskAttemptID taskID = new TaskAttemptID();
TaskAttemptContext taskContext = new TaskAttemptContext(hiveConf, taskID);
if (i % args.splitPrintPeriod == 0) {
System.err.println("Handling split " + i + " of " + splits.size());
}
RecordReader<WritableComparable, HiveReadableRecord> reader =
defaultInputFormat.createRecordReader(split, taskContext);
reader.initialize(split, taskContext);
numRows += readFully(reader);
}
System.err.println("Parsed " + numRows + " rows");
allTimerContext.stop();
new ConsoleReporter(System.err).run();
}