Path[] inputPaths = null;
Shard[] shards = null;
JobConf jobConf = new JobConf(conf);
IndexUpdateConfiguration iconf = new IndexUpdateConfiguration(jobConf);
if (inputPathsString != null) {
jobConf.set(org.apache.hadoop.mapreduce.lib.input.
FileInputFormat.INPUT_DIR, inputPathsString);
}
inputPaths = FileInputFormat.getInputPaths(jobConf);
if (inputPaths.length == 0) {
inputPaths = null;
}
if (outputPath == null) {
outputPath = FileOutputFormat.getOutputPath(jobConf);
}
if (inputPaths == null || outputPath == null) {
System.err.println("InputPaths and outputPath must be specified.");
printUsage("");
System.exit(-1);
}
if (shardsString != null) {
iconf.setIndexShards(shardsString);
}
shards = Shard.getIndexShards(iconf);
if (shards != null && shards.length == 0) {
shards = null;
}
if (indexPath == null) {
indexPath = getIndexPath(conf);
}
if (numShards <= 0) {
numShards = getNumShards(conf);
}
if (shards == null && indexPath == null) {
System.err.println("Either shards or indexPath must be specified.");
printUsage("");
System.exit(-1);
}
if (numMapTasks <= 0) {
numMapTasks = jobConf.getNumMapTasks();
}
try {
// create shards and set their directories if necessary
if (shards == null) {
shards = createShards(indexPath, numShards, conf);
}
long startTime = now();
try {
IIndexUpdater updater =
(IIndexUpdater) ReflectionUtils.newInstance(
iconf.getIndexUpdaterClass(), conf);
LOG.info("sea.index.updater = "
+ iconf.getIndexUpdaterClass().getName());
updater.run(conf, inputPaths, outputPath, numMapTasks, shards);
LOG.info("Index update job is done");
} finally {