Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

DBMain and Settings Manager #336

Merged
merged 666 commits into from May 27, 2019
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
666 commits
Select commit Hold shift + click to select a range
6880281
Merge branch 'master' into catalog
yeshengm Apr 4, 2019
bb4952a
Merge branch 'catalog' of https://github.com/yangjuns/terrier into ca…
pervazea Apr 5, 2019
0e68d18
Merge branch 'catalog' of https://github.com/yangjuns/terrier into ca…
pervazea Apr 5, 2019
9288bbe
Compilation fixes
pervazea Apr 5, 2019
10129d5
fix doc
yeshengm Apr 5, 2019
b491bff
move validation into settings_manager; implement temporary value comp…
YuzeLiao Apr 6, 2019
4fd6844
Design document
DarkForte Apr 6, 2019
afe722b
Design document title
DarkForte Apr 6, 2019
6d7f399
add simple main_database class
YuzeLiao Apr 6, 2019
ba41413
Merge branch 'settings_manager' of https://github.com/DarkForte/terri…
YuzeLiao Apr 6, 2019
d58e98e
Merge branch 'master' into settings_manager
DarkForte Apr 6, 2019
74b7e28
Merge branch 'master' into 15-721-project2-stats
wenxuanqiu Apr 7, 2019
7bfae07
fix jenkins
yeshengm Apr 7, 2019
5f059c2
change from storage::col_id_t to catalog::col_oid_t
wenhaoh2 Apr 7, 2019
46e0388
add thread to map
yangdsh Apr 7, 2019
19c829d
add callback to MainDatabase
wenhaoh2 Apr 7, 2019
428a629
Merge branch '15-721-project2-stats' of github.com:wenxuanqiu/terrier…
yangdsh Apr 7, 2019
5cca31c
remove plan node (irrelevant for this PR))
Apr 7, 2019
6ac5da2
fix compilation
Apr 7, 2019
3e0e50e
add test
Apr 7, 2019
20fcab8
Add design document
qdHe Apr 7, 2019
4bbb61e
Update DesignDocument.md
qdHe Apr 7, 2019
165696f
format
Apr 7, 2019
3bd9f42
Merge branch '15-721-project2-stats' of github.com:wenxuanqiu/terrier…
Apr 7, 2019
ac5a537
Add files via upload
qdHe Apr 7, 2019
8a758ca
Add image to DesignDocument.md
qdHe Apr 7, 2019
2a1d438
move design document
qdHe Apr 7, 2019
41671d1
linter fixes
Apr 7, 2019
cbfb528
Merge branch '15-721-project2-stats' of github.com:wenxuanqiu/terrier…
Apr 7, 2019
5461d02
style
Apr 7, 2019
8d087f1
fix clang-tidy errors; fix bugs in settings_handle schema
YuzeLiao Apr 8, 2019
0f28dc9
fix most doxygen error; fix settings handle test bug
YuzeLiao Apr 8, 2019
9fa2d0a
fix format errors
YuzeLiao Apr 8, 2019
e87d1a4
fix minor bugs; temporarily shut down catalog_benchmark
YuzeLiao Apr 8, 2019
57708e4
fix some lint bugs
YuzeLiao Apr 8, 2019
fc767d1
fix bug in settings test
YuzeLiao Apr 8, 2019
ce85cf0
add nolint for macro files
YuzeLiao Apr 8, 2019
0c25800
Fixed transaction mem leak by turning off GC
DarkForte Apr 8, 2019
4eaa81e
Merge branch 'settings_manager' of https://github.com/DarkForte/terri…
DarkForte Apr 8, 2019
9bd9e6e
test: callback
wenhaoh2 Apr 8, 2019
cd9ff68
debug
wenhaoh2 Apr 8, 2019
aaa6d46
remove deadcode and unintentional changes
Apr 8, 2019
a5b50c9
update design doc
Apr 9, 2019
a9a5d9f
move catalog entries outside catalog handles, prep for later refactoring
yeshengm Apr 9, 2019
64c15cd
refactored entries
yeshengm Apr 9, 2019
3327414
add test commit
yeshengm Apr 9, 2019
31be3fa
fix doxygen warnings
Apr 9, 2019
44f19c1
simple DBMain
YuzeLiao Apr 9, 2019
0cfa515
- modify Attribute handle to be use a table_oid rather than keeping
pervazea Apr 9, 2019
2975be3
Merge branch 'catalog' of https://github.com/yangjuns/terrier into ca…
pervazea Apr 9, 2019
97a6e5c
Formatting
pervazea Apr 9, 2019
e36037b
fix travis errors
YuzeLiao Apr 10, 2019
1c2b412
fix travis errors
YuzeLiao Apr 10, 2019
c02106c
Fix documentation
pervazea Apr 10, 2019
f16e30e
Initialize loggers first
DarkForte Apr 10, 2019
8963244
Removed try-catch in logger initialization
DarkForte Apr 10, 2019
5df0f3f
Add back try-catch in logger initialization
DarkForte Apr 10, 2019
ad0698d
Doc fix
pervazea Apr 10, 2019
dac0371
Add settings exception type in get_type()
wenhaoh2 Apr 10, 2019
c9a61f6
Partial review fixes
pervazea Apr 11, 2019
4d379c4
Review fixes - remove deprecated code from AttributeHandle
pervazea Apr 11, 2019
c3d787f
Quick fix for issue #339, segfault in catalog due to transaction
pervazea Apr 11, 2019
1848491
Format and tidy fixes
pervazea Apr 11, 2019
ed58855
merge latest catalog
YuzeLiao Apr 11, 2019
8271a01
Merge branch 'master' of https://github.com/cmu-db/terrier into catalog
pervazea Apr 11, 2019
5511259
More review fixes and doc fixes
pervazea Apr 12, 2019
5497842
remove C++11 synchronization headers and refactor thread collector/ag…
Apr 12, 2019
8722afd
rename method parameters to be consistent
Apr 12, 2019
09edf67
migrate to TransientValue
YuzeLiao Apr 12, 2019
697da7e
Add more documentation for TableEntry
Mar 25, 2019
37442d2
Support for deleting catalog entries
pervazea Mar 26, 2019
edb901c
migrate to TransientValue
YuzeLiao Apr 12, 2019
05244c0
fix bugs
YuzeLiao Apr 12, 2019
1d4cb3a
fix bugs
YuzeLiao Apr 12, 2019
883f05b
Merge branch 'master' into settings_manager
YuzeLiao Apr 12, 2019
3046cf7
More review fixes
pervazea Apr 12, 2019
0e1eac4
fix test bugs
YuzeLiao Apr 12, 2019
7ee8279
update test
YuzeLiao Apr 12, 2019
d9ad472
Merge branch 'master' into DBMain
tli2 Apr 12, 2019
a3aa601
fix doc errors
YuzeLiao Apr 12, 2019
a9849da
More review fixes
pervazea Apr 12, 2019
68edb9a
make things neat
YuzeLiao Apr 12, 2019
b8366c8
make things neat
YuzeLiao Apr 12, 2019
a49ac80
make things neat
YuzeLiao Apr 12, 2019
b01ae78
minor fix
YuzeLiao Apr 12, 2019
ffaf37c
add docs for param
YuzeLiao Apr 13, 2019
49e8652
fix typo in src/include/stats/abstract_metric.h
thepulkitagarwal Apr 13, 2019
ebd73d2
fix typo in src/include/stats/abstract_metric.h
thepulkitagarwal Apr 13, 2019
470ec40
fix typo in src/include/stats/abstract_metric.h
thepulkitagarwal Apr 13, 2019
e258e46
fix typo in src/include/stats/abstract_metric.h
huzaifaabbasi Apr 13, 2019
c8de3d8
fix typo in src/include/stats/thread_level_stats_collector.h
thepulkitagarwal Apr 13, 2019
722d1b2
fix typo in src/include/stats/thread_level_stats_collector.h
thepulkitagarwal Apr 13, 2019
7eeb17a
addressing review comments
Apr 13, 2019
05a654a
Merge branch '15-721-project2-stats' of github.com:wenxuanqiu/terrier…
Apr 13, 2019
cc0db34
fix typo in test/stats/stats_framework_test.cpp
utkarsh39 Apr 13, 2019
fc71ea2
Merge branch 'master' into catalog
yeshengm Apr 14, 2019
19227f4
Merge branch 'master' into catalog
yeshengm Apr 14, 2019
2ba49ee
Removed unnecessary headers, rearranged methods
DarkForte Apr 14, 2019
4c5fe46
Format code
DarkForte Apr 15, 2019
57e2ea2
Merge branch 'master' into DBMain
DarkForte Apr 15, 2019
53132c9
adding more comments, doxygen found new uncommented sections :(
Apr 15, 2019
5372481
Merge branch '15-721-project2-stats' of github.com:wenxuanqiu/terrier…
Apr 15, 2019
920b6e7
Merge branch 'master' into 15-721-project2-stats
wenxuanqiu Apr 15, 2019
ca3a8df
Merge branch 'master' of https://github.com/cmu-db/terrier into catalog
pervazea Apr 19, 2019
71c2d16
move stats/ to storage/metric/
Apr 20, 2019
bcaa01a
Merge branch '15-721-project2-stats' of github.com:wenxuanqiu/terrier…
Apr 20, 2019
7bc4937
modify pair to struct
yangdsh Apr 20, 2019
8e1b90d
modify pair to struct
yangdsh Apr 20, 2019
d41920a
change namespace
Apr 20, 2019
a1ddd6c
merge
Apr 20, 2019
310257c
change comment
Apr 20, 2019
e2bdd44
Merge pull request #4 from yangjuns/catalog
yangdsh Apr 20, 2019
22bef09
Run GC in tests, addressed several issues in CR
DarkForte Apr 20, 2019
d239733
add transaction metric
Apr 20, 2019
2d22e3c
Merge branch '15-721-project2-stats' of github.com:wenxuanqiu/terrier…
Apr 20, 2019
be6e631
add transaction metric
Apr 20, 2019
24ee371
Merge branch 'upstream_master' into settings_manager
DarkForte Apr 20, 2019
6ede7a2
add getters for transaction metreic
Apr 20, 2019
63d8233
Merge branch 'catalog' into settings_manager
DarkForte Apr 20, 2019
bd8a6e4
register transaction metrics
Apr 20, 2019
3a7c412
add database metric test
Apr 20, 2019
3fc2ade
Merge branch '15-721-project2-stats' of github.com:wenxuanqiu/terrier…
Apr 20, 2019
b07f788
format
Apr 20, 2019
86d97e4
update and persist to catalog
yangdsh Apr 20, 2019
75b04f7
resolve confilcts
yangdsh Apr 20, 2019
8d26b95
fix minor bug
yangdsh Apr 20, 2019
a350226
Merge branch 'master' into 15-721-project2-stats
wenxuanqiu Apr 21, 2019
c486a47
fix include errors
Apr 21, 2019
71edb53
add documentation
Apr 21, 2019
55a88e0
fix stats data types for inserting into tables
Apr 21, 2019
b666f5f
fix stats data types for inserting into tables
Apr 21, 2019
b9f3c9a
Use raw pointers for SqlTableRW instances
pervazea Apr 22, 2019
ca7da82
Partial changes for namespace fixes
pervazea Apr 22, 2019
55c8507
populate setting values outside DBMain
YuzeLiao Apr 22, 2019
2e628f2
minor fix
YuzeLiao Apr 22, 2019
d4a243d
Merge branch 'master' into catalog
yeshengm Apr 23, 2019
62c6335
More docs and explicit constructor
DarkForte Apr 23, 2019
021e8ae
WIP - namespace support changes
pervazea Apr 23, 2019
24eaec7
Merge branch 'upstream_master' into DBMain
DarkForte Apr 23, 2019
548152f
Merge branch 'master' into DBMain
DarkForte Apr 23, 2019
a145be0
Ignore settings_defs.h in check_format and check_lint
DarkForte Apr 23, 2019
b8db417
Merge branch 'master' into DBMain
DarkForte Apr 23, 2019
cad63ce
Whitelist settings_defs.h for doxygen and let it ignore one header ex…
DarkForte Apr 23, 2019
580ca27
Merge branch 'DBMain' of https://github.com/DarkForte/terrier into DB…
DarkForte Apr 23, 2019
40e936b
Documentation updates
pervazea Apr 24, 2019
1122ee6
Merge branch 'master' of https://github.com/cmu-db/terrier into catalog
pervazea Apr 24, 2019
b5a7ad6
Merge branch 'catalog' of https://github.com/yangjuns/terrier into ca…
pervazea Apr 24, 2019
5c27d7b
Doc and format fixes
pervazea Apr 25, 2019
1ded7a4
More review changes
pervazea Apr 25, 2019
1a1d5a8
Add more (unused) columns to pg_database, for compatibility
pervazea Apr 25, 2019
40eb181
Cleanups
pervazea Apr 25, 2019
19d47db
Merge branch 'master' into catalog
yangdsh Apr 25, 2019
dd8a62d
fix compilation error
pervazea Apr 25, 2019
194142f
Merge branch 'catalog' of https://github.com/yangjuns/terrier into ca…
pervazea Apr 25, 2019
16bcb31
Revert "Merge branch 'master' into catalog"
pervazea Apr 25, 2019
d8d87e0
add update_and_persist for transaction_metric
yangdsh Apr 25, 2019
8cbc96e
fix bug
yangdsh Apr 25, 2019
98f0a81
refactor database metric
Apr 25, 2019
a1c3a9a
refactor database metric
Apr 25, 2019
91b73e3
Merge branch 'master' into 15-721-project2-stats
wenxuanqiu Apr 25, 2019
9cf0bff
add storage test
Apr 25, 2019
131d372
Merge branch '15-721-project2-stats' of github.com:wenxuanqiu/terrier…
Apr 25, 2019
62ef0bb
remove catalog
Apr 25, 2019
2692d23
remove catalog
Apr 25, 2019
4ab4705
Merge branch '15-721-project2-stats' into catalog
wenxuanqiu Apr 25, 2019
456899e
Revert "Merge branch '15-721-project2-stats' into catalog"
Apr 25, 2019
76d0c76
add callbacks for other types in macro
wenhaoh2 Apr 26, 2019
5b702c6
add ActionContext
wenhaoh2 Apr 28, 2019
d2137fb
small fix
wenhaoh2 Apr 28, 2019
2b16a0a
More fixes
pervazea Apr 29, 2019
1459522
Merge branch 'catalog' of https://github.com/yangjuns/terrier into ca…
pervazea Apr 29, 2019
6e1349e
Merge branch 'master' of https://github.com/cmu-db/terrier into catalog
pervazea May 2, 2019
e599b05
Fix merge issue + sort strong typedefs by name
pervazea May 2, 2019
a79143b
Merge branch 'master' of https://github.com/cmu-db/terrier into catalog
pervazea May 2, 2019
0e4f86b
Fix merge error
pervazea May 2, 2019
764c012
refractor main object & adjust everything
YuzeLiao May 4, 2019
adecb4b
Merge branch 'DBMain' into settings_manager
DarkForte May 5, 2019
31fcfae
Merge branch 'upstream_master' into settings_manager
DarkForte May 5, 2019
7569099
Merge branch 'catalog' into settings_manager
DarkForte May 5, 2019
3b89253
update documentation
YuzeLiao May 5, 2019
1c0ce98
Merge branch 'settings_manager' of https://github.com/DarkForte/terri…
YuzeLiao May 5, 2019
1cb35b2
Fix merge errors
DarkForte May 5, 2019
332b44c
Merge branch 'settings_manager' of https://github.com/DarkForte/terri…
DarkForte May 5, 2019
1940a05
Addressed lint and clang-tidy problems
DarkForte May 5, 2019
bb5f56a
format & add doc
YuzeLiao May 5, 2019
134c8fd
Removed redundant code in invoking callbacks
DarkForte May 5, 2019
5db2f7d
fix bug
YuzeLiao May 5, 2019
07f17df
fix bug
YuzeLiao May 5, 2019
efd18ae
Merge branch 'settings_manager' of https://github.com/DarkForte/terri…
YuzeLiao May 5, 2019
7c353a6
Added tests for coverage
DarkForte May 5, 2019
d2f649d
Merge branch 'settings_manager' of https://github.com/DarkForte/terri…
DarkForte May 5, 2019
89b5dbf
Design doc
DarkForte May 5, 2019
81c5c55
Addressed a clang tidy issue
DarkForte May 6, 2019
52d69bc
impl minmax check && debug
wenhaoh2 May 7, 2019
3602f18
move populating param_map in main() into a static function
wenhaoh2 May 7, 2019
c999f12
combine callback_map into param_map
wenhaoh2 May 7, 2019
2df7074
add latch for settingsmanager
wenhaoh2 May 7, 2019
38466f6
Added ConcurrentModifyTest
DarkForte May 9, 2019
0823395
fix bugs
YuzeLiao May 10, 2019
b625df7
fix bugs
YuzeLiao May 10, 2019
cf8f175
fix bugs
YuzeLiao May 10, 2019
3f686bf
Increased coverage for settings_handle and loggers
DarkForte May 10, 2019
04c7dd3
coverage for GetCopy of TransientValue
YuzeLiao May 10, 2019
46485d6
Merge branch 'master' into settings_manager
YuzeLiao May 10, 2019
299c822
adjust for new master
YuzeLiao May 10, 2019
0ba2468
coverage for attribute_handle & tablespace_handle
YuzeLiao May 10, 2019
cc0b96d
fix doxygen
YuzeLiao May 10, 2019
f08512a
Merge clang tidy fix from Wan
DarkForte May 11, 2019
a6248ea
Remove unused functions, bring up coverage for out-of-bound set calls
DarkForte May 11, 2019
efff4b1
resolve conflict
YuzeLiao May 11, 2019
1960f27
Merge branch 'master' into settings_manager
YuzeLiao May 11, 2019
127f1d8
Addressed some code review comments
DarkForte May 12, 2019
b95f806
test concurrent modification to buffer pool size
wenhaoh2 May 13, 2019
7dc71a2
Peloton -> Terrier
wenhaoh2 May 13, 2019
0f29633
ConstructParamMap as a static SettingsManager function
wenhaoh2 May 13, 2019
3fbf3e6
use specified buffer pool size in bootstrap
YuzeLiao May 14, 2019
a24578e
merge master
YuzeLiao May 14, 2019
1d2d2fa
minor fix
YuzeLiao May 14, 2019
16334fc
fix travis for ConstructParamMap
YuzeLiao May 14, 2019
ed94615
address comments
YuzeLiao May 15, 2019
02a916d
return string copy in GetString()
YuzeLiao May 15, 2019
e903923
update document for DBMain
YuzeLiao May 15, 2019
991c9fe
minor fix
YuzeLiao May 15, 2019
44c9424
Merge branch 'master' into settings_manager
mbutrovich May 15, 2019
15773e6
Cleanup.
mbutrovich May 16, 2019
170ac87
Merge remote-tracking branch 'upstream/master' into settings_manager
mbutrovich May 20, 2019
3f7b3c6
Minor cleanups.
mbutrovich May 20, 2019
9a0365c
Merge remote-tracking branch 'upstream/master' into settings_manager
mbutrovich May 22, 2019
2990670
Fix GCC link order.
mbutrovich May 22, 2019
8a8a1e1
Enum cleanup. Remove settings brought over from Peloton that have no …
mbutrovich May 22, 2019
c9f5206
Consolidate logger initialization in one place.
mbutrovich May 22, 2019
b6d7792
Remove catalog interaction since the implementation is changing anyway.
mbutrovich May 22, 2019
16c3d18
Define an empty callback in transaction_util for internal transaction…
mbutrovich May 22, 2019
c249fce
Clean up memory leaks in DBMain.
mbutrovich May 22, 2019
5700953
Set debug logging interval in tests and main.
mbutrovich May 23, 2019
f2a1799
Fix double-free in settings_test after adding DBMain destructor.
mbutrovich May 23, 2019
5bc9e6a
More logic for reasoning about state of system during shut down.
mbutrovich May 23, 2019
a4a2504
Fix leak of buffer segment pool in DBMain.
mbutrovich May 23, 2019
a4cc5c8
Modify settings_test to use DBMain.
mbutrovich May 23, 2019
3829871
lint.
mbutrovich May 23, 2019
ce2af5a
Break SettingsManager callbacks out from DBMain.
mbutrovich May 24, 2019
447c4c0
Add settings_callbacks.h/.cpp.
mbutrovich May 24, 2019
5af2d5a
Define settings for buffer segment pool args and garbage collector th…
mbutrovich May 24, 2019
8e8e926
Remove buffer segment pool size stuff from Transaction Manager.
mbutrovich May 24, 2019
94bc483
Fix settings_test.
mbutrovich May 24, 2019
e0310ce
Merge remote-tracking branch 'upstream/master' into settings_manager
mbutrovich May 24, 2019
a2d957d
Initialize worker pool in DBMain, add setting for num worker threads …
mbutrovich May 24, 2019
3322310
Remove macro around test settings so Release unit tests work. Need to…
mbutrovich May 24, 2019
ce6f72b
Getters for SettingsManager changed to shared latch.
mbutrovich May 24, 2019
b9a6089
Remove test-only settings.
mbutrovich May 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -354,8 +354,10 @@ if (CMAKE_COMPILER_IS_GNUCXX)
endif()

set(TERRIER_LINK_LIBS
gflags
${TERRIER_LINK_LIBS}
${PTHREAD_LIBRARY}
gflags
pg_query)

set(TERRIER_TEST_LINK_LIBS
Expand Down
3 changes: 2 additions & 1 deletion apidoc/Doxyfile.in
Expand Up @@ -831,7 +831,8 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.

EXCLUDE = ../src/include/parser/parsenodes.h
EXCLUDE = ../src/include/parser/parsenodes.h \
../src/include/settings/settings_defs.h

# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
Expand Down
3 changes: 2 additions & 1 deletion benchmark/CMakeLists.txt
Expand Up @@ -7,9 +7,10 @@ list(APPEND BENCHMARK_UTIL_SRCS ${BENCHMARK_UTIL_HDRS})
###############################################
if (TERRIER_BUILD_BENCHMARKS)
add_library(benchmark_util STATIC ${BENCHMARK_UTIL_SRCS})
target_link_libraries(benchmark_util benchmark)
target_link_libraries(benchmark_util benchmark pthread)
add_dependencies(benchmark_util gtest)

add_subdirectory(catalog)
add_subdirectory(storage)
add_subdirectory(transaction)
endif()
1 change: 1 addition & 0 deletions benchmark/catalog/CMakeLists.txt
@@ -0,0 +1 @@
ADD_TERRIER_BENCHMARKS()
63 changes: 63 additions & 0 deletions benchmark/catalog/catalog_benchmark.cpp
@@ -0,0 +1,63 @@
#include <utility>
#include <vector>

#include "benchmark/benchmark.h"
#include "catalog/catalog.h"
#include "catalog/catalog_defs.h"
#include "common/scoped_timer.h"
#include "transaction/transaction_manager.h"
#include "util/transaction_benchmark_util.h"

namespace terrier {

class CatalogBenchmark : public benchmark::Fixture {
public:
void SetUp(const benchmark::State &state) final {
txn_manager_ = new transaction::TransactionManager(&buffer_pool_, true, LOGGING_DISABLED);

txn_ = txn_manager_->BeginTransaction();
catalog_ = new catalog::Catalog(txn_manager_, txn_);
}

void TearDown(const benchmark::State &state) final {
txn_manager_->Commit(txn_, TestCallbacks::EmptyCallback, nullptr);

delete catalog_; // need to delete catalog_first
delete txn_manager_;
delete txn_;
}

// transaction manager
transaction::TransactionManager *txn_manager_;
storage::RecordBufferSegmentPool buffer_pool_{100, 100};

transaction::TransactionContext *txn_;

catalog::Catalog *catalog_;

const int num_lookups = 100000;
};

// NOLINTNEXTLINE
BENCHMARK_DEFINE_F(CatalogBenchmark, DatabaseLookupTime)(benchmark::State &state) {
std::vector<type::TransientValue> search_vec, ret_row;
// setup search vector, lookup the default database
search_vec.push_back(type::TransientValueFactory::GetNull(type::TypeId::INTEGER));
search_vec.push_back(type::TransientValueFactory::GetVarChar("terrier"));

catalog::DatabaseHandle db_handle = catalog_->GetDatabaseHandle();

// NOLINTNEXTLINE
for (auto _ : state) {
for (int32_t iter = 0; iter < num_lookups; iter++) {
// TODO(pakhtar): replace with GetDatabaseEntry(from name);
// ret_row = db_handle.pg_database_rw_->FindRow(txn_, search_vec);
auto entry = db_handle.GetDatabaseEntry(txn_, "terrier");
}
}
state.SetItemsProcessed(state.iterations() * num_lookups);
}

BENCHMARK_REGISTER_F(CatalogBenchmark, DatabaseLookupTime)->Unit(benchmark::kMillisecond)->MinTime(2);

} // namespace terrier
2 changes: 2 additions & 0 deletions benchmark/util/benchmark_main.cpp
Expand Up @@ -18,6 +18,7 @@
// Modified from the Apache Arrow project for the Terrier project.

#include "benchmark/benchmark.h"
#include "loggers/catalog_logger.h"
#include "loggers/index_logger.h"
#include "loggers/main_logger.h"
#include "loggers/storage_logger.h"
Expand All @@ -29,6 +30,7 @@ int main(int argc, char **argv) {
terrier::storage::init_index_logger();
terrier::storage::init_storage_logger();
terrier::transaction::init_transaction_logger();
terrier::catalog::init_catalog_logger();

benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();
Expand Down
1 change: 1 addition & 0 deletions build-support/clang_format_exclusions.txt
@@ -1 +1,2 @@
*third_party*
*/include/settings/settings_defs.h
2 changes: 1 addition & 1 deletion build-support/run-clang-tidy.py
Expand Up @@ -362,4 +362,4 @@ def update_progress(current_file, num_files):
sys.exit(return_code)

if __name__ == '__main__':
main()
main()
YuzeLiao marked this conversation as resolved.
Show resolved Hide resolved
73 changes: 73 additions & 0 deletions src/catalog/attr_def_handle.cpp
@@ -0,0 +1,73 @@
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "catalog/attr_def_handle.h"
#include "catalog/catalog.h"
#include "catalog/catalog_defs.h"
#include "storage/sql_table.h"
#include "transaction/transaction_context.h"

namespace terrier::catalog {

const std::vector<SchemaCol> AttrDefHandle::schema_cols_ = {{0, true, "oid", type::TypeId::INTEGER},
{1, true, "adrelid", type::TypeId::INTEGER},
{2, true, "adnum", type::TypeId::INTEGER},
{3, true, "adbin", type::TypeId::VARCHAR},
{4, false, "adsrc", type::TypeId::VARCHAR}};

// Find entry with (row) oid and return it
std::shared_ptr<AttrDefEntry> AttrDefHandle::GetAttrDefEntry(transaction::TransactionContext *txn, col_oid_t oid) {
std::vector<type::TransientValue> search_vec, ret_row;
search_vec.push_back(type::TransientValueFactory::GetInteger(!oid));
ret_row = pg_attrdef_rw_->FindRow(txn, search_vec);
if (ret_row.empty()) {
return nullptr;
}
return std::make_shared<AttrDefEntry>(oid, pg_attrdef_rw_, std::move(ret_row));
}

void AttrDefHandle::DeleteEntries(transaction::TransactionContext *txn, table_oid_t table_oid) {
// auto layout = pg_attrdef_rw_->GetLayout();
int32_t col_index = pg_attrdef_rw_->ColNameToIndex("adrelid");

auto it = pg_attrdef_rw_->begin(txn);
while (it != pg_attrdef_rw_->end(txn)) {
// storage::ProjectedColumns::RowView row_view = it->InterpretAsRow(layout, 0);
storage::ProjectedColumns::RowView row_view = it->InterpretAsRow(0);
// check if a matching row, delete if it is
byte *col_p = row_view.AccessWithNullCheck(pg_attrdef_rw_->ColNumToOffset(col_index));
if (col_p == nullptr) {
continue;
}
auto col_int_value = *(reinterpret_cast<int32_t *>(col_p));
if (static_cast<uint32_t>(col_int_value) == !table_oid) {
// delete the entry
pg_attrdef_rw_->GetSqlTable()->Delete(txn, *(it->TupleSlots()));
}
++it;
}
}

SqlTableHelper *AttrDefHandle::Create(transaction::TransactionContext *txn, Catalog *catalog, db_oid_t db_oid,
const std::string &name) {
catalog::SqlTableHelper *pg_attrdef;

// get an oid
table_oid_t pg_attrdef_oid(catalog->GetNextOid());

// uninitialized storage
pg_attrdef = new catalog::SqlTableHelper(pg_attrdef_oid);

for (auto col : AttrDefHandle::schema_cols_) {
pg_attrdef->DefineColumn(col.col_name, col.type_id, false, col_oid_t(catalog->GetNextOid()));
}

// now actually create, with the provided schema
pg_attrdef->Create();
catalog->AddToMaps(db_oid, pg_attrdef_oid, name, pg_attrdef);
return pg_attrdef;
}

} // namespace terrier::catalog
97 changes: 97 additions & 0 deletions src/catalog/attribute_handle.cpp
@@ -0,0 +1,97 @@
#include "catalog/attribute_handle.h"
#include <iostream>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "catalog/catalog.h"
#include "catalog/schema.h"
#include "common/exception.h"
#include "loggers/catalog_logger.h"
#include "storage/block_layout.h"
#include "storage/sql_table.h"
#include "storage/storage_defs.h"
#include "type/type_id.h"

namespace terrier::catalog {

// note that this is not identical to Postgres's column sequence

const std::vector<SchemaCol> AttributeHandle::schema_cols_ = {
{0, true, "oid", type::TypeId::INTEGER}, {1, true, "attrelid", type::TypeId::INTEGER},
{2, true, "attname", type::TypeId::VARCHAR}, {3, true, "atttypid", type::TypeId::INTEGER},
{4, true, "attlen", type::TypeId::INTEGER}, {5, true, "attnum", type::TypeId::INTEGER}};

// TODO(pakhtar): add unused columns

std::shared_ptr<AttributeEntry> AttributeHandle::GetAttributeEntry(transaction::TransactionContext *txn,
table_oid_t table_oid, col_oid_t col_oid) {
std::vector<type::TransientValue> search_vec, ret_row;
search_vec.push_back(type::TransientValueFactory::GetInteger(!col_oid));
search_vec.push_back(type::TransientValueFactory::GetInteger(!table_oid));
ret_row = pg_attribute_hrw_->FindRow(txn, search_vec);
if (ret_row.empty()) {
return nullptr;
}
col_oid_t oid(type::TransientValuePeeker::PeekInteger(ret_row[0]));
return std::make_shared<AttributeEntry>(oid, pg_attribute_hrw_, std::move(ret_row));
}

std::shared_ptr<AttributeEntry> AttributeHandle::GetAttributeEntry(transaction::TransactionContext *txn,
table_oid_t table_oid, const std::string &name) {
std::vector<type::TransientValue> search_vec, ret_row;
search_vec.push_back(type::TransientValueFactory::GetNull(type::TypeId::INTEGER));
search_vec.push_back(type::TransientValueFactory::GetInteger(!table_oid));
search_vec.push_back(type::TransientValueFactory::GetVarChar(name));
ret_row = pg_attribute_hrw_->FindRow(txn, search_vec);
if (ret_row.empty()) {
return nullptr;
// throw CATALOG_EXCEPTION("attribute doesn't exist");
}
col_oid_t oid(type::TransientValuePeeker::PeekInteger(ret_row[0]));
return std::make_shared<AttributeEntry>(oid, pg_attribute_hrw_, std::move(ret_row));
}

void AttributeHandle::DeleteEntries(transaction::TransactionContext *txn, table_oid_t table_oid) {
// auto layout = pg_attribute_hrw_->GetLayout();
int32_t col_index = pg_attribute_hrw_->ColNameToIndex("attrelid");

auto it = pg_attribute_hrw_->begin(txn);
while (it != pg_attribute_hrw_->end(txn)) {
// storage::ProjectedColumns::RowView row_view = it->InterpretAsRow(layout, 0);
storage::ProjectedColumns::RowView row_view = it->InterpretAsRow(0);
// check if a matching row, delete if it is
byte *col_p = row_view.AccessWithNullCheck(pg_attribute_hrw_->ColNumToOffset(col_index));
if (col_p == nullptr) {
continue;
}
auto col_int_value = *(reinterpret_cast<int32_t *>(col_p));
if (static_cast<uint32_t>(col_int_value) == !table_oid) {
// delete the entry
pg_attribute_hrw_->GetSqlTable()->Delete(txn, *(it->TupleSlots()));
}
++it;
}
}

SqlTableHelper *AttributeHandle::Create(transaction::TransactionContext *txn, Catalog *catalog, db_oid_t db_oid,
const std::string &name) {
catalog::SqlTableHelper *pg_attr;

// get an oid
table_oid_t pg_attr_oid(catalog->GetNextOid());

// uninitialized storage
pg_attr = new catalog::SqlTableHelper(pg_attr_oid);

for (auto col : AttributeHandle::schema_cols_) {
pg_attr->DefineColumn(col.col_name, col.type_id, false, col_oid_t(catalog->GetNextOid()));
}

// now actually create, with the provided schema
pg_attr->Create();
catalog->AddToMaps(db_oid, pg_attr_oid, name, pg_attr);
return pg_attr;
}

} // namespace terrier::catalog