OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
57 namespace Fragmenter_Namespace {
58 
63  public:
64  virtual size_t const getRowCount() const = 0;
65  virtual size_t const getEntryCount() const = 0;
66  virtual StringDictionaryProxy* getLiteralDictionary() const = 0;
67  virtual std::vector<TargetValue> getEntryAt(const size_t index) const = 0;
68  virtual std::vector<TargetValue> getTranslatedEntryAt(const size_t index) const = 0;
69 };
70 
71 /*
72  * @type AbstractFragmenter
73  * @brief abstract base class for all table partitioners
74  *
75  * The virtual methods of this class provide an interface
76  * for an interface for getting the id and type of a
77  * partitioner, inserting data into a partitioner, and
78  * getting the partitions (fragments) managed by a
79  * partitioner that must be queried given a predicate
80  */
81 
83  public:
84  virtual ~AbstractFragmenter() {}
85 
93  // virtual void getFragmentsForQuery(QueryInfo &queryInfo, const void *predicate = 0) =
94  // 0
95 
99  virtual TableInfo getFragmentsForQuery() = 0;
100 
106  virtual void insertData(InsertData& insertDataStruct) = 0;
107 
113  virtual void insertDataNoCheckpoint(InsertData& insertDataStruct) = 0;
114 
119  virtual void dropFragmentsToSize(const size_t maxRows) = 0;
120 
124  virtual void updateChunkStats(
125  const ColumnDescriptor* cd,
126  std::unordered_map</*fragment_id*/ int, ChunkStats>& stats_map) = 0;
127 
131  virtual int getFragmenterId() = 0;
132 
137  virtual std::string getFragmenterType() = 0;
138 
139  virtual size_t getNumRows() = 0;
140  virtual void setNumRows(const size_t numTuples) = 0;
141 
142  virtual void updateColumn(const Catalog_Namespace::Catalog* catalog,
143  const TableDescriptor* td,
144  const ColumnDescriptor* cd,
145  const int fragment_id,
146  const std::vector<uint64_t>& frag_offsets,
147  const std::vector<ScalarTargetValue>& rhs_values,
148  const SQLTypeInfo& rhs_type,
149  const Data_Namespace::MemoryLevel memory_level,
150  UpdelRoll& updel_roll) = 0;
151 
152  virtual void updateColumns(const Catalog_Namespace::Catalog* catalog,
153  const TableDescriptor* td,
154  const int fragmentId,
155  const std::vector<TargetMetaInfo> sourceMetaInfo,
156  const std::vector<const ColumnDescriptor*> columnDescriptors,
157  const RowDataProvider& sourceDataProvider,
158  const size_t indexOffFragmentOffsetColumn,
159  const Data_Namespace::MemoryLevel memoryLevel,
160  UpdelRoll& updelRoll) = 0;
161 
162  virtual void updateColumn(const Catalog_Namespace::Catalog* catalog,
163  const TableDescriptor* td,
164  const ColumnDescriptor* cd,
165  const int fragment_id,
166  const std::vector<uint64_t>& frag_offsets,
167  const ScalarTargetValue& rhs_value,
168  const SQLTypeInfo& rhs_type,
169  const Data_Namespace::MemoryLevel memory_level,
170  UpdelRoll& updel_roll) = 0;
171 
172  virtual void updateColumnMetadata(const ColumnDescriptor* cd,
173  FragmentInfo& fragment,
174  std::shared_ptr<Chunk_NS::Chunk> chunk,
175  const bool null,
176  const double dmax,
177  const double dmin,
178  const int64_t lmax,
179  const int64_t lmin,
180  const SQLTypeInfo& rhs_type,
181  UpdelRoll& updel_roll) = 0;
182 
183  virtual void updateMetadata(const Catalog_Namespace::Catalog* catalog,
184  const MetaDataKey& key,
185  UpdelRoll& updel_roll) = 0;
186 
187  virtual void compactRows(const Catalog_Namespace::Catalog* catalog,
188  const TableDescriptor* td,
189  const int fragmentId,
190  const std::vector<uint64_t>& fragOffsets,
191  const Data_Namespace::MemoryLevel memoryLevel,
192  UpdelRoll& updelRoll) = 0;
193 
194  virtual const std::vector<uint64_t> getVacuumOffsets(
195  const std::shared_ptr<Chunk_NS::Chunk>& chunk) = 0;
196 };
197 
198 } // namespace Fragmenter_Namespace
199 
200 #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
virtual std::string getFragmenterType()=0
Gets the string type of the partitioner.
virtual void updateColumns(const Catalog_Namespace::Catalog *catalog, const TableDescriptor *td, const int fragmentId, const std::vector< TargetMetaInfo > sourceMetaInfo, const std::vector< const ColumnDescriptor * > columnDescriptors, const RowDataProvider &sourceDataProvider, const size_t indexOffFragmentOffsetColumn, const Data_Namespace::MemoryLevel memoryLevel, UpdelRoll &updelRoll)=0
std::pair< const TableDescriptor *, Fragmenter_Namespace::FragmentInfo * > MetaDataKey
Definition: UpdelRoll.h:40
virtual std::vector< TargetValue > getTranslatedEntryAt(const size_t index) const =0
virtual void updateColumn(const Catalog_Namespace::Catalog *catalog, const TableDescriptor *td, const ColumnDescriptor *cd, const int fragment_id, const std::vector< uint64_t > &frag_offsets, const std::vector< ScalarTargetValue > &rhs_values, const SQLTypeInfo &rhs_type, const Data_Namespace::MemoryLevel memory_level, UpdelRoll &updel_roll)=0
virtual void dropFragmentsToSize(const size_t maxRows)=0
Will truncate table to less than maxRows by dropping fragments.
virtual void compactRows(const Catalog_Namespace::Catalog *catalog, const TableDescriptor *td, const int fragmentId, const std::vector< uint64_t > &fragOffsets, const Data_Namespace::MemoryLevel memoryLevel, UpdelRoll &updelRoll)=0
virtual const std::vector< uint64_t > getVacuumOffsets(const std::shared_ptr< Chunk_NS::Chunk > &chunk)=0
virtual TableInfo getFragmentsForQuery()=0
Should get the partitions(fragments) where at least one tuple could satisfy the (optional) provided p...
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:79
virtual size_t const getEntryCount() const =0
virtual void insertDataNoCheckpoint(InsertData &insertDataStruct)=0
Given data wrapped in an InsertData struct, inserts it into the correct partitions No locks and check...
An AbstractBuffer is a unit of data management for a data manager.
virtual int getFragmenterId()=0
Gets the id of the partitioner.
specifies the content in-memory of a row in the column metadata table
virtual void setNumRows(const size_t numTuples)=0
virtual void updateMetadata(const Catalog_Namespace::Catalog *catalog, const MetaDataKey &key, UpdelRoll &updel_roll)=0
virtual StringDictionaryProxy * getLiteralDictionary() const =0
virtual void updateColumnMetadata(const ColumnDescriptor *cd, FragmentInfo &fragment, std::shared_ptr< Chunk_NS::Chunk > chunk, const bool null, const double dmax, const double dmin, const int64_t lmax, const int64_t lmin, const SQLTypeInfo &rhs_type, UpdelRoll &updel_roll)=0
FileBuffer Chunk
A Chunk is the fundamental unit of execution in Map-D.
Definition: FileMgr.h:67
The data to be inserted using the fragment manager.
Definition: Fragmenter.h:59
virtual void updateChunkStats(const ColumnDescriptor *cd, std::unordered_map< int, ChunkStats > &stats_map)=0
Update chunk stats.
virtual std::vector< TargetValue > getEntryAt(const size_t index) const =0
specifies the content in-memory of a row in the table metadata table
virtual void insertData(InsertData &insertDataStruct)=0
Given data wrapped in an InsertData struct, inserts it into the correct partitions with locks and che...
virtual size_t const getRowCount() const =0
boost::variant< int64_t, double, float, NullableString > ScalarTargetValue
Definition: TargetValue.h:156