本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
示例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;
}
示例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());
}
示例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());
}
示例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;
}
示例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());
}
示例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());
}
示例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);
}