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
53
65
74
84
94
103 void setSchema(Schema* new_schema);
104
113 void setRecordData(Data* new_data);
114
125 void setRecordData(std::vector<std::string> tuple_vals);
126
133 std::string getFieldData(FieldId field_id);
134
135 Key getKey(SearchKeyFormat* key_format, Data* key_data);
136
150 bool compareFieldToValue(FieldId field_id, void *value, Comp comp);
151
152
165 std::int32_t getIntField(FieldId field_id);
166
179 float getFloatField(FieldId field_id);
180
196 char *getStringField(FieldId field_id, FieldOffset *length);
197
215 void combineRecords(std::vector<FieldId> field_list, Record *other_rec,
216 Record *result_rec);
217
218 //TODO: new method setRecordFromRecord, takes result_rec and field_list
219 // of current record that should be copied into result_rec
220
234 void setRecordFromRecord(std::vector<FieldId> field_list,
235 Record *result_rec);
236
237 private:
238
251 void _getOffset(FieldId field_id, FieldOffset *offset,
252 FieldOffset *length);
253
259
265
266};
267
268#endif
Definition data.h:26
Definition key.h:38
Definition record.h:34
Data * record_data
Definition record.h:264
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:258
void setSchema(Schema *new_schema)
Setter for schema.
Record(Schema *schema)
Constructor given appropriate Schema*.
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:73
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