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 decodeOne (std::unique_ptr< DataRecord > &&record, std::vector< Payload > &payloads_out)

Static Public Member Functions

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


class BufferedWriteDecoderImpl

Member Function Documentation

◆ create()

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

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.

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.)

If 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).

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.

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

◆ getBatchSize()

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

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

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