-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathInsertDestinationInterface.hpp
158 lines (140 loc) · 6.17 KB
/
InsertDestinationInterface.hpp
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
**/
#ifndef QUICKSTEP_STORAGE_INSERT_DESTINATION_INTERFACE_HPP_
#define QUICKSTEP_STORAGE_INSERT_DESTINATION_INTERFACE_HPP_
#include <utility>
#include <vector>
#include "catalog/CatalogTypedefs.hpp"
#include "catalog/PartitionSchemeHeader.hpp"
#include "types/containers/Tuple.hpp"
namespace quickstep {
class CatalogRelationSchema;
class ValueAccessor;
/** \addtogroup Storage
* @{
*/
/**
* @brief A pure interface class that InsertDestination and its subclasses
* implement. This class is used to separate interface from
* implementation and resolve what would otherwise be a circular
* dependency between StorageBlock and InsertDestination.
*
* @note This interface only contains methods to logically insert tuples, plus
* a few basic informational methods. Methods involving explicit
* management of blocks are in the InsertDestination class.
**/
class InsertDestinationInterface {
public:
virtual ~InsertDestinationInterface() {
}
/**
* @brief Get the relation which tuples are inserted into.
*
* @return The relation which tuples are inserted into.
**/
virtual const CatalogRelationSchema& getRelation() const = 0;
/**
* @brief Get the attribute IDs used for partitioning, if any.
* @note This is intended only for use by StorageBlock::update(), to
* determine whether it is safe to do in-place updates or whether all
* updated Tuples must be relocated to land in the correct partition.
*
* @return The IDs of the attribute used for partitioning, or empty if there
* is no partitioning.
**/
virtual PartitionSchemeHeader::PartitionAttributeIds getPartitioningAttributes() const = 0;
/**
* @brief Insert a single tuple into a block managed by this
* InsertDestination.
*
* @param tuple The tuple to insert.
* @exception TupleTooLargeForBlock Even though a block was initially empty,
* the tuple was too large to insert. Only thrown if a block is
* initially empty, otherwise failure to insert simply causes
* another block to be used.
**/
virtual void insertTuple(const Tuple &tuple) = 0;
/**
* @brief Insert a single tuple into a block managed by this
* InsertDestination using the batch-insert path (i.e. do not rebuild
* blocks until they are full or all insertions are complete).
*
* @param tuple The tuple to insert.
* @exception TupleTooLargeForBlock Even though a block was initially empty,
* the tuple was too large to insert. Only thrown if a block is
* initially empty, otherwise failure to insert simply causes
* another block to be used.
**/
virtual void insertTupleInBatch(const Tuple &tuple) = 0;
/**
* @brief Bulk-insert tuples from a ValueAccessor into blocks managed by this
* InsertDestination.
*
* @param accessor A ValueAccessor whose tuples will by inserted into blocks
* from this InsertDestination.
* @param always_mark_full If \c true, always mark the blocks full after
* insertion from ValueAccessor even when partially full.
**/
virtual void bulkInsertTuples(ValueAccessor *accessor,
const bool always_mark_full = false) = 0;
/**
* @brief Bulk-insert tuples from a ValueAccessor with differently-ordered
* attributes into blocks managed by this InsertDestination.
*
* @param attribute_map A vector which maps the attributes of this
* InsertDestination's relation (in order with no gaps) to the
* corresponding attributes which should be read from accessor.
* @param accessor A ValueAccessor whose tuples will by inserted into blocks
* from this InsertDestination.
**/
virtual void bulkInsertTuplesWithRemappedAttributes(
const std::vector<attribute_id> &attribute_map,
ValueAccessor *accessor) = 0;
/**
* @brief Bulk-insert tuples from one or more ValueAccessors
* into blocks managed by this InsertDestination.
*
* @warning It is implicitly assumed that all the input ValueAccessors have
* the same number of tuples in them.
*
* @param accessor_attribute_map A vector of pairs of ValueAccessor and
* corresponding attribute map
* The i-th attribute ID in the attr map for a value accessor is "n"
* if the attribute_id "i" in the output relation
* is the attribute_id "n" in corresponding input value accessor.
* Set the i-th element to kInvalidCatalogId if it doesn't come from
* the corresponding value accessor.
**/
virtual void bulkInsertTuplesFromValueAccessors(
const std::vector<std::pair<ValueAccessor *, std::vector<attribute_id>>> &accessor_attribute_map) = 0;
/**
* @brief Insert tuples from a range of Tuples in a vector.
* @warning Unlike bulkInsertTuples(), this is not well-optimized and not
* intended for general use. It should only be used by
* StorageBlock::update().
*
* @param begin The first element in the range of Tuples to insert.
* @param end One-past-the-end of the range of Tuples to insert.
**/
virtual void insertTuplesFromVector(std::vector<Tuple>::const_iterator begin,
std::vector<Tuple>::const_iterator end) = 0;
};
/** @} */
} // namespace quickstep
#endif // QUICKSTEP_STORAGE_INSERT_DESTINATION_INTERFACE_HPP_