String path = location.getDirectoryPath() ;
new File(path, "node2id.dat").delete() ;
new File(path, "node2id.idn").delete() ;
ObjectFile objects = FileFactory.createObjectFileDisk(path + File.separator + "nodes.dat");
Index nodeToId = SetupTDB.makeIndex(location, Names.indexNode2Id, LenNodeHash, SizeOfNodeId, -1 ,-1) ;
RecordFactory recordFactory = nodeToId.getRecordFactory();
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(recordFactory.keyLength()) ;
setHash(hash, node) ;
byte k[] = hash.getBytes() ;
Record record = recordFactory.create(k) ;
Bytes.setLong(id, record.getValue(), 0) ;
nodeToId.add(record);
if ( monitor != null ) monitor.tick();
}
nodeToId.sync();
nodeToId.close();
objects.sync();
objects.close();
}