} else if (nonFlagArgs.size() > 1) {
getPrintStream().printf("Too many arguments: %s%n", nonFlagArgs);
return FAILURE;
}
final KijiURI argURI = KijiURI.newBuilder(nonFlagArgs.get(0)).build();
if ((null == argURI.getZookeeperQuorum())
|| (null == argURI.getInstance())
|| (null == argURI.getTable())) {
// TODO: Send this error to a future getErrorStream()
getPrintStream().printf("Specify a cluster, instance, and "
+ "table with argument kiji://zkhost/instance/table%n");
return FAILURE;
}
if (mMaxVersions < 1) {
// TODO: Send this error to a future getErrorStream()
getPrintStream().printf("--max-versions must be positive, got %d%n", mMaxVersions);
return FAILURE;
}
if (mEntityIdFlag == null) {
// TODO: Send this error to a future getErrorStream()
getPrintStream().printf("Specify entity with --entity-id=eid%n");
return FAILURE;
}
final Pattern timestampPattern = Pattern.compile("([0-9]*)\\.\\.([0-9]*)");
final Matcher timestampMatcher = timestampPattern.matcher(mTimestamp);
if (timestampMatcher.matches()) {
mMinTimestamp = ("".equals(timestampMatcher.group(1))) ? 0
: Long.parseLong(timestampMatcher.group(1));
final String rightEndpoint = timestampMatcher.group(2);
mMaxTimestamp = ("".equals(rightEndpoint)) ? Long.MAX_VALUE : Long.parseLong(rightEndpoint);
} else {
// TODO: Send this error to a future getErrorStream()
getPrintStream().printf("--timestamp must be like [0-9]*..[0-9]*, instead got %s%n",
mTimestamp);
return FAILURE;
}
final Kiji kiji = Kiji.Factory.open(argURI, getConf());
try {
final KijiTable table = kiji.openTable(argURI.getTable());
try {
final KijiTableLayout tableLayout = table.getLayout();
final Map<FamilyLayout, List<String>> mapTypeFamilies =
ToolUtils.getMapTypeFamilies(argURI.getColumns(), tableLayout);
final Map<FamilyLayout, List<ColumnLayout>> groupTypeColumns =
ToolUtils.getGroupTypeColumns(argURI.getColumns(), tableLayout);
final KijiDataRequest request = ToolUtils.getDataRequest(
mapTypeFamilies, groupTypeColumns, mMaxVersions, mMinTimestamp, mMaxTimestamp);
final KijiTableReader reader = table.openTableReader();