SwatDB
Loading...
Searching...
No Matches
record.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_RECORD_H_
11#define _SWATDB_RECORD_H_
12
13
14
19#include "swatdb_types.h"
20
21class Schema;
22class Data;
23class SearchKeyFormat;
24class Key;
25
26
34class Record {
35
36 public:
37
42
59
71
80
90
100
109 void setSchema(Schema* new_schema);
110
119 void setRecordData(Data* new_data);
120
131 void setRecordData(std::vector<std::string> tuple_vals);
132
139 std::string getFieldData(FieldId field_id);
140
141 Key getKey(SearchKeyFormat* key_format, Data* key_data);
142
156 bool compareFieldToValue(FieldId field_id, void *value, Comp comp);
157
158
171 std::int32_t getIntField(FieldId field_id);
172
185 float getFloatField(FieldId field_id);
186
202 char *getStringField(FieldId field_id, FieldOffset *length);
203
221 void combineRecords(std::vector<FieldId> field_list, Record *other_rec,
222 Record *result_rec);
223
224 //TODO: new method setRecordFromRecord, takes result_rec and field_list
225 // of current record that should be copied into result_rec
226
240 void setRecordFromRecord(std::vector<FieldId> field_list,
241 Record *result_rec);
242
243 private:
244
257 void _getOffset(FieldId field_id, FieldOffset *offset,
258 FieldOffset *length);
259
265
271
272};
273
274#endif
Definition data.h:26
Definition key.h:38
Definition record.h:34
Data * record_data
Definition record.h:270
void setRecordFromRecord(std::vector< FieldId > field_list, Record *result_rec)
Method that extracts data values from the current record and inserts the values associated with the p...
Data * getRecordData()
Getter for record_data.
Schema * getSchema()
Getter function for schema.
char * getStringField(FieldId field_id, FieldOffset *length)
Method that returns a pointer to the start of the desired string field from a record.
Schema * schema
Definition record.h:264
void setSchema(Schema *new_schema)
Setter for schema.
Record(Schema *schema)
Constructor given appropriate Schema*. This constructor allocates space that the caller must free.
std::string getFieldData(FieldId field_id)
Method that returns the value of specified field in string format.
void setRecordData(std::vector< std::string > tuple_vals)
Setter for record_data with structured input.
void setRecordData(Data *new_data)
Setter for record_data.
float getFloatField(FieldId field_id)
Method that returns a float field from a record.
void _getOffset(FieldId field_id, FieldOffset *offset, FieldOffset *length)
helper method to calculate the offset value and field length given a field_id
~Record()
Destructor.
Definition record.h:79
void combineRecords(std::vector< FieldId > field_list, Record *other_rec, Record *result_rec)
Method that combines two records fields into one larger method, with field_ids passed in that should ...
std::int32_t getIntField(FieldId field_id)
Method that returns the int field from a record.
Record()
Default constructor. Sets schema and record_data to nullptr.
Record(Schema *schema, Data *record_data)
Constructor given appropriate Data* and Schema*.
bool compareFieldToValue(FieldId field_id, void *value, Comp comp)
Compare function for a record and a given value.
Definition schema.h:37
Definition searchkeyformat.h:32
std::uint32_t FieldId
Definition swatdb_types.h:86
std::uint16_t FieldOffset
Definition swatdb_types.h:92