-
Notifications
You must be signed in to change notification settings - Fork 90
/
AbstractTable.h
116 lines (98 loc) · 2.7 KB
/
AbstractTable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* Copyright (C) GridGain Systems. All Rights Reserved.
* _________ _____ __________________ _____
* __ ____/___________(_)______ /__ ____/______ ____(_)_______
* _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
* / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
* \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
*/
#pragma once
#include "UUID.h"
#include <cstddef>
#include <memory>
#include <string>
#include <vector>
// Forward declarations.
class SchemaDescriptor;
class TupleAssembler;
/**
* Interface to read rows of a table in one-by-one fashion.
*/
class AbstractRowIterator {
public:
/**
* @brief Construct a new Iterator object.
*/
AbstractRowIterator() noexcept = default;
/**
* @brief Destroy the Iterator object.
*/
virtual ~AbstractRowIterator() = default;
/**
* @brief Check if there are any rows to read yet.
*
* @return true in case there is one or more available rows.
* @return false in case there are no available rows at all.
*/
virtual bool hasNext() const = 0;
/**
* @brief Get the the next single row.
* The row contains each required column in binary form, key-sorted order.
*
* @param ta Tuple assembler
*/
virtual void getNext(TupleAssembler &ta) = 0;
};
/**
* Interface for a table.
*/
class AbstractTable {
std::string name;
UUID uuid;
public:
/**
* @brief Construct a new Table object.
*/
AbstractTable() noexcept = default;
/**
* @brief Destroy the Table object.
*/
virtual ~AbstractTable() = default;
/**
* @brief Get schema descriptor.
*
* @return The table schema descriptor.
*/
virtual const SchemaDescriptor &getSchema() const noexcept = 0;
/**
* @brief Get iterator for selected columns of storage.
*
* @param requiredColumns Indices of iterated columns.
* @return AbstractRowIterator Row iterator.
*/
virtual std::unique_ptr<AbstractRowIterator> getRowIterator(const std::vector<int> &requiredColumns) = 0;
/**
* @brief Set the table name.
*
* @param n The name of the table.
*/
void setName(const std::string &n) { name = n; }
/**
* @brief Get the table name.
*
* @return The name of the table.
*/
const std::string &getName() const noexcept { return name; }
/**
* @brief Set the table UUID.
*
* @param u The UUID of the table.
*/
void setUUID(const UUID &u) noexcept { uuid = u; }
/**
* @brief Get the table UUID.
*
* @return The UUID of the table.
*/
const UUID &getUUID() const noexcept { return uuid; }
};