Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <string-buffer.h>
Public Member Functions | |
StringBuffer (MemPool *pool, StringValue *str=NULL) | |
void | Append (const char *str, int len) |
Append 'str' to the current string, allocating a new buffer as necessary. More... | |
void | Append (const uint8_t *str, int len) |
TODO: switch everything to uint8_t? More... | |
void | Assign (const char *str, int len) |
Assigns contents to StringBuffer. More... | |
void | Clear () |
Clear the underlying StringValue. The allocated buffer can be reused. More... | |
void | Reset () |
Clears the underlying buffer and StringValue. More... | |
bool | Empty () const |
Returns whether the current string is empty. More... | |
int | Size () const |
Returns the length of the current string. More... | |
const StringValue & | str () const |
Returns the underlying StringValue. More... | |
int | buffer_size () const |
Returns the buffer size. More... | |
Private Member Functions | |
void | GrowBuffer (int new_len) |
Private Attributes | |
MemPool * | pool_ |
StringValue | string_value_ |
int | buffer_size_ |
Dynamic-sizable string (similar to std::string) but without as many copies and allocations. StringBuffer wraps a StringValue object with a pool and memory buffer length. It supports a subset of the std::string functionality but will only allocate bigger string buffers as necessary. std::string tries to be immutable and will reallocate very often. std::string should be avoided in all hot paths.
Definition at line 30 of file string-buffer.h.
|
inline |
C'tor for StringBuffer. Memory backing the string will be allocated from the pool as necessary. Can optionally be initialized from a StringValue.
Definition at line 34 of file string-buffer.h.
References buffer_size_, impala::StringValue::len, pool_, str(), and string_value_.
|
inline |
Append 'str' to the current string, allocating a new buffer as necessary.
Definition at line 44 of file string-buffer.h.
References buffer_size_, GrowBuffer(), impala::StringValue::len, impala::StringValue::ptr, and string_value_.
Referenced by Append(), Assign(), impala::HdfsTextScanner::ProcessRange(), and impala::TEST().
|
inline |
TODO: switch everything to uint8_t?
Definition at line 54 of file string-buffer.h.
References Append().
|
inline |
Assigns contents to StringBuffer.
Definition at line 59 of file string-buffer.h.
References Append(), and Clear().
Referenced by impala::TEST().
|
inline |
Returns the buffer size.
Definition at line 91 of file string-buffer.h.
References buffer_size_.
Referenced by impala::TEST().
|
inline |
Clear the underlying StringValue. The allocated buffer can be reused.
Definition at line 65 of file string-buffer.h.
References impala::StringValue::len, and string_value_.
Referenced by Assign(), impala::HdfsTextScanner::ProcessRange(), impala::HdfsTextScanner::ResetScanner(), impala::TEST(), and impala::HdfsTextScanner::WriteFields().
|
inline |
Returns whether the current string is empty.
Definition at line 76 of file string-buffer.h.
References impala::StringValue::len, and string_value_.
Referenced by impala::HdfsTextScanner::FinishScanRange(), impala::HdfsTextScanner::LogRowParseError(), impala::HdfsTextScanner::ProcessRange(), and impala::ValidateString().
|
inlineprivate |
Grows the buffer backing the string to be at least new_size, copying over the previous string data into the new buffer.
Definition at line 98 of file string-buffer.h.
References impala::MemPool::Allocate(), buffer_size_, impala::StringValue::len, pool_, impala::StringValue::ptr, and string_value_.
Referenced by Append().
|
inline |
Clears the underlying buffer and StringValue.
Definition at line 70 of file string-buffer.h.
References buffer_size_, impala::StringValue::len, and string_value_.
|
inline |
Returns the length of the current string.
Definition at line 81 of file string-buffer.h.
References impala::StringValue::len, and string_value_.
Referenced by impala::HdfsTextScanner::CopyBoundaryField(), impala::HdfsTextScanner::FinishScanRange(), and impala::ValidateString().
|
inline |
Returns the underlying StringValue.
Definition at line 86 of file string-buffer.h.
References string_value_.
Referenced by impala::HdfsTextScanner::CopyBoundaryField(), impala::HdfsTextScanner::FinishScanRange(), impala::HdfsTextScanner::LogRowParseError(), StringBuffer(), and impala::ValidateString().
|
private |
Definition at line 110 of file string-buffer.h.
Referenced by Append(), buffer_size(), GrowBuffer(), Reset(), and StringBuffer().
|
private |
Definition at line 108 of file string-buffer.h.
Referenced by GrowBuffer(), and StringBuffer().
|
private |
Definition at line 109 of file string-buffer.h.
Referenced by Append(), Clear(), Empty(), GrowBuffer(), Reset(), Size(), str(), and StringBuffer().