SwatDB
Loading...
Searching...
No Matches
data.h
Go to the documentation of this file.
1/*
2 * SwatDB
3 *
4 * @authors: See Contributors.doc for code contributors
5 *
6 * Copyright (c) 2020 Swarthmore College Computer Science Department
7 * Swarthmore PA, Professors Tia Newhall, Ameet Soni
8 */
9
10#ifndef _SWATDB_DATA_H_
11#define _SWATDB_DATA_H_
12
17#include "swatdb_types.h"
18
26class Data {
27
28 friend class Key;
29 friend class Record;
30
31 public:
32
36 Data() = delete;
37
41 Data(const Data& other) = delete;
42
46 Data& operator=(const Data& other) = delete;
47
56 Data(std::uint32_t size, const char* other_data);
57
67 Data(std::uint32_t size, std::uint32_t capacity);
68
76 Data(std::uint32_t capacity);
77
85
94 char* getData();
95
104 std::uint32_t getSize();
105
116 void setSize(std::uint32_t new_size);
117
126 std::uint32_t getCapacity();
127
128 private:
129
130
144 static void _copyDataValue(Data *src, std::uint32_t src_offset,
145 Data *dst, std::uint32_t dst_offset, std::uint32_t len);
146
154 static void _copyFromBuff(char *src, char *dst, std::uint32_t len);
155
180 static bool _compareFieldValue(Data *data1, FieldId field_id1,
181 FieldId num_fields1, Data *data2, FieldId field_id2,
182 FieldId num_fields2, Comp comp_op, FieldType field_type);
183
192 static bool _compareFromBuff(char *data1, char *data2, Comp comp_op,
193 FieldType field_type, FieldOffset length1, FieldOffset length2);
194
212 void _getOffsetLength(FieldId field_id, FieldOffset *offset,
213 FieldOffset *length, FieldId num_fields);
214
218 char* data;
219
223 std::uint32_t size;
224
228 std::uint32_t capacity;
229
230};
231
232#endif
Definition data.h:26
void setSize(std::uint32_t new_size)
Setter for size.
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
std::uint32_t getCapacity()
Getter for capacity.
Data(const Data &other)=delete
Disable copy constructor.
Data(std::uint32_t capacity)
Constructor with given capacity.
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.
char * data
Definition data.h:218
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
static void _copyFromBuff(char *src, char *dst, std::uint32_t len)
helper function for _copyDataValue that does low level copy from char bufs
Data()=delete
Disable base constructor.
Data & operator=(const Data &other)=delete
Disable copy assignment constructor.
std::uint32_t getSize()
Getter for size.
~Data()
Destructor.
std::uint32_t capacity
Definition data.h:228
char * getData()
Getter for data char array.
std::uint32_t size
Definition data.h:223
Data(std::uint32_t size, const char *other_data)
Constructor with given char array and size.
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)
Data(std::uint32_t size, std::uint32_t capacity)
Constructor with given size and capacity.
Definition key.h:38
Definition record.h:34
std::uint32_t FieldId
Definition swatdb_types.h:86
std::uint16_t FieldOffset
Definition swatdb_types.h:92
FieldType
Definition swatdb_types.h:97