proio
Public Member Functions | Friends | List of all members
proio::Event Class Reference

#include <event.h>

Public Member Functions

 Event ()
 
 Event (const std::string &proto)
 
uint64_t AddEntry (google::protobuf::Message *entry, std::string tag="")
 
google::protobuf::Message * GetEntry (uint64_t id)
 
void TagEntry (uint64_t id, std::string tag)
 
void UntagEntry (uint64_t id, std::string tag)
 
void RemoveEntry (uint64_t id)
 
std::vector< std::string > Tags ()
 
std::vector< uint64_t > TaggedEntries (std::string tag)
 
std::vector< uint64_t > AllEntries ()
 
std::vector< std::string > EntryTags (uint64_t id)
 
void DeleteTag (std::string tag)
 
google::protobuf::Message * Free (const google::protobuf::Descriptor *desc)
 
std::map< std::string, std::shared_ptr< const std::string > > & Metadata ()
 
std::string String ()
 
bool SerializeToString (std::string *output)
 
void FlushCache ()
 
void Clear ()
 
void SetDescriptorPool (const google::protobuf::DescriptorPool *pool=NULL)
 
void UseGeneratedPool (bool useGenPool=true)
 
Eventoperator= (const Event &event)
 

Friends

class Writer
 
class Reader
 

Detailed Description

Class representing a single event

Definition at line 14 of file event.h.

Constructor & Destructor Documentation

Event::Event ( )

Default constructor

Definition at line 11 of file event.cc.

Event::Event ( const std::string &  proto)

This constructor initializes the event from the protobuf wire format.

Definition at line 18 of file event.cc.

Member Function Documentation

uint64_t Event::AddEntry ( google::protobuf::Message *  entry,
std::string  tag = "" 
)

AddEntry takes a tag and protobuf message entry and adds it to the Event. The return value is a uint64_t ID number used to reference the added entry. Once the entry is added, it is owned by the Event object.

Definition at line 27 of file event.cc.

std::vector< uint64_t > Event::AllEntries ( )

AllEntries returns IDs for all entries in the event.

Definition at line 120 of file event.cc.

void Event::Clear ( )

Clear prepares the Event for data from a new event.

Definition at line 191 of file event.cc.

void Event::DeleteTag ( std::string  tag)

DeleteTag removes a tag from the Event.

Definition at line 140 of file event.cc.

std::vector< std::string > Event::EntryTags ( uint64_t  id)

EntryTags performs a reverse lookup of tags that point to an entry. This is a relatively expensive search.

Definition at line 127 of file event.cc.

void Event::FlushCache ( )

FlushCache forces all event entries to be serialized. This is useful for putting the main serialization load into parallel threads before aggregating the events into an output stream.

Definition at line 172 of file event.cc.

Message * Event::Free ( const google::protobuf::Descriptor *  desc)

Free returns an allocated and cleared entry Message of the type described by the given Descriptor, or NULL if no already-allocated messages of this type are available.

Definition at line 142 of file event.cc.

Message * Event::GetEntry ( uint64_t  id)

GetEntry takes an entry ID and returns the corresponding entry. The returned entries are still owned by the Event object. If the entry does not exist, NULL is returned.

If the specified entry's type is one that is not known at compile time, GetEntry will attempt to create and return a dynamic protobuf Message using the information from the stream.

Definition at line 43 of file event.cc.

std::map<std::string, std::shared_ptr<const std::string> >& proio::Event::Metadata ( )
inline

Metadata returns a mapping from a string key to a pointer to a string that contains metadata associated with the Event by a Reader. These metadata are all the entries received on the stream up to this Event.

Definition at line 74 of file event.h.

void Event::RemoveEntry ( uint64_t  id)

RemoveEntry removes an entry from the event.

Definition at line 89 of file event.cc.

bool proio::Event::SerializeToString ( std::string *  output)
inline

SerializeToString stores the event in the given string in protobuf wire format.

Definition at line 82 of file event.h.

void Event::SetDescriptorPool ( const google::protobuf::DescriptorPool *  pool = NULL)

SetDescriptorPool sets the protobuf DescriptorPool for the Event to use to create dynamic protobuf Messages when the entry type is not available at compile time. This is automatically set using information from the stream if a Reader was used to create the event.

Definition at line 205 of file event.cc.

std::string Event::String ( )

String returns a human-readable string representing the event.

Definition at line 152 of file event.cc.

void Event::TagEntry ( uint64_t  id,
std::string  tag 
)

TagEntry adds a tag to an entry that has already been added, identified by its ID.

Definition at line 75 of file event.cc.

std::vector< uint64_t > Event::TaggedEntries ( std::string  tag)

TaggedEntries tages a tag string and returns a list of entry IDs that the tag references.

Definition at line 109 of file event.cc.

std::vector< std::string > Event::Tags ( )

Tags returns a list of tags that exist in the event.

Definition at line 100 of file event.cc.

void Event::UntagEntry ( uint64_t  id,
std::string  tag 
)

UntagEntry removes a tag from a specified entry.

Definition at line 77 of file event.cc.

void Event::UseGeneratedPool ( bool  useGenPool = true)

UseGeneratedPool can be used to disable this Event's use of the protobuf generated pool. By default, the event will first try to use the protobuf generated pool when GetEntry is called. If this method is called with an argument of false, GetEntry will always attempt to create dynamic protobuf Messages from a pool either set by a Reader or by SetDescriptorPool. This is for testing purposes and can also to be used to gain access to new data model fields.

Definition at line 212 of file event.cc.


The documentation for this class was generated from the following files: