Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 8373fd9

Browse files
committed
Merge remote-tracking branch 'upstream/master' into brain_rl_testing_framework
2 parents f1efdcd + 196f663 commit 8373fd9

File tree

327 files changed

+15217
-22501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

327 files changed

+15217
-22501
lines changed

Diff for: cmake/Dependencies.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ llvm_map_components_to_libnames(LLVM_LIBRARIES core mcjit nativecodegen native)
8686
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
8787
list(APPEND Peloton_LINKER_LIBS ${LLVM_LIBRARIES})
8888

89+
# --[ FFI
90+
find_package(Libffi)
91+
include_directories(SYSTEM ${LIBFFI_INCLUDE_DIRS})
92+
list(APPEND Peloton_LINKER_LIBS ${LIBFFI_LIBRARIES})
93+
8994
# --[ IWYU
9095

9196
# Generate clang compilation database

Diff for: cmake/Modules/FindLibffi.cmake

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# - Try to find Libffi
2+
#
3+
# A Portable Foreign Function Interface Library (https://sourceware.org/libffi)
4+
#
5+
# Usage:
6+
# LIBFFI_INCLUDE_DIRS, location of header files
7+
# LIBFFI_LIBRARIES, location of library
8+
# LIBFFI_FOUND, indicates if libffi was found
9+
10+
# Look for the header file.
11+
execute_process(COMMAND brew --prefix libffi OUTPUT_VARIABLE LIBFFI_BREW_PREFIX)
12+
13+
find_library(LIBFFI_LIBRARY NAMES ffi libffi
14+
PATHS /usr /usr/local /opt/local
15+
PATH_SUFFIXES lib lib64 x86_64-linux-gnu lib/x86_64-linux-gnu
16+
)
17+
18+
find_path(LIBFFI_INCLUDE_DIR ffi.h
19+
PATHS /usr /usr/local /opt/local /usr/include/ffi
20+
PATH_SUFFIXES include include/ffi include/x86_64-linux-gnu x86_64-linux-gnu
21+
HINT LIBFFI_BREW_PREFIX
22+
)
23+
24+
include(FindPackageHandleStandardArgs)
25+
find_package_handle_standard_args(LIBFFI DEFAULT_MSG LIBFFI_LIBRARY LIBFFI_INCLUDE_DIR)
26+
27+
28+
# Copy the results to the output variables.
29+
IF(LIBFFI_FOUND)
30+
SET(LIBFFI_LIBRARIES ${LIBFFI_LIBRARY})
31+
SET(LIBFFI_INCLUDE_DIRS ${LIBFFI_INCLUDE_DIR})
32+
ELSE(LIBFFI_FOUND)
33+
SET(LIBFFI_LIBRARIES)
34+
SET(LIBFFI_INCLUDE_DIRS)
35+
ENDIF(LIBFFI_FOUND)
36+
37+
MARK_AS_ADVANCED(LIBFFI_INCLUDE_DIRS LIBFFI_LIBRARIES)
38+
39+
message(STATUS "Found Libffi (include: ${LIBFFI_INCLUDE_DIRS}, library: ${LIBFFI_LIBRARIES})")

Diff for: script/installation/packages.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ TF_TYPE="cpu"
4747
function install_protobuf3.4.0() {
4848
# Install Relevant tooling
4949
# Remove any old versions of protobuf
50+
# Note: Protobuf 3.5+ PPA available Ubuntu Bionic(18.04) onwards - Should be used
51+
# when we retire 16.04 too: https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf
52+
# This PPA unfortunately doesnt have Protobuf 3.5 for 16.04, but does for 14.04/18.04+
5053
DISTRIB=$1 # ubuntu/fedora
5154
if [ "$DISTRIB" == "ubuntu" ]; then
5255
sudo apt-get --yes --force-yes remove --purge libprotobuf-dev protobuf-compiler
@@ -63,7 +66,7 @@ function install_protobuf3.4.0() {
6366
wget -O protobuf-cpp-3.4.0.tar.gz https://github.com/google/protobuf/releases/download/v3.4.0/protobuf-cpp-3.4.0.tar.gz
6467
tar -xzf protobuf-cpp-3.4.0.tar.gz
6568
cd protobuf-3.4.0
66-
./autogen.sh && ./configure && make -j4 && sudo make install && sudo ldconfig
69+
./autogen.sh && ./configure && make -j4 && sudo make install && sudo ldconfig || exit 1
6770
cd ..
6871
# Cleanup
6972
rm -rf protobuf-3.4.0 protobuf-cpp-3.4.0.tar.gz
@@ -173,6 +176,8 @@ if [ "$DISTRO" = "UBUNTU" ]; then
173176
libedit-dev \
174177
libssl-dev \
175178
postgresql-client \
179+
libffi6 \
180+
libffi-dev \
176181
libtbb-dev \
177182
python3-pip \
178183
curl \
@@ -216,6 +221,7 @@ elif [ "$DISTRO" = "DARWIN" ]; then
216221
brew install libedit
217222
brew install [email protected]
218223
brew install postgresql
224+
brew install libffi
219225
brew install tbb
220226
brew install curl
221227
brew install wget

Diff for: src/CMakeLists.txt

+1-28
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,6 @@ set_target_properties(peloton-bin PROPERTIES OUTPUT_NAME peloton)
6262

6363
##################################################################################
6464

65-
# --[ Benchmarks
66-
67-
# --[ tpcc
68-
file(GLOB_RECURSE tpcc_srcs ${PROJECT_SOURCE_DIR}/src/main/tpcc/*.cpp)
69-
add_executable(tpcc EXCLUDE_FROM_ALL ${tpcc_srcs})
70-
target_link_libraries(tpcc peloton)
71-
72-
# --[ ycsb
73-
file(GLOB_RECURSE ycsb_srcs ${PROJECT_SOURCE_DIR}/src/main/ycsb/*.cpp)
74-
add_executable(ycsb EXCLUDE_FROM_ALL ${ycsb_srcs})
75-
target_link_libraries(ycsb peloton)
76-
77-
# --[ sdbench
78-
file(GLOB_RECURSE sdbench_srcs ${PROJECT_SOURCE_DIR}/src/main/sdbench/*.cpp)
79-
add_executable(sdbench EXCLUDE_FROM_ALL ${sdbench_srcs})
80-
target_link_libraries(sdbench peloton)
81-
82-
# --[ tpch
83-
file(GLOB_RECURSE tpch_srcs ${PROJECT_SOURCE_DIR}/src/main/tpch/*.cpp)
84-
add_executable(tpch EXCLUDE_FROM_ALL ${tpch_srcs})
85-
target_link_libraries(tpch peloton)
86-
8765
# --[ logger
8866
#file(GLOB_RECURSE logger_srcs ${PROJECT_SOURCE_DIR}/src/main/logger/*.cpp)
8967
#list(APPEND logger_srcs ${ycsb_srcs})
@@ -96,16 +74,11 @@ target_link_libraries(tpch peloton)
9674
# --[ link to jemalloc
9775
set(EXE_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
9876
set(EXE_LINK_FLAGS "-Wl,--no-as-needed")
99-
set(EXE_LIST peloton-bin ycsb tpcc sdbench tpch)
77+
set(EXE_LIST peloton-bin)
10078
foreach(exe_name ${EXE_LIST})
10179
target_link_libraries(${exe_name} ${EXE_LINK_LIBRARIES})
10280
if (LINUX)
10381
set_target_properties(${exe_name} PROPERTIES LINK_FLAGS ${EXE_LINK_FLAGS})
10482
endif ()
10583
endforeach()
10684

107-
# --[ benchmark
108-
109-
add_custom_target(benchmark)
110-
add_dependencies(benchmark tpcc ycsb sdbench)
111-

Diff for: src/binder/bind_node_visitor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void BindNodeVisitor::Visit(parser::AnalyzeStatement *node) {
208208
void BindNodeVisitor::Visit(expression::TupleValueExpression *expr) {
209209
if (!expr->GetIsBound()) {
210210
std::tuple<oid_t, oid_t, oid_t> col_pos_tuple;
211-
std::shared_ptr<catalog::TableCatalogObject> table_obj = nullptr;
211+
std::shared_ptr<catalog::TableCatalogEntry> table_obj = nullptr;
212212
type::TypeId value_type;
213213
int depth = -1;
214214

Diff for: src/binder/binder_context.cpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ void BinderContext::AddRegularTable(const std::string db_name,
3838
const std::string table_alias,
3939
concurrency::TransactionContext *txn) {
4040
// using catalog object to retrieve meta-data
41-
auto table_object = catalog::Catalog::GetInstance()->GetTableObject(
42-
db_name, schema_name, table_name, txn);
41+
auto table_object = catalog::Catalog::GetInstance()->GetTableCatalogEntry(txn,
42+
db_name,
43+
schema_name,
44+
table_name);
4345

4446
if (regular_table_alias_map_.find(table_alias) !=
4547
regular_table_alias_map_.end() ||
@@ -79,9 +81,9 @@ void BinderContext::AddNestedTable(
7981

8082
bool BinderContext::GetColumnPosTuple(
8183
const std::string &col_name,
82-
std::shared_ptr<catalog::TableCatalogObject> table_obj,
84+
std::shared_ptr<catalog::TableCatalogEntry> table_obj,
8385
std::tuple<oid_t, oid_t, oid_t> &col_pos_tuple, type::TypeId &value_type) {
84-
auto column_object = table_obj->GetColumnObject(col_name);
86+
auto column_object = table_obj->GetColumnCatalogEntry(col_name);
8587
if (column_object == nullptr) {
8688
return false;
8789
}
@@ -138,7 +140,7 @@ bool BinderContext::GetColumnPosTuple(
138140

139141
bool BinderContext::GetRegularTableObj(
140142
std::shared_ptr<BinderContext> current_context, std::string &alias,
141-
std::shared_ptr<catalog::TableCatalogObject> &table_obj, int &depth) {
143+
std::shared_ptr<catalog::TableCatalogEntry> &table_obj, int &depth) {
142144
while (current_context != nullptr) {
143145
auto iter = current_context->regular_table_alias_map_.find(alias);
144146
if (iter != current_context->regular_table_alias_map_.end()) {
@@ -174,9 +176,9 @@ void BinderContext::GenerateAllColumnExpressions(
174176
std::vector<std::unique_ptr<expression::AbstractExpression>> &exprs) {
175177
for (auto &entry : regular_table_alias_map_) {
176178
auto &table_obj = entry.second;
177-
auto col_cnt = table_obj->GetColumnObjects().size();
179+
auto col_cnt = table_obj->GetColumnCatalogEntries().size();
178180
for (size_t i = 0; i < col_cnt; i++) {
179-
auto col_obj = table_obj->GetColumnObject(i);
181+
auto col_obj = table_obj->GetColumnCatalogEntry(i);
180182
auto tv_expr = new expression::TupleValueExpression(
181183
std::string(col_obj->GetColumnName()), std::string(entry.first));
182184
tv_expr->SetValueType(col_obj->GetColumnType());

Diff for: src/brain/index_selection_job.cpp

+17-17
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ void IndexSelectionJob::OnJobInvocation(BrainEnvironment *env) {
2828

2929
// Analyze stats for all the tables.
3030
// TODO: AnalyzeStatsForAllTables crashes sometimes.
31-
optimizer::StatsStorage *stats_storage =
32-
optimizer::StatsStorage::GetInstance();
33-
ResultType stats_result = stats_storage->AnalyzeStatsForAllTables(txn);
34-
if (stats_result != ResultType::SUCCESS) {
35-
LOG_ERROR(
36-
"Cannot generate stats for table columns. Not performing index "
37-
"suggestion...");
38-
txn_manager.AbortTransaction(txn);
39-
return;
40-
}
31+
// optimizer::StatsStorage *stats_storage =
32+
// optimizer::StatsStorage::GetInstance();
33+
// ResultType stats_result = stats_storage->AnalyzeStatsForAllTables(txn);
34+
// if (stats_result != ResultType::SUCCESS) {
35+
// LOG_ERROR(
36+
// "Cannot generate stats for table columns. Not performing index "
37+
// "suggestion...");
38+
// txn_manager.AbortTransaction(txn);
39+
// return;
40+
// }
4141

4242
// Query the catalog for new SQL queries.
4343
// New SQL queries are the queries that were added to the system
@@ -71,12 +71,12 @@ void IndexSelectionJob::OnJobInvocation(BrainEnvironment *env) {
7171
}
7272

7373
// Get the index objects from database.
74-
auto database_object = catalog::Catalog::GetInstance()->GetDatabaseObject(
75-
DEFAULT_DB_NAME, txn);
74+
auto database_object = catalog::Catalog::GetInstance()->GetDatabaseCatalogEntry(
75+
txn, DEFAULT_DB_NAME);
7676
auto pg_index = catalog::Catalog::GetInstance()
7777
->GetSystemCatalogs(database_object->GetDatabaseOid())
7878
->GetIndexCatalog();
79-
auto cur_indexes = pg_index->GetIndexObjects(txn);
79+
auto cur_indexes = pg_index->GetIndexCatalogEntries(txn, database_object->GetDatabaseOid());
8080
auto drop_indexes = GetIndexesToDrop(cur_indexes, best_config);
8181

8282
// Drop useless indexes.
@@ -97,12 +97,12 @@ void IndexSelectionJob::OnJobInvocation(BrainEnvironment *env) {
9797
txn_manager.CommitTransaction(txn);
9898
}
9999

100-
std::vector<std::shared_ptr<catalog::IndexCatalogObject>>
100+
std::vector<std::shared_ptr<catalog::IndexCatalogEntry>>
101101
IndexSelectionJob::GetIndexesToDrop(
102-
std::unordered_map<oid_t, std::shared_ptr<catalog::IndexCatalogObject>>
102+
std::unordered_map<oid_t, std::shared_ptr<catalog::IndexCatalogEntry>>
103103
&index_objects,
104104
brain::IndexConfiguration best_config) {
105-
std::vector<std::shared_ptr<catalog::IndexCatalogObject>> ret_indexes;
105+
std::vector<std::shared_ptr<catalog::IndexCatalogEntry>> ret_indexes;
106106
// Get the existing indexes and drop them.
107107
for (auto index : index_objects) {
108108
auto index_name = index.second->GetIndexName();
@@ -162,7 +162,7 @@ void IndexSelectionJob::CreateIndexRPC(brain::HypotheticalIndexObject *index) {
162162
}
163163

164164
void IndexSelectionJob::DropIndexRPC(oid_t database_oid,
165-
catalog::IndexCatalogObject *index) {
165+
catalog::IndexCatalogEntry *index) {
166166
// TODO: Remove hardcoded database name and server end point.
167167
// TODO: Have to be removed when merged with tli's code.
168168
capnp::EzRpcClient client("localhost:15445");

Diff for: src/brain/indextune/compressed_index_config.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ CompressedIndexConfigContainer::CompressedIndexConfigContainer(
3535

3636
auto txn = txn_manager_->BeginTransaction();
3737

38-
const auto db_obj = catalog_->GetDatabaseObject(database_name_, txn);
38+
const auto db_obj = catalog_->GetDatabaseCatalogEntry(txn, database_name_);
3939
database_oid_ = db_obj->GetDatabaseOid();
40-
const auto table_objs = db_obj->GetTableObjects();
40+
const auto table_objs = db_obj->GetTableCatalogEntries();
4141

4242
// Uniq identifier per index config
4343
size_t next_index_id = 0;
@@ -54,7 +54,7 @@ CompressedIndexConfigContainer::CompressedIndexConfigContainer(
5454
indexid_table_map_[table_oid] = {};
5555
auto &indexconf_id_map = table_indexid_map_[table_oid];
5656
auto &id_indexconf_map = indexid_table_map_[table_oid];
57-
const auto col_objs = table_obj.second->GetColumnObjects();
57+
const auto col_objs = table_obj.second->GetColumnCatalogEntries();
5858
std::vector<oid_t> null_conf;
5959
std::vector<oid_t> cols;
6060
for (const auto &col_obj : col_objs) {
@@ -79,7 +79,7 @@ CompressedIndexConfigContainer::CompressedIndexConfigContainer(
7979
continue;
8080
}
8181

82-
const auto index_objs = table_obj.second->GetIndexObjects();
82+
const auto index_objs = table_obj.second->GetIndexCatalogEntries();
8383
if (index_objs.empty()) {
8484
SetBit(table_offset_map_.at(table_oid));
8585
} else {

Diff for: src/brain/indextune/compressed_index_config_util.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void CompressedIndexConfigUtil::AddCandidates(
4141
} else if (cand_sel_type == CandidateSelectionType::Simple || cand_sel_type == CandidateSelectionType::Exhaustive) {
4242
auto sql_stmt_list = ToBindedSqlStmtList(container, query);
4343
auto txn = container.GetTransactionManager()->BeginTransaction();
44-
container.GetCatalog()->GetDatabaseObject(container.GetDatabaseName(), txn);
44+
container.GetCatalog()->GetDatabaseCatalogEntry(txn, container.GetDatabaseName());
4545

4646
std::vector<planner::col_triplet> indexable_cols_vector =
4747
planner::PlanUtil::GetIndexableColumns(txn->catalog_cache,
@@ -106,7 +106,7 @@ void CompressedIndexConfigUtil::DropCandidates(
106106
auto sql_stmt = sql_stmt_list->GetStatement(0);
107107

108108
auto txn = container.GetTransactionManager()->BeginTransaction();
109-
container.GetCatalog()->GetDatabaseObject(container.GetDatabaseName(), txn);
109+
container.GetCatalog()->GetDatabaseCatalogEntry(txn, container.GetDatabaseName());
110110
std::vector<planner::col_triplet> affected_indexes =
111111
planner::PlanUtil::GetAffectedIndexes(txn->catalog_cache, *sql_stmt,
112112
true);
@@ -126,9 +126,9 @@ CompressedIndexConfigUtil::ConvertIndexTriplet(
126126
const auto idx_oid = std::get<2>(idx_triplet);
127127

128128
auto txn = container.GetTransactionManager()->BeginTransaction();
129-
const auto db_obj = container.GetCatalog()->GetDatabaseObject(db_oid, txn);
130-
const auto table_obj = db_obj->GetTableObject(table_oid);
131-
const auto idx_obj = table_obj->GetIndexObject(idx_oid);
129+
const auto db_obj = container.GetCatalog()->GetDatabaseCatalogEntry(txn, db_oid);
130+
const auto table_obj = db_obj->GetTableCatalogEntry(table_oid);
131+
const auto idx_obj = table_obj->GetIndexCatalogEntries(idx_oid);
132132
const auto col_oids = idx_obj->GetKeyAttrs();
133133
std::vector<oid_t> input_oids(col_oids);
134134

@@ -224,8 +224,8 @@ void CompressedIndexConfigUtil::GetIgnoreTables(
224224

225225
auto txn = txn_manager->BeginTransaction();
226226
const auto table_objs = catalog::Catalog::GetInstance()
227-
->GetDatabaseObject(db_name, txn)
228-
->GetTableObjects();
227+
->GetDatabaseCatalogEntry(txn, db_name)
228+
->GetTableCatalogEntries();
229229

230230
for (const auto &it : table_objs) {
231231
ori_table_oids.insert(it.first);

Diff for: src/brain/query_logger.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ void QueryLogger::LogQuery(std::string query_string, uint64_t timestamp) {
4141

4242
// Log query + fingerprint
4343
auto &query_history_catalog = catalog::QueryHistoryCatalog::GetInstance();
44-
query_history_catalog.InsertQueryHistory(
45-
query_string, fingerprint.GetFingerprint(), timestamp, nullptr, txn);
44+
query_history_catalog.InsertQueryHistory(txn,
45+
query_string,
46+
fingerprint.GetFingerprint(),
47+
timestamp,
48+
nullptr);
4649

4750
// We're done
4851
txn_manager.CommitTransaction(txn);

Diff for: src/brain/what_if_index.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,24 @@ WhatIfIndex::GetCostAndBestPlanTree(
4444
// Load the tables into cache.
4545

4646
// TODO: Hard coding the schema name for build to pass.
47-
auto table_object = catalog::Catalog::GetInstance()->GetTableObject(
48-
database_name, "public", table_name, txn);
47+
auto table_object = catalog::Catalog::GetInstance()->GetTableCatalogEntry(
48+
txn, database_name, "public", table_name);
4949

5050
// Evict all the existing real indexes and
5151
// insert the what-if indexes into the cache.
52-
table_object->EvictAllIndexObjects();
52+
table_object->EvictAllIndexCatalogEntries();
5353

5454
// Upon evict index objects, the index set becomes
5555
// invalid. Set it to valid so that we don't query
5656
// the catalog again while doing query optimization later.
57-
table_object->SetValidIndexObjects(true);
57+
table_object->SetValidIndexCatalogEntries(true);
5858

5959
auto index_set = config.GetIndexes();
6060
for (auto it = index_set.begin(); it != index_set.end(); it++) {
6161
auto index = *it;
6262
if (index->table_oid == table_object->GetTableOid()) {
63-
auto index_catalog_obj = CreateIndexCatalogObject(index.get());
64-
table_object->InsertIndexObject(index_catalog_obj);
63+
auto index_catalog_obj = CreateIndexCatalogEntry(index.get());
64+
table_object->InsertIndexCatalogEntry(index_catalog_obj);
6565
LOG_TRACE("Created a new hypothetical index %d on table: %d",
6666
index_catalog_obj->GetIndexOid(),
6767
index_catalog_obj->GetTableOid());
@@ -84,8 +84,8 @@ WhatIfIndex::GetCostAndBestPlanTree(
8484
return opt_info_obj;
8585
}
8686

87-
std::shared_ptr<catalog::IndexCatalogObject>
88-
WhatIfIndex::CreateIndexCatalogObject(HypotheticalIndexObject *index_obj) {
87+
std::shared_ptr<catalog::IndexCatalogEntry>
88+
WhatIfIndex::CreateIndexCatalogEntry(HypotheticalIndexObject *index_obj) {
8989
// Create an index name:
9090
// index_<database_name>_<table_name>_<col_oid1>_<col_oid2>_...
9191
std::ostringstream index_name_oss;
@@ -101,8 +101,8 @@ WhatIfIndex::CreateIndexCatalogObject(HypotheticalIndexObject *index_obj) {
101101
// Create a dummy catalog object.
102102
auto col_oids = std::vector<oid_t>(index_obj->column_oids.begin(),
103103
index_obj->column_oids.end());
104-
auto index_cat_obj = std::shared_ptr<catalog::IndexCatalogObject>(
105-
new catalog::IndexCatalogObject(
104+
auto index_cat_obj = std::shared_ptr<catalog::IndexCatalogEntry>(
105+
new catalog::IndexCatalogEntry(
106106
index_seq_no++, index_name_oss.str(), index_obj->table_oid,
107107
IndexType::BWTREE, IndexConstraintType::DEFAULT, false, col_oids));
108108
return index_cat_obj;

0 commit comments

Comments
 (0)