HBASE-14770 RowCounter argument input parse error
Signed-off-by: stack <stack@apache.org>
This commit is contained in:
parent
efc7a0d347
commit
59b03c77de
|
@ -118,10 +118,7 @@ public class RowCounter extends Configured implements Tool {
|
||||||
}
|
}
|
||||||
startKey = startEnd[0];
|
startKey = startEnd[0];
|
||||||
endKey = startEnd[1];
|
endKey = startEnd[1];
|
||||||
}
|
continue;
|
||||||
if (startTime < endTime) {
|
|
||||||
printUsage("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
if (args[i].startsWith(startTimeArgKey)) {
|
if (args[i].startsWith(startTimeArgKey)) {
|
||||||
startTime = Long.parseLong(args[i].substring(startTimeArgKey.length()));
|
startTime = Long.parseLong(args[i].substring(startTimeArgKey.length()));
|
||||||
|
@ -136,11 +133,13 @@ public class RowCounter extends Configured implements Tool {
|
||||||
Long.parseLong(args[i].substring(expectedCountArg.length())));
|
Long.parseLong(args[i].substring(expectedCountArg.length())));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
// if no switch, assume column names
|
||||||
// if no switch, assume column names
|
sb.append(args[i]);
|
||||||
sb.append(args[i]);
|
sb.append(" ");
|
||||||
sb.append(" ");
|
}
|
||||||
}
|
if (endTime < startTime) {
|
||||||
|
printUsage("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Job job = Job.getInstance(conf, conf.get(JOB_NAME_CONF_KEY, NAME + "_" + tableName));
|
Job job = Job.getInstance(conf, conf.get(JOB_NAME_CONF_KEY, NAME + "_" + tableName));
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class TestRowCounter {
|
||||||
private static final Log LOG = LogFactory.getLog(TestRowCounter.class);
|
private static final Log LOG = LogFactory.getLog(TestRowCounter.class);
|
||||||
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
|
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
|
||||||
private final static String TABLE_NAME = "testRowCounter";
|
private final static String TABLE_NAME = "testRowCounter";
|
||||||
|
private final static String TABLE_NAME_TS_RANGE = "testRowCounter_ts_range";
|
||||||
private final static String COL_FAM = "col_fam";
|
private final static String COL_FAM = "col_fam";
|
||||||
private final static String COL1 = "c1";
|
private final static String COL1 = "c1";
|
||||||
private final static String COL2 = "c2";
|
private final static String COL2 = "c2";
|
||||||
|
@ -138,6 +139,21 @@ public class TestRowCounter {
|
||||||
runRowCount(args, 10);
|
runRowCount(args, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test a case when the column specified in command line arguments is
|
||||||
|
* exclusive for few rows and also a row range filter is specified
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testRowCounterColumnAndRowRange() throws Exception {
|
||||||
|
String[] args = new String[] {
|
||||||
|
TABLE_NAME, "--range=rov,rox", COL_FAM + ":" + COL1
|
||||||
|
};
|
||||||
|
runRowCount(args, 8);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a case when the timerange is specified with --starttime and --endtime options
|
* Test a case when the timerange is specified with --starttime and --endtime options
|
||||||
*
|
*
|
||||||
|
@ -154,7 +170,8 @@ public class TestRowCounter {
|
||||||
long ts;
|
long ts;
|
||||||
|
|
||||||
// clean up content of TABLE_NAME
|
// clean up content of TABLE_NAME
|
||||||
Table table = TEST_UTIL.deleteTableData(TableName.valueOf(TABLE_NAME));
|
Table table = TEST_UTIL.createTable(TableName.valueOf(TABLE_NAME_TS_RANGE), Bytes.toBytes(COL_FAM));
|
||||||
|
|
||||||
ts = System.currentTimeMillis();
|
ts = System.currentTimeMillis();
|
||||||
put1.addColumn(family, col1, ts, Bytes.toBytes("val1"));
|
put1.addColumn(family, col1, ts, Bytes.toBytes("val1"));
|
||||||
table.put(put1);
|
table.put(put1);
|
||||||
|
@ -168,28 +185,28 @@ public class TestRowCounter {
|
||||||
table.close();
|
table.close();
|
||||||
|
|
||||||
String[] args = new String[] {
|
String[] args = new String[] {
|
||||||
TABLE_NAME, COL_FAM + ":" + COL1,
|
TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1,
|
||||||
"--starttime=" + 0,
|
"--starttime=" + 0,
|
||||||
"--endtime=" + ts
|
"--endtime=" + ts
|
||||||
};
|
};
|
||||||
runRowCount(args, 1);
|
runRowCount(args, 1);
|
||||||
|
|
||||||
args = new String[] {
|
args = new String[] {
|
||||||
TABLE_NAME, COL_FAM + ":" + COL1,
|
TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1,
|
||||||
"--starttime=" + 0,
|
"--starttime=" + 0,
|
||||||
"--endtime=" + (ts - 10)
|
"--endtime=" + (ts - 10)
|
||||||
};
|
};
|
||||||
runRowCount(args, 1);
|
runRowCount(args, 1);
|
||||||
|
|
||||||
args = new String[] {
|
args = new String[] {
|
||||||
TABLE_NAME, COL_FAM + ":" + COL1,
|
TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1,
|
||||||
"--starttime=" + ts,
|
"--starttime=" + ts,
|
||||||
"--endtime=" + (ts + 1000)
|
"--endtime=" + (ts + 1000)
|
||||||
};
|
};
|
||||||
runRowCount(args, 2);
|
runRowCount(args, 2);
|
||||||
|
|
||||||
args = new String[] {
|
args = new String[] {
|
||||||
TABLE_NAME, COL_FAM + ":" + COL1,
|
TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1,
|
||||||
"--starttime=" + (ts - 30 * 1000),
|
"--starttime=" + (ts - 30 * 1000),
|
||||||
"--endtime=" + (ts + 30 * 1000),
|
"--endtime=" + (ts + 30 * 1000),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue