Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Hama Pipes provides the following methods for C/C++ integration: (similar to the BSPModel)

Function

Description

void sendMessage(const string& peerName, const string& msg)

Send a message to another peer. Messages sent by this method are not guaranteed to be received in a sent order.

string& getCurrentMessage()

Returns a message from the peer's received messages queue (a FIFO).

int getNumCurrentMessages()

Returns the number of messages in the peer's received messages queue.

void sync()

Starts the barrier synchronization and sends all the messages in the outgoing message queues to the corresponding remote peers.

long getSuperstepCount()

Returns the count of current super-step.

string& getPeerName()

Returns the name of this peer in the format "hostname:port".

string& getPeerName(int index)

Returns the name of n-th peer from sorted array by name.

int getPeerIndex()

Returns the index of this peer from sorted array by name.

vector<string> getAllPeerNames()

Returns the names of all the peers executing tasks from the same job (including this peer).

int getNumPeers()

Returns the number of peers.

void clear()

Clears all queues entries.

void write(const string& key, const string& value)

Writes a key/value pair to the output collector.

bool readNext(string& key, string& value)

Deserializes the next input key value into the given objects.

void reopenInput()

Closes the input and opens it right away, so that the file pointer is at the beginning again.

...

Function

Description

int sequenceFileOpen(const string& path, const string& option)

Opens a SequenceFile with option "r" or "w" returns the corresponding fileID.

bool sequenceFileReadNext(int fileID, string& key, string& value)

Reads the next key/value pair from the SequenceFile.

bool sequenceFileAppend(int fileID, const string& key, const string& value)

Appends the next key/value pair to the SequenceFile.

bool sequenceFileClose(int fileID)

Closes a SequenceFile.

Finally here is the Pi Estimator example implemented with Hama Pipes:

...