OmniSciDB  04ee39c94c
AbstractFragmenter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #ifndef _ABSTRACT_FRAGMENTER_H
23 #define _ABSTRACT_FRAGMENTER_H
24 
25 #include <boost/variant.hpp>
26 #include <string>
27 #include <vector>
28 #include "../QueryEngine/TargetMetaInfo.h"
29 #include "../QueryEngine/TargetValue.h"
30 #include "../Shared/UpdelRoll.h"
31 #include "../Shared/sqltypes.h"
32 #include "../StringDictionary/StringDictionaryProxy.h"
33 #include "Fragmenter.h"
34 
35 // Should the ColumnInfo and FragmentInfo structs be in
36 // AbstractFragmenter?
37 
38 namespace Chunk_NS {
39 class Chunk;
40 };
41 
42 namespace Data_Namespace {
43 class AbstractBuffer;
44 class AbstractDataMgr;
45 }; // namespace Data_Namespace
46 
47 namespace Importer_NS {
48 class TypedImportBuffer;
49 };
50 
51 namespace Catalog_Namespace {
52 class Catalog;
53 }
54 struct TableDescriptor;
55 struct ColumnDescriptor;
56 
58 
63  public:
64  virtual size_t count() const = 0;
65  virtual StringDictionaryProxy* getLiteralDictionary() const = 0;
66  virtual std::vector<TargetValue> getEntryAt(const size_t index) const = 0;
67  virtual std::vector<TargetValue> getTranslatedEntryAt(const size_t index) const = 0;
68 };
69 
70 /*
71  * @type AbstractFragmenter
72  * @brief abstract base class for all table partitioners
73  *
74  * The virtual methods of this class provide an interface
75  * for an interface for getting the id and type of a
76  * partitioner, inserting data into a partitioner, and
77  * getting the partitions (fragments) managed by a
78  * partitioner that must be queried given a predicate
79  */
80 
82  public:
83  virtual ~AbstractFragmenter() {}
84 
92  // virtual void getFragmentsForQuery(QueryInfo &queryInfo, const void *predicate = 0) =
93  // 0
94 
98  virtual TableInfo getFragmentsForQuery() = 0;
99 
105  virtual void insertData(InsertData& insertDataStruct) = 0;
106 
112  virtual void insertDataNoCheckpoint(InsertData& insertDataStruct) = 0;
113 
118  virtual void dropFragmentsToSize(const size_t maxRows) = 0;
119 
123  virtual void updateChunkStats(
124  const ColumnDescriptor* cd,
125  std::unordered_map</*fragment_id*/ int, ChunkStats>& stats_map) = 0;
126 
130  virtual int getFragmenterId() = 0;
131 
136  virtual std::string getFragmenterType() = 0;
137 
138  virtual size_t getNumRows() = 0;
139  virtual void setNumRows(const size_t numTuples) = 0;
140 
141  virtual void updateColumn(const Catalog_Namespace::Catalog* catalog,
142  const TableDescriptor* td,
143  const ColumnDescriptor* cd,
144  const int fragment_id,
145  const std::vector<uint64_t>& frag_offsets,
146  const std::vector<ScalarTargetValue>& rhs_values,
147  const SQLTypeInfo& rhs_type,
148  const Data_Namespace::MemoryLevel memory_level,
149  UpdelRoll& updel_roll) = 0;
150 
151  virtual void updateColumns(const Catalog_Namespace::Catalog* catalog,
152  const TableDescriptor* td,
153  const int fragmentId,
154  const std::vector<TargetMetaInfo> sourceMetaInfo,
155  const std::vector<const ColumnDescriptor*> columnDescriptors,
156  const RowDataProvider& sourceDataProvider,
157  const size_t indexOffFragmentOffsetColumn,
158  const Data_Namespace::MemoryLevel memoryLevel,
159  UpdelRoll& updelRoll) = 0;
160 
161  virtual void updateColumn(const Catalog_Namespace::Catalog* catalog,
162  const TableDescriptor* td,
163  const ColumnDescriptor* cd,
164  const int fragment_id,
165  const std::vector<uint64_t>& frag_offsets,
166  const ScalarTargetValue& rhs_value,
167  const SQLTypeInfo& rhs_type,
168  const Data_Namespace::MemoryLevel memory_level,
169  UpdelRoll& updel_roll) = 0;
170 
171  virtual void updateColumnMetadata(const ColumnDescriptor* cd,
172  FragmentInfo& fragment,
173  std::shared_ptr<Chunk_NS::Chunk> chunk,
174  const bool null,
175  const double dmax,
176  const double dmin,
177  const int64_t lmax,
178  const int64_t lmin,
179  const SQLTypeInfo& rhs_type,
180  UpdelRoll& updel_roll) = 0;
181 
182  virtual void updateMetadata(const Catalog_Namespace::Catalog* catalog,
183  const MetaDataKey& key,
184  UpdelRoll& updel_roll) = 0;
185 
186  virtual void compactRows(const Catalog_Namespace::Catalog* catalog,
187  const TableDescriptor* td,
188  const int fragmentId,
189  const std::vector<uint64_t>& fragOffsets,
190  const Data_Namespace::MemoryLevel memoryLevel,
191  UpdelRoll& updelRoll) = 0;
192 
193  virtual const std::vector<uint64_t> getVacuumOffsets(
194  const std::shared_ptr<Chunk_NS::Chunk>& chunk) = 0;
195 };
196 
197 } // namespace Fragmenter_Namespace
198 
199 #endif // _ABSTRACT_FRAGMENTER_H
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:81
std::pair< const TableDescriptor *, Fragmenter_Namespace::FragmentInfo * > MetaDataKey
Definition: UpdelRoll.h:40
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:79
An AbstractBuffer is a unit of data management for a data manager.
specifies the content in-memory of a row in the column metadata table
FileBuffer Chunk
A Chunk is the fundamental unit of execution in Map-D.
Definition: FileMgr.h:68
The data to be inserted using the fragment manager.
Definition: Fragmenter.h:59
specifies the content in-memory of a row in the table metadata table
boost::variant< int64_t, double, float, NullableString > ScalarTargetValue
Definition: TargetValue.h:156