Class RangePartitioner<T>
- java.lang.Object
-
- org.openrefine.runners.local.pll.partitioning.RangePartitioner<T>
-
- All Implemented Interfaces:
Partitioner<T>
- Direct Known Subclasses:
LongRangePartitioner
public class RangePartitioner<T> extends Object implements Partitioner<T>
A partitioner which assumes that the keys are sorted in increasing order.- Author:
- Antonin Delpeuch
-
-
Field Summary
Fields Modifier and Type Field Description protected Comparator<T>
comparator
protected List<T>
firstKeys
protected int
numPartitions
-
Constructor Summary
Constructors Constructor Description RangePartitioner(int nbPartitions, List<T> firstKeys, Comparator<T> comparator)
Constructs a partitioner by supplying the first key value in each partition but the first one.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Comparator<T>
getComparator()
List<Optional<T>>
getFirstKeys()
List of (n-1) values, where n is the number of partitions.int
getPartition(T key)
Retrieves the partition id given a key.int
numPartitions()
Returns the number of partitions assumed by this partitioner.
-
-
-
Field Detail
-
numPartitions
protected final int numPartitions
-
comparator
protected final Comparator<T> comparator
-
-
Constructor Detail
-
RangePartitioner
public RangePartitioner(int nbPartitions, List<T> firstKeys, Comparator<T> comparator)
Constructs a partitioner by supplying the first key value in each partition but the first one.- Parameters:
nbPartitions
- the number of partitions of the PLL this partitioner is built forfirstKeys
- list of (n-1) values, where n is the number of partitions. The first element of the list is the first key value in the second partition. If a partition is empty, null is used.comparator
- the comparator used to compare the keys
-
-
Method Detail
-
getPartition
public int getPartition(T key)
Description copied from interface:Partitioner
Retrieves the partition id given a key.- Specified by:
getPartition
in interfacePartitioner<T>
- Returns:
-
numPartitions
public int numPartitions()
Description copied from interface:Partitioner
Returns the number of partitions assumed by this partitioner.- Specified by:
numPartitions
in interfacePartitioner<T>
-
getFirstKeys
public List<Optional<T>> getFirstKeys()
List of (n-1) values, where n is the number of partitions. The first element of the list is the first key value in the second partition. If a partition is empty, no value is returned.
-
getComparator
public Comparator<T> getComparator()
-
-