proio

class proio.Event(proto_obj=None)[source]

Class representing a single event

add_entries(tag, *entries)[source]

is like add_entry(), except that it takes any number of entries, and returns a list of corresponding IDs.

Parameters
  • tag (string) – tag

  • *entries (Message) – entries

Returns

identifiers for entry

Return type

int list

add_entry(tag, entry)[source]

takes a tag and protobuf message entry and adds it to the Event. The return value is an integer ID number used to reference the added entry.

Parameters
  • tag (string) – tag

  • entry (Message) – entry

Returns

identifier for entry

Return type

int

all_entries()[source]

returns a list of entry IDs for the event.

Returns

identifiers for entries

Return type

int list

delete_tag(tag)[source]

removes the tag that matches the given tag string from the event.

Parameters

tag (string) – tag

entry_tags(ID)[source]

returns a list of tags that point to a given entry ID.

Parameters

ID (int) – identifier for entry

Returns

list of strings

get_entry(ID)[source]

takes an entry ID and returns the corresponding entry. Returns None if the entry does not exist.

Parameters

ID (int) – identifier for entry

Returns

entry message object

Return type

google.protobuf.message.Message

remove_entry(ID)[source]

removes an entry from the event by its entry ID.

Parameters

ID (int) – identifier for entry

tag_entry(ID, *tags)[source]

adds tags to an entry identified by ID.

Parameters
  • ID (int) – identifier for entry

  • *tags (string) – tags

tagged_entries(tag)[source]

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

Parameters

tag (string) – tag

Returns

identifiers for entries

Return type

int list

tags()[source]

returns a list of tags that exist in the event.

Returns

list of strings

untag_entry(ID, tag)[source]

removes the specified tag from the entry ID

Parameters
  • ID (int) – identifier for entry

  • tag (string) – tag

class proio.Reader(filename=None, fileobj=None)[source]

Reader for proio files

This class can be used with the with statement, and it also may be used as an iterator that sequentially iterates all events. A filename may be omitted in favor of specifying fileobj.

Parameters
  • filename (string) – name of input file to read

  • fileobj – file object to read from

Example

with proio.Reader('input.proio') as reader:
    for event in reader:
        ...
close()[source]

closes the underlying input file object.

seek_to_start()[source]

seeks, if possible, to the start of the input file object. This can be used along with skip() to directly access events.

Returns

success

Return type

boolean

skip(n_events)[source]

skips the next n_events events.

Parameters

n_events (int) – number of events to skip

Returns

number of events skipped

Return type

int

class proio.Writer(filename=None, fileobj=None)[source]

Writer for proio files

This class can be used with the with statement. A filename may be omitted in favor of specifying fileobj.

Parameters
  • filename (string) – name of output file to create or overwrite

  • fileobj – file object to write to

Example

with proio.Writer('output.proio') as writer:
    ...
close()[source]

closes the file object assigned to the Writer. This is automatically called at the end of a with statement.

flush()[source]

flushes all buffered data to the output file object. This is automatically called at the end of a with statement.

push(event)[source]

takes an event and serializes it into the output bucket.

Parameters

event (Event) – event to serialize to output

push_metadata(key, value)[source]

takes a human-readable string key and a byte string value and inserts it into the stream as metadata. A reader will then assign these metadata to events that follow in the stream.

Parameters
  • key (string) – key

  • value (bytes) – value

set_compression(comp)[source]

sets the compression type to use for future output buckets.

Parameters

comp – can be one of proio.LZ4, proio.GZIP, or proio.UNCOMPRESSED

Indices and tables