Package lupos.datastructures.dbmergesortedds

Examples of lupos.datastructures.dbmergesortedds.DBMergeSortedSetUsingTrie


      // Construct dictionary:

      final Thread codeMapConstructionThread = new Thread() {
        @Override
        public void run() {
            final DBMergeSortedSetUsingTrie rdftermsRepresentations = new DBMergeSortedSetUsingTrie(new SortConfiguration(), String.class);

            final TripleConsumer tc = new TripleConsumer() {

              @Override
              public void consume(final Triple triple) {
                for (final Literal l : triple) {
                  rdftermsRepresentations.add(l.toString());
                  if (l.originalStringDiffers()) {
                    rdftermsRepresentations.add(l.originalString());
                  }
                }
              }

            };
            for (final URILiteral u : defaultGraphs) {
              insertUsedStringRepresentations(u, dataFormat, rdftermsRepresentations, tc);
            }
            for (final URILiteral u : namedGraphs) {
              insertUsedStringRepresentations(u, dataFormat, rdftermsRepresentations, tc);
            }
            // now generate B+-tree for integer-string map and
            // string-integer
            // map of the codemap!
            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 = rdftermsRepresentations.iterator();
                  int index = 1;

                  @Override
                  public boolean hasNext() {
                    return this.it.hasNext();
                  }

                  @Override
                  public java.util.Map.Entry<String, Integer> next() {
                    if (!this.it.hasNext()) {
                      return null;
                    } else {
                      return new java.util.Map.Entry<String, Integer>() {
                        String s = it.next();
                        int localIndex = index++;

                        @Override
                        public String getKey() {
                          return this.s;
                        }

                        @Override
                        public Integer getValue() {
                          return this.localIndex;
                        }

                        @Override
                        public Integer setValue(
                            final Integer arg0) {
                          throw new UnsupportedOperationException();
                        }

                      };
                    }
                  }
                };
              }

              @Override
              public int size() {
                return rdftermsRepresentations.size();
              }

            };

            rdftermsRepresentations.sort();

            final Thread thread0 = new Thread() {
              @Override
              public void run() {
                lupos.datastructures.paged_dbbptree.DBBPTree<String, Integer> simap;
                try {
                  simap = new lupos.datastructures.paged_dbbptree.DBBPTree<String, Integer>(
                      k,
                      k_,
                      new StringIntegerNodeDeSerializer());
                  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(rdftermsRepresentations.iterator());
                  LazyLiteral.setV(ismap);
                } catch (final IOException e) {
                  log.error(e.getMessage(), e);
                }
              }
            };
            thread0.start();
            thread1.start();
            try {
              thread0.join();
              thread1.join();
            } catch (final InterruptedException e) {
              log.error(e.getMessage(), e);
            }
            rdftermsRepresentations.release();

        }
      };
      codeMapConstructionThread.start();
View Full Code Here


      this.codeMapConstructionThread = new Thread() {
        @Override
        public void run() {
          final SortedSet<String> rdftermsRepresentations = (SortingApproach == SORT.NORMAL) ? new DBMergeSortedSet<String>(
              new SortConfiguration(), String.class)
              : new DBMergeSortedSetUsingTrie(
                  new SortConfiguration(), String.class);

              if(toAddToRdftermsRepresentations!=null){
                for(final String s: toAddToRdftermsRepresentations){
                  rdftermsRepresentations.add(s);
View Full Code Here

TOP

Related Classes of lupos.datastructures.dbmergesortedds.DBMergeSortedSetUsingTrie

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.