public class PartitionSet extends Base implements ExternalizableLite, PortableObject
Note that all PartitionSet operations that take another set as an argument assume that both sets have the same partition count.
This implementation is not thread-safe.
Base.LoggingWriter, Base.StackFrame
Modifier and Type | Field and Description |
---|---|
protected static int |
MARKED_ALL
Serialization format indicator: Indicates that all partitions are
marked; MARKED_ALL requires no additional data.
|
protected static int |
MARKED_FEW
Serialization format indicator: Indicates that a small number of
partitions are marked; followed by stream of packed integers indicating
gaps between each marked partition, terminated with a -1.
|
protected static int |
MARKED_MANY
Serialization format indicator: Indicates that a large number of
partitions are marked; followed by a sequence of 64-bit values
sufficient to represent the cardinality of the PartitionSet.
|
protected static int |
MARKED_NONE
Serialization format indicator: Indicates that no partitions are
marked; MARKED_NONE requires no additional data.
|
Constructor and Description |
---|
PartitionSet()
Default constructor (necessary for the ExternalizableLite interface).
|
PartitionSet(int cPartitions)
Construct an empty partition set with a given count.
|
PartitionSet(PartitionSet partitions)
Copy constructor: construct a new PartitionSet object equivalent to the
specified one.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(int nPartition)
Add the specified partition to the set.
|
boolean |
add(PartitionSet partitions)
Add the specified PartitionSet to this set.
|
int |
cardinality()
Returns the number of marked partitions.
|
PartitionSet |
clear()
Clear the set.
|
boolean |
contains(int nPartition)
Check whether or not the specified partition belongs to the set.
|
boolean |
contains(PartitionSet partitions)
Check whether or not the specified partition set belongs to this set.
|
boolean |
equals(Object o)
Indicates whether some other object is "equal to" this one.
|
PartitionSet |
fill()
Fill the set to contain all the partitions.
|
int |
getPartitionCount()
Return the number of partitions represented by this PartitionSet.
|
int |
hashCode()
Returns a hash code value for this PartitionSet.
|
boolean |
intersects(PartitionSet partitions)
Check whether or not the specified partition set intersects with this
set.
|
PartitionSet |
invert()
Invert all the partitions.
|
boolean |
isEmpty()
Check whether or not the partition set is empty.
|
boolean |
isFull()
Check whether or not the partition set is full.
|
int |
next(int nPartition)
Return an index of the first marked partition that is greater than or
equal to the specified partition.
|
void |
readExternal(DataInput in)
Restore the contents of this object by loading the object's state from
the passed DataInput object.
|
void |
readExternal(PofReader in)
Restore the contents of a user type instance by reading its state using
the specified PofReader object.
|
boolean |
remove(int nPartition)
Remove the specified partition from the set.
|
boolean |
remove(PartitionSet partitions)
Remove the specified PartitionSet from this set.
|
int |
removeNext(int nPartition)
Remove the first marked partition starting at the specified partition.
|
boolean |
retain(PartitionSet partitions)
Retain only partitions in this set that are contained in the specified
PartitionSet.
|
int |
rnd()
Obtain a random partition from the partition set.
|
PartitionSet |
split()
Split this partition set into two partition sets that are mutually
exclusive.
|
int[] |
toArray()
Convert the partition set to an array of partition identifiers.
|
String |
toString()
Returns a string representation of this PartitionSet.
|
String |
toString(boolean fVerbose)
Returns a string representation of this PartitionSet.
|
static PartitionSet |
union(PartitionSet partsA,
PartitionSet partsB)
Return a union of the two provided PartitionSets.
|
void |
writeExternal(DataOutput out)
Save the contents of this object by storing the object's state into
the passed DataOutput object.
|
void |
writeExternal(PofWriter out)
Save the contents of a POF user type instance by writing its state using
the specified PofWriter object.
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
protected static final int MARKED_NONE
protected static final int MARKED_FEW
protected static final int MARKED_MANY
protected static final int MARKED_ALL
public PartitionSet()
public PartitionSet(int cPartitions)
cPartitions
- the partition countpublic PartitionSet(PartitionSet partitions)
partitions
- the partition set to copypublic boolean add(int nPartition)
nPartition
- the partition to addpublic boolean add(PartitionSet partitions)
partitions
- the PartitionSet to addpublic boolean remove(int nPartition)
nPartition
- the partition to removepublic int removeNext(int nPartition)
nPartition
- the partition to start checking from (inclusive)IndexOutOfBoundsException
- if the specified partition is invalidpublic boolean remove(PartitionSet partitions)
partitions
- the PartitionSet to removepublic boolean retain(PartitionSet partitions)
partitions
- the PartitionSet to retainpublic boolean contains(int nPartition)
nPartition
- the partition to checkpublic boolean contains(PartitionSet partitions)
partitions
- the partition set to checkpublic boolean intersects(PartitionSet partitions)
partitions
- the partition set to checkpublic boolean isEmpty()
public boolean isFull()
public PartitionSet clear()
public PartitionSet fill()
public PartitionSet invert()
public int next(int nPartition)
This method could be used to iterate over all marked partitions:
for (int i = ps.next(0); i >= 0; i = ps.next(i+1))
{
// process partition
}
nPartition
- the partition to start checking from (inclusive)IndexOutOfBoundsException
- if the specified partition is
invalidpublic int cardinality()
public int[] toArray()
public int rnd()
public PartitionSet split()
public static PartitionSet union(PartitionSet partsA, PartitionSet partsB)
This method will return a reference to one of the provided sets (or null), and may mutate the returned set.
partsA
- set ApartsB
- set BA & B
public void readExternal(DataInput in) throws IOException
readExternal
in interface ExternalizableLite
in
- the DataInput stream to read data from in order to restore
the state of this objectIOException
- if an I/O exception occursNotActiveException
- if the object is not in its initial
state, and therefore cannot be deserialized intopublic void writeExternal(DataOutput out) throws IOException
writeExternal
in interface ExternalizableLite
out
- the DataOutput stream to write the state of this object toIOException
- if an I/O exception occurspublic void readExternal(PofReader in) throws IOException
readExternal
in interface PortableObject
in
- the PofReader from which to read the object's stateIOException
- if an I/O error occurspublic void writeExternal(PofWriter out) throws IOException
writeExternal
in interface PortableObject
out
- the PofWriter to which to write the object's stateIOException
- if an I/O error occurspublic boolean equals(Object o)
public int hashCode()
public String toString()
public String toString(boolean fVerbose)
fVerbose
- true for full information, false for tersepublic int getPartitionCount()