Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::ThriftSerializer Class Reference

#include <thrift-util.h>

Collaboration diagram for impala::ThriftSerializer:

Public Member Functions

 ThriftSerializer (bool compact, int initial_buffer_size=1024)
 
template<class T >
Status Serialize (T *obj, std::vector< uint8_t > *result)
 Serializes obj into result. Result will contain a copy of the memory. More...
 
template<class T >
Status Serialize (T *obj, uint32_t *len, uint8_t **buffer)
 
template<class T >
Status Serialize (T *obj, std::string *result)
 

Private Attributes

boost::shared_ptr
< apache::thrift::transport::TMemoryBuffer > 
mem_buffer_
 
boost::shared_ptr
< apache::thrift::protocol::TProtocol > 
protocol_
 

Detailed Description

Utility class to serialize thrift objects to a binary format. This object should be reused if possible to reuse the underlying memory. Note: thrift will encode NULLs into the serialized buffer so it is not valid to treat it as a string.

Definition at line 39 of file thrift-util.h.

Constructor & Destructor Documentation

impala::ThriftSerializer::ThriftSerializer ( bool  compact,
int  initial_buffer_size = 1024 
)

If compact, the objects will be serialized using the Compact Protocol. Otherwise, we'll use the binary protocol. Note: the deserializer must be matching.

Definition at line 66 of file thrift-util.cc.

References mem_buffer_, and protocol_.

Member Function Documentation

template<class T >
Status impala::ThriftSerializer::Serialize ( T *  obj,
std::vector< uint8_t > *  result 
)
inline

Serializes obj into result. Result will contain a copy of the memory.

Definition at line 48 of file thrift-util.h.

References impala::Status::OK, and RETURN_IF_ERROR.

Referenced by impala::AdmissionController::AddPoolUpdates(), impala::CatalogServer::BuildTopicUpdates(), main(), impala::SerializeThriftMsg(), and impala::TEST().

template<class T >
Status impala::ThriftSerializer::Serialize ( T *  obj,
uint32_t *  len,
uint8_t **  buffer 
)
inline

Serialize obj into a memory buffer. The result is returned in buffer/len. The memory returned is owned by this object and will be invalid when another object is serialized.

Definition at line 61 of file thrift-util.h.

References mem_buffer_, impala::Status::OK, and protocol_.

template<class T >
Status impala::ThriftSerializer::Serialize ( T *  obj,
std::string *  result 
)
inline

Definition at line 75 of file thrift-util.h.

References mem_buffer_, impala::Status::OK, and protocol_.

Member Data Documentation

boost::shared_ptr<apache::thrift::transport::TMemoryBuffer> impala::ThriftSerializer::mem_buffer_
private

Definition at line 89 of file thrift-util.h.

Referenced by Serialize(), and ThriftSerializer().

boost::shared_ptr<apache::thrift::protocol::TProtocol> impala::ThriftSerializer::protocol_
private

Definition at line 90 of file thrift-util.h.

Referenced by Serialize(), and ThriftSerializer().


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