String path = location.getDirectoryPath() ;
new File(path, "node2id.dat").delete() ;
new File(path, "node2id.idn").delete() ;
// input
ObjectFile objects = FileFactory.createObjectFileDisk(path + File.separator + "nodes.dat");
// sorted bag
ThresholdPolicyCount<Pair<byte[],Long>> policy = new ThresholdPolicyCount<Pair<byte[],Long>>(10000000);
Comparator<Pair<byte[],Long>> comparator = new PairComparator();
SortedDataBag<Pair<byte[],Long>> sortedDataBag = new SortedDataBag<Pair<byte[],Long>>(policy, new PairSerializationFactory(), comparator);
Iterator<Pair<Long,ByteBuffer>> iter = objects.all();
while ( iter.hasNext() ) {
Pair<Long, ByteBuffer> pair = iter.next();
long id = pair.getLeft();
Node node = NodeLib.fetchDecode(id, objects);
Hash hash = new Hash(SystemTDB.LenNodeHash);
setHash(hash, node);
byte k[] = hash.getBytes();
sortedDataBag.send(new Pair<byte[],Long>(k, id));
if ( monitor != null ) monitor.tick();
}
objects.sync();
objects.close();
// output
final ProgressLogger monitor2 = new ProgressLogger(log, "Data (2/2)", BulkLoader.DataTickPoint,BulkLoader.superTick);
log.info("Data (2/2)...");
monitor2.start();