Package lupos.datastructures.patriciatrie.diskseq

Examples of lupos.datastructures.patriciatrie.diskseq.DBSeqTrieSet


        for(int j=0; j<3; j++) {
          triple[j] = mapping[triple[j]];
        }
      }
      // write out patricia trie
      final DBSeqTrieSet disk_set = new DBSeqTrieSet(this.dir+"Set_"+this.runNumber);
      try {
        disk_set.copy(this.map);
        this.listOfTries.add(disk_set);
      } catch (final TrieNotCopyableException e) {
        log.error(e.getMessage(), e);
      }
      // free resources of map in main memory
View Full Code Here


      }
      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
View Full Code Here

    return this.trie.add(toBeAdded);
  }

  @Override
  public Run swapRun() {
    TrieSet diskbasedTrie = new DBSeqTrieSet(Run.getFilenameForNewRun());
    try {
      diskbasedTrie.copy(this.trie);
    } catch (TrieNotCopyableException e) {
      System.err.println(e);
      e.printStackTrace();
    }
    return new TrieSetRun(diskbasedTrie);
View Full Code Here

  public Run merge(final List<Run> runs, final boolean inmemory) {
    ArrayList<TrieSet> triestoBeMerged = new ArrayList<TrieSet>(runs.size());
    for(Run run: runs){
      triestoBeMerged.add(((TrieSetRun)run).getTrie());
    }
    TrieSet result = (inmemory)? new RBTrieSet() : new DBSeqTrieSet(Run.getFilenameForNewRun());
    try {
      result.merge(triestoBeMerged);
    } catch (TrieNotMergeableException e) {
      System.err.println(e);
      e.printStackTrace();
View Full Code Here

TOP

Related Classes of lupos.datastructures.patriciatrie.diskseq.DBSeqTrieSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.