OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UpdelRoll.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 #ifndef UPDELROLL_H
17 #define UPDELROLL_H
18 
19 #include <map>
20 #include <mutex>
21 #include <set>
22 #include <utility>
23 
24 #include "../Chunk/Chunk.h"
25 #include "../DataMgr/ChunkMetadata.h"
26 #include "../DataMgr/MemoryLevel.h"
27 
28 namespace Fragmenter_Namespace {
29 class InsertOrderFragmenter;
30 class FragmentInfo;
31 } // namespace Fragmenter_Namespace
32 
33 namespace Catalog_Namespace {
34 class Catalog;
35 }
36 
37 struct TableDescriptor;
38 
39 using MetaDataKey =
40  std::pair<const TableDescriptor*, Fragmenter_Namespace::FragmentInfo*>;
41 
42 // this roll records stuff that need to be roll back/forw after upd/del fails or finishes
43 struct UpdelRoll {
45  if (dirtyChunks.size()) {
46  cancelUpdate();
47  }
48  }
49  std::mutex mutex;
50 
51  // chunks changed during this query
52  std::map<Chunk_NS::Chunk*, std::shared_ptr<Chunk_NS::Chunk>> dirtyChunks;
53  std::set<ChunkKey> dirtyChunkeys;
54 
55  // new FragmentInfo.numTuples
56  std::map<MetaDataKey, size_t> numTuples;
57 
58  // new FragmentInfo.ChunkMetadata;
59  std::map<MetaDataKey, std::map<int, ChunkMetadata>> chunkMetadata;
60 
61  // on aggregater it's possible that updateColumn is never called but
62  // commitUpdate is still called, so this nullptr is a protection
66 
67  bool is_varlen_update = false;
68 
69  void cancelUpdate();
70  void commitUpdate();
71 };
72 
73 #endif
Data_Namespace::MemoryLevel memoryLevel
Definition: UpdelRoll.h:65
bool is_varlen_update
Definition: UpdelRoll.h:67
void commitUpdate()
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
void cancelUpdate()
std::map< Chunk_NS::Chunk *, std::shared_ptr< Chunk_NS::Chunk > > dirtyChunks
Definition: UpdelRoll.h:52
std::set< ChunkKey > dirtyChunkeys
Definition: UpdelRoll.h:53
~UpdelRoll()
Definition: UpdelRoll.h:44
const Catalog_Namespace::Catalog * catalog
Definition: UpdelRoll.h:63
std::map< MetaDataKey, std::map< int, ChunkMetadata > > chunkMetadata
Definition: UpdelRoll.h:59
int logicalTableId
Definition: UpdelRoll.h:64
specifies the content in-memory of a row in the table metadata table
std::mutex mutex
Definition: UpdelRoll.h:49
std::map< MetaDataKey, size_t > numTuples
Definition: UpdelRoll.h:56