当前位置: 首页>>代码示例>>Java>>正文


Java QuickSort类代码示例

本文整理汇总了Java中org.apache.hadoop.util.QuickSort的典型用法代码示例。如果您正苦于以下问题:Java QuickSort类的具体用法?Java QuickSort怎么用?Java QuickSort使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


QuickSort类属于org.apache.hadoop.util包,在下文中一共展示了QuickSort类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPartitions

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
/**
 * Find the split points for a given sample. The sample keys are sorted
 * and down sampled to find even split points for the partitions. The
 * returned keys should be the start of their respective partitions.
 * @param numPartitions the desired number of partitions
 * @return an array of size numPartitions - 1 that holds the split points
 */
Text[] createPartitions(int numPartitions) {
  int numRecords = records.size();
  System.out.println("Making " + numPartitions + " from " + numRecords + 
                     " sampled records");
  if (numPartitions > numRecords) {
    throw new IllegalArgumentException
      ("Requested more partitions than input keys (" + numPartitions +
       " > " + numRecords + ")");
  }
  new QuickSort().sort(this, 0, records.size());
  float stepSize = numRecords / (float) numPartitions;
  Text[] result = new Text[numPartitions-1];
  for(int i=1; i < numPartitions; ++i) {
    result[i-1] = records.get(Math.round(stepSize * i));
  }
  return result;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TeraInputFormat.java

示例2: createPartitions

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
/**
 * Find the split points for a given sample. The sample keys are sorted
 * and down sampled to find even split points for the partitions. The
 * returned keys should be the start of their respective partitions.
 * @param numPartitions the desired number of partitions
 * @return an array of size numPartitions - 1 that holds the split points
 */
Text[] createPartitions(int numPartitions) {
  int numRecords = records.size();
  System.out.println("Making " + numPartitions + " from " + numRecords + 
                     " records");
  if (numPartitions > numRecords) {
    throw new IllegalArgumentException
      ("Requested more partitions than input keys (" + numPartitions +
       " > " + numRecords + ")");
  }
  new QuickSort().sort(this, 0, records.size());
  float stepSize = numRecords / (float) numPartitions;
  System.out.println("Step size is " + stepSize);
  Text[] result = new Text[numPartitions-1];
  for(int i=1; i < numPartitions; ++i) {
    result[i-1] = records.get(Math.round(stepSize * i));
  }
  return result;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:26,代码来源:TeraInputFormat.java

示例3: createPartitions

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
/**
* Find the split points for a given sample. The sample keys are sorted
* and down sampled to find even split points for the partitions. The
* returned keys should be the start of their respective partitions.
* @param numPartitions the desired number of partitions
* @return an array of size numPartitions - 1 that holds the split points
*/
public ArrayList<WritableComparable> createPartitions(int numPartitions) 
{
	int numRecords = records.size();
	if (numPartitions > numRecords) {
		throw new IllegalArgumentException
		("Requested more partitions than input keys (" + numPartitions +
				" > " + numRecords + ")");
	}
	new QuickSort().sort(this, 0, records.size());
	//System.out.println("after sort: "+ toString());
	float stepSize = numRecords / (float) numPartitions;
	//System.out.println("Step size is " + stepSize);
	ArrayList<WritableComparable> result = new ArrayList<>(numPartitions-1);
	for(int i=1; i < numPartitions; i++) {
		result.add(records.get(Math.round(stepSize * i)));
	}
	
	return result;
}
 
开发者ID:apache,项目名称:systemml,代码行数:27,代码来源:SamplingSortMRInputFormat.java

示例4: createPartitions

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
/**
 * Find the split points for a given sample. The sample keys are sorted
 * and down sampled to find even split points for the partitions. The
 * returned keys should be the start of their respective partitions.
 * @param numPartitions the desired number of partitions
 * @return an array of size numPartitions - 1 that holds the split points
 */
Text[] createPartitions(int numPartitions) {
  int numRecords = records.size();
  System.out.println("Making " + numPartitions + " from " + numRecords +
                     " sampled records");
  if (numPartitions > numRecords) {
    throw new IllegalArgumentException
      ("Requested more partitions than input keys (" + numPartitions +
       " > " + numRecords + ")");
  }
  new QuickSort().sort(this, 0, records.size());
  float stepSize = numRecords / (float) numPartitions;
  Text[] result = new Text[numPartitions-1];
  for(int i=1; i < numPartitions; ++i) {
    result[i-1] = records.get(Math.round(stepSize * i));
  }
  return result;
}
 
开发者ID:cloudera,项目名称:RecordServiceClient,代码行数:25,代码来源:TeraInputFormat.java

示例5: createPartitions

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
Text[] createPartitions(int numPartitions) {
    int numRecords = this.records.size();
    System.out.println("Making " + numPartitions + " from " + numRecords + " records");
    if(numPartitions > numRecords) {
        throw new IllegalArgumentException("Requested more partitions than input keys (" + numPartitions + " > " + numRecords + ")");
    } else {
        (new QuickSort()).sort(this, 0, this.records.size());
        float stepSize = (float)numRecords / (float)numPartitions;
        System.out.println("Step size is " + stepSize);
        Text[] result = new Text[numPartitions - 1];

        for(int i = 1; i < numPartitions; ++i) {
            result[i - 1] = (Text)this.records.get(Math.round(stepSize * (float)i));
        }

        return result;
    }
}
 
开发者ID:dstreev,项目名称:HiveHoney,代码行数:19,代码来源:HiveTeraInputFormat.java

示例6: createPartitions

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
/**
 * Find the split points for a given sample. The sample keys are sorted
 * and down sampled to find even split points for the partitions. The
 * returned keys should be the start of their respective partitions.
 *
 * @param numPartitions the desired number of partitions
 * @return an array of size numPartitions - 1 that holds the split
 * points
 */
Text[] createPartitions(int numPartitions) {
    int numRecords = records.size();
    System.out.println("Making " + numPartitions + " from " + numRecords
            + " records");
    if (numPartitions > numRecords) {
        throw new IllegalArgumentException("Requested more partitions than input keys (" + numPartitions
                + " > " + numRecords + ")");
    }
    new QuickSort().sort(this, 0, records.size());
    float stepSize = numRecords / (float) numPartitions;
    System.out.println("Step size is " + stepSize);
    Text[] result = new Text[numPartitions - 1];
    for (int i = 1; i < numPartitions; ++i) {
        result[i - 1] = records.get(Math.round(stepSize * i));
    }
    return result;
}
 
开发者ID:elephantscale,项目名称:hadoop-book,代码行数:27,代码来源:TeraInputFormat.java

示例7: initialize

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
public void initialize(JobConf job, TaskReporter reporter, TaskAttemptID taskId) throws ClassNotFoundException, IOException{
	this.reporter = reporter;     
  this.taskId = taskId;
  mapOutputByteCounter = reporter.getCounter(MAP_OUTPUT_BYTES);
  mapOutputRecordCounter = reporter.getCounter(MAP_OUTPUT_RECORDS);    
  this.job = job;
  
  sorter = ReflectionUtils.newInstance(
      job.getClass("map.sort.class", QuickSort.class, IndexedSorter.class), job);
  partitions = job.getNumReduceTasks();
  if (partitionInd == null || partitions * 2 != partitionInd.length) {
  	partitionInd = new int[partitions * 2];
  }
  comparator = job.getOutputKeyComparator();
  keyClass = (Class)job.getMapOutputKeyClass();
  valClass = (Class)job.getMapOutputValueClass();
  serializationFactory = new SerializationFactory(job);
  keySerializer = serializationFactory.getSerializer(keyClass);
  keySerializer.open(bb);
  valSerializer = serializationFactory.getSerializer(valClass);
  valSerializer.open(bb);
  reset();
}
 
开发者ID:mammothcm,项目名称:mammoth,代码行数:24,代码来源:MemoryElement.java

示例8: createPartitions

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
/**
 * Find the split points for a given sample. The sample keys are sorted
 * and down sampled to find even split points for the partitions. The
 * returned keys should be the start of their respective partitions.
 * @param numPartitions the desired number of partitions
 * @return an array of size numPartitions - 1 that holds the split points
 */
Text[] createPartitions(int numPartitions) {
	int numRecords = records.size();
	System.out.println("Making " + numPartitions + " from " + numRecords +
										 " records");
	if (numPartitions > numRecords) {
		throw new IllegalArgumentException
			("Requested more partitions than input keys (" + numPartitions +
			 " > " + numRecords + ")");
	}
	new QuickSort().sort(this, 0, records.size());
	float stepSize = numRecords / (float) numPartitions;
	System.out.println("Step size is " + stepSize);
	Text[] result = new Text[numPartitions-1];
	for(int i=1; i < numPartitions; ++i) {
		result[i-1] = records.get(Math.round(stepSize * i));
	}
	return result;
}
 
开发者ID:ilveroluca,项目名称:seal,代码行数:26,代码来源:TextSampler.java

示例9: sort

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
@Override
public void sort(SelectionVector4 vector4, VectorContainer container){
  Stopwatch watch = new Stopwatch();
  watch.start();
  QuickSort qs = new QuickSort();
  qs.sort(this, 0, vector4.getTotalCount());
  logger.debug("Took {} us to sort {} records", watch.elapsed(TimeUnit.MICROSECONDS), vector4.getTotalCount());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:9,代码来源:SortTemplate.java

示例10: sort

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
@Override
public void sort(SelectionVector2 vector2){
  QuickSort qs = new QuickSort();
  Stopwatch watch = new Stopwatch();
  watch.start();
  if (vector2.getCount() > 0) {
    qs.sort(this, 0, vector2.getCount());
  }
  logger.debug("Took {} us to sort {} records", watch.elapsed(TimeUnit.MICROSECONDS), vector2.getCount());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:SingleBatchSorterTemplate.java

示例11: doSort

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
public long doSort(){
  QuickSort qs = new QuickSort();
  ByteSortable b = new ByteSortable();
  long nano = System.nanoTime();
  qs.sort(b, 0, RECORD_COUNT);
  return System.nanoTime() - nano;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:8,代码来源:SortTest.java

示例12: sort

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
@Override
public void sort(SelectionVector2 vector2){
  QuickSort qs = new QuickSort();
  Stopwatch watch = Stopwatch.createStarted();
  if (vector2.getCount() > 0) {
    qs.sort(this, 0, vector2.getCount());
  }
  logger.debug("Took {} us to sort {} records", watch.elapsed(TimeUnit.MICROSECONDS), vector2.getCount());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:10,代码来源:SingleBatchSorterTemplate.java

示例13: sort

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
@Override
public void sort(SelectionVector4 vector4, VectorContainer container){
  Stopwatch watch = Stopwatch.createStarted();
  QuickSort qs = new QuickSort();
  qs.sort(this, 0, vector4.getTotalCount());
  logger.debug("Took {} us to sort {} records", watch.elapsed(TimeUnit.MICROSECONDS), vector4.getTotalCount());
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:8,代码来源:SortTemplate.java

示例14: sortMemBlock

import org.apache.hadoop.util.QuickSort; //导入依赖的package包/类
protected void sortMemBlock(MemoryBlock memBlock) {
  if (memBlock.currentPtr <= 0) {
    return;
  }
  // quick sort the offsets
  OffsetSortable sortableObj = new OffsetSortable(memBlock, kvbuffer);
  QuickSort quickSort = new QuickSort();
  quickSort.sort(sortableObj, 0, memBlock.currentPtr);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:10,代码来源:BasicReducePartition.java


注:本文中的org.apache.hadoop.util.QuickSort类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。