Package lupos.datastructures.sort.run

Examples of lupos.datastructures.sort.run.Run


      }

      final Date start = new Date();
      System.out.println("\n"+t+": Start processing:"+start+"\n");

      final Run result = algo.sort(new BufferedInputStream(new FileInputStream(args[1])), args[2]);

      // just access all elements in the bag by iterating one time through
      final Iterator<String> it = result.iterator();
      long i=0;
      while(it.hasNext()){
        it.next();
        i++;
        // System.out.println((++i)+":"+it.next());
      }
      result.release();
      final Date end = new Date();

      System.out.println("\n"+t+": End processing:"+end);
      System.out.println("\nNumber of sorted RDF terms/Strings:"+i);
      System.out.println("Number of runs swapped to disk:" + algo.getNumberOfRunsOnDisk());
View Full Code Here


      System.err.println(e);
      e.printStackTrace();
    }

    // final merge phase: merge all runs (which are stored on disk)
    Run result;
    if(this.runsOnDisk.size()==0){
      System.err.println("No runs there to be merged!");
      return null;
    } else if(this.runsOnDisk.size()==1){
      // already merge in main memory?
View Full Code Here

    @Override
    public void run(){
      try {
        while(true){
          Run runToBeSwapped = this.initialRunsLevel0.get();
          if(runToBeSwapped==null){
            break;
          }
          final Run runOnDisk = runToBeSwapped.swapRun();
          runToBeSwapped = null;
          System.gc();
          ExternalSorter.this.runsOnDisk.add(runOnDisk);
        }
      } catch (final InterruptedException e) {
View Full Code Here

    buffer.endOfData(); // signal that all has read
    adder.join(); // wait for the adder to finish its job (=adding all elements)
    replacementSelectionDatastructure.sort();
    this.numberOfRunsOndisk = replacementSelectionDatastructure.getNewId()-1; // this is a dirty trick to determine the number of runs stored on disk (as ids are generated for each new run)
    // the final Run just must have the functionality to return the iterator from replacementSelectionDatastructure
    return new Run(){

      @Override
      public boolean add(String toBeAdded) {
        throw new UnsupportedOperationException();
      }
View Full Code Here

    // first collect all remaining runs!
    LinkedList<Run> runstoBeFinallyMerged = new LinkedList<Run>(this.runsOnDisk);
    for(LinkedList<Run> level: levels){
      runstoBeFinallyMerged.addAll(level);
    }
    Run result;
    if(runstoBeFinallyMerged.size()==0){
      System.err.println("No runs there to be merged!");
      return null;
    } else if(runstoBeFinallyMerged.size()==1){
      // already merge in main memory?
View Full Code Here

        while(true){
          // get as many runs to merge as specified
          Object[] bagsToMerge = this.initialRunsLevel0.get(ExternalParallelSorter.this.NUMBER_OF_RUNS_TO_JOIN, ExternalParallelSorter.this.NUMBER_OF_RUNS_TO_JOIN);
         
          if(bagsToMerge!=null && bagsToMerge.length>0){
            Run run = null;
            if(bagsToMerge.length>1){
              ArrayList<Run> toBeMerged = new ArrayList<Run>(bagsToMerge.length);
              for(Object bag: bagsToMerge){
                toBeMerged.add((Run) bag);
              }
View Full Code Here

       
        while(listOfRunsToBeMerged.size()<ExternalParallelSorter.this.NUMBER_OF_RUNS_TO_JOIN){
          listOfRunsToBeMerged.add(level.remove());         
        }
       
        Run resultOfMerge = ExternalParallelSorter.this.runs.merge(listOfRunsToBeMerged, true);
       
        // put the merged run to one level higher (and recursively merge there the runs if enough are there)
        this.addToLevel(addLevel + 1, resultOfMerge);       
      }
     
View Full Code Here

        // get one of the biggest runs for storing it on disk and free it in memory...
        int levelnr=this.levels.size();
        do {
          levelnr--;
        } while(levelnr>0 && this.levels.get(levelnr).size()==0);
        final Run runOnDisk;
        if(levelnr==0 || addLevel>=levelnr){
          System.err.println("ExternalParallelMergeSort: Heap space to low or FREE_MEMORY_LIMIT to high...");
          runOnDisk = toBeAdded;
          flag = true;
        } else {
View Full Code Here

    }
  }
 
  public void finishInitialRun() throws InterruptedException{
    if(!this.run.isEmpty()){
      Run sortedRun = this.run.sort();
      this.initialRunsLevel0.put(sortedRun);
      this.run = this.runs.createRun();
    }
  }
View Full Code Here

    final Iterator<String>[] iterators = new Iterator[runs.size()];
    // a heap is used to get every time the smallest under the current elements of the different runs
    // (this allows to have logarithmical complexity (concerning the number of runs) for getting the next smallest element)
    final Heap<Container> heap = Heap.createInstance(runs.size(), true, Heap.HEAPTYPE.OPTIMIZEDSEQUENTIAL);
    for(int i=0; i<runs.size(); i++){
      final Run run = runs.get(i);
      maxsize += run.size();
      iterators[i] = run.iterator();
      // assuming the different runs are non-empty!
      heap.add(new Container(i, iterators[i].next()));
    }
    final Iterator<String> iterator = new ImmutableIterator<String>(){
View Full Code Here

TOP

Related Classes of lupos.datastructures.sort.run.Run

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.