#include <coherence/net/partition/PartitionSet.hpp>
Inherits Object, and PortableObject.
This set quite often accompanies a result of partial parallel execution and is used to determine whether or not the entire set of partitions was successfully processed.
Note that all PartitionSet operations that take another set as an argument assume that both sets have the same partition count.
Public Types | |
enum | Format { marked_none, marked_few, marked_many, marked_all } |
Serialization format indicator. More... | |
typedef spec::Handle | Handle |
PartitionSet Handle definition. | |
typedef spec::View | View |
PartitionSet View definition. | |
typedef spec::Holder | Holder |
PartitionSet Holder definition. | |
Public Member Functions | |
PartitionSet () | |
Default constructor. | |
virtual bool | add (int32_t nPartition) |
Add the specified partition to the set. | |
virtual bool | add (PartitionSet::View vPartitions) |
Add the specified PartitionSet to this set. | |
virtual void | fill () |
Fill the set to contain all the partitions. | |
virtual int32_t | next (int32_t nPartition) const |
Return an index of the first marked partition that is greater than or equal to the specified partition. | |
virtual TypedHandle < const String > | toString () const |
Output a human-readable description of this Object to the given stream. Note that when overriding this method the return type must be TypedHandle<const String> rather then String::View. These two types are assignment compatible but not equivalent and declaring the override with String::View will not be a compatible override. coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toString method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents and is generally how toString() will be implemented.
Object::View vKey = ... Object::View vValue = ... std::cout << vKey << " = " << vValue << std::endl; String::View vs = COH_TO_STRING(vKey << " = " << vValue); The COH_TO_STRING macro is also the most common way to implement the toString method. For example:
virtual TypedHandle<const String> Person::toString() const { return COH_TO_STRING("Name: " << f_sName << " SSN: " << f_nSSN); }
| |
virtual void | readExternal (PofReader::Handle hIn) |
virtual void | writeExternal (PofWriter::Handle hOut) const |
Static Protected Member Functions | |
static int32_t | getTrailingZeroCount (int64_t l) |
Determine the number of trailing zero bits in the passed long value. | |
Protected Attributes | |
int32_t | m_cPartitions |
Total partition count. | |
FinalHandle< Array < int64_t > > | f_halBits |
A bit array representing the partitions, stored as an array of longs. | |
int64_t | m_lTailMask |
A mask for the last long that indicates what bits get used. | |
int32_t | m_cMarked |
A cached count of marked partitions; -1 indicates that the value must be recalculated. |
enum Format |
Serialization format indicator.
marked_none | Indicates that no partitions are marked; MARKED_NONE requires no additional data. |
marked_few | 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. |
marked_many | 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. |
marked_all | Indicates that all partitions are marked; MARKED_ALL requires no additional data. |
virtual bool add | ( | int32_t | nPartition | ) | [virtual] |
virtual bool add | ( | PartitionSet::View | vPartitions | ) | [virtual] |
Add the specified PartitionSet to this set.
vPartitions | the PartitionSet to add |
virtual int32_t next | ( | int32_t | nPartition | ) | const [virtual] |
Return an index of the first marked partition that is greater than or equal to the specified partition.
If no such partition exists then -1 is returned.
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 invalid |
static int32_t getTrailingZeroCount | ( | int64_t | l | ) | [static, protected] |
Determine the number of trailing zero bits in the passed long value.
l | a long value |