OmniSciDB  17c254d2f8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AbstractFragmenter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2020 OmniSci, 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 #pragma once
23 
24 #include "Fragmenter/Fragmenter.h"
25 
26 #include <boost/variant.hpp>
27 #include <string>
28 #include <vector>
29 
32 #include "Shared/UpdelRoll.h"
33 #include "Shared/sqltypes.h"
35 
36 // Should the ColumnInfo and FragmentInfo structs be in
37 // AbstractFragmenter?
38 
39 namespace Chunk_NS {
40 class Chunk;
41 };
42 
43 namespace Data_Namespace {
44 class AbstractBuffer;
45 class AbstractDataMgr;
46 }; // namespace Data_Namespace
47 
48 namespace Importer_NS {
49 class TypedImportBuffer;
50 };
51 
52 namespace Catalog_Namespace {
53 class Catalog;
54 }
55 struct TableDescriptor;
56 struct ColumnDescriptor;
57 
58 namespace Fragmenter_Namespace {
59 
64  public:
65  virtual size_t const getRowCount() const = 0;
66  virtual size_t const getEntryCount() const = 0;
67  virtual StringDictionaryProxy* getLiteralDictionary() const = 0;
68  virtual std::vector<TargetValue> getEntryAt(const size_t index) const = 0;
69  virtual std::vector<TargetValue> getTranslatedEntryAt(const size_t index) const = 0;
70 };
71 
72 /*
73  * @type AbstractFragmenter
74  * @brief abstract base class for all table partitioners
75  *
76  * The virtual methods of this class provide an interface
77  * for an interface for getting the id and type of a
78  * partitioner, inserting data into a partitioner, and
79  * getting the partitions (fragments) managed by a
80  * partitioner that must be queried given a predicate
81  */
82 
84  public:
85  virtual ~AbstractFragmenter() {}
86 
94  // virtual void getFragmentsForQuery(QueryInfo &queryInfo, const void *predicate = 0) =
95  // 0
96 
100  virtual TableInfo getFragmentsForQuery() = 0;
101 
107  virtual void insertData(InsertData& insertDataStruct) = 0;
108 
114  virtual void insertDataNoCheckpoint(InsertData& insertDataStruct) = 0;
115 
120  virtual void dropFragmentsToSize(const size_t maxRows) = 0;
121 
125  virtual void updateChunkStats(
126  const ColumnDescriptor* cd,
127  std::unordered_map</*fragment_id*/ int, ChunkStats>& stats_map) = 0;
128 
132  virtual FragmentInfo* getFragmentInfo(const int fragment_id) const = 0;
133 
137  virtual int getFragmenterId() = 0;
138 
143  virtual std::string getFragmenterType() = 0;
144 
145  virtual size_t getNumRows() = 0;
146  virtual void setNumRows(const size_t numTuples) = 0;
147 
148  virtual void updateColumn(const Catalog_Namespace::Catalog* catalog,
149  const TableDescriptor* td,
150  const ColumnDescriptor* cd,
151  const int fragment_id,
152  const std::vector<uint64_t>& frag_offsets,
153  const std::vector<ScalarTargetValue>& rhs_values,
154  const SQLTypeInfo& rhs_type,
155  const Data_Namespace::MemoryLevel memory_level,
156  UpdelRoll& updel_roll) = 0;
157 
158  virtual void updateColumns(const Catalog_Namespace::Catalog* catalog,
159  const TableDescriptor* td,
160  const int fragmentId,
161  const std::vector<TargetMetaInfo> sourceMetaInfo,
162  const std::vector<const ColumnDescriptor*> columnDescriptors,
163  const RowDataProvider& sourceDataProvider,
164  const size_t indexOffFragmentOffsetColumn,
165  const Data_Namespace::MemoryLevel memoryLevel,
166  UpdelRoll& updelRoll) = 0;
167 
168  virtual void updateColumn(const Catalog_Namespace::Catalog* catalog,
169  const TableDescriptor* td,
170  const ColumnDescriptor* cd,
171  const int fragment_id,
172  const std::vector<uint64_t>& frag_offsets,
173  const ScalarTargetValue& rhs_value,
174  const SQLTypeInfo& rhs_type,
175  const Data_Namespace::MemoryLevel memory_level,
176  UpdelRoll& updel_roll) = 0;
177 
178  virtual void updateColumnMetadata(const ColumnDescriptor* cd,
179  FragmentInfo& fragment,
180  std::shared_ptr<Chunk_NS::Chunk> chunk,
181  const bool null,
182  const double dmax,
183  const double dmin,
184  const int64_t lmax,
185  const int64_t lmin,
186  const SQLTypeInfo& rhs_type,
187  UpdelRoll& updel_roll) = 0;
188 
189  virtual void updateMetadata(const Catalog_Namespace::Catalog* catalog,
190  const MetaDataKey& key,
191  UpdelRoll& updel_roll) = 0;
192 
193  virtual void compactRows(const Catalog_Namespace::Catalog* catalog,
194  const TableDescriptor* td,
195  const int fragmentId,
196  const std::vector<uint64_t>& fragOffsets,
197  const Data_Namespace::MemoryLevel memoryLevel,
198  UpdelRoll& updelRoll) = 0;
199 
200  virtual const std::vector<uint64_t> getVacuumOffsets(
201  const std::shared_ptr<Chunk_NS::Chunk>& chunk) = 0;
202 
203  virtual void dropColumns(const std::vector<int>& columnIds) = 0;
204 
206  virtual bool hasDeletedRows(const int delete_column_id) = 0;
207 };
208 
209 } // namespace Fragmenter_Namespace
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:86
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 bool hasDeletedRows(const int delete_column_id)=0
Iterates through chunk metadata to return whether any rows have been deleted.
Constants for Builtin SQL Types supported by OmniSci.
virtual void dropColumns(const std::vector< int > &columnIds)=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...
virtual FragmentInfo * getFragmentInfo(const int fragment_id) const =0
Retrieve the fragment info object for an individual fragment for editing.
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:78
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