String rootDir = "/tmp/shard_bulk/" + dataTableName;
fs.mkdirs(new Path(rootDir));
BatchWriter dataWriter = new SeqfileBatchWriter(conf, fs, rootDir + "/data.seq");
BatchWriter indexWriter = new SeqfileBatchWriter(conf, fs, rootDir + "/index.seq");
for (int i = 0; i < numToInsert; i++) {
String docID = Insert.insertRandomDocument(nextDocID++, dataWriter, indexWriter, indexTableName, dataTableName, numPartitions, rand);
log.debug("Bulk inserting document " + docID);
}
state.set("nextDocID", Long.valueOf(nextDocID));
dataWriter.close();
indexWriter.close();
sort(state, fs, dataTableName, rootDir + "/data.seq", rootDir + "/data_bulk", rootDir + "/data_work", maxSplits);
sort(state, fs, indexTableName, rootDir + "/index.seq", rootDir + "/index_bulk", rootDir + "/index_work", maxSplits);
bulkImport(fs, state, dataTableName, rootDir, "data");