APIdia Launch Partner
Top Description Inners Constructors Methods
java.util

pack-priv Class ArraysParallelSortHelpers

extends Object
Class Inheritance
Imports
java.util.concurrent.CountedCompleter

Helper utilities for the parallel sort methods in Arrays.parallelSort. For each primitive type, plus Object, we define a static class to contain the Sorter and Merger implementations for that type: Sorter classes based mainly on CilkSort Cilk: Basic algorithm: if array size is small, just use a sequential sort (via Arrays.sort) Otherwise: 1. Break array in half. 2. For each half, a. break the half in half (i.e., quarters), b. sort the quarters c. merge them together 3. merge together the two halves. One reason for splitting in quarters is that this guarantees that the final sort is in the main array, not the workspace array. (workspace and main swap roles on each subsort step.) Leaf-level sorts use the associated sequential sort. Merger classes perform merging for Sorter. They are structured such that if the underlying sort is stable (as is true for TimSort), then so is the full sort. If big enough, they split the largest of the two partitions in half, find the greatest point in smaller partition less than the beginning of the second half of larger via binary search; and then merge in parallel the two partitions. In part to ensure tasks are triggered in stability-preserving order, the current CountedCompleter design requires some little tasks to serve as place holders for triggering completion tasks. These classes (EmptyCompleter and Relay) don't need to keep track of the arrays, and are never themselves forked, so don't hold any task state. The base sequential sorts rely on non-public versions of TimSort, ComparableTimSort sort methods that accept temp workspace array slices that we will have already allocated, so avoids redundant allocation.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
ArraysParallelSortHelpers.EmptyCompleter

A placeholder task for Sorters, used for the lowest quartile task, that does not need to maintain array state.

pack-priv static class
ArraysParallelSortHelpers.FJObject

Object + Comparator support class

pack-priv static class
ArraysParallelSortHelpers.Relay

A trigger for secondary merge of two merges

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ArraysParallelSortHelpersback to summary
pack-priv ArraysParallelSortHelpers()
java.util back to summary

pack-priv final Class ArraysParallelSortHelpers.EmptyCompleter

extends CountedCompleter<Void>
Class Inheritance

A placeholder task for Sorters, used for the lowest quartile task, that does not need to maintain array state.

Field Summary

Modifier and TypeField and Description
pack-priv static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final void
compute()

Implements abstract java.util.concurrent.CountedCompleter.compute.

The main computation performed by this task.

Inherited from java.util.concurrent.CountedCompleter:
addToPendingCountcompareAndSetPendingCountcompletedecrementPendingCountUnlessZeroexecfirstCompletegetCompletergetPendingCountgetRawResultgetRoothelpCompletenextCompleteonCompletiononExceptionalCompletionpropagateCompletionquietlyCompleteRootsetPendingCountsetRawResulttryComplete

Field Detail

serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides java.util.concurrent.CountedCompleter.serialVersionUID.

Annotations
@Serial

Constructor Detail

EmptyCompleterback to summary
pack-priv EmptyCompleter(CountedCompleter<?> p)

Method Detail

computeback to summary
public final void compute()

Implements abstract java.util.concurrent.CountedCompleter.compute.

Doc from java.util.concurrent.CountedCompleter.compute.

The main computation performed by this task.

java.util back to summary

pack-priv final Class ArraysParallelSortHelpers.FJObject

extends Object
Class Inheritance

Object + Comparator support class

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

FJObjectback to summary
pack-priv FJObject()
java.util back to summary

pack-priv final Class ArraysParallelSortHelpers.FJObject.Merger<T>

extends CountedCompleter<Void>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final T[]
a

pack-priv Comparator<? super T>
pack-priv final int
pack-priv final int
pack-priv final int
pack-priv final int
pack-priv final int
pack-priv static final long
pack-priv final T[]
w

pack-priv final int

Constructor Summary

AccessConstructor and Description
pack-priv
Merger(CountedCompleter<?> par, T[] a, T[] w, int lbase, int lsize, int rbase, int rsize, int wbase, int gran, Comparator<? super T> comparator)

Field Detail

aback to summary
pack-priv final T[] a
Annotations
@SuppressWarnings:serial
comparatorback to summary
pack-priv Comparator<? super T> comparator
Annotations
@SuppressWarnings:serial
granback to summary
pack-priv final int gran
lbaseback to summary
pack-priv final int lbase
lsizeback to summary
pack-priv final int lsize
rbaseback to summary
pack-priv final int rbase
rsizeback to summary
pack-priv final int rsize
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides java.util.concurrent.CountedCompleter.serialVersionUID.

Annotations
@Serial
wback to summary
pack-priv final T[] w
Annotations
@SuppressWarnings:serial
wbaseback to summary
pack-priv final int wbase

Constructor Detail

Mergerback to summary
pack-priv Merger(CountedCompleter<?> par, T[] a, T[] w, int lbase, int lsize, int rbase, int rsize, int wbase, int gran, Comparator<? super T> comparator)

Method Detail

computeback to summary
public final void compute()

Implements abstract java.util.concurrent.CountedCompleter.compute.

Doc from java.util.concurrent.CountedCompleter.compute.

The main computation performed by this task.

java.util back to summary

pack-priv final Class ArraysParallelSortHelpers.FJObject.Sorter<T>

extends CountedCompleter<Void>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final T[]
a

pack-priv final int
pack-priv Comparator<? super T>
pack-priv final int
pack-priv static final long
pack-priv final int
pack-priv final T[]
w

pack-priv final int

Constructor Summary

AccessConstructor and Description
pack-priv
Sorter(CountedCompleter<?> par, T[] a, T[] w, int base, int size, int wbase, int gran, Comparator<? super T> comparator)

Field Detail

aback to summary
pack-priv final T[] a
Annotations
@SuppressWarnings:serial
baseback to summary
pack-priv final int base
comparatorback to summary
pack-priv Comparator<? super T> comparator
Annotations
@SuppressWarnings:serial
granback to summary
pack-priv final int gran
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides java.util.concurrent.CountedCompleter.serialVersionUID.

Annotations
@Serial
sizeback to summary
pack-priv final int size
wback to summary
pack-priv final T[] w
Annotations
@SuppressWarnings:serial
wbaseback to summary
pack-priv final int wbase

Constructor Detail

Sorterback to summary
pack-priv Sorter(CountedCompleter<?> par, T[] a, T[] w, int base, int size, int wbase, int gran, Comparator<? super T> comparator)

Method Detail

computeback to summary
public final void compute()

Implements abstract java.util.concurrent.CountedCompleter.compute.

Doc from java.util.concurrent.CountedCompleter.compute.

The main computation performed by this task.

java.util back to summary

pack-priv final Class ArraysParallelSortHelpers.Relay

extends CountedCompleter<Void>
Class Inheritance

A trigger for secondary merge of two merges

Field Summary

Modifier and TypeField and Description
pack-priv static final long
pack-priv final CountedCompleter<?>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final void
compute()

Implements abstract java.util.concurrent.CountedCompleter.compute.

The main computation performed by this task.

public final void
onCompletion(CountedCompleter<?> t)

Overrides java.util.concurrent.CountedCompleter.onCompletion.

Performs an action when method tryComplete is invoked and the pending count is zero, or when the unconditional method complete is invoked.

Inherited from java.util.concurrent.CountedCompleter:
addToPendingCountcompareAndSetPendingCountcompletedecrementPendingCountUnlessZeroexecfirstCompletegetCompletergetPendingCountgetRawResultgetRoothelpCompletenextCompleteonExceptionalCompletionpropagateCompletionquietlyCompleteRootsetPendingCountsetRawResulttryComplete

Field Detail

serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides java.util.concurrent.CountedCompleter.serialVersionUID.

Annotations
@Serial
taskback to summary
pack-priv final CountedCompleter<?> task

Constructor Detail

Relayback to summary
pack-priv Relay(CountedCompleter<?> task)

Method Detail

computeback to summary
public final void compute()

Implements abstract java.util.concurrent.CountedCompleter.compute.

Doc from java.util.concurrent.CountedCompleter.compute.

The main computation performed by this task.

onCompletionback to summary
public final void onCompletion(CountedCompleter<?> t)

Overrides java.util.concurrent.CountedCompleter.onCompletion.

Doc from java.util.concurrent.CountedCompleter.onCompletion.

Performs an action when method tryComplete is invoked and the pending count is zero, or when the unconditional method complete is invoked. By default, this method does nothing. You can distinguish cases by checking the identity of the given caller argument. If not equal to this, then it is typically a subtask that may contain results (and/or links to other results) to combine.