SwatDB
|
#include <data.h>
Public Member Functions | |
Data ()=delete | |
Disable base constructor. | |
Data (const Data &other)=delete | |
Disable copy constructor. | |
Data & | operator= (const Data &other)=delete |
Disable copy assignment constructor. | |
Data (std::uint32_t size, const char *other_data) | |
Constructor with given char array and size. | |
Data (std::uint32_t size, std::uint32_t capacity) | |
Constructor with given size and capacity. | |
Data (std::uint32_t capacity) | |
Constructor with given capacity. | |
~Data () | |
Destructor. | |
char * | getData () |
Getter for data char array. | |
std::uint32_t | getSize () |
Getter for size. | |
void | setSize (std::uint32_t new_size) |
Setter for size. | |
std::uint32_t | getCapacity () |
Getter for capacity. | |
Private Member Functions | |
void | _getOffsetLength (FieldId field_id, FieldOffset *offset, FieldOffset *length, FieldId num_fields) |
helper method to calculate the offset value and field length given a field_id. | |
Static Private Member Functions | |
static void | _copyDataValue (Data *src, std::uint32_t src_offset, Data *dst, std::uint32_t dst_offset, std::uint32_t len) |
copy data from one Data object to another | |
static void | _copyFromBuff (char *src, char *dst, std::uint32_t len) |
helper function for _copyDataValue that does low level copy from char bufs | |
static bool | _compareFieldValue (Data *data1, FieldId field_id1, FieldId num_fields1, Data *data2, FieldId field_id2, FieldId num_fields2, Comp comp_op, FieldType field_type) |
compare a field value from one Data object to another (data1 comp_op data2) | |
static bool | _compareFromBuff (char *data1, char *data2, Comp comp_op, FieldType field_type, FieldOffset length1, FieldOffset length2) |
helper function for _compareFieldValue that does low level compare on data char bufs | |
Private Attributes | |
char * | data |
std::uint32_t | size |
std::uint32_t | capacity |
Friends | |
class | Key |
class | Record |
SwatDB Data Class. Data a is class that allows storing and moving data of specified size in a more convenient way. A lot of times used as a serialized object that could be given structure by storing it as data member of another object with appropriate methods.
Data::Data | ( | std::uint32_t | size, |
const char * | other_data | ||
) |
Constructor with given char array and size.
Data::Data | ( | std::uint32_t | size, |
std::uint32_t | capacity | ||
) |
Constructor with given size and capacity.
InvalidSizeData | If size is greater than capacity. |
Data::Data | ( | std::uint32_t | capacity | ) |
Constructor with given capacity.
Data::~Data | ( | ) |
|
staticprivate |
compare a field value from one Data object to another (data1 comp_op data2)
data1 | the first Data object |
offset1 | offset into dtaa1's data buffer of the field to comp |
data2 | the second Data object |
offset2 | offset into dtaa2's data buffer of the field to comp |
comp_op | the comparison to perform (LESS, GREATER, EQUAL, NOT_EQUAL, LESS_EQUAL, or GREATER_EQUAL) |
field_type | the types of fields being compared |
len | number of bytes of the fields (for strings field types) |
|
staticprivate |
helper function for _compareFieldValue that does low level compare on data char bufs
this may be useful if don't have two Data objects, so we are making this a function instead of internal to implementation
|
staticprivate |
|
staticprivate |
helper function for _copyDataValue that does low level copy from char bufs
this may be useful if don't have two Data objects, so we are making this a function instead of internal to implementation
|
private |
helper method to calculate the offset value and field length given a field_id.
This is a function for extracting formatted information out of the data object.
FieldId | field_id position of the desired record field |
FieldOffset | *length pointer to the length of the field passed in from caller |
FieldOffset | *offset pointer to the offset passed in from caller |
num_fields | FieldId number of fields, used to get length of last bucket. |
std::uint32_t Data::getCapacity | ( | ) |
char * Data::getData | ( | ) |
Getter for data char array.
std::uint32_t Data::getSize | ( | ) |
void Data::setSize | ( | std::uint32_t | new_size | ) |
Setter for size.
size | New size to be set to. |
InvalidSizeData | If new_size is greater than capacity. |
|
private |
The actual size of dynamically allocated data array.
|
private |
char* to dynamically allocated array that stores the data.
|
private |
Size in bytes up to which the data array is valid.