}
runGenerator.endOfBlock();
// merge local dictionaries
final List<TrieSet> listOfTries = runGenerator.getTries();
final TrieSet final_trie = new DBSeqTrieSet(dir + "FinalTrie");
if(listOfTries.size()>1){
final_trie.merge(listOfTries);
} else {
final_trie.copy(listOfTries.get(0));
}
// create real dictionary
final Generator<String, Integer> smsi = new Generator<String, Integer>() {
@Override
public Iterator<java.util.Map.Entry<String, Integer>> iterator() {
return new ImmutableIterator<java.util.Map.Entry<String, Integer>>() {
Iterator<String> it = final_trie.iterator();
int index = 1;
@Override
public boolean hasNext() {
return this.it.hasNext();
}
@Override
public Entry<String, Integer> next() {
return new MapEntry<String, Integer>(this.it.next(), this.index++);
}
};
}
@Override
public int size() {
return final_trie.size();
}
};
final lupos.datastructures.paged_dbbptree.DBBPTree<String, Integer> simap = new lupos.datastructures.paged_dbbptree.DBBPTree<String, Integer>(
k,
k_,
new StringIntegerNodeDeSerializer());
final Thread thread0 = new Thread() {
@Override
public void run() {
try {
simap.generateDBBPTree(smsi);
LazyLiteral.setHm(new StringIntegerMapJava(simap));
} catch (final IOException e) {
log.error(e.getMessage(), e);
}
}
};
final Thread thread1 = new Thread() {
@Override
public void run() {
StringArray ismap;
try {
ismap = new StringArray();
ismap.generate(final_trie.iterator());
LazyLiteral.setV(ismap);
} catch (final IOException e) {
log.error(e.getMessage(), e);
}
}
};
// TODO make thread-safe!
LiteralFactory.setTypeWithoutInitializing(LiteralFactory.MapType.LAZYLITERALWITHOUTINITIALPREFIXCODEMAP);
thread0.run();
thread1.run();
try {
thread0.join();
thread1.join();
} catch (final InterruptedException e) {
log.error(e.getMessage(), e);
}
final_trie.release();
// map local ids to global ids of initial runs
int runNumber = 0;
for(final TrieSet trie: listOfTries) {
// determine mapping