LogDevice API
Public Member Functions | Static Public Member Functions | Friends | List of all members
facebook::logdevice::BufferedWriteDecoder Class Reference

Public Member Functions

int decode (std::vector< std::unique_ptr< DataRecord >> &&records, std::vector< Payload > &payloads_out)
 
int decode (std::vector< std::unique_ptr< DataRecord >> &&records, std::vector< PayloadGroup > &payload_groups_out)
 
int decodeOne (std::unique_ptr< DataRecord > &&record, std::vector< Payload > &payloads_out)
 
int decodeOne (std::unique_ptr< DataRecord > &&record, std::vector< PayloadGroup > &payload_groups_out)
 
int decodeOneCompressed (std::unique_ptr< DataRecord > &&record, CompressedPayloadGroups &compressed_payload_groups_out)
 

Static Public Member Functions

static std::unique_ptr< BufferedWriteDecodercreate ()
 
static int getBatchSize (const DataRecord &record, size_t *size_out)
 

Friends

class BufferedWriteDecoderImpl
 

Member Function Documentation

◆ create()

static std::unique_ptr<BufferedWriteDecoder> facebook::logdevice::BufferedWriteDecoder::create ( )
static

Creates a BufferedWriteDecoder instance. It can be used to decode batched writes made by any BufferedWriter.

◆ decode()

int facebook::logdevice::BufferedWriteDecoder::decode ( std::vector< std::unique_ptr< DataRecord >> &&  records,
std::vector< Payload > &  payloads_out 
)

This method is meant to be used with data records returned by the Reader API.

Payload overload: Original payloads are appended to `payloads_out' and they point into memory owned by this decoder after the call has returned. It is only safe to use the returned Payload instances as long as this decoder still exists. (For any successfully decoded DataRecord instances, this class assumes ownership of the payloads, which is why `records' is taken by reference.)

PayloadGroup overload: IOBufs in returned PayloadGroups are managed and can outlive the decoder.

It is fine to use the same decoder instance to decode multiple batches of records read from LogDevice. However, the decoder pins memory so it should typically be short-lived (its lifetime is tied to the Payload instances in payloads_out as explained above).

Returns
On success, returns 0. If some DataRecord's failed to decode, return -1, leaving malformed records in `records'.

◆ decodeOne()

int facebook::logdevice::BufferedWriteDecoder::decodeOne ( std::unique_ptr< DataRecord > &&  record,
std::vector< Payload > &  payloads_out 
)

Same as decode() but for a single record only.

Returns
On success, returns 0. If the DataRecord failed to decode, return -1.

◆ decodeOneCompressed()

int facebook::logdevice::BufferedWriteDecoder::decodeOneCompressed ( std::unique_ptr< DataRecord > &&  record,
CompressedPayloadGroups &  compressed_payload_groups_out 
)

Decodes record without uncompressing any of the payloads. Batch must be written using PayloadGroups API in BufferedWriter, otherwise decoding will fail. Claims ownership of DataRecord on success.

Returns
On success, returns 0. If the DataRecord failed to decode, returns -1.

◆ getBatchSize()

static int facebook::logdevice::BufferedWriteDecoder::getBatchSize ( const DataRecord &  record,
size_t *  size_out 
)
static

Returns the number of individual records stored in a single DataRecord.


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