├── ownbase ├── .gitignore ├── ownbase.h ├── main.cpp ├── lib │ └── README.md ├── CMakeLists.txt └── README.md ├── deps ├── CMakeLists.txt └── googletest │ ├── docs │ ├── _config.yml │ ├── assets │ │ └── css │ │ │ └── style.scss │ ├── community_created_documentation.md │ ├── platforms.md │ ├── index.md │ ├── samples.md │ ├── _data │ │ └── navigation.yml │ └── _layouts │ │ └── default.html │ ├── .github │ ├── ISSUE_TEMPLATE │ │ ├── config.yml │ │ ├── 10-feature_request.md │ │ └── 00-bug_report.md │ └── workflows │ │ └── gtest-ci.yml │ ├── .clang-format │ ├── googlemock │ ├── docs │ │ └── README.md │ ├── include │ │ └── gmock │ │ │ └── internal │ │ │ └── custom │ │ │ ├── gmock-generated-actions.h │ │ │ ├── README.md │ │ │ ├── gmock-matchers.h │ │ │ └── gmock-port.h │ ├── cmake │ │ ├── gmock.pc.in │ │ └── gmock_main.pc.in │ ├── README.md │ ├── test │ │ ├── gmock_link2_test.cc │ │ ├── gmock_link_test.cc │ │ ├── gmock-port_test.cc │ │ └── gmock_all_test.cc │ └── src │ │ └── gmock-all.cc │ ├── googletest │ ├── docs │ │ └── README.md │ ├── cmake │ │ ├── Config.cmake.in │ │ ├── gtest.pc.in │ │ ├── gtest_main.pc.in │ │ └── libgtest.la.in │ ├── include │ │ └── gtest │ │ │ ├── internal │ │ │ └── custom │ │ │ │ ├── README.md │ │ │ │ ├── gtest.h │ │ │ │ ├── gtest-port.h │ │ │ │ └── gtest-printers.h │ │ │ └── gtest_prod.h │ ├── test │ │ ├── production.cc │ │ ├── gtest_main_unittest.cc │ │ ├── googletest-uninitialized-test_.cc │ │ ├── gtest_testbridge_test_.cc │ │ ├── gtest-typed-test2_test.cc │ │ ├── googletest-setuptestsuite-test_.cc │ │ ├── gtest_xml_outfile1_test_.cc │ │ ├── gtest_xml_outfile2_test_.cc │ │ ├── googletest-param-test-invalid-name1-test_.cc │ │ ├── gtest_skip_test.cc │ │ ├── gtest_help_test_.cc │ │ ├── gtest_skip_in_environment_setup_test.cc │ │ ├── googletest-param-test-invalid-name2-test_.cc │ │ ├── production.h │ │ ├── gtest_prod_test.cc │ │ ├── gtest_sole_header_test.cc │ │ ├── gtest_all_test.cc │ │ ├── gtest_skip_environment_check_output_test.py │ │ ├── googletest-param-test-test.h │ │ ├── googletest-setuptestsuite-test.py │ │ ├── googletest-global-environment-unittest_.cc │ │ ├── gtest_no_test_unittest.cc │ │ ├── gtest-typed-test_test.h │ │ ├── googletest-param-test-invalid-name2-test.py │ │ ├── gtest_skip_check_output_test.py │ │ ├── googletest-param-test-invalid-name1-test.py │ │ └── gtest_json_test_utils.py │ ├── samples │ │ ├── sample1.h │ │ ├── sample4_unittest.cc │ │ ├── sample4.cc │ │ ├── sample4.h │ │ ├── sample2.cc │ │ └── sample1.cc │ └── src │ │ ├── gtest_main.cc │ │ └── gtest-all.cc │ ├── CMakeLists.txt │ ├── LICENSE │ ├── WORKSPACE │ ├── .gitignore │ └── CONTRIBUTORS ├── pics ├── ast.png ├── 锁表结构.png ├── B+树删除流程.png ├── B+树插入流程.png ├── B+树的结构.png ├── 执行模块流程图.jpg ├── 存储层-类之间的关系.png └── architecture_fixed.jpg ├── src ├── index │ ├── ix.h │ ├── ix_scan.cpp │ ├── CMakeLists.txt │ ├── ix_scan.h │ ├── ix_defs.h │ └── ix_index_handle.h ├── common │ ├── CMakeLists.txt │ ├── context.h │ ├── macros.h │ ├── rwlatch.cpp │ ├── rwlatch.h │ └── config.h ├── execution │ ├── execution_defs.h │ ├── execution.h │ ├── ExecutorTest_db_task2and3 │ │ ├── grade │ │ ├── student │ │ └── db.meta │ ├── input_task2.sql │ ├── input_task1.sql │ ├── CMakeLists.txt │ ├── input_task3.sql │ ├── task1_test.sh │ ├── taskall_test.sh │ ├── task2_test.sh │ ├── task3_test.sh │ ├── README.md │ ├── input_all_task.sql │ ├── executor_insert.h │ ├── res_task1_output.txt │ ├── executor_delete.h │ ├── exec_sql.cpp │ ├── executor_abstract.h │ ├── executor_projection.h │ └── executor_update.h ├── record │ ├── rm.h │ ├── CMakeLists.txt │ ├── rm_scan.h │ ├── rm_scan.cpp │ ├── bitmap.h │ ├── rm_manager.h │ └── rm_defs.h ├── system │ ├── sm.h │ ├── sm_defs.h │ └── CMakeLists.txt ├── parser │ ├── ast.cpp │ ├── parser.h │ ├── parser_defs.h │ └── CMakeLists.txt ├── recovery │ ├── checkpoint.cpp │ ├── CMakeLists.txt │ ├── log_defs.h │ ├── log_recovery.cpp │ ├── checkpoint.h │ ├── log_recovery.h │ └── log_manager.cpp ├── replacer │ ├── CMakeLists.txt │ ├── clock_replacer.cpp │ ├── lru_replacer.cpp │ ├── replacer.h │ ├── lru_replacer.h │ ├── clock_replacer.h │ └── clock_replacer_test.cpp ├── transaction │ ├── CMakeLists.txt │ ├── transaction_manager.cpp │ ├── concurrency │ │ └── lock_manager.cpp │ └── transaction_manager.h ├── CMakeLists.txt ├── storage │ └── CMakeLists.txt ├── defs.h └── record_printer.h ├── rucbase_client └── CMakeLists.txt ├── CMakeLists.txt ├── README.md └── LICENSE /ownbase/.gitignore: -------------------------------------------------------------------------------- 1 | /build/* 2 | /lib/*.a -------------------------------------------------------------------------------- /deps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(googletest) -------------------------------------------------------------------------------- /deps/googletest/docs/_config.yml: -------------------------------------------------------------------------------- 1 | title: GoogleTest 2 | -------------------------------------------------------------------------------- /deps/googletest/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /ownbase/ownbase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | int ownbase_start(int argc, char **argv); -------------------------------------------------------------------------------- /pics/ast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdu-database/rucbase-lab/HEAD/pics/ast.png -------------------------------------------------------------------------------- /pics/锁表结构.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdu-database/rucbase-lab/HEAD/pics/锁表结构.png -------------------------------------------------------------------------------- /pics/B+树删除流程.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdu-database/rucbase-lab/HEAD/pics/B+树删除流程.png -------------------------------------------------------------------------------- /pics/B+树插入流程.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdu-database/rucbase-lab/HEAD/pics/B+树插入流程.png -------------------------------------------------------------------------------- /pics/B+树的结构.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdu-database/rucbase-lab/HEAD/pics/B+树的结构.png -------------------------------------------------------------------------------- /pics/执行模块流程图.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdu-database/rucbase-lab/HEAD/pics/执行模块流程图.jpg -------------------------------------------------------------------------------- /src/index/ix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ix_scan.h" 4 | #include "ix_manager.h" 5 | -------------------------------------------------------------------------------- /pics/存储层-类之间的关系.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdu-database/rucbase-lab/HEAD/pics/存储层-类之间的关系.png -------------------------------------------------------------------------------- /src/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SOURCES rwlatch.cpp) 2 | add_library(rwlatch STATIC ${SOURCES}) 3 | -------------------------------------------------------------------------------- /src/execution/execution_defs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "defs.h" 4 | #include "errors.h" 5 | -------------------------------------------------------------------------------- /deps/googletest/docs/assets/css/style.scss: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | 4 | @import "jekyll-theme-primer"; 5 | @import "main"; 6 | -------------------------------------------------------------------------------- /ownbase/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ownbase.h" 2 | 3 | int main(int argc, char *argv[]) { return ownbase_start(argc, argv); } -------------------------------------------------------------------------------- /pics/architecture_fixed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdu-database/rucbase-lab/HEAD/pics/architecture_fixed.jpg -------------------------------------------------------------------------------- /src/execution/execution.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "execution_defs.h" 4 | #include "execution_manager.h" 5 | -------------------------------------------------------------------------------- /src/record/rm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rm_scan.h" 4 | #include "rm_manager.h" 5 | #include "rm_defs.h" 6 | -------------------------------------------------------------------------------- /src/system/sm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "sm_manager.h" 4 | #include "sm_meta.h" 5 | #include "sm_defs.h" 6 | -------------------------------------------------------------------------------- /src/parser/ast.cpp: -------------------------------------------------------------------------------- 1 | #include "ast.h" 2 | 3 | namespace ast { 4 | 5 | std::shared_ptr parse_tree; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/parser/parser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ast_printer.h" 4 | #include "ast.h" 5 | #include "parser_defs.h" 6 | -------------------------------------------------------------------------------- /src/system/sm_defs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "defs.h" 4 | #include 5 | 6 | static const std::string DB_META_NAME = "db.meta"; 7 | -------------------------------------------------------------------------------- /src/execution/ExecutorTest_db_task2and3/grade: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdu-database/rucbase-lab/HEAD/src/execution/ExecutorTest_db_task2and3/grade -------------------------------------------------------------------------------- /src/execution/ExecutorTest_db_task2and3/student: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xdu-database/rucbase-lab/HEAD/src/execution/ExecutorTest_db_task2and3/student -------------------------------------------------------------------------------- /src/recovery/checkpoint.cpp: -------------------------------------------------------------------------------- 1 | #include "checkpoint.h" 2 | 3 | void CheckpointManager::BeginCheckpoint() {} 4 | 5 | void CheckpointManager::EndCheckpoint() {} -------------------------------------------------------------------------------- /deps/googletest/.clang-format: -------------------------------------------------------------------------------- 1 | # Run manually to reformat a file: 2 | # clang-format -i --style=file 3 | Language: Cpp 4 | BasedOnStyle: Google 5 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/docs/README.md: -------------------------------------------------------------------------------- 1 | # Content Moved 2 | 3 | We are working on updates to the GoogleTest documentation, which has moved to 4 | the top-level [docs](../../docs) directory. 5 | -------------------------------------------------------------------------------- /deps/googletest/googletest/docs/README.md: -------------------------------------------------------------------------------- 1 | # Content Moved 2 | 3 | We are working on updates to the GoogleTest documentation, which has moved to 4 | the top-level [docs](../../docs) directory. 5 | -------------------------------------------------------------------------------- /ownbase/lib/README.md: -------------------------------------------------------------------------------- 1 | ## ownbase 静态库目录 2 | 3 | > 这里存放各个模块的静态库,你可以用自己实现的库替换 4 | 5 | 6 | 7 | 8 | 9 | ```bash 10 | find ./lib/*.a -type f -print0 |xargs -0 md5sum>libmd5.txt 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /src/execution/input_task2.sql: -------------------------------------------------------------------------------- 1 | select * from student; 2 | select * from grade; 3 | select * from student where id>=2; 4 | select * from student, grade; 5 | select id, name, major, course from student, grade where student.id = grade.student_id; 6 | # -------------------------------------------------------------------------------- /src/recovery/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # revovery module 2 | set(SOURCES log_manager.cpp log_recovery.cpp checkpoint.cpp) 3 | add_library(recovery STATIC ${SOURCES}) 4 | add_library(recoverys SHARED ${SOURCES}) 5 | target_link_libraries(recovery system pthread) -------------------------------------------------------------------------------- /src/system/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SOURCES sm_manager.cpp) 2 | add_library(system STATIC ${SOURCES}) 3 | target_link_libraries(system index record) 4 | 5 | 6 | # sm_gtest 7 | add_executable(sm_gtest sm_gtest.cpp) 8 | target_link_libraries(sm_gtest system gtest_main) 9 | -------------------------------------------------------------------------------- /src/execution/input_task1.sql: -------------------------------------------------------------------------------- 1 | show tables; 2 | create table tb(s int, a int, b float, c char(16)); 3 | create table tb2(x int, y float, z char(16), s int); 4 | show tables; 5 | desc tb; 6 | drop table tb; 7 | show tables; 8 | drop table tb2; 9 | show tables; 10 | # -------------------------------------------------------------------------------- /src/parser/parser_defs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "defs.h" 4 | 5 | int yyparse(); 6 | 7 | typedef struct yy_buffer_state *YY_BUFFER_STATE; 8 | 9 | YY_BUFFER_STATE yy_scan_string(const char *str); 10 | 11 | void yy_delete_buffer(YY_BUFFER_STATE buffer); 12 | -------------------------------------------------------------------------------- /src/execution/ExecutorTest_db_task2and3/db.meta: -------------------------------------------------------------------------------- 1 | ExecutorTest_db 2 | 2 3 | grade 4 | 3 5 | grade course 2 32 0 0 6 | grade student_id 0 4 32 0 7 | grade score 1 4 36 0 8 | 9 | student 10 | 3 11 | student id 0 4 0 0 12 | student name 2 32 4 0 13 | student major 2 32 36 0 14 | 15 | -------------------------------------------------------------------------------- /ownbase/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(YourBase) 3 | 4 | link_directories(./lib) 5 | 6 | add_executable(yourbase main.cpp) 7 | target_link_libraries(yourbase ownbase parser execution system index record transaction recovery storage rwlatch readline pthread) 8 | -------------------------------------------------------------------------------- /src/recovery/log_defs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "defs.h" 4 | #include "storage/disk_manager.h" 5 | #include "common/config.h" 6 | 7 | #include 8 | #include 9 | 10 | static constexpr std::chrono::duration FLUSH_TIMEOUT = std::chrono::seconds(1); 11 | -------------------------------------------------------------------------------- /rucbase_client/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(rucbase_client) 3 | 4 | set(CMAKE_CXX_STANDARD 20) 5 | find_package(Threads REQUIRED) 6 | 7 | 8 | 9 | add_executable(${PROJECT_NAME} main.cpp) 10 | 11 | 12 | target_link_libraries(rucbase_client 13 | pthread readline 14 | ) -------------------------------------------------------------------------------- /src/execution/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SOURCES execution_manager.cpp) 2 | add_library(execution STATIC ${SOURCES}) 3 | 4 | target_link_libraries(execution system record system transaction) 5 | 6 | 7 | 8 | ## exec_sql 9 | add_executable(exec_sql exec_sql.cpp) 10 | target_link_libraries(exec_sql execution parser gtest_main) 11 | -------------------------------------------------------------------------------- /src/record/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # record module 2 | set(SOURCES rm_file_handle.cpp rm_scan.cpp) 3 | add_library(record STATIC ${SOURCES}) 4 | add_library(records SHARED ${SOURCES}) 5 | target_link_libraries(record storage system transaction) 6 | 7 | # rm_gtest 8 | add_executable(rm_gtest rm_gtest.cpp) 9 | target_link_libraries(rm_gtest record gtest_main) -------------------------------------------------------------------------------- /deps/googletest/googletest/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | if (@GTEST_HAS_PTHREAD@) 4 | set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@) 5 | find_dependency(Threads) 6 | endif() 7 | 8 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 9 | check_required_components("@project_name@") 10 | -------------------------------------------------------------------------------- /ownbase/README.md: -------------------------------------------------------------------------------- 1 | ## OwnBase 2 | OwnBase是rucbase项目中参与者构建自己的db程序的子项目。 3 | 4 | ### 使用方法 5 | 1. 完成对应lab,通过编译和测试 6 | 2. 在rucbase主目录`/build/lib`下找到自己实现的模块的对应`.lib`文件,替换`/ownbase/lib`下对应文件 7 | 3. 8 | ```bash 9 | cd ownbase 10 | mkdir build 11 | cd build 12 | cmake .. 13 | make 14 | ``` 15 | 4. 你将获得对应模块功能由自己实现的`yourbase`可执行文件,可以用`rucbase_client`进行连接测试 -------------------------------------------------------------------------------- /deps/googletest/googletest/cmake/gtest.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest 5 | Description: GoogleTest (without main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@ 9 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 10 | -------------------------------------------------------------------------------- /src/record/rm_scan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rm_defs.h" 4 | 5 | class RmFileHandle; 6 | 7 | class RmScan : public RecScan { 8 | const RmFileHandle *file_handle_; 9 | Rid rid_; 10 | public: 11 | RmScan(const RmFileHandle *file_handle); 12 | 13 | void next() override; 14 | 15 | bool is_end() const override; 16 | 17 | Rid rid() const override; 18 | }; 19 | -------------------------------------------------------------------------------- /src/execution/input_task3.sql: -------------------------------------------------------------------------------- 1 | select * from student; 2 | update student set major = 'Electrical Engineering' where id = 2; 3 | select * from student; 4 | delete from student where name = 'Jack'; 5 | select * from student; 6 | update student set major = 'Computer Science' where id = 2; 7 | select * from student; 8 | insert into student values (3, 'Jack', 'Electrical Engineering'); 9 | select * from student; 10 | -------------------------------------------------------------------------------- /deps/googletest/docs/community_created_documentation.md: -------------------------------------------------------------------------------- 1 | # Community-Created Documentation 2 | 3 | The following is a list, in no particular order, of links to documentation 4 | created by the Googletest community. 5 | 6 | * [Googlemock Insights](https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles/blob/master/googletest/insights.md), 7 | by [ElectricRCAircraftGuy](https://github.com/ElectricRCAircraftGuy) 8 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h: -------------------------------------------------------------------------------- 1 | // IWYU pragma: private, include "gmock/gmock.h" 2 | // IWYU pragma: friend gmock/.* 3 | 4 | #ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 5 | #define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 6 | 7 | #endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 8 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/cmake/gmock.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gmock 5 | Description: GoogleMock (without main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gtest = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgmock @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(RucBase) 3 | 4 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 5 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) 6 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 7 | 8 | set(CMAKE_CXX_STANDARD 17) 9 | set(CMAKE_CXX_FLAGS "-Wall") 10 | 11 | 12 | 13 | enable_testing() 14 | add_subdirectory(src) 15 | add_subdirectory(deps) 16 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/cmake/gmock_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gmock_main 5 | Description: GoogleMock (with main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gmock = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgmock_main @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /deps/googletest/googletest/cmake/gtest_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest_main 5 | Description: GoogleTest (with main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gtest = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /src/parser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # parser module 2 | find_package(BISON REQUIRED) 3 | find_package(FLEX REQUIRED) 4 | 5 | bison_target(yacc yacc.y ${CMAKE_CURRENT_SOURCE_DIR}/yacc.tab.cpp 6 | DEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/yacc.tab.h) 7 | flex_target(lex lex.l ${CMAKE_CURRENT_SOURCE_DIR}/lex.yy.cpp) 8 | add_flex_bison_dependency(lex yacc) 9 | 10 | set(SOURCES ${BISON_yacc_OUTPUT_SOURCE} ${FLEX_lex_OUTPUTS} ast.cpp) 11 | add_library(parser STATIC ${SOURCES}) 12 | 13 | -------------------------------------------------------------------------------- /src/replacer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # replacer module 2 | set(SOURCES lru_replacer.cpp clock_replacer.cpp) 3 | add_library(lru_replacer STATIC ${SOURCES}) 4 | add_library(clock_replacer STATIC ${SOURCES}) 5 | 6 | add_executable(lru_replacer_test lru_replacer_test.cpp) 7 | target_link_libraries(lru_replacer_test lru_replacer gtest_main) # add gtest 8 | 9 | 10 | 11 | add_executable(clock_replacer_test clock_replacer_test.cpp) 12 | target_link_libraries(clock_replacer_test clock_replacer gtest_main) # add gtest 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/execution/task1_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -r ExecutorTest_db 3 | rm output.txt 4 | cat input_task1.sql | while read line 5 | do 6 | if [ ${#line} -eq 0 ] || [ ${line:0:1} == "#" ] 7 | then 8 | echo "$line" 9 | continue 10 | fi 11 | echo ">> $line" 12 | ../../build/bin/exec_sql "$line" 13 | echo "------------------------------" 14 | done | tee -a output.txt 15 | echo "check different" 16 | diff res_task1_output.txt output.txt 17 | if [ $? != 0 ] 18 | then 19 | echo "Pass Failed!" 20 | else 21 | echo "Pass Success!" 22 | fi -------------------------------------------------------------------------------- /src/execution/taskall_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -r ExecutorTest_db 3 | rm output.txt 4 | cat input_all_task.sql | while read line 5 | do 6 | if [ ${#line} -eq 0 ] || [ ${line:0:1} == "#" ] 7 | then 8 | echo "$line" 9 | continue 10 | fi 11 | echo ">> $line" 12 | ../../build/bin/exec_sql "$line" 13 | echo "------------------------------" 14 | done | tee -a output.txt 15 | echo "check different" 16 | diff res_taskall_output.txt output.txt 17 | if [ $? != 0 ] 18 | then 19 | echo "Pass Failed!" 20 | else 21 | echo "Pass Success!" 22 | fi 23 | rm -r ExecutorTest_db -------------------------------------------------------------------------------- /deps/googletest/googletest/cmake/libgtest.la.in: -------------------------------------------------------------------------------- 1 | # libgtest.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Names of this library. 8 | library_names='libgtest.so' 9 | 10 | # Is this an already installed library? 11 | installed=yes 12 | 13 | # Should we warn about portability when linking against -modules? 14 | shouldnotlink=no 15 | 16 | # Files to dlopen/dlpreopen 17 | dlopen='' 18 | dlpreopen='' 19 | 20 | # Directory that this library needs to be installed in: 21 | libdir='@CMAKE_INSTALL_FULL_LIBDIR@' 22 | -------------------------------------------------------------------------------- /src/execution/task2_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -r ExecutorTest_db 3 | rm output.txt 4 | cp -r ExecutorTest_db_task2and3 ExecutorTest_db 5 | cat input_task2.sql | while read line 6 | do 7 | if [ ${#line} -eq 0 ] || [ ${line:0:1} == "#" ] 8 | then 9 | echo "$line" 10 | continue 11 | fi 12 | echo ">> $line" 13 | ../../build/bin/exec_sql "$line" 14 | echo "------------------------------" 15 | done | tee -a output.txt 16 | echo "check different" 17 | diff res_task2_output.txt output.txt 18 | if [ $? != 0 ] 19 | then 20 | echo "Pass Failed!" 21 | else 22 | echo "Pass Success!" 23 | fi -------------------------------------------------------------------------------- /src/execution/task3_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -r ExecutorTest_db 3 | rm output.txt 4 | cp -r ExecutorTest_db_task2and3 ExecutorTest_db 5 | cat input_task3.sql | while read line 6 | do 7 | if [ ${#line} -eq 0 ] || [ ${line:0:1} == "#" ] 8 | then 9 | echo "$line" 10 | continue 11 | fi 12 | echo ">> $line" 13 | ../../build/bin/exec_sql "$line" 14 | echo "------------------------------" 15 | done | tee -a output.txt 16 | echo "check different" 17 | diff res_task3_output.txt output.txt 18 | if [ $? != 0 ] 19 | then 20 | echo "Pass Failed!" 21 | else 22 | echo "Pass Success!" 23 | fi -------------------------------------------------------------------------------- /deps/googletest/googlemock/include/gmock/internal/custom/README.md: -------------------------------------------------------------------------------- 1 | # Customization Points 2 | 3 | The custom directory is an injection point for custom user configurations. 4 | 5 | ## Header `gmock-port.h` 6 | 7 | The following macros can be defined: 8 | 9 | ### Flag related macros: 10 | 11 | * `GMOCK_DECLARE_bool_(name)` 12 | * `GMOCK_DECLARE_int32_(name)` 13 | * `GMOCK_DECLARE_string_(name)` 14 | * `GMOCK_DEFINE_bool_(name, default_val, doc)` 15 | * `GMOCK_DEFINE_int32_(name, default_val, doc)` 16 | * `GMOCK_DEFINE_string_(name, default_val, doc)` 17 | * `GMOCK_FLAG_GET(flag_name)` 18 | * `GMOCK_FLAG_SET(flag_name, value)` 19 | -------------------------------------------------------------------------------- /src/index/ix_scan.cpp: -------------------------------------------------------------------------------- 1 | #include "ix_scan.h" 2 | 3 | /** 4 | * @brief 找到leaf page的下一个slot_no 5 | */ 6 | void IxScan::next() { 7 | assert(!is_end()); 8 | IxNodeHandle *node = ih_->FetchNode(iid_.page_no); 9 | assert(node->IsLeafPage()); 10 | assert(iid_.slot_no < node->GetSize()); 11 | // increment slot no 12 | iid_.slot_no++; 13 | if (iid_.page_no != ih_->file_hdr_.last_leaf && iid_.slot_no == node->GetSize()) { 14 | // go to next leaf 15 | iid_.slot_no = 0; 16 | iid_.page_no = node->GetNextLeaf(); 17 | } 18 | } 19 | 20 | Rid IxScan::rid() const { 21 | return ih_->get_rid(iid_); 22 | } 23 | -------------------------------------------------------------------------------- /src/common/context.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "transaction/concurrency/lock_manager.h" 4 | #include "recovery/log_manager.h" 5 | 6 | // used for data_send 7 | static int const_offset = -1; 8 | 9 | class Context { 10 | public: 11 | Context (LockManager *lock_mgr, LogManager *log_mgr, 12 | Transaction *txn, char *data_send = nullptr, int *offset = &const_offset) 13 | : lock_mgr_(lock_mgr), log_mgr_(log_mgr), txn_(txn), 14 | data_send_(data_send), offset_(offset) {} 15 | 16 | LockManager *lock_mgr_; 17 | LogManager *log_mgr_; 18 | Transaction *txn_; 19 | char *data_send_; 20 | int *offset_; 21 | }; -------------------------------------------------------------------------------- /src/transaction/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SOURCES concurrency/lock_manager.cpp transaction_manager.cpp) 2 | add_library(transaction STATIC ${SOURCES}) 3 | target_link_libraries(transaction system recovery pthread) 4 | 5 | add_executable(txn_manager_test txn_manager_test.cpp) 6 | target_link_libraries(txn_manager_test transaction execution parser gtest_main) 7 | 8 | add_executable(lock_manager_test lock_manager_test.cpp) 9 | target_link_libraries(lock_manager_test transaction execution gtest_main) 10 | 11 | # concurrency_test 12 | add_executable(concurrency_test concurrency_test.cpp) 13 | target_link_libraries(concurrency_test transaction execution parser gtest_main) -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 2 | 3 | add_subdirectory(record) 4 | add_subdirectory(index) 5 | add_subdirectory(system) 6 | add_subdirectory(execution) 7 | add_subdirectory(parser) 8 | add_subdirectory(storage) 9 | add_subdirectory(common) 10 | add_subdirectory(replacer) 11 | add_subdirectory(transaction) 12 | add_subdirectory(recovery) 13 | 14 | # 后续lab开放 15 | # add_executable(rawcli rawcli.cpp) 16 | # target_link_libraries(rawcli parser execution pthread) 17 | 18 | # add_executable(rucbase rucbase.cpp) 19 | # target_link_libraries(rucbase parser execution readline pthread) 20 | 21 | # add_library(ownbase STATIC ownbase.cpp) -------------------------------------------------------------------------------- /src/recovery/log_recovery.cpp: -------------------------------------------------------------------------------- 1 | #include "log_recovery.h" 2 | #include "record/rm.h" 3 | #include "system/sm_manager.h" 4 | 5 | /** 6 | * 重做未刷入磁盘的写操作 7 | * 只需要考虑DML操作,暂时不需要考虑DDL操作 8 | */ 9 | void LogRecovery::Redo() { 10 | // Todo: 11 | // 1. 从磁盘的日志文件中顺序读取日志记录 12 | // 2. 根据日志对应操作的类型,执行相应的操作 13 | // 2.1 如果是事务相关操作,则需要维护事务活动列表active_txns_ 14 | // 2.2 如果是写操作,需要比较该日志的日志序列号和对应数据页的page_lsn_,判断是否要执行写操作 15 | 16 | } 17 | 18 | /** 19 | * 撤销未完成事务的写操作 20 | * 只需要考虑DML操作,暂时不需要考虑DDL操作 21 | */ 22 | void LogRecovery::Undo() { 23 | // Todo: 24 | // 1. 遍历事务活动列表active_txns_获取所有未完成事务 25 | // 2. 根据日志中的prev_lsn_信息遍历该事务已经执行的所有写操作 26 | // 3. 撤销该事务的所有写操作 27 | 28 | } -------------------------------------------------------------------------------- /src/recovery/checkpoint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "transaction/transaction_manager.h" 4 | 5 | class CheckpointManager { 6 | public: 7 | CheckpointManager(TransactionManager * txn_manager, LogManager *log_manager, 8 | BufferPoolManager *buffer_pool_manager) 9 | : txn_manager_(txn_manager), log_manager_(log_manager), 10 | buffer_pool_manager_(buffer_pool_manager){} 11 | 12 | ~CheckpointManager() = default; 13 | 14 | void BeginCheckpoint(); 15 | void EndCheckpoint(); 16 | 17 | private: 18 | TransactionManager *txn_manager_; 19 | LogManager *log_manager_; 20 | BufferPoolManager *buffer_pool_manager_; 21 | }; -------------------------------------------------------------------------------- /src/storage/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # storage module 2 | set(SOURCES 3 | disk_manager.cpp 4 | buffer_pool_manager.cpp 5 | ../replacer/replacer.h 6 | ../replacer/lru_replacer.cpp 7 | ../replacer/clock_replacer.cpp 8 | ) 9 | add_library(storage STATIC ${SOURCES}) 10 | 11 | # disk_manager_test 12 | add_library(disk STATIC disk_manager.cpp) 13 | add_executable(disk_manager_test disk_manager_test.cpp) 14 | target_link_libraries(disk_manager_test disk gtest_main) # add gtest 15 | 16 | # buffer_pool_manager_test 17 | add_executable(buffer_pool_manager_test buffer_pool_manager_test.cpp) 18 | target_link_libraries(buffer_pool_manager_test storage gtest_main) # add gtest 19 | -------------------------------------------------------------------------------- /src/index/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(SOURCES ix_node_handle.cpp ix_index_handle.cpp ix_scan.cpp ../common/rwlatch.cpp) 2 | add_library(index STATIC ${SOURCES}) 3 | target_link_libraries(index storage) 4 | 5 | # insert test 6 | add_executable(b_plus_tree_insert_test b_plus_tree_insert_test.cpp) 7 | target_link_libraries(b_plus_tree_insert_test index gtest_main) 8 | 9 | # delete test 10 | add_executable(b_plus_tree_delete_test b_plus_tree_delete_test.cpp) 11 | target_link_libraries(b_plus_tree_delete_test index gtest_main) 12 | 13 | # concurrent insert and delete test 14 | add_executable(b_plus_tree_concurrent_test b_plus_tree_concurrent_test.cpp) 15 | target_link_libraries(b_plus_tree_concurrent_test index gtest_main) -------------------------------------------------------------------------------- /deps/googletest/.github/ISSUE_TEMPLATE/10-feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Propose a new feature 4 | title: '' 5 | labels: 'enhancement' 6 | assignees: '' 7 | --- 8 | 9 | **Does the feature exist in the most recent commit?** 10 | 11 | We recommend using the latest commit from GitHub in your projects. 12 | 13 | **Why do we need this feature?** 14 | 15 | Ideally, explain why a combination of existing features cannot be used instead. 16 | 17 | **Describe the proposal** 18 | 19 | Include a detailed description of the feature, with usage examples. 20 | 21 | **Is the feature specific to an operating system, compiler, or build system version?** 22 | 23 | If it is, please specify which versions. 24 | 25 | -------------------------------------------------------------------------------- /src/index/ix_scan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ix_defs.h" 4 | #include "ix_index_handle.h" 5 | 6 | /** 7 | * @brief 用于直接遍历叶子结点,而不用FindLeafPage()来得到叶子结点 8 | */ 9 | class IxScan : public RecScan { 10 | const IxIndexHandle *ih_; 11 | Iid iid_; // 初始为lower(用于遍历的指针) 12 | Iid end_; // 初始为upper 13 | BufferPoolManager *bpm_; 14 | 15 | public: 16 | IxScan(const IxIndexHandle *ih, const Iid &lower, const Iid &upper, BufferPoolManager *bpm) 17 | : ih_(ih), iid_(lower), end_(upper), bpm_(bpm) {} 18 | 19 | void next() override; 20 | 21 | bool is_end() const override { return iid_ == end_; } 22 | 23 | Rid rid() const override; 24 | 25 | const Iid &iid() const { return iid_; } 26 | }; 27 | -------------------------------------------------------------------------------- /src/record/rm_scan.cpp: -------------------------------------------------------------------------------- 1 | #include "rm_scan.h" 2 | 3 | #include "rm_file_handle.h" 4 | 5 | /** 6 | * @brief 初始化file_handle和rid 7 | * 8 | * @param file_handle 9 | */ 10 | RmScan::RmScan(const RmFileHandle *file_handle) : file_handle_(file_handle) { 11 | // Todo: 12 | // 初始化file_handle和rid(指向第一个存放了记录的位置) 13 | 14 | } 15 | 16 | /** 17 | * @brief 找到文件中下一个存放了记录的位置 18 | */ 19 | void RmScan::next() { 20 | // Todo: 21 | // 找到文件中下一个存放了记录的非空闲位置,用rid_来指向这个位置 22 | 23 | } 24 | 25 | /** 26 | * @brief ​ 判断是否到达文件末尾 27 | */ 28 | bool RmScan::is_end() const { 29 | // Todo: 修改返回值 30 | return false; 31 | } 32 | 33 | /** 34 | * @brief RmScan内部存放的rid 35 | */ 36 | Rid RmScan::rid() const { 37 | // Todo: 修改返回值 38 | return Rid{-1, -1}; 39 | } -------------------------------------------------------------------------------- /src/execution/README.md: -------------------------------------------------------------------------------- 1 | ## lab3测试说明 2 | 3 | 在lab3中,系统目前不使用`GoogleTest`框架进行测试,而是采用`Linux Bash`脚本对你完成的各个任务进行`SQL`语句执行并比对正确的结果,你能够在脚本执行完成时看到通过测试与否的提示,如果未能通过,系统会使用`diff`将你的输出和正确输出进行比对方便你定位执行错误的地方。 4 | 5 | - `output.txt` : 你的执行输出文件 6 | - `res_output.txt`:正确的执行输出文件 7 | - `input_*.sql`:各个任务点执行的SQL语句 8 | - `task_test.sh`:测试脚本 9 | 10 | 测试脚本依赖二进制程序`exec_sql`,你可以按照下列语句进行编译: 11 | 12 | ```bash 13 | cd rucbase; 14 | cd build 15 | cmake .. 16 | make exec_sql 17 | ``` 18 | 19 | 得到的`exec_sql`程序在`rucbase/build/bin/`目录下,请不要移动该程序。 20 | 21 | 22 | ### 其他事项 23 | 24 | 如果你无法执行`.sh`脚本,请执行以下命令,以`task1`为例: 25 | 26 | ```bash 27 | chmod +x task1_test.sh 28 | ./task1_test.sh 29 | ``` 30 | 31 | 注意:**不能**使用`sh task1_test.sh`运行脚本。 32 | 33 | 34 | 在不影响主要比对逻辑的情况下,你可以自行根据需求修改测试脚本。 35 | 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 《数据库原理》课程代码作业 2 | 3 | ## 实验环境: 4 | - 操作系统:Ubuntu 18.04 及以上(64位) 5 | - 编译器:GCC 6 | - 编程语言:C++17 7 | - 管理工具:cmake 8 | - 推荐编辑器:VScode 9 | 10 | ### 依赖环境库配置: 11 | - gcc 7.1及以上版本(要求完全支持C++17) 12 | - cmake 3.16及以上版本 13 | - flex 14 | - bison 15 | - readline 16 | 17 | 欲查看有关依赖运行库和编译工具的更多信息,以及如何运行的说明,请查阅[Rucbase使用文档](docs/Rucbase使用文档.md) 18 | 19 | 欲了解如何在非Linux系统PC上部署实验环境的指导,请查阅[Rucbase环境配置文档](docs/Rucbase环境配置文档.md) 20 | 21 | ## 实验文档索引 22 | 23 | > 这里给出目前公开的文档分类索引 24 | 25 | ### 项目说明文档 26 | 27 | - [Rucbase环境配置文档](docs/Rucbase环境配置文档.md) 28 | - [Rucbase使用文档](docs/Rucbase使用文档.md) 29 | - [Rucbase项目结构](docs/Rucbase项目结构.md) 30 | 31 | ### 学生实验文档 32 | 33 | - [Rucbase-Lab1实验文档](docs/Rucbase-Lab1[实验文档].md)(只需完成任务一存储管理) 34 | - [Rucbase学生实验操作说明示例](docs/Rucbase学生实验操作说明示例.md) 35 | 36 | ### 实验任务时间安排 37 | 38 | | **任务** |**截止时间** | 39 | | ------------ | ----------------- | 40 | | 存储管理 | 7.2 | 41 | 42 | ### 作业提交方式 43 | 在西电智课平台相应位置上传附件,包括完成每个任务后的代码文件及作业报告,打包成压缩包。压缩包命名方式为学号-姓名。报告格式不限,内容包含代码思路及通过测试截图。 44 | -------------------------------------------------------------------------------- /deps/googletest/.github/workflows/gtest-ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: 4 | push: 5 | pull_request: 6 | 7 | env: 8 | BAZEL_CXXOPTS: -std=c++14 9 | 10 | jobs: 11 | Linux: 12 | runs-on: ubuntu-latest 13 | steps: 14 | 15 | - uses: actions/checkout@v2 16 | with: 17 | fetch-depth: 0 18 | 19 | - name: Tests 20 | run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... 21 | 22 | MacOs: 23 | runs-on: macos-latest 24 | steps: 25 | 26 | - uses: actions/checkout@v2 27 | with: 28 | fetch-depth: 0 29 | 30 | - name: Tests 31 | run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... 32 | 33 | 34 | Windows: 35 | runs-on: windows-latest 36 | steps: 37 | 38 | - uses: actions/checkout@v2 39 | with: 40 | fetch-depth: 0 41 | 42 | - name: Tests 43 | run: bazel test --cxxopt=/std:c++14 --features=external_include_paths --test_output=errors ... 44 | -------------------------------------------------------------------------------- /deps/googletest/docs/platforms.md: -------------------------------------------------------------------------------- 1 | # Supported Platforms 2 | 3 | GoogleTest requires a codebase and compiler compliant with the C++11 standard or 4 | newer. 5 | 6 | The GoogleTest code is officially supported on the following platforms. 7 | Operating systems or tools not listed below are community-supported. For 8 | community-supported platforms, patches that do not complicate the code may be 9 | considered. 10 | 11 | If you notice any problems on your platform, please file an issue on the 12 | [GoogleTest GitHub Issue Tracker](https://github.com/google/googletest/issues). 13 | Pull requests containing fixes are welcome! 14 | 15 | ### Operating systems 16 | 17 | * Linux 18 | * macOS 19 | * Windows 20 | 21 | ### Compilers 22 | 23 | * gcc 5.0+ 24 | * clang 5.0+ 25 | * MSVC 2015+ 26 | 27 | **macOS users:** Xcode 9.3+ provides clang 5.0+. 28 | 29 | ### Build systems 30 | 31 | * [Bazel](https://bazel.build/) 32 | * [CMake](https://cmake.org/) 33 | 34 | Bazel is the build system used by the team internally and in tests. CMake is 35 | supported on a best-effort basis and by the community. 36 | -------------------------------------------------------------------------------- /deps/googletest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Note: CMake support is community-based. The maintainers do not use CMake 2 | # internally. 3 | 4 | cmake_minimum_required(VERSION 3.5) 5 | 6 | if (POLICY CMP0048) 7 | cmake_policy(SET CMP0048 NEW) 8 | endif (POLICY CMP0048) 9 | 10 | if (POLICY CMP0069) 11 | cmake_policy(SET CMP0069 NEW) 12 | endif (POLICY CMP0069) 13 | 14 | if (POLICY CMP0077) 15 | cmake_policy(SET CMP0077 NEW) 16 | endif (POLICY CMP0077) 17 | 18 | project(googletest-distribution) 19 | set(GOOGLETEST_VERSION 1.12.1) 20 | 21 | if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) 22 | set(CMAKE_CXX_EXTENSIONS OFF) 23 | endif() 24 | 25 | enable_testing() 26 | 27 | include(CMakeDependentOption) 28 | include(GNUInstallDirs) 29 | 30 | #Note that googlemock target already builds googletest 31 | option(BUILD_GMOCK "Builds the googlemock subproject" ON) 32 | option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON) 33 | 34 | if(BUILD_GMOCK) 35 | add_subdirectory( googlemock ) 36 | else() 37 | add_subdirectory( googletest ) 38 | endif() 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 ruc-deke 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /deps/googletest/docs/index.md: -------------------------------------------------------------------------------- 1 | # GoogleTest User's Guide 2 | 3 | ## Welcome to GoogleTest! 4 | 5 | GoogleTest is Google's C++ testing and mocking framework. This user's guide has 6 | the following contents: 7 | 8 | * [GoogleTest Primer](primer.md) - Teaches you how to write simple tests using 9 | GoogleTest. Read this first if you are new to GoogleTest. 10 | * [GoogleTest Advanced](advanced.md) - Read this when you've finished the 11 | Primer and want to utilize GoogleTest to its full potential. 12 | * [GoogleTest Samples](samples.md) - Describes some GoogleTest samples. 13 | * [GoogleTest FAQ](faq.md) - Have a question? Want some tips? Check here 14 | first. 15 | * [Mocking for Dummies](gmock_for_dummies.md) - Teaches you how to create mock 16 | objects and use them in tests. 17 | * [Mocking Cookbook](gmock_cook_book.md) - Includes tips and approaches to 18 | common mocking use cases. 19 | * [Mocking Cheat Sheet](gmock_cheat_sheet.md) - A handy reference for 20 | matchers, actions, invariants, and more. 21 | * [Mocking FAQ](gmock_faq.md) - Contains answers to some mocking-specific 22 | questions. 23 | -------------------------------------------------------------------------------- /src/common/macros.h: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // BusTub 4 | // 5 | // macros.h 6 | // 7 | // Identification: src/include/common/macros.h 8 | // 9 | // Copyright (c) 2015-2019, Carnegie Mellon University Database Group 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #pragma once 14 | 15 | #include 16 | #include 17 | 18 | #define BUSTUB_ASSERT(expr, message) assert((expr) && (message)) 19 | 20 | #define UNREACHABLE(message) throw std::logic_error(message) 21 | 22 | // Macros to disable copying and moving 23 | #define DISALLOW_COPY(cname) \ 24 | cname(const cname &) = delete; /* NOLINT */ \ 25 | cname &operator=(const cname &) = delete; /* NOLINT */ 26 | 27 | #define DISALLOW_MOVE(cname) \ 28 | cname(cname &&) = delete; /* NOLINT */ \ 29 | cname &operator=(cname &&) = delete; /* NOLINT */ 30 | 31 | #define DISALLOW_COPY_AND_MOVE(cname) \ 32 | DISALLOW_COPY(cname); \ 33 | DISALLOW_MOVE(cname); 34 | 35 | -------------------------------------------------------------------------------- /deps/googletest/docs/samples.md: -------------------------------------------------------------------------------- 1 | # Googletest Samples 2 | 3 | If you're like us, you'd like to look at 4 | [googletest samples.](https://github.com/google/googletest/blob/main/googletest/samples) 5 | The sample directory has a number of well-commented samples showing how to use a 6 | variety of googletest features. 7 | 8 | * Sample #1 shows the basic steps of using googletest to test C++ functions. 9 | * Sample #2 shows a more complex unit test for a class with multiple member 10 | functions. 11 | * Sample #3 uses a test fixture. 12 | * Sample #4 teaches you how to use googletest and `googletest.h` together to 13 | get the best of both libraries. 14 | * Sample #5 puts shared testing logic in a base test fixture, and reuses it in 15 | derived fixtures. 16 | * Sample #6 demonstrates type-parameterized tests. 17 | * Sample #7 teaches the basics of value-parameterized tests. 18 | * Sample #8 shows using `Combine()` in value-parameterized tests. 19 | * Sample #9 shows use of the listener API to modify Google Test's console 20 | output and the use of its reflection API to inspect test results. 21 | * Sample #10 shows use of the listener API to implement a primitive memory 22 | leak checker. 23 | -------------------------------------------------------------------------------- /src/common/rwlatch.cpp: -------------------------------------------------------------------------------- 1 | #include "rwlatch.h" 2 | 3 | /** 4 | * Acquire a write latch. 5 | */ 6 | void ReaderWriterLatch::WLock() { 7 | std::unique_lock latch(mutex_); 8 | while (writer_entered_) { 9 | reader_.wait(latch); 10 | } 11 | writer_entered_ = true; 12 | while (reader_count_ > 0) { 13 | writer_.wait(latch); 14 | } 15 | } 16 | 17 | /** 18 | * Release a write latch. 19 | */ 20 | void ReaderWriterLatch::WUnlock() { 21 | std::lock_guard guard(mutex_); 22 | writer_entered_ = false; 23 | reader_.notify_all(); 24 | } 25 | 26 | /** 27 | * Acquire a read latch. 28 | */ 29 | void ReaderWriterLatch::RLock() { 30 | std::unique_lock latch(mutex_); 31 | while (writer_entered_ || reader_count_ == MAX_READERS) { 32 | reader_.wait(latch); 33 | } 34 | reader_count_++; 35 | } 36 | 37 | /** 38 | * Release a read latch. 39 | */ 40 | void ReaderWriterLatch::RUnlock() { 41 | std::lock_guard guard(mutex_); 42 | reader_count_--; 43 | if (writer_entered_) { 44 | if (reader_count_ == 0) { 45 | writer_.notify_one(); 46 | } 47 | } else { 48 | if (reader_count_ == MAX_READERS - 1) { 49 | reader_.notify_one(); 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/execution/input_all_task.sql: -------------------------------------------------------------------------------- 1 | create table student (id int, name char(32), major char(32)); 2 | create index student (id); 3 | create table grade (course char(32), student_id int, score float); 4 | create index grade (student_id); 5 | show tables; 6 | desc student; 7 | insert into student values (1, 'Tom', 'Computer Science'); 8 | insert into student values (2, 'Jerry', 'Computer Science'); 9 | insert into student values (3, 'Jack', 'Electrical Engineering'); 10 | select * from student where id>=1; 11 | update student set major = 'Electrical Engineering' where id = 2; 12 | select * from student where id>=1; 13 | delete from student where name = 'Jack'; 14 | select * from student where id>=1; 15 | insert into grade values ('Data Structure', 1, 90.0); 16 | insert into grade values ('Data Structure', 2, 95.0); 17 | insert into grade values ('Calculus', 2, 82.0); 18 | insert into grade values ('Calculus', 1, 88.5); 19 | select * from student, grade; 20 | select id, name, major, course, score from student, grade where student.id = grade.student_id; 21 | select id, name, major, course, score from student join grade where student.id = grade.student_id; 22 | drop index student (id); 23 | desc student; 24 | drop table student; 25 | drop table grade; 26 | show tables; 27 | # -------------------------------------------------------------------------------- /src/execution/executor_insert.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "execution_defs.h" 3 | #include "execution_manager.h" 4 | #include "executor_abstract.h" 5 | #include "index/ix.h" 6 | #include "system/sm.h" 7 | 8 | class InsertExecutor : public AbstractExecutor { 9 | private: 10 | TabMeta tab_; 11 | std::vector values_; 12 | RmFileHandle *fh_; 13 | std::string tab_name_; 14 | Rid rid_; 15 | SmManager *sm_manager_; 16 | 17 | public: 18 | InsertExecutor(SmManager *sm_manager, const std::string &tab_name, std::vector values, Context *context) { 19 | sm_manager_ = sm_manager; 20 | tab_ = sm_manager_->db_.get_table(tab_name); 21 | values_ = values; 22 | tab_name_ = tab_name; 23 | if (values.size() != tab_.cols.size()) { 24 | throw InvalidValueCountError(); 25 | } 26 | // Get record file handle 27 | fh_ = sm_manager_->fhs_.at(tab_name).get(); 28 | context_ = context; 29 | }; 30 | 31 | std::unique_ptr Next() override { 32 | // 查询执行 task3 Todo 33 | // Make record buffer 34 | // Insert into record file 35 | // Insert into index 36 | // 查询执行 task3 Todo end 37 | return nullptr; 38 | } 39 | Rid &rid() override { return rid_; } 40 | }; -------------------------------------------------------------------------------- /src/recovery/log_recovery.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "log_record.h" 4 | #include "system/sm_manager.h" 5 | 6 | class LogRecovery { 7 | public: 8 | LogRecovery(SmManager *sm_manager, DiskManager *disk_manager) { 9 | log_buffer_ = new char[LOG_BUFFER_SIZE]; 10 | log_offset_ = 0; 11 | active_txns_ = std::unordered_map(); 12 | lsn_mapping_ = std::unordered_map(); 13 | sm_manager_ = sm_manager; 14 | disk_manager_ = disk_manager; 15 | } 16 | 17 | ~LogRecovery() { 18 | delete[] log_buffer_; 19 | sm_manager_ = nullptr; 20 | disk_manager_ = nullptr; 21 | } 22 | 23 | void Redo(); 24 | void Undo(); 25 | inline bool GetRecoveryMode() { return recovery_mode_; } 26 | 27 | bool DeserializeLogRecord(const char* data, LogRecord &log_record); 28 | 29 | private: 30 | // store the running transactions, the mapping of running transactions to their lastest log records 31 | std::unordered_map active_txns_; // 活动事务列表,记录当前系统运行过程中所有正在执行的事务 32 | std::unordered_map lsn_mapping_; 33 | char *log_buffer_; // 从磁盘中读取的日志记录 34 | int log_offset_; // log_buffer_的偏移量 35 | SmManager *sm_manager_; 36 | DiskManager *disk_manager_; 37 | bool recovery_mode_ = false; // 用于标识在系统开启时是否进行系统故障恢复 38 | }; -------------------------------------------------------------------------------- /src/replacer/clock_replacer.cpp: -------------------------------------------------------------------------------- 1 | #include "replacer/clock_replacer.h" 2 | 3 | #include 4 | 5 | ClockReplacer::ClockReplacer(size_t num_pages) 6 | : circular_{num_pages, ClockReplacer::Status::EMPTY_OR_PINNED}, hand_{0}, capacity_{num_pages} { 7 | // 成员初始化列表语法 8 | circular_.reserve(num_pages); 9 | } 10 | 11 | ClockReplacer::~ClockReplacer() = default; 12 | 13 | bool ClockReplacer::Victim(frame_id_t *frame_id) { 14 | const std::lock_guard guard(mutex_); 15 | // Todo: try to find a victim frame in buffer pool with clock scheme 16 | // and make the *frame_id = victim_frame_id 17 | // not found, frame_id=nullptr and return false 18 | 19 | return false; 20 | } 21 | 22 | void ClockReplacer::Pin(frame_id_t frame_id) { 23 | const std::lock_guard guard(mutex_); 24 | // Todo: you can implement it! 25 | } 26 | 27 | void ClockReplacer::Unpin(frame_id_t frame_id) { 28 | const std::lock_guard guard(mutex_); 29 | // Todo: you can implement it! 30 | } 31 | 32 | size_t ClockReplacer::Size() { 33 | // Todo: 34 | // 返回在[arg0, arg1)范围内满足特定条件(arg2)的元素的数目 35 | // return all items that in the range[circular_.begin, circular_.end ) 36 | // and be met the condition: status!=EMPTY_OR_PINNED 37 | // That is the number of frames in the buffer pool that storage page (NOT EMPTY_OR_PINNED) 38 | return -1; 39 | } 40 | -------------------------------------------------------------------------------- /deps/googletest/docs/_data/navigation.yml: -------------------------------------------------------------------------------- 1 | nav: 2 | - section: "Get Started" 3 | items: 4 | - title: "Supported Platforms" 5 | url: "/platforms.html" 6 | - title: "Quickstart: Bazel" 7 | url: "/quickstart-bazel.html" 8 | - title: "Quickstart: CMake" 9 | url: "/quickstart-cmake.html" 10 | - section: "Guides" 11 | items: 12 | - title: "GoogleTest Primer" 13 | url: "/primer.html" 14 | - title: "Advanced Topics" 15 | url: "/advanced.html" 16 | - title: "Mocking for Dummies" 17 | url: "/gmock_for_dummies.html" 18 | - title: "Mocking Cookbook" 19 | url: "/gmock_cook_book.html" 20 | - title: "Mocking Cheat Sheet" 21 | url: "/gmock_cheat_sheet.html" 22 | - section: "References" 23 | items: 24 | - title: "Testing Reference" 25 | url: "/reference/testing.html" 26 | - title: "Mocking Reference" 27 | url: "/reference/mocking.html" 28 | - title: "Assertions" 29 | url: "/reference/assertions.html" 30 | - title: "Matchers" 31 | url: "/reference/matchers.html" 32 | - title: "Actions" 33 | url: "/reference/actions.html" 34 | - title: "Testing FAQ" 35 | url: "/faq.html" 36 | - title: "Mocking FAQ" 37 | url: "/gmock_faq.html" 38 | - title: "Code Samples" 39 | url: "/samples.html" 40 | - title: "Using pkg-config" 41 | url: "/pkgconfig.html" 42 | - title: "Community Documentation" 43 | url: "/community_created_documentation.html" 44 | -------------------------------------------------------------------------------- /src/replacer/lru_replacer.cpp: -------------------------------------------------------------------------------- 1 | #include "lru_replacer.h" 2 | 3 | LRUReplacer::LRUReplacer(size_t num_pages) { max_size_ = num_pages; } 4 | 5 | LRUReplacer::~LRUReplacer() = default; 6 | 7 | /** 8 | * @brief 使用LRU策略删除一个victim frame,这个函数能得到frame_id 9 | * @param[out] frame_id id of frame that was removed, nullptr if no victim was found 10 | * @return true if a victim frame was found, false otherwise 11 | */ 12 | bool LRUReplacer::Victim(frame_id_t *frame_id) { 13 | // C++17 std::scoped_lock 14 | // 它能够避免死锁发生,其构造函数能够自动进行上锁操作,析构函数会对互斥量进行解锁操作,保证线程安全。 15 | std::scoped_lock lock{latch_}; 16 | 17 | // Todo: 18 | // 利用lru_replacer中的LRUlist_,LRUHash_实现LRU策略 19 | // 选择合适的frame指定为淘汰页面,赋值给*frame_id 20 | 21 | return true; 22 | } 23 | 24 | /** 25 | * @brief 固定一个frame, 表明它不应该成为victim(即在replacer中移除该frame_id) 26 | * @param frame_id the id of the frame to pin 27 | */ 28 | void LRUReplacer::Pin(frame_id_t frame_id) { 29 | std::scoped_lock lock{latch_}; 30 | // Todo: 31 | // 固定指定id的frame 32 | // 在数据结构中移除该frame 33 | } 34 | 35 | /** 36 | * 取消固定一个frame, 表明它可以成为victim(即将该frame_id添加到replacer) 37 | * @param frame_id the id of the frame to unpin 38 | */ 39 | void LRUReplacer::Unpin(frame_id_t frame_id) { 40 | // Todo: 41 | // 支持并发锁 42 | // 选择一个frame取消固定 43 | } 44 | 45 | /** @return replacer中能够victim的数量 */ 46 | size_t LRUReplacer::Size() { 47 | // Todo: 48 | // 改写return size 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /src/transaction/transaction_manager.cpp: -------------------------------------------------------------------------------- 1 | #include "transaction_manager.h" 2 | #include "record/rm_file_handle.h" 3 | 4 | std::unordered_map TransactionManager::txn_map = {}; 5 | 6 | /** 7 | * 事务的开始方法 8 | * @param txn 事务指针 9 | * @param log_manager 日志管理器,用于日志lab 10 | * @return 当前事务指针 11 | * @tips: 事务的指针可能为空指针 12 | */ 13 | Transaction * TransactionManager::Begin(Transaction *txn, LogManager *log_manager) { 14 | // Todo: 15 | // 1. 判断传入事务参数是否为空指针 16 | // 2. 如果为空指针,创建新事务 17 | // 3. 把开始事务加入到全局事务表中 18 | // 4. 返回当前事务指针 19 | 20 | return txn; 21 | } 22 | 23 | /** 24 | * 事务的提交方法 25 | * @param txn 事务指针 26 | * @param log_manager 日志管理器,用于日志lab 27 | * @param sm_manager 系统管理器,用于commit,后续会删掉 28 | */ 29 | void TransactionManager::Commit(Transaction * txn, LogManager *log_manager) { 30 | // Todo: 31 | // 1. 如果存在未提交的写操作,提交所有的写操作 32 | // 2. 释放所有锁 33 | // 3. 释放事务相关资源,eg.锁集 34 | // 4. 更新事务状态 35 | 36 | } 37 | 38 | /** 39 | * 事务的终止方法 40 | * @param txn 事务指针 41 | * @param log_manager 日志管理器,用于日志lab 42 | * @param sm_manager 系统管理器,用于rollback,后续会删掉 43 | */ 44 | void TransactionManager::Abort(Transaction * txn, LogManager *log_manager) { 45 | // Todo: 46 | // 1. 回滚所有写操作 47 | // 2. 释放所有锁 48 | // 3. 清空事务相关资源,eg.锁集 49 | // 4. 更新事务状态 50 | 51 | } 52 | 53 | /** 以下函数用于日志实验中的checkpoint */ 54 | void TransactionManager::BlockAllTransactions() {} 55 | 56 | void TransactionManager::ResumeAllTransactions() {} -------------------------------------------------------------------------------- /src/common/rwlatch.h: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // BusTub 4 | // 5 | // rwlatch.h 6 | // 7 | // Identification: src/include/common/rwlatch.h 8 | // 9 | // Copyright (c) 2015-2019, Carnegie Mellon University Database Group 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #pragma once 14 | 15 | #include 16 | #include // NOLINT 17 | #include // NOLINT 18 | 19 | #include "common/macros.h" 20 | 21 | /** 22 | * Reader-Writer latch backed by std::mutex. 23 | */ 24 | class ReaderWriterLatch { 25 | using mutex_t = std::mutex; 26 | using cond_t = std::condition_variable; 27 | static const uint32_t MAX_READERS = UINT_MAX; 28 | 29 | public: 30 | ReaderWriterLatch() = default; 31 | ~ReaderWriterLatch() { std::lock_guard guard(mutex_); } 32 | 33 | DISALLOW_COPY(ReaderWriterLatch); 34 | 35 | /** 36 | * Acquire a write latch. 37 | */ 38 | void WLock(); 39 | 40 | /** 41 | * Release a write latch. 42 | */ 43 | void WUnlock(); 44 | 45 | /** 46 | * Acquire a read latch. 47 | */ 48 | void RLock(); 49 | 50 | /** 51 | * Release a read latch. 52 | */ 53 | void RUnlock(); 54 | 55 | private: 56 | mutex_t mutex_; 57 | cond_t writer_; 58 | cond_t reader_; 59 | uint32_t reader_count_{0}; 60 | bool writer_entered_{false}; 61 | }; 62 | -------------------------------------------------------------------------------- /src/defs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | // 此处重载了<<操作符,在ColMeta中进行了调用 7 | template::value, T>::type> 8 | std::ostream &operator<<(std::ostream &os, const T &enum_val) { 9 | os << static_cast(enum_val); 10 | return os; 11 | } 12 | 13 | template::value, T>::type> 14 | std::istream &operator>>(std::istream &is, T &enum_val) { 15 | int int_val; 16 | is >> int_val; 17 | enum_val = static_cast(int_val); 18 | return is; 19 | } 20 | 21 | struct Rid { 22 | int page_no; 23 | int slot_no; 24 | 25 | friend bool operator==(const Rid &x, const Rid &y) { 26 | return x.page_no == y.page_no && x.slot_no == y.slot_no; 27 | } 28 | 29 | friend bool operator!=(const Rid &x, const Rid &y) { return !(x == y); } 30 | }; 31 | 32 | enum ColType { 33 | TYPE_INT, TYPE_FLOAT, TYPE_STRING 34 | }; 35 | 36 | inline std::string coltype2str(ColType type) { 37 | std::map m = { 38 | {TYPE_INT, "INT"}, 39 | {TYPE_FLOAT, "FLOAT"}, 40 | {TYPE_STRING, "STRING"} 41 | }; 42 | return m.at(type); 43 | } 44 | 45 | class RecScan { 46 | public: 47 | virtual ~RecScan() = default; 48 | 49 | virtual void next() = 0; 50 | 51 | virtual bool is_end() const = 0; 52 | 53 | virtual Rid rid() const = 0; 54 | }; 55 | -------------------------------------------------------------------------------- /deps/googletest/.github/ISSUE_TEMPLATE/00-bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: 'bug' 6 | assignees: '' 7 | --- 8 | 9 | **Describe the bug** 10 | 11 | Include a clear and concise description of what the problem is, including what 12 | you expected to happen, and what actually happened. 13 | 14 | **Steps to reproduce the bug** 15 | 16 | It's important that we are able to reproduce the problem that you are 17 | experiencing. Please provide all code and relevant steps to reproduce the 18 | problem, including your `BUILD`/`CMakeLists.txt` file and build commands. Links 19 | to a GitHub branch or [godbolt.org](https://godbolt.org/) that demonstrate the 20 | problem are also helpful. 21 | 22 | **Does the bug persist in the most recent commit?** 23 | 24 | We recommend using the latest commit in the master branch in your projects. 25 | 26 | **What operating system and version are you using?** 27 | 28 | If you are using a Linux distribution please include the name and version of the 29 | distribution as well. 30 | 31 | **What compiler and version are you using?** 32 | 33 | Please include the output of `gcc -v` or `clang -v`, or the equivalent for your 34 | compiler. 35 | 36 | **What build system are you using?** 37 | 38 | Please include the output of `bazel --version` or `cmake --version`, or the 39 | equivalent for your build system. 40 | 41 | **Additional context** 42 | 43 | Add any other context about the problem here. 44 | -------------------------------------------------------------------------------- /deps/googletest/googletest/include/gtest/internal/custom/README.md: -------------------------------------------------------------------------------- 1 | # Customization Points 2 | 3 | The custom directory is an injection point for custom user configurations. 4 | 5 | ## Header `gtest.h` 6 | 7 | ### The following macros can be defined: 8 | 9 | * `GTEST_OS_STACK_TRACE_GETTER_` - The name of an implementation of 10 | `OsStackTraceGetterInterface`. 11 | * `GTEST_CUSTOM_TEMPDIR_FUNCTION_` - An override for `testing::TempDir()`. See 12 | `testing::TempDir` for semantics and signature. 13 | 14 | ## Header `gtest-port.h` 15 | 16 | The following macros can be defined: 17 | 18 | ### Logging: 19 | 20 | * `GTEST_LOG_(severity)` 21 | * `GTEST_CHECK_(condition)` 22 | * Functions `LogToStderr()` and `FlushInfoLog()` have to be provided too. 23 | 24 | ### Threading: 25 | 26 | * `GTEST_HAS_NOTIFICATION_` - Enabled if Notification is already provided. 27 | * `GTEST_HAS_MUTEX_AND_THREAD_LOCAL_` - Enabled if `Mutex` and `ThreadLocal` 28 | are already provided. Must also provide `GTEST_DECLARE_STATIC_MUTEX_(mutex)` 29 | and `GTEST_DEFINE_STATIC_MUTEX_(mutex)` 30 | * `GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)` 31 | * `GTEST_LOCK_EXCLUDED_(locks)` 32 | 33 | ### Underlying library support features 34 | 35 | * `GTEST_HAS_CXXABI_H_` 36 | 37 | ### Exporting API symbols: 38 | 39 | * `GTEST_API_` - Specifier for exported symbols. 40 | 41 | ## Header `gtest-printers.h` 42 | 43 | * See documentation at `gtest/gtest-printers.h` for details on how to define a 44 | custom printer. 45 | -------------------------------------------------------------------------------- /src/replacer/replacer.h: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // BusTub 4 | // 5 | // replacer.h 6 | // 7 | // Identification: src/include/buffer/replacer.h 8 | // 9 | // Copyright (c) 2015-2019, Carnegie Mellon University Database Group 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #pragma once 14 | 15 | #include "common/config.h" 16 | 17 | /** 18 | * Replacer is an abstract class that tracks page usage. 19 | */ 20 | class Replacer { 21 | public: 22 | Replacer() = default; 23 | virtual ~Replacer() = default; 24 | 25 | /** 26 | * Remove the victim frame as defined by the replacement policy. 27 | * @param[out] frame_id id of frame that was removed, nullptr if no victim was found 28 | * @return true if a victim frame was found, false otherwise 29 | */ 30 | virtual bool Victim(frame_id_t *frame_id) = 0; 31 | 32 | /** 33 | * Pins a frame, indicating that it should not be victimized until it is unpinned. 34 | * @param frame_id the id of the frame to pin 35 | */ 36 | virtual void Pin(frame_id_t frame_id) = 0; 37 | 38 | /** 39 | * Unpins a frame, indicating that it can now be victimized. 40 | * @param frame_id the id of the frame to unpin 41 | */ 42 | virtual void Unpin(frame_id_t frame_id) = 0; 43 | 44 | /** @return the number of elements in the replacer that can be victimized */ 45 | virtual size_t Size() = 0; 46 | }; 47 | -------------------------------------------------------------------------------- /src/recovery/log_manager.cpp: -------------------------------------------------------------------------------- 1 | #include "log_manager.h" 2 | 3 | #include 4 | 5 | /** 6 | * 开启日志刷新线程 7 | */ 8 | void LogManager::RunFlushThread() { 9 | // Todo: 10 | // 1. 如果系统未开启日志功能,则不能开启日志刷新线程(通过log_mode_判断) 11 | // 2. 开启一个新线程,用来把flush_buffer_中的内容刷新到磁盘当中 12 | // 3. 在刷新之前,需要判断当前线程由于哪种原因被唤醒,如果是time_out唤醒,则需要交换log_buffer和flush_buffer 13 | // 4. 刷新之后需要更新flush_buffer的偏移量、persistent_lsn_等信息 14 | 15 | } 16 | 17 | /** 18 | * 辅助函数,用于DiskManager唤醒flush_thread_ 19 | * @param p 20 | */ 21 | void LogManager::WakeUpFlushThread(std::promise *p) { 22 | { 23 | std::unique_lock lock(latch_); 24 | SwapBuffer(); 25 | SetPromise(p); 26 | } 27 | 28 | cv_.notify_one(); 29 | 30 | // waiting for flush_done 31 | if (promise != nullptr) { 32 | promise->get_future().wait(); 33 | } 34 | 35 | SetPromise(nullptr); 36 | } 37 | 38 | /** 39 | * 辅助函数,交换log_buffer_和flush_buffer_及其相关信息 40 | */ 41 | void LogManager::SwapBuffer() { 42 | std::swap(log_buffer_, flush_buffer_); 43 | std::swap(log_buffer_write_offset_, flush_buffer_write_offset_); 44 | flush_lsn_ = next_lsn_ - 1; 45 | } 46 | 47 | /** 48 | * 添加一条日志记录到log_buffer_中 49 | * @param log_record 要添加的日志记录 50 | * @return 返回该日志的日志序列号 51 | */ 52 | lsn_t LogManager::AppendLogRecord(LogRecord *log_record) { 53 | // Todo: 54 | // 1. 获取互斥锁latch_ 55 | // 2. 判断log_buffer_中是否还存在足够的剩余空间,如果空间不足,需要交换log_buffer_和flush_buffer_,唤醒日志刷新线程 56 | // 3. 为该日志分配日志序列号 57 | // 4. 把该日志写入到log_buffer_中 58 | 59 | return log_record->lsn_; 60 | } -------------------------------------------------------------------------------- /deps/googletest/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /src/index/ix_defs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "defs.h" 4 | #include "storage/buffer_pool_manager.h" 5 | 6 | struct IxFileHdr { 7 | page_id_t first_free_page_no; 8 | int num_pages; // disk pages 9 | page_id_t root_page; // root page no 10 | ColType col_type; 11 | int col_len; // ColMeta->len 12 | int btree_order; // children per page 每个结点最多可插入的键值对数量 13 | int keys_size; // keys_size = (btree_order + 1) * col_len 14 | // first_leaf初始化之后没有进行修改,只不过是在测试文件中遍历叶子结点的时候用了 15 | page_id_t first_leaf; // 在上层IxManager的open函数进行初始化,初始化为root page_no 16 | page_id_t last_leaf; 17 | }; 18 | 19 | struct IxPageHdr { 20 | page_id_t next_free_page_no; 21 | page_id_t parent; // its parent's page_no 22 | int num_key; // # current keys (always equals to #child - 1) 已插入的keys数量,key_idx∈[0,num_key) 23 | bool is_leaf; 24 | page_id_t prev_leaf; // previous leaf node's page_no, effective only when is_leaf is true 25 | page_id_t next_leaf; // next leaf node's page_no, effective only when is_leaf is true 26 | }; 27 | 28 | // 这个其实和Rid结构类似 29 | struct Iid { 30 | int page_no; 31 | int slot_no; 32 | 33 | friend bool operator==(const Iid &x, const Iid &y) { return x.page_no == y.page_no && x.slot_no == y.slot_no; } 34 | 35 | friend bool operator!=(const Iid &x, const Iid &y) { return !(x == y); } 36 | }; 37 | 38 | constexpr int IX_NO_PAGE = -1; 39 | constexpr int IX_FILE_HDR_PAGE = 0; 40 | constexpr int IX_LEAF_HEADER_PAGE = 1; 41 | constexpr int IX_INIT_ROOT_PAGE = 2; 42 | constexpr int IX_INIT_NUM_PAGES = 3; 43 | constexpr int IX_MAX_COL_LEN = 512; 44 | -------------------------------------------------------------------------------- /src/replacer/lru_replacer.h: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // BusTub 4 | // 5 | // lru_replacer.h 6 | // 7 | // Identification: src/include/buffer/lru_replacer.h 8 | // 9 | // Copyright (c) 2015-2019, Carnegie Mellon University Database Group 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #pragma once 14 | 15 | #include 16 | #include // NOLINT 包含std::mutex、std::scoped_lock 17 | #include 18 | 19 | #include "common/config.h" 20 | #include "replacer/replacer.h" 21 | #include "unordered_map" 22 | 23 | /** 24 | * LRUReplacer implements the lru replacement policy, which approximates the Least Recently Used policy. 25 | */ 26 | class LRUReplacer : public Replacer { 27 | public: 28 | /** 29 | * Create a new LRUReplacer. 30 | * @param num_pages the maximum number of pages the LRUReplacer will be required to store 31 | */ 32 | explicit LRUReplacer(size_t num_pages); 33 | // explicit关键字只能用来修饰类内部的构造函数声明,作用于单个参数的构造函数;被修饰的构造函数的类,不能发生相应的隐式类型转换。 34 | 35 | /** 36 | * Destroys the LRUReplacer. 37 | */ 38 | ~LRUReplacer(); 39 | 40 | bool Victim(frame_id_t *frame_id); 41 | 42 | void Pin(frame_id_t frame_id); 43 | 44 | void Unpin(frame_id_t frame_id); 45 | 46 | size_t Size(); 47 | 48 | private: 49 | std::mutex latch_; // 互斥锁 50 | std::list LRUlist_; // 按加入的时间顺序存放unpinned pages的frame id,首部表示最近被访问 51 | std::unordered_map::iterator> LRUhash_; // frame_id_t -> unpinned pages的frame id 52 | size_t max_size_; // 最大容量(与缓冲池的容量相同) 53 | }; 54 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/README.md: -------------------------------------------------------------------------------- 1 | # Googletest Mocking (gMock) Framework 2 | 3 | ### Overview 4 | 5 | Google's framework for writing and using C++ mock classes. It can help you 6 | derive better designs of your system and write better tests. 7 | 8 | It is inspired by: 9 | 10 | * [jMock](http://www.jmock.org/) 11 | * [EasyMock](http://www.easymock.org/) 12 | * [Hamcrest](http://code.google.com/p/hamcrest/) 13 | 14 | It is designed with C++'s specifics in mind. 15 | 16 | gMock: 17 | 18 | - Provides a declarative syntax for defining mocks. 19 | - Can define partial (hybrid) mocks, which are a cross of real and mock 20 | objects. 21 | - Handles functions of arbitrary types and overloaded functions. 22 | - Comes with a rich set of matchers for validating function arguments. 23 | - Uses an intuitive syntax for controlling the behavior of a mock. 24 | - Does automatic verification of expectations (no record-and-replay needed). 25 | - Allows arbitrary (partial) ordering constraints on function calls to be 26 | expressed. 27 | - Lets a user extend it by defining new matchers and actions. 28 | - Does not use exceptions. 29 | - Is easy to learn and use. 30 | 31 | Details and examples can be found here: 32 | 33 | * [gMock for Dummies](https://google.github.io/googletest/gmock_for_dummies.html) 34 | * [Legacy gMock FAQ](https://google.github.io/googletest/gmock_faq.html) 35 | * [gMock Cookbook](https://google.github.io/googletest/gmock_cook_book.html) 36 | * [gMock Cheat Sheet](https://google.github.io/googletest/gmock_cheat_sheet.html) 37 | 38 | GoogleMock is a part of 39 | [GoogleTest C++ testing framework](http://github.com/google/googletest/) and a 40 | subject to the same requirements. 41 | -------------------------------------------------------------------------------- /src/replacer/clock_replacer.h: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // BusTub 4 | // 5 | // clock_replacer.h 6 | // 7 | // Identification: src/include/buffer/clock_replacer.h 8 | // 9 | // Copyright (c) 2015-2019, Carnegie Mellon University Database Group 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #pragma once 14 | 15 | #include // NOLINT 16 | #include 17 | 18 | #include "common/config.h" 19 | #include "replacer/replacer.h" 20 | 21 | /** 22 | * ClockReplacer implements the clock replacement policy, which approximates the Least Recently Used 23 | * policy. 24 | */ 25 | class ClockReplacer : public Replacer { 26 | using mutex_t = std::mutex; 27 | 28 | public: 29 | // EMPTY: This frame not storage page or pinned (is using by some thread,can not be victim) 30 | // ACCESSED: This frame is used by some thread not so long ago 31 | // UNTOUCHED: This frame can be victim 32 | enum class Status { UNTOUCHED, ACCESSED, EMPTY_OR_PINNED }; 33 | /** 34 | * Create a new ClockReplacer. 35 | * @param num_pages the maximum number of pages the ClockReplacer will be required to store 36 | */ 37 | explicit ClockReplacer(size_t num_pages); 38 | 39 | /** 40 | * Destroys the ClockReplacer. 41 | */ 42 | ~ClockReplacer() override; 43 | 44 | bool Victim(frame_id_t *frame_id) override; 45 | 46 | void Pin(frame_id_t frame_id) override; 47 | 48 | void Unpin(frame_id_t frame_id) override; 49 | 50 | size_t Size() override; 51 | 52 | private: 53 | std::vector circular_; 54 | frame_id_t hand_{0}; // initial hand_ value = 0, the scan starter 55 | size_t capacity_; 56 | mutex_t mutex_; 57 | }; -------------------------------------------------------------------------------- /deps/googletest/googletest/test/production.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // This is part of the unit test for gtest_prod.h. 32 | 33 | #include "production.h" 34 | 35 | PrivateCode::PrivateCode() : x_(0) {} 36 | -------------------------------------------------------------------------------- /src/record/bitmap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | static constexpr int BITMAP_WIDTH = 8; 7 | static constexpr unsigned BITMAP_HIGHEST_BIT = 0x80u; // 128 (2^7) 8 | 9 | class Bitmap { 10 | public: 11 | // 从地址bm开始的size个字节全部置0 12 | static void init(char *bm, int size) { memset(bm, 0, size); } 13 | 14 | // pos位 置1 15 | static void set(char *bm, int pos) { bm[get_bucket(pos)] |= get_bit(pos); } 16 | 17 | // pos位 置0 18 | static void reset(char *bm, int pos) { bm[get_bucket(pos)] &= static_cast(~get_bit(pos)); } 19 | 20 | // 如果pos位是1,则返回true 21 | static bool is_set(const char *bm, int pos) { return (bm[get_bucket(pos)] & get_bit(pos)) != 0; } 22 | 23 | /** 24 | * @brief 找下一个为0 or 1的位 25 | * @param bit false表示要找下一个为0的位,true表示要找下一个为1的位 26 | * @param bm 要找的起始地址为bm 27 | * @param max_n 要找的从起始地址开始的偏移为[curr+1,max_n) 28 | * @param curr 要找的从起始地址开始的偏移为[curr+1,max_n) 29 | * @return 找到了就返回偏移位置,没找到就返回max_n 30 | */ 31 | static int next_bit(bool bit, const char *bm, int max_n, int curr) { 32 | for (int i = curr + 1; i < max_n; i++) { 33 | if (is_set(bm, i) == bit) { 34 | return i; 35 | } 36 | } 37 | return max_n; 38 | } 39 | 40 | // 找第一个为0 or 1的位 41 | static int first_bit(bool bit, const char *bm, int max_n) { return next_bit(bit, bm, max_n, -1); } 42 | 43 | // for example: 44 | // rid_.slot_no = Bitmap::next_bit(true, page_handle.bitmap, file_handle_->file_hdr_.num_records_per_page, 45 | // rid_.slot_no); int slot_no = Bitmap::first_bit(false, page_handle.bitmap, file_hdr_.num_records_per_page); 46 | 47 | private: 48 | static int get_bucket(int pos) { return pos / BITMAP_WIDTH; } 49 | 50 | static char get_bit(int pos) { return BITMAP_HIGHEST_BIT >> static_cast(pos % BITMAP_WIDTH); } 51 | }; 52 | -------------------------------------------------------------------------------- /deps/googletest/WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "com_google_googletest") 2 | 3 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 4 | 5 | http_archive( 6 | name = "com_google_absl", 7 | sha256 = "1a1745b5ee81392f5ea4371a4ca41e55d446eeaee122903b2eaffbd8a3b67a2b", 8 | strip_prefix = "abseil-cpp-01cc6567cff77738e416a7ddc17de2d435a780ce", 9 | urls = ["https://github.com/abseil/abseil-cpp/archive/01cc6567cff77738e416a7ddc17de2d435a780ce.zip"], # 2022-06-21T19:28:27Z 10 | ) 11 | 12 | # Note this must use a commit from the `abseil` branch of the RE2 project. 13 | # https://github.com/google/re2/tree/abseil 14 | http_archive( 15 | name = "com_googlesource_code_re2", 16 | sha256 = "0a890c2aa0bb05b2ce906a15efb520d0f5ad4c7d37b8db959c43772802991887", 17 | strip_prefix = "re2-a427f10b9fb4622dd6d8643032600aa1b50fbd12", 18 | urls = ["https://github.com/google/re2/archive/a427f10b9fb4622dd6d8643032600aa1b50fbd12.zip"], # 2022-06-09 19 | ) 20 | 21 | http_archive( 22 | name = "rules_python", 23 | sha256 = "0b460f17771258341528753b1679335b629d1d25e3af28eda47d009c103a6e15", 24 | strip_prefix = "rules_python-aef17ad72919d184e5edb7abf61509eb78e57eda", 25 | urls = ["https://github.com/bazelbuild/rules_python/archive/aef17ad72919d184e5edb7abf61509eb78e57eda.zip"], # 2022-06-21T23:44:47Z 26 | ) 27 | 28 | http_archive( 29 | name = "bazel_skylib", 30 | urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz"], 31 | sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728", 32 | ) 33 | 34 | http_archive( 35 | name = "platforms", 36 | sha256 = "a879ea428c6d56ab0ec18224f976515948822451473a80d06c2e50af0bbe5121", 37 | strip_prefix = "platforms-da5541f26b7de1dc8e04c075c99df5351742a4a2", 38 | urls = ["https://github.com/bazelbuild/platforms/archive/da5541f26b7de1dc8e04c075c99df5351742a4a2.zip"], # 2022-05-27 39 | ) 40 | -------------------------------------------------------------------------------- /deps/googletest/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore CI build directory 2 | build/ 3 | xcuserdata 4 | cmake-build-debug/ 5 | .idea/ 6 | bazel-bin 7 | bazel-genfiles 8 | bazel-googletest 9 | bazel-out 10 | bazel-testlogs 11 | # python 12 | *.pyc 13 | 14 | # Visual Studio files 15 | .vs 16 | *.sdf 17 | *.opensdf 18 | *.VC.opendb 19 | *.suo 20 | *.user 21 | _ReSharper.Caches/ 22 | Win32-Debug/ 23 | Win32-Release/ 24 | x64-Debug/ 25 | x64-Release/ 26 | 27 | # Ignore autoconf / automake files 28 | Makefile.in 29 | aclocal.m4 30 | configure 31 | build-aux/ 32 | autom4te.cache/ 33 | googletest/m4/libtool.m4 34 | googletest/m4/ltoptions.m4 35 | googletest/m4/ltsugar.m4 36 | googletest/m4/ltversion.m4 37 | googletest/m4/lt~obsolete.m4 38 | googlemock/m4 39 | 40 | # Ignore generated directories. 41 | googlemock/fused-src/ 42 | googletest/fused-src/ 43 | 44 | # macOS files 45 | .DS_Store 46 | googletest/.DS_Store 47 | googletest/xcode/.DS_Store 48 | 49 | # Ignore cmake generated directories and files. 50 | CMakeFiles 51 | CTestTestfile.cmake 52 | Makefile 53 | cmake_install.cmake 54 | googlemock/CMakeFiles 55 | googlemock/CTestTestfile.cmake 56 | googlemock/Makefile 57 | googlemock/cmake_install.cmake 58 | googlemock/gtest 59 | /bin 60 | /googlemock/gmock.dir 61 | /googlemock/gmock_main.dir 62 | /googlemock/RUN_TESTS.vcxproj.filters 63 | /googlemock/RUN_TESTS.vcxproj 64 | /googlemock/INSTALL.vcxproj.filters 65 | /googlemock/INSTALL.vcxproj 66 | /googlemock/gmock_main.vcxproj.filters 67 | /googlemock/gmock_main.vcxproj 68 | /googlemock/gmock.vcxproj.filters 69 | /googlemock/gmock.vcxproj 70 | /googlemock/gmock.sln 71 | /googlemock/ALL_BUILD.vcxproj.filters 72 | /googlemock/ALL_BUILD.vcxproj 73 | /lib 74 | /Win32 75 | /ZERO_CHECK.vcxproj.filters 76 | /ZERO_CHECK.vcxproj 77 | /RUN_TESTS.vcxproj.filters 78 | /RUN_TESTS.vcxproj 79 | /INSTALL.vcxproj.filters 80 | /INSTALL.vcxproj 81 | /googletest-distribution.sln 82 | /CMakeCache.txt 83 | /ALL_BUILD.vcxproj.filters 84 | /ALL_BUILD.vcxproj 85 | -------------------------------------------------------------------------------- /src/execution/res_task1_output.txt: -------------------------------------------------------------------------------- 1 | >> show tables; 2 | rucbase> show tables; 3 | +------------------+ 4 | | Tables | 5 | +------------------+ 6 | +------------------+ 7 | 8 | ------------------------------ 9 | >> create table tb(s int, a int, b float, c char(16)); 10 | rucbase> create table tb(s int, a int, b float, c char(16)); 11 | 12 | ------------------------------ 13 | >> create table tb2(x int, y float, z char(16), s int); 14 | rucbase> create table tb2(x int, y float, z char(16), s int); 15 | 16 | ------------------------------ 17 | >> show tables; 18 | rucbase> show tables; 19 | +------------------+ 20 | | Tables | 21 | +------------------+ 22 | | tb | 23 | | tb2 | 24 | +------------------+ 25 | 26 | ------------------------------ 27 | >> desc tb; 28 | rucbase> desc tb; 29 | +------------------+------------------+------------------+ 30 | | Field | Type | Index | 31 | +------------------+------------------+------------------+ 32 | | s | INT | NO | 33 | | a | INT | NO | 34 | | b | FLOAT | NO | 35 | | c | STRING | NO | 36 | +------------------+------------------+------------------+ 37 | 38 | ------------------------------ 39 | >> drop table tb; 40 | rucbase> drop table tb; 41 | 42 | ------------------------------ 43 | >> show tables; 44 | rucbase> show tables; 45 | +------------------+ 46 | | Tables | 47 | +------------------+ 48 | | tb2 | 49 | +------------------+ 50 | 51 | ------------------------------ 52 | >> drop table tb2; 53 | rucbase> drop table tb2; 54 | 55 | ------------------------------ 56 | >> show tables; 57 | rucbase> show tables; 58 | +------------------+ 59 | | Tables | 60 | +------------------+ 61 | +------------------+ 62 | 63 | ------------------------------ 64 | -------------------------------------------------------------------------------- /src/execution/executor_delete.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "execution_defs.h" 3 | #include "execution_manager.h" 4 | #include "executor_abstract.h" 5 | #include "index/ix.h" 6 | #include "system/sm.h" 7 | 8 | class DeleteExecutor : public AbstractExecutor { 9 | private: 10 | TabMeta tab_; 11 | std::vector conds_; 12 | RmFileHandle *fh_; 13 | std::vector rids_; 14 | std::string tab_name_; 15 | SmManager *sm_manager_; 16 | 17 | public: 18 | DeleteExecutor(SmManager *sm_manager, const std::string &tab_name, std::vector conds, 19 | std::vector rids, Context *context) { 20 | sm_manager_ = sm_manager; 21 | tab_name_ = tab_name; 22 | tab_ = sm_manager_->db_.get_table(tab_name); 23 | fh_ = sm_manager_->fhs_.at(tab_name).get(); 24 | conds_ = conds; 25 | rids_ = rids; 26 | context_ = context; 27 | } 28 | std::unique_ptr Next() override { 29 | // Get all index files 30 | std::vector ihs(tab_.cols.size(), nullptr); 31 | for (size_t col_i = 0; col_i < tab_.cols.size(); col_i++) { 32 | if (tab_.cols[col_i].index) { 33 | // 查询执行 task3 Todo 34 | // 获取需要的索引句柄,填充vector ihs 35 | // 查询执行 task3 Todo end 36 | } 37 | } 38 | // Delete each rid from record file and index file 39 | for (auto &rid : rids_) { 40 | auto rec = fh_->get_record(rid, context_); 41 | // 查询执行 task3 Todo 42 | // Delete from index file 43 | // Delete from record file 44 | // 查询执行 task3 Todo end 45 | 46 | // record a delete operation into the transaction 47 | RmRecord delete_record{rec->size}; 48 | memcpy(delete_record.data, rec->data, rec->size); 49 | } 50 | return nullptr; 51 | } 52 | Rid &rid() override { return _abstract_rid; } 53 | }; -------------------------------------------------------------------------------- /src/transaction/concurrency/lock_manager.cpp: -------------------------------------------------------------------------------- 1 | #include "lock_manager.h" 2 | 3 | /** 4 | * 申请行级读锁 5 | * @param txn 要申请锁的事务对象指针 6 | * @param rid 加锁的目标记录ID 7 | * @param tab_fd 记录所在的表的fd 8 | * @return 返回加锁是否成功 9 | */ 10 | bool LockManager::LockSharedOnRecord(Transaction *txn, const Rid &rid, int tab_fd) { 11 | // Todo: 12 | // 1. 通过mutex申请访问全局锁表 13 | // 2. 检查事务的状态 14 | // 3. 查找当前事务是否已经申请了目标数据项上的锁,如果存在则根据锁类型进行操作,否则执行下一步操作 15 | // 4. 将要申请的锁放入到全局锁表中,并通过组模式来判断是否可以成功授予锁 16 | // 5. 如果成功,更新目标数据项在全局锁表中的信息,否则阻塞当前操作 17 | // 提示:步骤5中的阻塞操作可以通过条件变量来完成,所有加锁操作都遵循上述步骤,在下面的加锁操作中不再进行注释提示 18 | return true; 19 | } 20 | 21 | /** 22 | * 申请行级写锁 23 | * @param txn 要申请锁的事务对象指针 24 | * @param rid 加锁的目标记录ID 25 | * @param tab_fd 记录所在的表的fd 26 | * @return 返回加锁是否成功 27 | */ 28 | bool LockManager::LockExclusiveOnRecord(Transaction *txn, const Rid &rid, int tab_fd) { 29 | 30 | return true; 31 | } 32 | 33 | /** 34 | * 申请表级读锁 35 | * @param txn 要申请锁的事务对象指针 36 | * @param tab_fd 目标表的fd 37 | * @return 返回加锁是否成功 38 | */ 39 | bool LockManager::LockSharedOnTable(Transaction *txn, int tab_fd) { 40 | 41 | return true; 42 | } 43 | 44 | /** 45 | * 申请表级写锁 46 | * @param txn 要申请锁的事务对象指针 47 | * @param tab_fd 目标表的fd 48 | * @return 返回加锁是否成功 49 | */ 50 | bool LockManager::LockExclusiveOnTable(Transaction *txn, int tab_fd) { 51 | 52 | return true; 53 | } 54 | 55 | /** 56 | * 申请表级意向读锁 57 | * @param txn 要申请锁的事务对象指针 58 | * @param tab_fd 目标表的fd 59 | * @return 返回加锁是否成功 60 | */ 61 | bool LockManager::LockISOnTable(Transaction *txn, int tab_fd) { 62 | 63 | return true; 64 | } 65 | 66 | /** 67 | * 申请表级意向写锁 68 | * @param txn 要申请锁的事务对象指针 69 | * @param tab_fd 目标表的fd 70 | * @return 返回加锁是否成功 71 | */ 72 | bool LockManager::LockIXOnTable(Transaction *txn, int tab_fd) { 73 | 74 | return true; 75 | } 76 | 77 | /** 78 | * 释放锁 79 | * @param txn 要释放锁的事务对象指针 80 | * @param lock_data_id 要释放的锁ID 81 | * @return 返回解锁是否成功 82 | */ 83 | bool LockManager::Unlock(Transaction *txn, LockDataId lock_data_id) { 84 | 85 | return true; 86 | } -------------------------------------------------------------------------------- /src/execution/exec_sql.cpp: -------------------------------------------------------------------------------- 1 | #undef NDEBUG 2 | 3 | #include "execution.h" 4 | #include "gtest/gtest.h" 5 | #include "interp_test.h" 6 | 7 | #define BUFFER_LENGTH 8192 8 | 9 | std::string db_name_ = "ExecutorTest_db"; 10 | std::unique_ptr disk_manager_ = std::make_unique(); 11 | std::unique_ptr buffer_pool_manager_ = 12 | std::make_unique(BUFFER_POOL_SIZE, disk_manager_.get()); 13 | std::unique_ptr rm_manager_ = std::make_unique(disk_manager_.get(), buffer_pool_manager_.get()); 14 | std::unique_ptr ix_manager_ = std::make_unique(disk_manager_.get(), buffer_pool_manager_.get()); 15 | std::unique_ptr sm_manager_ = 16 | std::make_unique(disk_manager_.get(), buffer_pool_manager_.get(), rm_manager_.get(), ix_manager_.get()); 17 | 18 | std::unique_ptr ql_manager_ = std::make_unique(sm_manager_.get()); 19 | 20 | std::unique_ptr interp_ = std::make_unique(sm_manager_.get(), ql_manager_.get()); 21 | 22 | char *result = new char[BUFFER_LENGTH]; 23 | int offset; 24 | 25 | char *exec_sql(const std::string &sql) { 26 | std::cout << "rucbase> " + sql << std::endl; 27 | YY_BUFFER_STATE yy_buffer = yy_scan_string(sql.c_str()); 28 | assert(yyparse() == 0 && ast::parse_tree != nullptr); 29 | yy_delete_buffer(yy_buffer); 30 | memset(result, 0, BUFFER_LENGTH); 31 | offset = 0; 32 | Context *context = new Context(nullptr, nullptr, new Transaction(0), result, &offset); 33 | interp_->interp_sql(ast::parse_tree, context); // 主要执行逻辑 34 | // std::cout << result << std::endl; 35 | return result; 36 | }; 37 | 38 | int main(int argc, char *argv[]) { 39 | if (argc == 2) { 40 | if (!sm_manager_->is_dir(db_name_)) { 41 | sm_manager_->create_db(db_name_); 42 | } 43 | sm_manager_->open_db(db_name_); 44 | std::cout << exec_sql(argv[1]) << std::endl; 45 | } 46 | sm_manager_->close_db(); 47 | } 48 | -------------------------------------------------------------------------------- /deps/googletest/googletest/include/gtest/internal/custom/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 35 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 36 | 37 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 38 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_main_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "gtest/gtest.h" 31 | 32 | // Tests that we don't have to define main() when we link to 33 | // gtest_main instead of gtest. 34 | 35 | namespace { 36 | 37 | TEST(GTestMainTest, ShouldSucceed) {} 38 | 39 | } // namespace 40 | 41 | // We are using the main() function defined in gtest_main.cc, so we 42 | // don't define it here. 43 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/test/gmock_link2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Google Mock - a framework for writing C++ mock classes. 31 | // 32 | // This file is for verifying that various Google Mock constructs do not 33 | // produce linker errors when instantiated in different translation units. 34 | // Please see gmock_link_test.h for details. 35 | 36 | #define LinkTest LinkTest2 37 | 38 | #include "test/gmock_link_test.h" 39 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/test/gmock_link_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Google Mock - a framework for writing C++ mock classes. 31 | // 32 | // This file is for verifying that various Google Mock constructs do not 33 | // produce linker errors when instantiated in different translation units. 34 | // Please see gmock_link_test.h for details. 35 | 36 | #define LinkTest LinkTest1 37 | 38 | #include "test/gmock_link_test.h" 39 | -------------------------------------------------------------------------------- /deps/googletest/googletest/include/gtest/internal/custom/gtest-port.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 35 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 36 | 37 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_ 38 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/googletest-uninitialized-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "gtest/gtest.h" 31 | 32 | TEST(DummyTest, Dummy) { 33 | // This test doesn't verify anything. We just need it to create a 34 | // realistic stage for testing the behavior of Google Test when 35 | // RUN_ALL_TESTS() is called without 36 | // testing::InitGoogleTest() being called first. 37 | } 38 | 39 | int main() { return RUN_ALL_TESTS(); } 40 | -------------------------------------------------------------------------------- /deps/googletest/googletest/samples/sample1.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #ifndef GOOGLETEST_SAMPLES_SAMPLE1_H_ 33 | #define GOOGLETEST_SAMPLES_SAMPLE1_H_ 34 | 35 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 36 | int Factorial(int n); 37 | 38 | // Returns true if and only if n is a prime number. 39 | bool IsPrime(int n); 40 | 41 | #endif // GOOGLETEST_SAMPLES_SAMPLE1_H_ 42 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/include/gmock/internal/custom/gmock-matchers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Injection point for custom user configurations. See README for details 31 | 32 | // IWYU pragma: private, include "gmock/gmock.h" 33 | // IWYU pragma: friend gmock/.* 34 | 35 | #ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ 36 | #define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ 37 | #endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_MATCHERS_H_ 38 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_testbridge_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018, Google LLC. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // This program is meant to be run by gtest_test_filter_test.py. Do not run 31 | // it directly. 32 | 33 | #include "gtest/gtest.h" 34 | 35 | // These tests are used to detect if filtering is working. Only 36 | // 'TestThatSucceeds' should ever run. 37 | 38 | TEST(TestFilterTest, TestThatSucceeds) {} 39 | 40 | TEST(TestFilterTest, TestThatFails) { 41 | ASSERT_TRUE(false) << "This test should never be run."; 42 | } 43 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest-typed-test2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | #include "test/gtest-typed-test_test.h" 34 | 35 | // Tests that the same type-parameterized test case can be 36 | // instantiated in different translation units linked together. 37 | // (ContainerTest is also instantiated in gtest-typed-test_test.cc.) 38 | INSTANTIATE_TYPED_TEST_SUITE_P(Vector, ContainerTest, 39 | testing::Types >); 40 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/include/gmock/internal/custom/gmock-port.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Injection point for custom user configurations. See README for details 31 | // 32 | // ** Custom implementation starts here ** 33 | 34 | // IWYU pragma: private, include "gmock/gmock.h" 35 | // IWYU pragma: friend gmock/.* 36 | 37 | #ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ 38 | #define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ 39 | 40 | #endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_PORT_H_ 41 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/googletest-setuptestsuite-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "gtest/gtest.h" 31 | 32 | class SetupFailTest : public ::testing::Test { 33 | protected: 34 | static void SetUpTestSuite() { ASSERT_EQ("", "SET_UP_FAIL"); } 35 | }; 36 | 37 | TEST_F(SetupFailTest, NoopPassingTest) {} 38 | 39 | class TearDownFailTest : public ::testing::Test { 40 | protected: 41 | static void TearDownTestSuite() { ASSERT_EQ("", "TEAR_DOWN_FAIL"); } 42 | }; 43 | 44 | TEST_F(TearDownFailTest, NoopPassingTest) {} 45 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_xml_outfile1_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // gtest_xml_outfile1_test_ writes some xml via TestProperty used by 31 | // gtest_xml_outfiles_test.py 32 | 33 | #include "gtest/gtest.h" 34 | 35 | class PropertyOne : public testing::Test { 36 | protected: 37 | void SetUp() override { RecordProperty("SetUpProp", 1); } 38 | void TearDown() override { RecordProperty("TearDownProp", 1); } 39 | }; 40 | 41 | TEST_F(PropertyOne, TestSomeProperties) { 42 | RecordProperty("TestSomeProperty", 1); 43 | } 44 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_xml_outfile2_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // gtest_xml_outfile2_test_ writes some xml via TestProperty used by 31 | // gtest_xml_outfiles_test.py 32 | 33 | #include "gtest/gtest.h" 34 | 35 | class PropertyTwo : public testing::Test { 36 | protected: 37 | void SetUp() override { RecordProperty("SetUpProp", 2); } 38 | void TearDown() override { RecordProperty("TearDownProp", 2); } 39 | }; 40 | 41 | TEST_F(PropertyTwo, TestSomeProperties) { 42 | RecordProperty("TestSomeProperty", 2); 43 | } 44 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/test/gmock-port_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Google Mock - a framework for writing C++ mock classes. 31 | // 32 | // This file tests the internal cross-platform support utilities. 33 | 34 | #include "gmock/internal/gmock-port.h" 35 | 36 | #include "gtest/gtest.h" 37 | 38 | // NOTE: if this file is left without tests for some reason, put a dummy 39 | // test here to make references to symbols in the gtest library and avoid 40 | // 'undefined symbol' linker errors in gmock_main: 41 | 42 | TEST(DummyTest, Dummy) {} 43 | -------------------------------------------------------------------------------- /deps/googletest/googletest/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | 34 | #if GTEST_OS_ESP8266 || GTEST_OS_ESP32 35 | #if GTEST_OS_ESP8266 36 | extern "C" { 37 | #endif 38 | void setup() { testing::InitGoogleTest(); } 39 | 40 | void loop() { RUN_ALL_TESTS(); } 41 | 42 | #if GTEST_OS_ESP8266 43 | } 44 | #endif 45 | 46 | #else 47 | 48 | GTEST_API_ int main(int argc, char **argv) { 49 | printf("Running main() from %s\n", __FILE__); 50 | testing::InitGoogleTest(&argc, argv); 51 | return RUN_ALL_TESTS(); 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/googletest-param-test-invalid-name1-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "gtest/gtest.h" 31 | 32 | namespace { 33 | class DummyTest : public ::testing::TestWithParam {}; 34 | 35 | TEST_P(DummyTest, Dummy) {} 36 | 37 | INSTANTIATE_TEST_SUITE_P(InvalidTestName, DummyTest, 38 | ::testing::Values("InvalidWithQuotes"), 39 | ::testing::PrintToStringParamName()); 40 | 41 | } // namespace 42 | 43 | int main(int argc, char *argv[]) { 44 | testing::InitGoogleTest(&argc, argv); 45 | return RUN_ALL_TESTS(); 46 | } 47 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_skip_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: arseny.aprelev@gmail.com (Arseny Aprelev) 31 | // 32 | 33 | #include "gtest/gtest.h" 34 | 35 | using ::testing::Test; 36 | 37 | TEST(SkipTest, DoesSkip) { 38 | GTEST_SKIP() << "skipping single test"; 39 | EXPECT_EQ(0, 1); 40 | } 41 | 42 | class Fixture : public Test { 43 | protected: 44 | void SetUp() override { 45 | GTEST_SKIP() << "skipping all tests for this fixture"; 46 | } 47 | }; 48 | 49 | TEST_F(Fixture, SkipsOneTest) { EXPECT_EQ(5, 7); } 50 | 51 | TEST_F(Fixture, SkipsAnotherTest) { EXPECT_EQ(99, 100); } 52 | -------------------------------------------------------------------------------- /deps/googletest/googletest/samples/sample4_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "sample4.h" 31 | 32 | #include "gtest/gtest.h" 33 | 34 | namespace { 35 | // Tests the Increment() method. 36 | 37 | TEST(Counter, Increment) { 38 | Counter c; 39 | 40 | // Test that counter 0 returns 0 41 | EXPECT_EQ(0, c.Decrement()); 42 | 43 | // EXPECT_EQ() evaluates its arguments exactly once, so they 44 | // can have side effects. 45 | 46 | EXPECT_EQ(0, c.Increment()); 47 | EXPECT_EQ(1, c.Increment()); 48 | EXPECT_EQ(2, c.Increment()); 49 | 50 | EXPECT_EQ(3, c.Decrement()); 51 | } 52 | 53 | } // namespace 54 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_help_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // This program is meant to be run by gtest_help_test.py. Do not run 31 | // it directly. 32 | 33 | #include "gtest/gtest.h" 34 | 35 | // When a help flag is specified, this program should skip the tests 36 | // and exit with 0; otherwise the following test will be executed, 37 | // causing this program to exit with a non-zero code. 38 | TEST(HelpFlagTest, ShouldNotBeRun) { 39 | ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; 40 | } 41 | 42 | #if GTEST_HAS_DEATH_TEST 43 | TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} 44 | #endif 45 | -------------------------------------------------------------------------------- /deps/googletest/googletest/include/gtest/internal/custom/gtest-printers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // This file provides an injection point for custom printers in a local 31 | // installation of gTest. 32 | // It will be included from gtest-printers.h and the overrides in this file 33 | // will be visible to everyone. 34 | // 35 | // Injection point for custom user configurations. See README for details 36 | // 37 | // ** Custom implementation starts here ** 38 | 39 | #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 40 | #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 41 | 42 | #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 43 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/src/gmock-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Google C++ Mocking Framework (Google Mock) 32 | // 33 | // This file #includes all Google Mock implementation .cc files. The 34 | // purpose is to allow a user to build Google Mock by compiling this 35 | // file alone. 36 | 37 | // This line ensures that gmock.h can be compiled on its own, even 38 | // when it's fused. 39 | #include "gmock/gmock.h" 40 | 41 | // The following lines pull in the real gmock *.cc files. 42 | #include "src/gmock-cardinalities.cc" 43 | #include "src/gmock-internal-utils.cc" 44 | #include "src/gmock-matchers.cc" 45 | #include "src/gmock-spec-builders.cc" 46 | #include "src/gmock.cc" 47 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_skip_in_environment_setup_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2019, Google LLC. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google LLC. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // This test verifies that skipping in the environment results in the 31 | // testcases being skipped. 32 | 33 | #include 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class SetupEnvironment : public testing::Environment { 38 | public: 39 | void SetUp() override { GTEST_SKIP() << "Skipping the entire environment"; } 40 | }; 41 | 42 | TEST(Test, AlwaysFails) { EXPECT_EQ(true, false); } 43 | 44 | int main(int argc, char **argv) { 45 | testing::InitGoogleTest(&argc, argv); 46 | 47 | testing::AddGlobalTestEnvironment(new SetupEnvironment()); 48 | 49 | return RUN_ALL_TESTS(); 50 | } 51 | -------------------------------------------------------------------------------- /deps/googletest/googletest/samples/sample4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #include "sample4.h" 33 | 34 | #include 35 | 36 | // Returns the current counter value, and increments it. 37 | int Counter::Increment() { return counter_++; } 38 | 39 | // Returns the current counter value, and decrements it. 40 | // counter can not be less than 0, return 0 in this case 41 | int Counter::Decrement() { 42 | if (counter_ == 0) { 43 | return counter_; 44 | } else { 45 | return counter_--; 46 | } 47 | } 48 | 49 | // Prints the current counter value to STDOUT. 50 | void Counter::Print() const { printf("%d", counter_); } 51 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/googletest-param-test-invalid-name2-test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include "gtest/gtest.h" 31 | 32 | namespace { 33 | class DummyTest : public ::testing::TestWithParam {}; 34 | 35 | std::string StringParamTestSuffix( 36 | const testing::TestParamInfo &info) { 37 | return std::string(info.param); 38 | } 39 | 40 | TEST_P(DummyTest, Dummy) {} 41 | 42 | INSTANTIATE_TEST_SUITE_P(DuplicateTestNames, DummyTest, 43 | ::testing::Values("a", "b", "a", "c"), 44 | StringParamTestSuffix); 45 | } // namespace 46 | 47 | int main(int argc, char *argv[]) { 48 | testing::InitGoogleTest(&argc, argv); 49 | return RUN_ALL_TESTS(); 50 | } 51 | -------------------------------------------------------------------------------- /deps/googletest/googletest/samples/sample4.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | #ifndef GOOGLETEST_SAMPLES_SAMPLE4_H_ 32 | #define GOOGLETEST_SAMPLES_SAMPLE4_H_ 33 | 34 | // A simple monotonic counter. 35 | class Counter { 36 | private: 37 | int counter_; 38 | 39 | public: 40 | // Creates a counter that starts at 0. 41 | Counter() : counter_(0) {} 42 | 43 | // Returns the current counter value, and increments it. 44 | int Increment(); 45 | 46 | // Returns the current counter value, and decrements it. 47 | int Decrement(); 48 | 49 | // Prints the current counter value to STDOUT. 50 | void Print() const; 51 | }; 52 | 53 | #endif // GOOGLETEST_SAMPLES_SAMPLE4_H_ 54 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/production.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // This is part of the unit test for gtest_prod.h. 32 | 33 | #ifndef GOOGLETEST_TEST_PRODUCTION_H_ 34 | #define GOOGLETEST_TEST_PRODUCTION_H_ 35 | 36 | #include "gtest/gtest_prod.h" 37 | 38 | class PrivateCode { 39 | public: 40 | // Declares a friend test that does not use a fixture. 41 | FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers); 42 | 43 | // Declares a friend test that uses a fixture. 44 | FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers); 45 | 46 | PrivateCode(); 47 | 48 | int x() const { return x_; } 49 | 50 | private: 51 | void set_x(int an_x) { x_ = an_x; } 52 | int x_; 53 | }; 54 | 55 | #endif // GOOGLETEST_TEST_PRODUCTION_H_ 56 | -------------------------------------------------------------------------------- /src/execution/executor_abstract.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "execution_defs.h" 4 | #include "execution_manager.h" 5 | #include "index/ix.h" 6 | #include "system/sm.h" 7 | 8 | class AbstractExecutor { 9 | public: 10 | Rid _abstract_rid; 11 | 12 | Context *context_; 13 | 14 | virtual ~AbstractExecutor() = default; 15 | 16 | virtual size_t tupleLen() const { return 0; }; 17 | 18 | virtual const std::vector &cols() const { 19 | std::vector *_cols = nullptr; 20 | return *_cols; 21 | }; 22 | 23 | virtual std::string getType() { return "AbstractExecutor"; }; 24 | 25 | virtual void beginTuple(){}; 26 | 27 | virtual void nextTuple(){}; 28 | 29 | virtual bool is_end() const { return true; }; 30 | 31 | virtual Rid &rid() = 0; 32 | 33 | virtual std::unique_ptr Next() = 0; 34 | 35 | virtual void feed(const std::map &feed_dict){}; 36 | 37 | std::vector::const_iterator get_col(const std::vector &rec_cols, const TabCol &target) { 38 | auto pos = std::find_if(rec_cols.begin(), rec_cols.end(), [&](const ColMeta &col) { 39 | return col.tab_name == target.tab_name && col.name == target.col_name; 40 | }); 41 | if (pos == rec_cols.end()) { 42 | throw ColumnNotFoundError(target.tab_name + '.' + target.col_name); 43 | } 44 | return pos; 45 | } 46 | 47 | std::map rec2dict(const std::vector &cols, const RmRecord *rec) { 48 | std::map rec_dict; 49 | for (auto &col : cols) { 50 | TabCol key = {.tab_name = col.tab_name, .col_name = col.name}; 51 | Value val; 52 | char *val_buf = rec->data + col.offset; 53 | if (col.type == TYPE_INT) { 54 | val.set_int(*(int *)val_buf); 55 | } else if (col.type == TYPE_FLOAT) { 56 | val.set_float(*(float *)val_buf); 57 | } else if (col.type == TYPE_STRING) { 58 | std::string str_val((char *)val_buf, col.len); 59 | str_val.resize(strlen(str_val.c_str())); 60 | val.set_str(str_val); 61 | } 62 | assert(rec_dict.count(key) == 0); 63 | val.init_raw(col.len); 64 | rec_dict[key] = val; 65 | } 66 | return rec_dict; 67 | } 68 | }; -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_prod_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Unit test for gtest_prod.h. 32 | 33 | #include "production.h" 34 | #include "gtest/gtest.h" 35 | 36 | // Tests that private members can be accessed from a TEST declared as 37 | // a friend of the class. 38 | TEST(PrivateCodeTest, CanAccessPrivateMembers) { 39 | PrivateCode a; 40 | EXPECT_EQ(0, a.x_); 41 | 42 | a.set_x(1); 43 | EXPECT_EQ(1, a.x_); 44 | } 45 | 46 | typedef testing::Test PrivateCodeFixtureTest; 47 | 48 | // Tests that private members can be accessed from a TEST_F declared 49 | // as a friend of the class. 50 | TEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) { 51 | PrivateCode a; 52 | EXPECT_EQ(0, a.x_); 53 | 54 | a.set_x(2); 55 | EXPECT_EQ(2, a.x_); 56 | } 57 | -------------------------------------------------------------------------------- /src/execution/executor_projection.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "execution_defs.h" 3 | #include "execution_manager.h" 4 | #include "executor_abstract.h" 5 | #include "index/ix.h" 6 | #include "system/sm.h" 7 | 8 | class ProjectionExecutor : public AbstractExecutor { 9 | private: 10 | std::unique_ptr prev_; 11 | std::vector cols_; 12 | size_t len_; 13 | std::vector sel_idxs_; 14 | 15 | public: 16 | ProjectionExecutor(std::unique_ptr prev, const std::vector &sel_cols) { 17 | prev_ = std::move(prev); 18 | 19 | size_t curr_offset = 0; 20 | auto &prev_cols = prev_->cols(); 21 | for (auto &sel_col : sel_cols) { 22 | auto pos = get_col(prev_cols, sel_col); 23 | sel_idxs_.push_back(pos - prev_cols.begin()); 24 | auto col = *pos; 25 | col.offset = curr_offset; 26 | curr_offset += col.len; 27 | cols_.push_back(col); 28 | } 29 | len_ = curr_offset; 30 | } 31 | 32 | std::string getType() override { return "Projection"; } 33 | 34 | size_t tupleLen() const override { return len_; } 35 | 36 | const std::vector &cols() const override { return cols_; } 37 | 38 | void beginTuple() override { prev_->beginTuple(); } 39 | 40 | void nextTuple() override { 41 | assert(!prev_->is_end()); 42 | prev_->nextTuple(); 43 | } 44 | 45 | bool is_end() const override { return prev_->is_end(); } 46 | 47 | std::unique_ptr Next() override { 48 | assert(!is_end()); 49 | auto &prev_cols = prev_->cols(); 50 | auto prev_rec = prev_->Next(); 51 | auto &proj_cols = cols_; 52 | auto proj_rec = std::make_unique(len_); 53 | for (size_t proj_idx = 0; proj_idx < proj_cols.size(); proj_idx++) { 54 | size_t prev_idx = sel_idxs_[proj_idx]; 55 | auto &prev_col = prev_cols[prev_idx]; 56 | auto &proj_col = proj_cols[proj_idx]; 57 | // 查询执行 task2 Todo 58 | // 利用memcpy生成proj_rec 59 | // 查询执行 task2 Todo End 60 | } 61 | return proj_rec; 62 | } 63 | 64 | void feed(const std::map &feed_dict) override { 65 | throw InternalError("Cannot feed a projection node"); 66 | } 67 | Rid &rid() override { return _abstract_rid; } 68 | }; -------------------------------------------------------------------------------- /deps/googletest/googletest/src/gtest-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Google C++ Testing and Mocking Framework (Google Test) 32 | // 33 | // Sometimes it's desirable to build Google Test by compiling a single file. 34 | // This file serves this purpose. 35 | 36 | // This line ensures that gtest.h can be compiled on its own, even 37 | // when it's fused. 38 | #include "gtest/gtest.h" 39 | 40 | // The following lines pull in the real gtest *.cc files. 41 | #include "src/gtest-assertion-result.cc" 42 | #include "src/gtest-death-test.cc" 43 | #include "src/gtest-filepath.cc" 44 | #include "src/gtest-matchers.cc" 45 | #include "src/gtest-port.cc" 46 | #include "src/gtest-printers.cc" 47 | #include "src/gtest-test-part.cc" 48 | #include "src/gtest-typed-test.cc" 49 | #include "src/gtest.cc" 50 | -------------------------------------------------------------------------------- /src/record_printer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "common/context.h" 9 | 10 | class RecordPrinter { 11 | static constexpr size_t COL_WIDTH = 16; 12 | size_t num_cols; 13 | public: 14 | RecordPrinter(size_t num_cols_) : num_cols(num_cols_) { 15 | assert(num_cols_ > 0); 16 | } 17 | 18 | void print_separator(Context *context) const { 19 | for (size_t i = 0; i < num_cols; i++) { 20 | // std::cout << '+' << std::string(COL_WIDTH + 2, '-'); 21 | std::string str = "+" + std::string(COL_WIDTH + 2, '-'); 22 | memcpy(context->data_send_ + *(context->offset_), str.c_str(), str.length()); 23 | *(context->offset_) = *(context->offset_) + str.length(); 24 | } 25 | std::string str = "+\n"; 26 | memcpy(context->data_send_ + *(context->offset_), str.c_str(), str.length()); 27 | *(context->offset_) = *(context->offset_) + str.length(); 28 | // std::cout << "+\n"; 29 | } 30 | 31 | void print_record(const std::vector &rec_str, Context *context) const { 32 | assert(rec_str.size() == num_cols); 33 | for (auto col: rec_str) { 34 | if (col.size() > COL_WIDTH) { 35 | col = col.substr(0, COL_WIDTH - 3) + "..."; 36 | } 37 | // std::cout << "| " << std::setw(COL_WIDTH) << col << ' '; 38 | std::stringstream ss; 39 | ss << "| " << std::setw(COL_WIDTH) << col << " "; 40 | memcpy(context->data_send_ + *(context->offset_), ss.str().c_str(), ss.str().length()); 41 | *(context->offset_) = *(context->offset_) + ss.str().length(); 42 | } 43 | // std::cout << "|\n"; 44 | std::string str = "|\n"; 45 | memcpy(context->data_send_ + *(context->offset_), str.c_str(), str.length()); 46 | *(context->offset_) = *(context->offset_) + str.length(); 47 | } 48 | 49 | static void print_record_count(size_t num_rec, Context *context) { 50 | // std::cout << "Total record(s): " << num_rec << '\n'; 51 | std::string str = "Total record(s): " + std::to_string(num_rec) + '\n'; 52 | memcpy(context->data_send_ + *(context->offset_), str.c_str(), str.length()); 53 | *(context->offset_) = *(context->offset_) + str.length(); 54 | } 55 | }; 56 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_sole_header_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // This test verifies that it's possible to use Google Test by including 32 | // the gtest.h header file alone. 33 | 34 | #include "gtest/gtest.h" 35 | 36 | namespace { 37 | 38 | void Subroutine() { EXPECT_EQ(42, 42); } 39 | 40 | TEST(NoFatalFailureTest, ExpectNoFatalFailure) { 41 | EXPECT_NO_FATAL_FAILURE(;); 42 | EXPECT_NO_FATAL_FAILURE(SUCCEED()); 43 | EXPECT_NO_FATAL_FAILURE(Subroutine()); 44 | EXPECT_NO_FATAL_FAILURE({ SUCCEED(); }); 45 | } 46 | 47 | TEST(NoFatalFailureTest, AssertNoFatalFailure) { 48 | ASSERT_NO_FATAL_FAILURE(;); 49 | ASSERT_NO_FATAL_FAILURE(SUCCEED()); 50 | ASSERT_NO_FATAL_FAILURE(Subroutine()); 51 | ASSERT_NO_FATAL_FAILURE({ SUCCEED(); }); 52 | } 53 | 54 | } // namespace 55 | -------------------------------------------------------------------------------- /src/execution/executor_update.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "execution_defs.h" 3 | #include "execution_manager.h" 4 | #include "executor_abstract.h" 5 | #include "index/ix.h" 6 | #include "system/sm.h" 7 | 8 | class UpdateExecutor : public AbstractExecutor { 9 | private: 10 | TabMeta tab_; 11 | std::vector conds_; 12 | RmFileHandle *fh_; 13 | std::vector rids_; 14 | std::string tab_name_; 15 | std::vector set_clauses_; 16 | SmManager *sm_manager_; 17 | 18 | public: 19 | UpdateExecutor(SmManager *sm_manager, const std::string &tab_name, std::vector set_clauses, 20 | std::vector conds, std::vector rids, Context *context) { 21 | sm_manager_ = sm_manager; 22 | tab_name_ = tab_name; 23 | set_clauses_ = set_clauses; 24 | tab_ = sm_manager_->db_.get_table(tab_name); 25 | fh_ = sm_manager_->fhs_.at(tab_name).get(); 26 | conds_ = conds; 27 | rids_ = rids; 28 | context_ = context; 29 | } 30 | std::unique_ptr Next() override { 31 | // Get all necessary index files 32 | std::vector ihs(tab_.cols.size(), nullptr); 33 | for (auto &set_clause : set_clauses_) { 34 | auto lhs_col = tab_.get_col(set_clause.lhs.col_name); 35 | if (lhs_col->index) { 36 | size_t lhs_col_idx = lhs_col - tab_.cols.begin(); 37 | // 查询执行 task3 Todo 38 | // 获取需要的索引句柄,填充vector ihs 39 | // 查询执行 task3 Todo end 40 | } 41 | } 42 | // Update each rid from record file and index file 43 | for (auto &rid : rids_) { 44 | auto rec = fh_->get_record(rid, context_); 45 | // 查询执行 task3 Todo 46 | // Remove old entry from index 47 | // 查询执行 task3 Todo end 48 | 49 | // record a update operation into the transaction 50 | RmRecord update_record{rec->size}; 51 | memcpy(update_record.data, rec->data, rec->size); 52 | 53 | // 查询执行 task3 Todo 54 | // Update record in record file 55 | // 查询执行 task3 Todo end 56 | 57 | // 查询执行 task3 Todo 58 | // Insert new entry into index 59 | // 查询执行 task3 Todo end 60 | } 61 | return nullptr; 62 | } 63 | Rid &rid() override { return _abstract_rid; } 64 | }; -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_all_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Tests for Google C++ Testing and Mocking Framework (Google Test) 32 | // 33 | // Sometimes it's desirable to build most of Google Test's own tests 34 | // by compiling a single file. This file serves this purpose. 35 | #include "test/googletest-filepath-test.cc" 36 | #include "test/googletest-message-test.cc" 37 | #include "test/googletest-options-test.cc" 38 | #include "test/googletest-port-test.cc" 39 | #include "test/googletest-test-part-test.cc" 40 | #include "test/gtest-typed-test2_test.cc" 41 | #include "test/gtest-typed-test_test.cc" 42 | #include "test/gtest_pred_impl_unittest.cc" 43 | #include "test/gtest_prod_test.cc" 44 | #include "test/gtest_skip_test.cc" 45 | #include "test/gtest_unittest.cc" 46 | #include "test/production.cc" 47 | -------------------------------------------------------------------------------- /deps/googletest/googletest/samples/sample2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #include "sample2.h" 33 | 34 | #include 35 | 36 | // Clones a 0-terminated C string, allocating memory using new. 37 | const char* MyString::CloneCString(const char* a_c_string) { 38 | if (a_c_string == nullptr) return nullptr; 39 | 40 | const size_t len = strlen(a_c_string); 41 | char* const clone = new char[len + 1]; 42 | memcpy(clone, a_c_string, len + 1); 43 | 44 | return clone; 45 | } 46 | 47 | // Sets the 0-terminated C string this MyString object 48 | // represents. 49 | void MyString::Set(const char* a_c_string) { 50 | // Makes sure this works when c_string == c_string_ 51 | const char* const temp = MyString::CloneCString(a_c_string); 52 | delete[] c_string_; 53 | c_string_ = temp; 54 | } 55 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_skip_environment_check_output_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2019 Google LLC. All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """Tests Google Test's gtest skip in environment setup behavior. 31 | 32 | This script invokes gtest_skip_in_environment_setup_test_ and verifies its 33 | output. 34 | """ 35 | 36 | from googletest.test import gtest_test_utils 37 | 38 | # Path to the gtest_skip_in_environment_setup_test binary 39 | EXE_PATH = gtest_test_utils.GetTestExecutablePath( 40 | 'gtest_skip_in_environment_setup_test') 41 | 42 | OUTPUT = gtest_test_utils.Subprocess([EXE_PATH]).output 43 | 44 | 45 | # Test. 46 | class SkipEntireEnvironmentTest(gtest_test_utils.TestCase): 47 | 48 | def testSkipEntireEnvironmentTest(self): 49 | self.assertIn('Skipping the entire environment', OUTPUT) 50 | self.assertNotIn('FAILED', OUTPUT) 51 | 52 | 53 | if __name__ == '__main__': 54 | gtest_test_utils.Main() 55 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/googletest-param-test-test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // The Google C++ Testing and Mocking Framework (Google Test) 31 | // 32 | // This header file provides classes and functions used internally 33 | // for testing Google Test itself. 34 | 35 | #ifndef GOOGLETEST_TEST_GOOGLETEST_PARAM_TEST_TEST_H_ 36 | #define GOOGLETEST_TEST_GOOGLETEST_PARAM_TEST_TEST_H_ 37 | 38 | #include "gtest/gtest.h" 39 | 40 | // Test fixture for testing definition and instantiation of a test 41 | // in separate translation units. 42 | class ExternalInstantiationTest : public ::testing::TestWithParam {}; 43 | 44 | // Test fixture for testing instantiation of a test in multiple 45 | // translation units. 46 | class InstantiationInMultipleTranslationUnitsTest 47 | : public ::testing::TestWithParam {}; 48 | 49 | #endif // GOOGLETEST_TEST_GOOGLETEST_PARAM_TEST_TEST_H_ 50 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/googletest-setuptestsuite-test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2019, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | """Verifies that SetUpTestSuite and TearDownTestSuite errors are noticed.""" 33 | 34 | from googletest.test import gtest_test_utils 35 | 36 | COMMAND = gtest_test_utils.GetTestExecutablePath( 37 | 'googletest-setuptestsuite-test_') 38 | 39 | 40 | class GTestSetUpTestSuiteTest(gtest_test_utils.TestCase): 41 | 42 | def testSetupErrorAndTearDownError(self): 43 | p = gtest_test_utils.Subprocess(COMMAND) 44 | self.assertNotEqual(p.exit_code, 0, msg=p.output) 45 | 46 | self.assertIn( 47 | '[ FAILED ] SetupFailTest: SetUpTestSuite or TearDownTestSuite\n' 48 | '[ FAILED ] TearDownFailTest: SetUpTestSuite or TearDownTestSuite\n' 49 | '\n' 50 | ' 2 FAILED TEST SUITES\n', 51 | p.output) 52 | 53 | if __name__ == '__main__': 54 | gtest_test_utils.Main() 55 | -------------------------------------------------------------------------------- /deps/googletest/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Benoit Sigoure 9 | Bharat Mediratta 10 | Bogdan Piloca 11 | Chandler Carruth 12 | Chris Prince 13 | Chris Taylor 14 | Dan Egnor 15 | Dave MacLachlan 16 | David Anderson 17 | Dean Sturtevant 18 | Eric Roman 19 | Gene Volovich 20 | Hady Zalek 21 | Hal Burch 22 | Jeffrey Yasskin 23 | Jim Keller 24 | Joe Walnes 25 | Jon Wray 26 | Jói Sigurðsson 27 | Keir Mierle 28 | Keith Ray 29 | Kenton Varda 30 | Kostya Serebryany 31 | Krystian Kuzniarek 32 | Lev Makhlis 33 | Manuel Klimek 34 | Mario Tanev 35 | Mark Paskin 36 | Markus Heule 37 | Martijn Vels 38 | Matthew Simmons 39 | Mika Raento 40 | Mike Bland 41 | Miklós Fazekas 42 | Neal Norwitz 43 | Nermin Ozkiranartli 44 | Owen Carlsen 45 | Paneendra Ba 46 | Pasi Valminen 47 | Patrick Hanna 48 | Patrick Riley 49 | Paul Menage 50 | Peter Kaminski 51 | Piotr Kaminski 52 | Preston Jackson 53 | Rainer Klaffenboeck 54 | Russ Cox 55 | Russ Rufer 56 | Sean Mcafee 57 | Sigurður Ásgeirsson 58 | Sverre Sundsdal 59 | Szymon Sobik 60 | Takeshi Yoshino 61 | Tracy Bialik 62 | Vadim Berman 63 | Vlad Losev 64 | Wolfgang Klier 65 | Zhanyong Wan 66 | -------------------------------------------------------------------------------- /src/transaction/transaction_manager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "transaction.h" 7 | #include "recovery/log_manager.h" 8 | #include "concurrency/lock_manager.h" 9 | #include "system/sm_manager.h" 10 | 11 | enum class ConcurrencyMode { TWO_PHASE_LOCKING = 0, BASIC_TO }; 12 | 13 | class TransactionManager{ 14 | public: 15 | explicit TransactionManager(LockManager *lock_manager, SmManager *sm_manager, 16 | ConcurrencyMode concurrency_mode = ConcurrencyMode::TWO_PHASE_LOCKING) { 17 | sm_manager_ = sm_manager; 18 | lock_manager_ = lock_manager; 19 | concurrency_mode_ = concurrency_mode; 20 | } 21 | 22 | ~TransactionManager() = default; 23 | 24 | Transaction * Begin(Transaction * txn, LogManager *log_manager); 25 | 26 | void Commit(Transaction * txn, LogManager *log_manager); 27 | 28 | void Abort(Transaction * txn, LogManager *log_manager); 29 | 30 | ConcurrencyMode GetConcurrencyMode() { return concurrency_mode_; } 31 | 32 | void SetConcurrencyMode(ConcurrencyMode concurrency_mode) { concurrency_mode_ = concurrency_mode; } 33 | 34 | LockManager *GetLockManager() { return lock_manager_; } 35 | 36 | /** 37 | * 获取对应ID的事务指针 38 | * @param txn_id 事务ID 39 | * @return 对应事务对象的指针 40 | */ 41 | Transaction *GetTransaction(txn_id_t txn_id) { 42 | if(txn_id == INVALID_TXN_ID) return nullptr; 43 | 44 | assert(TransactionManager::txn_map.find(txn_id) != TransactionManager::txn_map.end()); 45 | 46 | auto *res = TransactionManager::txn_map[txn_id]; 47 | assert(res != nullptr); 48 | assert(res->GetThreadId() == std::this_thread::get_id()); 49 | return res; 50 | } 51 | 52 | // used for test 53 | inline txn_id_t GetNextTxnId() { return next_txn_id_; } 54 | 55 | // global map of transactions which are running in the system. 56 | static std::unordered_map txn_map; 57 | 58 | /** 59 | * @brief used for checkpoint 60 | */ 61 | void BlockAllTransactions(); 62 | void ResumeAllTransactions(); 63 | 64 | private: 65 | ConcurrencyMode concurrency_mode_; // 事务使用的并发控制算法,目前只需要考虑2PL 66 | // Transaction * current_txn_; 67 | std::atomic next_txn_id_{0}; // 用于分发事务ID 68 | std::atomic next_timestamp_{0}; // 用于分发事务时间戳 69 | SmManager *sm_manager_; 70 | LockManager *lock_manager_; 71 | }; -------------------------------------------------------------------------------- /src/record/rm_manager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "bitmap.h" 6 | #include "rm_defs.h" 7 | #include "rm_file_handle.h" 8 | 9 | //只用于创建/打开/关闭/删除文件,打开文件的时候会返回record file handle 10 | //它可以管理多个record文件(管理多个record file handle) 11 | class RmManager { 12 | private: 13 | DiskManager *disk_manager_; 14 | BufferPoolManager *buffer_pool_manager_; 15 | 16 | public: 17 | RmManager(DiskManager *disk_manager, BufferPoolManager *buffer_pool_manager) 18 | : disk_manager_(disk_manager), buffer_pool_manager_(buffer_pool_manager) {} 19 | 20 | void create_file(const std::string &filename, int record_size) { 21 | if (record_size < 1 || record_size > RM_MAX_RECORD_SIZE) { 22 | throw InvalidRecordSizeError(record_size); 23 | } 24 | disk_manager_->create_file(filename); 25 | int fd = disk_manager_->open_file(filename); 26 | 27 | // 初始化file header 28 | RmFileHdr file_hdr{}; 29 | file_hdr.record_size = record_size; 30 | file_hdr.num_pages = 1; 31 | file_hdr.first_free_page_no = RM_NO_PAGE; 32 | // We have: sizeof(hdr) + (n + 7) / 8 + n * record_size <= PAGE_SIZE 33 | file_hdr.num_records_per_page = 34 | (BITMAP_WIDTH * (PAGE_SIZE - 1 - (int)sizeof(RmFileHdr)) + 1) / (1 + record_size * BITMAP_WIDTH); 35 | file_hdr.bitmap_size = (file_hdr.num_records_per_page + BITMAP_WIDTH - 1) / BITMAP_WIDTH; 36 | 37 | // 将file header写入磁盘文件(名为file name,文件描述符为fd)中的第0页 38 | // head page直接写入磁盘,没有经过缓冲区的NewPage,那么也就不需要FlushPage 39 | disk_manager_->write_page(fd, RM_FILE_HDR_PAGE, (char *)&file_hdr, sizeof(file_hdr)); 40 | disk_manager_->close_file(fd); 41 | } 42 | 43 | void destroy_file(const std::string &filename) { disk_manager_->destroy_file(filename); } 44 | 45 | // 注意这里打开文件,创建并返回了record file handle的指针 46 | std::unique_ptr open_file(const std::string &filename) { 47 | int fd = disk_manager_->open_file(filename); 48 | return std::make_unique(disk_manager_, buffer_pool_manager_, fd); 49 | } 50 | 51 | void close_file(const RmFileHandle *file_handle) { 52 | disk_manager_->write_page(file_handle->fd_, RM_FILE_HDR_PAGE, (char *)&file_handle->file_hdr_, 53 | sizeof(file_handle->file_hdr_)); 54 | // 缓冲区的所有页刷到磁盘,注意这句话必须写在close_file前面 55 | buffer_pool_manager_->FlushAllPages(file_handle->fd_); 56 | disk_manager_->close_file(file_handle->fd_); 57 | } 58 | }; 59 | -------------------------------------------------------------------------------- /deps/googletest/docs/_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {% seo %} 9 | 10 | 18 | 19 | 20 | 21 | 44 |
45 |
46 | {{ content }} 47 |
48 | 54 |
55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/googletest-global-environment-unittest_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Unit test for Google Test global test environments. 31 | // 32 | // The program will be invoked from a Python unit test. Don't run it 33 | // directly. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | namespace { 38 | 39 | // An environment that always fails in its SetUp method. 40 | class FailingEnvironment final : public ::testing::Environment { 41 | public: 42 | void SetUp() override { FAIL() << "Canned environment setup error"; } 43 | }; 44 | 45 | // Register the environment. 46 | auto* const g_environment_ = 47 | ::testing::AddGlobalTestEnvironment(new FailingEnvironment); 48 | 49 | // A test that doesn't actually run. 50 | TEST(SomeTest, DoesFoo) { FAIL() << "Unexpected call"; } 51 | 52 | } // namespace 53 | 54 | int main(int argc, char** argv) { 55 | ::testing::InitGoogleTest(&argc, argv); 56 | 57 | return RUN_ALL_TESTS(); 58 | } 59 | -------------------------------------------------------------------------------- /src/common/config.h: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // BusTub 4 | // 5 | // config.h 6 | // 7 | // Identification: src/include/common/config.h 8 | // 9 | // Copyright (c) 2015-2019, Carnegie Mellon University Database Group 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #pragma once 14 | 15 | #include 16 | #include // NOLINT 17 | #include 18 | 19 | /** Cycle detection is performed every CYCLE_DETECTION_INTERVAL milliseconds. */ 20 | extern std::chrono::milliseconds cycle_detection_interval; 21 | 22 | /** True if logging should be enabled, false otherwise. */ 23 | extern std::atomic enable_logging; 24 | 25 | /** If ENABLE_LOGGING is true, the log should be flushed to disk every LOG_TIMEOUT. */ 26 | extern std::chrono::duration log_timeout; 27 | 28 | static constexpr int INVALID_FRAME_ID = -1; // invalid frame id 29 | static constexpr int INVALID_PAGE_ID = -1; // invalid page id 30 | static constexpr int INVALID_TXN_ID = -1; // invalid transaction id 31 | static constexpr int INVALID_TIMESTAMP = -1; // invalid transaction timestamp 32 | static constexpr int INVALID_LSN = -1; // invalid log sequence number 33 | static constexpr int HEADER_PAGE_ID = 0; // the header page id 34 | static constexpr int PAGE_SIZE = 4096; // size of a data page in byte 35 | static constexpr int BUFFER_POOL_SIZE = 65536; // size of buffer pool 36 | static constexpr int LOG_BUFFER_SIZE = ((BUFFER_POOL_SIZE + 1) * PAGE_SIZE); // size of a log buffer in byte 37 | static constexpr int BUCKET_SIZE = 50; // size of extendible hash bucket 38 | 39 | using frame_id_t = int32_t; // frame id type, 帧页ID, 页在BufferPool中的存储单元称为帧,一帧对应一页 40 | using page_id_t = int32_t; // page id type , 页ID 41 | using txn_id_t = int32_t; // transaction id type 42 | using lsn_t = int32_t; // log sequence number type 43 | using slot_offset_t = size_t; // slot offset type 44 | using oid_t = uint16_t; 45 | using timestamp_t = int32_t; // timestamp type, used for transaction concurrency 46 | 47 | // log file 48 | static const std::string LOG_FILE_NAME = "db.log"; 49 | 50 | // replacer 51 | static const std::string REPLACER_TYPE = "LRU"; 52 | -------------------------------------------------------------------------------- /src/record/rm_defs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common/macros.h" 4 | #include "defs.h" 5 | #include "storage/buffer_pool_manager.h" 6 | 7 | constexpr int RM_NO_PAGE = -1; 8 | constexpr int RM_FILE_HDR_PAGE = 0; 9 | constexpr int RM_FIRST_RECORD_PAGE = 1; 10 | constexpr int RM_MAX_RECORD_SIZE = 512; 11 | 12 | // record file header(RmManager::create_file函数初始化,并写入磁盘文件中的第0页) 13 | struct RmFileHdr { 14 | int record_size; // 元组大小(长度不固定,由上层进行初始化) 15 | // std::atomic num_pages; 16 | int num_pages; // 文件中当前分配的page个数(初始化为1) 17 | int num_records_per_page; // 每个page最多能存储的元组个数 18 | int first_free_page_no; // 文件中当前第一个可用的page no(初始化为-1) 19 | int bitmap_size; // bitmap大小 20 | }; 21 | 22 | // record page header(RmFileHandle::create_page函数进行初始化) 23 | struct RmPageHdr { 24 | int next_free_page_no; // 当前page满了之后,下一个可用的page no(初始化为-1) 25 | int num_records; // 当前page中当前分配的record个数(初始化为0) 26 | }; 27 | 28 | // 类似于Tuple 29 | struct RmRecord { 30 | char *data; // data初始化分配size个字节的空间 31 | int size; // size = RmFileHdr的record_size 32 | bool allocated_ = false; 33 | 34 | // DISALLOW_COPY(RmRecord); 35 | // RmRecord(const RmRecord &other) = delete; 36 | // RmRecord &operator=(const RmRecord &other) = delete; 37 | 38 | RmRecord() = default; 39 | 40 | RmRecord(const RmRecord &other) { 41 | size = other.size; 42 | data = new char[size]; 43 | memcpy(data, other.data, size); 44 | allocated_ = true; 45 | }; 46 | 47 | RmRecord &operator=(const RmRecord &other) { 48 | size = other.size; 49 | data = new char[size]; 50 | memcpy(data, other.data, size); 51 | allocated_ = true; 52 | return *this; 53 | }; 54 | 55 | RmRecord(int size_) { 56 | size = size_; 57 | data = new char[size_]; 58 | allocated_ = true; 59 | } 60 | 61 | RmRecord(int size_, char *data_) { 62 | size = size_; 63 | data = new char[size_]; 64 | memcpy(data, data_, size_); 65 | allocated_ = true; 66 | } 67 | 68 | void SetData(char *data_) { 69 | memcpy(data, data_, size); 70 | } 71 | 72 | void Deserialize(const char *data_) { 73 | size = *reinterpret_cast(data_); 74 | delete[] data; 75 | data = new char[size]; 76 | memcpy(data, data_ + sizeof(int), size); 77 | } 78 | 79 | ~RmRecord() { 80 | if(allocated_) { 81 | delete[] data; 82 | } 83 | allocated_ = false; 84 | data = nullptr; 85 | } 86 | }; 87 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_no_test_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Tests that a Google Test program that has no test defined can run 31 | // successfully. 32 | 33 | #include "gtest/gtest.h" 34 | 35 | int main(int argc, char **argv) { 36 | testing::InitGoogleTest(&argc, argv); 37 | 38 | // An ad-hoc assertion outside of all tests. 39 | // 40 | // This serves three purposes: 41 | // 42 | // 1. It verifies that an ad-hoc assertion can be executed even if 43 | // no test is defined. 44 | // 2. It verifies that a failed ad-hoc assertion causes the test 45 | // program to fail. 46 | // 3. We had a bug where the XML output won't be generated if an 47 | // assertion is executed before RUN_ALL_TESTS() is called, even 48 | // though --gtest_output=xml is specified. This makes sure the 49 | // bug is fixed and doesn't regress. 50 | EXPECT_EQ(1, 2); 51 | 52 | // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero. 53 | return RUN_ALL_TESTS() ? 0 : 1; 54 | } 55 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest-typed-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #ifndef GOOGLETEST_TEST_GTEST_TYPED_TEST_TEST_H_ 31 | #define GOOGLETEST_TEST_GTEST_TYPED_TEST_TEST_H_ 32 | 33 | #include "gtest/gtest.h" 34 | 35 | using testing::Test; 36 | 37 | // For testing that the same type-parameterized test case can be 38 | // instantiated in different translation units linked together. 39 | // ContainerTest will be instantiated in both gtest-typed-test_test.cc 40 | // and gtest-typed-test2_test.cc. 41 | 42 | template 43 | class ContainerTest : public Test {}; 44 | 45 | TYPED_TEST_SUITE_P(ContainerTest); 46 | 47 | TYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) { TypeParam container; } 48 | 49 | TYPED_TEST_P(ContainerTest, InitialSizeIsZero) { 50 | TypeParam container; 51 | EXPECT_EQ(0U, container.size()); 52 | } 53 | 54 | REGISTER_TYPED_TEST_SUITE_P(ContainerTest, CanBeDefaultConstructed, 55 | InitialSizeIsZero); 56 | 57 | #endif // GOOGLETEST_TEST_GTEST_TYPED_TEST_TEST_H_ 58 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/googletest-param-test-invalid-name2-test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2015 Google Inc. All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Verifies that Google Test warns the user when not initialized properly.""" 32 | 33 | from googletest.test import gtest_test_utils 34 | 35 | binary_name = 'googletest-param-test-invalid-name2-test_' 36 | COMMAND = gtest_test_utils.GetTestExecutablePath(binary_name) 37 | 38 | 39 | def Assert(condition): 40 | if not condition: 41 | raise AssertionError 42 | 43 | 44 | def TestExitCodeAndOutput(command): 45 | """Runs the given command and verifies its exit code and output.""" 46 | 47 | err = ('Duplicate parameterized test name \'a\'') 48 | 49 | p = gtest_test_utils.Subprocess(command) 50 | Assert(p.terminated_by_signal) 51 | 52 | # Check for appropriate output 53 | Assert(err in p.output) 54 | 55 | 56 | class GTestParamTestInvalidName2Test(gtest_test_utils.TestCase): 57 | 58 | def testExitCodeAndOutput(self): 59 | TestExitCodeAndOutput(COMMAND) 60 | 61 | if __name__ == '__main__': 62 | gtest_test_utils.Main() 63 | -------------------------------------------------------------------------------- /src/index/ix_index_handle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ix_defs.h" 4 | #include "ix_node_handle.h" 5 | #include "transaction/transaction.h" 6 | 7 | enum class Operation { FIND = 0, INSERT, DELETE }; // 三种操作:查找、插入、删除 8 | 9 | /** 10 | * @brief B+树索引 11 | */ 12 | class IxIndexHandle { 13 | friend class IxScan; 14 | friend class IxManager; 15 | 16 | private: 17 | DiskManager *disk_manager_; 18 | BufferPoolManager *buffer_pool_manager_; 19 | int fd_; 20 | IxFileHdr file_hdr_; // 存了root_page,但root_page初始化为2(第0页存FILE_HDR_PAGE,第1页存LEAF_HEADER_PAGE) 21 | std::mutex root_latch_; // 用于索引并发(请自行选择并发粒度在 Tree级 或 Page级 ) 22 | 23 | public: 24 | IxIndexHandle(DiskManager *disk_manager, BufferPoolManager *buffer_pool_manager, int fd); 25 | 26 | // for search 27 | bool GetValue(const char *key, std::vector *result, Transaction *transaction); 28 | 29 | IxNodeHandle *FindLeafPage(const char *key, Operation operation, Transaction *transaction); 30 | 31 | // for insert 32 | bool insert_entry(const char *key, const Rid &value, Transaction *transaction); 33 | 34 | IxNodeHandle *Split(IxNodeHandle *node); 35 | 36 | void InsertIntoParent(IxNodeHandle *old_node, const char *key, IxNodeHandle *new_node, Transaction *transaction); 37 | 38 | // for delete 39 | bool delete_entry(const char *key, Transaction *transaction); 40 | 41 | bool CoalesceOrRedistribute(IxNodeHandle *node, Transaction *transaction = nullptr); 42 | 43 | bool AdjustRoot(IxNodeHandle *old_root_node); 44 | 45 | void Redistribute(IxNodeHandle *neighbor_node, IxNodeHandle *node, IxNodeHandle *parent, int index); 46 | 47 | bool Coalesce(IxNodeHandle **neighbor_node, IxNodeHandle **node, IxNodeHandle **parent, int index, 48 | Transaction *transaction); 49 | 50 | // 辅助函数,lab3执行层将使用 51 | Iid lower_bound(const char *key); 52 | 53 | Iid upper_bound(const char *key); 54 | 55 | Iid leaf_end() const; 56 | 57 | Iid leaf_begin() const; 58 | 59 | private: 60 | // 辅助函数 61 | void UpdateRootPageNo(page_id_t root) { file_hdr_.root_page = root; } 62 | 63 | bool IsEmpty() const { return file_hdr_.root_page == IX_NO_PAGE; } 64 | 65 | // for get/create node 66 | IxNodeHandle *FetchNode(int page_no) const; 67 | 68 | IxNodeHandle *CreateNode(); 69 | 70 | // for maintain data structure 71 | void maintain_parent(IxNodeHandle *node); 72 | 73 | void erase_leaf(IxNodeHandle *leaf); 74 | 75 | void release_node_handle(IxNodeHandle &node); 76 | 77 | void maintain_child(IxNodeHandle *node, int child_idx); 78 | 79 | // for index test 80 | Rid get_rid(const Iid &iid) const; 81 | }; 82 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_skip_check_output_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2019 Google LLC. All Rights Reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """Tests Google Test's gtest skip in environment setup behavior. 31 | 32 | This script invokes gtest_skip_in_environment_setup_test_ and verifies its 33 | output. 34 | """ 35 | 36 | import re 37 | 38 | from googletest.test import gtest_test_utils 39 | 40 | # Path to the gtest_skip_in_environment_setup_test binary 41 | EXE_PATH = gtest_test_utils.GetTestExecutablePath('gtest_skip_test') 42 | 43 | OUTPUT = gtest_test_utils.Subprocess([EXE_PATH]).output 44 | 45 | 46 | # Test. 47 | class SkipEntireEnvironmentTest(gtest_test_utils.TestCase): 48 | 49 | def testSkipEntireEnvironmentTest(self): 50 | self.assertIn('Skipped\nskipping single test\n', OUTPUT) 51 | skip_fixture = 'Skipped\nskipping all tests for this fixture\n' 52 | self.assertIsNotNone( 53 | re.search(skip_fixture + '.*' + skip_fixture, OUTPUT, flags=re.DOTALL), 54 | repr(OUTPUT)) 55 | self.assertNotIn('FAILED', OUTPUT) 56 | 57 | 58 | if __name__ == '__main__': 59 | gtest_test_utils.Main() 60 | -------------------------------------------------------------------------------- /deps/googletest/googlemock/test/gmock_all_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // 31 | // Tests for Google C++ Mocking Framework (Google Mock) 32 | // 33 | // Some users use a build system that Google Mock doesn't support directly, 34 | // yet they still want to build and run Google Mock's own tests. This file 35 | // includes most such tests, making it easier for these users to maintain 36 | // their build scripts (they just need to build this file, even though the 37 | // below list of actual *_test.cc files might change). 38 | #include "test/gmock-actions_test.cc" 39 | #include "test/gmock-cardinalities_test.cc" 40 | #include "test/gmock-internal-utils_test.cc" 41 | #include "test/gmock-matchers-arithmetic_test.cc" 42 | #include "test/gmock-matchers-comparisons_test.cc" 43 | #include "test/gmock-matchers-containers_test.cc" 44 | #include "test/gmock-matchers-misc_test.cc" 45 | #include "test/gmock-more-actions_test.cc" 46 | #include "test/gmock-nice-strict_test.cc" 47 | #include "test/gmock-port_test.cc" 48 | #include "test/gmock-spec-builders_test.cc" 49 | #include "test/gmock_test.cc" 50 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/googletest-param-test-invalid-name1-test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Copyright 2015 Google Inc. All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are 7 | # met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # * Redistributions in binary form must reproduce the above 12 | # copyright notice, this list of conditions and the following disclaimer 13 | # in the documentation and/or other materials provided with the 14 | # distribution. 15 | # * Neither the name of Google Inc. nor the names of its 16 | # contributors may be used to endorse or promote products derived from 17 | # this software without specific prior written permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | """Verifies that Google Test warns the user when not initialized properly.""" 32 | 33 | from googletest.test import gtest_test_utils 34 | 35 | binary_name = 'googletest-param-test-invalid-name1-test_' 36 | COMMAND = gtest_test_utils.GetTestExecutablePath(binary_name) 37 | 38 | 39 | def Assert(condition): 40 | if not condition: 41 | raise AssertionError 42 | 43 | 44 | def TestExitCodeAndOutput(command): 45 | """Runs the given command and verifies its exit code and output.""" 46 | 47 | err = ('Parameterized test name \'"InvalidWithQuotes"\' is invalid') 48 | 49 | p = gtest_test_utils.Subprocess(command) 50 | Assert(p.terminated_by_signal) 51 | 52 | # Verify the output message contains appropriate output 53 | Assert(err in p.output) 54 | 55 | 56 | class GTestParamTestInvalidName1Test(gtest_test_utils.TestCase): 57 | 58 | def testExitCodeAndOutput(self): 59 | TestExitCodeAndOutput(COMMAND) 60 | 61 | 62 | if __name__ == '__main__': 63 | gtest_test_utils.Main() 64 | -------------------------------------------------------------------------------- /src/replacer/clock_replacer_test.cpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // 3 | // BusTub 4 | // 5 | // clock_replacer_test.cpp 6 | // 7 | // Identification: test/buffer/clock_replacer_test.cpp 8 | // 9 | // Copyright (c) 2015-2019, Carnegie Mellon University Database Group 10 | // 11 | //===----------------------------------------------------------------------===// 12 | 13 | #include "replacer/clock_replacer.h" 14 | 15 | #include 16 | #include // NOLINT 17 | #include 18 | 19 | #include "gtest/gtest.h" 20 | 21 | /** 22 | * @note 选做 23 | */ 24 | TEST(ClockReplacerTest, SimpleTest) { 25 | ClockReplacer clock_replacer(7); 26 | 27 | // Scenario: unpin six elements, i.e. add them to the replacer. 28 | clock_replacer.Unpin(1); 29 | clock_replacer.Unpin(2); 30 | clock_replacer.Unpin(3); 31 | clock_replacer.Unpin(4); 32 | clock_replacer.Unpin(5); 33 | clock_replacer.Unpin(6); 34 | clock_replacer.Unpin(1); 35 | EXPECT_EQ(6, clock_replacer.Size()); 36 | 37 | // Scenario: get three victims from the clock. 38 | int value; 39 | clock_replacer.Victim(&value); 40 | EXPECT_EQ(1, value); 41 | clock_replacer.Victim(&value); 42 | EXPECT_EQ(2, value); 43 | clock_replacer.Victim(&value); 44 | EXPECT_EQ(3, value); 45 | 46 | // Scenario: pin elements in the replacer. 47 | // Note that 3 has already been victimized, so pinning 3 should have no effect. 48 | clock_replacer.Pin(3); 49 | clock_replacer.Pin(4); 50 | EXPECT_EQ(2, clock_replacer.Size()); 51 | 52 | // Scenario: unpin 4. We expect that the reference bit of 4 will be set to 1. 53 | clock_replacer.Unpin(4); 54 | 55 | // Scenario: continue looking for victims. We expect these victims. 56 | clock_replacer.Victim(&value); 57 | EXPECT_EQ(5, value); 58 | clock_replacer.Victim(&value); 59 | EXPECT_EQ(6, value); 60 | clock_replacer.Victim(&value); 61 | EXPECT_EQ(4, value); 62 | } 63 | 64 | /** 65 | * @note 选做 66 | */ 67 | TEST(ClockReplacerTest, CornerCaseTest) { 68 | ClockReplacer clock_replacer(4); 69 | int value; 70 | bool result = clock_replacer.Victim(&value); 71 | EXPECT_FALSE(result); 72 | 73 | clock_replacer.Unpin(3); 74 | clock_replacer.Unpin(2); 75 | EXPECT_EQ(2, clock_replacer.Size()); 76 | clock_replacer.Victim(&value); 77 | EXPECT_EQ(2, value); 78 | clock_replacer.Unpin(1); 79 | EXPECT_EQ(2, clock_replacer.Size()); 80 | clock_replacer.Victim(&value); 81 | EXPECT_EQ(3, value); 82 | clock_replacer.Victim(&value); 83 | EXPECT_EQ(1, value); 84 | EXPECT_FALSE(clock_replacer.Victim(&value)); 85 | EXPECT_EQ(0, clock_replacer.Size()); 86 | } 87 | -------------------------------------------------------------------------------- /deps/googletest/googletest/samples/sample1.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | 32 | #include "sample1.h" 33 | 34 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 35 | int Factorial(int n) { 36 | int result = 1; 37 | for (int i = 1; i <= n; i++) { 38 | result *= i; 39 | } 40 | 41 | return result; 42 | } 43 | 44 | // Returns true if and only if n is a prime number. 45 | bool IsPrime(int n) { 46 | // Trivial case 1: small numbers 47 | if (n <= 1) return false; 48 | 49 | // Trivial case 2: even numbers 50 | if (n % 2 == 0) return n == 2; 51 | 52 | // Now, we have that n is odd and n >= 3. 53 | 54 | // Try to divide n by every odd number i, starting from 3 55 | for (int i = 3;; i += 2) { 56 | // We only have to try i up to the square root of n 57 | if (i > n / i) break; 58 | 59 | // Now, we have i <= n/i < n. 60 | // If n is divisible by i, n is not prime. 61 | if (n % i == 0) return false; 62 | } 63 | 64 | // n has no integer factor in the range (1, n), and thus is prime. 65 | return true; 66 | } 67 | -------------------------------------------------------------------------------- /deps/googletest/googletest/test/gtest_json_test_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018, Google Inc. 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are 6 | # met: 7 | # 8 | # * Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # * Redistributions in binary form must reproduce the above 11 | # copyright notice, this list of conditions and the following disclaimer 12 | # in the documentation and/or other materials provided with the 13 | # distribution. 14 | # * Neither the name of Google Inc. nor the names of its 15 | # contributors may be used to endorse or promote products derived from 16 | # this software without specific prior written permission. 17 | # 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | """Unit test utilities for gtest_json_output.""" 31 | 32 | import re 33 | 34 | 35 | def normalize(obj): 36 | """Normalize output object. 37 | 38 | Args: 39 | obj: Google Test's JSON output object to normalize. 40 | 41 | Returns: 42 | Normalized output without any references to transient information that may 43 | change from run to run. 44 | """ 45 | def _normalize(key, value): 46 | if key == 'time': 47 | return re.sub(r'^\d+(\.\d+)?s$', '*', value) 48 | elif key == 'timestamp': 49 | return re.sub(r'^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ$', '*', value) 50 | elif key == 'failure': 51 | value = re.sub(r'^.*[/\\](.*:)\d+\n', '\\1*\n', value) 52 | return re.sub(r'Stack trace:\n(.|\n)*', 'Stack trace:\n*', value) 53 | elif key == 'file': 54 | return re.sub(r'^.*[/\\](.*)', '\\1', value) 55 | else: 56 | return normalize(value) 57 | if isinstance(obj, dict): 58 | return {k: _normalize(k, v) for k, v in obj.items()} 59 | if isinstance(obj, list): 60 | return [normalize(x) for x in obj] 61 | else: 62 | return obj 63 | -------------------------------------------------------------------------------- /deps/googletest/googletest/include/gtest/gtest_prod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Google C++ Testing and Mocking Framework definitions useful in production 31 | // code. 32 | 33 | #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_ 34 | #define GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_ 35 | 36 | // When you need to test the private or protected members of a class, 37 | // use the FRIEND_TEST macro to declare your tests as friends of the 38 | // class. For example: 39 | // 40 | // class MyClass { 41 | // private: 42 | // void PrivateMethod(); 43 | // FRIEND_TEST(MyClassTest, PrivateMethodWorks); 44 | // }; 45 | // 46 | // class MyClassTest : public testing::Test { 47 | // // ... 48 | // }; 49 | // 50 | // TEST_F(MyClassTest, PrivateMethodWorks) { 51 | // // Can call MyClass::PrivateMethod() here. 52 | // } 53 | // 54 | // Note: The test class must be in the same namespace as the class being tested. 55 | // For example, putting MyClassTest in an anonymous namespace will not work. 56 | 57 | #define FRIEND_TEST(test_case_name, test_name) \ 58 | friend class test_case_name##_##test_name##_Test 59 | 60 | #endif // GOOGLETEST_INCLUDE_GTEST_GTEST_PROD_H_ 61 | --------------------------------------------------------------------------------