OmniSciDB  91042dcc5b
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LockMgr.cpp
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 
17 #include "LockMgr/LockMgrImpl.h"
18 
19 #include <string>
20 
21 #include "Catalog/Catalog.h"
22 #include "LockMgr/LegacyLockMgr.h"
25 #include "Shared/types.h"
26 #include "gen-cpp/CalciteServer.h"
27 
28 namespace lockmgr {
29 
30 namespace helpers {
31 
33  const std::string& tableName) {
34  const auto table_id = cat.getTableId(tableName);
35  if (table_id.has_value()) {
36  ChunkKey chunk_key{cat.getCurrentDB().dbId, table_id.value()};
37  return chunk_key;
38  } else {
39  throw std::runtime_error("Table/View " + tableName + " for catalog " +
40  cat.getCurrentDB().dbName + " does not exist");
41  }
42 }
43 
44 } // namespace helpers
45 
46 } // namespace lockmgr
std::vector< int > ChunkKey
Definition: types.h:37
std::string cat(Ts &&...args)
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:114
std::optional< int32_t > getTableId(const std::string &table_name) const
Definition: Catalog.cpp:1553
This file contains the class specification and related data structures for Catalog.
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:228
ChunkKey chunk_key_for_table(const Catalog_Namespace::Catalog &cat, const std::string &tableName)
Definition: LockMgr.cpp:32