mirror of
https://github.com/YuhangQ/InvoDB.git
synced 2025-01-26 06:30:57 +00:00
src 目录改为一个独立的 C++ cmake 项目
This commit is contained in:
parent
68b847e04a
commit
60cab69963
@ -10,7 +10,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
|
||||
|
||||
include_directories(${CMAKE_JS_INC})
|
||||
|
||||
file(GLOB SOURCE_FILES "src/*.h" "src/*.cpp" "src/btree/*.h" "src/collection/*.h" "src/collection/*.cpp" "src/file/*.h" "src/file/*.cpp" "src/test/*.h" "src/utils/*.h")
|
||||
file(GLOB SOURCE_FILES "src/api.h" "src/api.cpp" "src/btree/*.h" "src/collection/*.h" "src/collection/*.cpp" "src/file/*.h" "src/file/*.cpp" "src/test/*.h" "src/utils/*.h")
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
|
||||
|
6
benchmark/.gitignore
vendored
6
benchmark/.gitignore
vendored
@ -1 +1,5 @@
|
||||
node_modules
|
||||
node_modules
|
||||
benchmark.invodb
|
||||
benchmark.sqlite
|
||||
test.log
|
||||
test2.log
|
Binary file not shown.
199986
benchmark/test.log
199986
benchmark/test.log
File diff suppressed because it is too large
Load Diff
400008
benchmark/test2.log
400008
benchmark/test2.log
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
||||
"scripts": {
|
||||
"test": "clear && node-gyp build && node demo/test.js",
|
||||
"install": "cmake-js compile",
|
||||
"build": "node-gyp build"
|
||||
"build": "cmake-js compile"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
5
src/.gitignore
vendored
Normal file
5
src/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
cmake_install.cmake
|
||||
CMakeLists.txt
|
||||
CMakeFiles
|
||||
InvoDB
|
||||
MakeFile
|
361
src/CMakeCache.txt
Normal file
361
src/CMakeCache.txt
Normal file
@ -0,0 +1,361 @@
|
||||
# This is the CMakeCache file.
|
||||
# For build in directory: /Users/yuhangq/Documents/invodb/src
|
||||
# It was generated by CMake: /opt/homebrew/Cellar/cmake/3.21.4/bin/cmake
|
||||
# You can edit this file to change values found and used by cmake.
|
||||
# If you do not want to change any of the values, simply exit the editor.
|
||||
# If you do want to change a value, simply edit, save, and exit the editor.
|
||||
# The syntax for the file is as follows:
|
||||
# KEY:TYPE=VALUE
|
||||
# KEY is the name of a variable in the cache.
|
||||
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
|
||||
# VALUE is the current value for the KEY.
|
||||
|
||||
########################
|
||||
# EXTERNAL cache entries
|
||||
########################
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_ADDR2LINE:FILEPATH=CMAKE_ADDR2LINE-NOTFOUND
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_AR:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/ar
|
||||
|
||||
//Choose the type of build, options are: None Debug Release RelWithDebInfo
|
||||
// MinSizeRel ...
|
||||
CMAKE_BUILD_TYPE:STRING=
|
||||
|
||||
//Enable/Disable color output during build.
|
||||
CMAKE_COLOR_MAKEFILE:BOOL=ON
|
||||
|
||||
//CXX compiler
|
||||
CMAKE_CXX_COMPILER:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/c++
|
||||
|
||||
//Flags used by the CXX compiler during all build types.
|
||||
CMAKE_CXX_FLAGS:STRING=
|
||||
|
||||
//Flags used by the CXX compiler during DEBUG builds.
|
||||
CMAKE_CXX_FLAGS_DEBUG:STRING=-g
|
||||
|
||||
//Flags used by the CXX compiler during MINSIZEREL builds.
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
|
||||
|
||||
//Flags used by the CXX compiler during RELEASE builds.
|
||||
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
|
||||
|
||||
//Flags used by the CXX compiler during RELWITHDEBINFO builds.
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
|
||||
|
||||
//C compiler
|
||||
CMAKE_C_COMPILER:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/cc
|
||||
|
||||
//Flags used by the C compiler during all build types.
|
||||
CMAKE_C_FLAGS:STRING=
|
||||
|
||||
//Flags used by the C compiler during DEBUG builds.
|
||||
CMAKE_C_FLAGS_DEBUG:STRING=-g
|
||||
|
||||
//Flags used by the C compiler during MINSIZEREL builds.
|
||||
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
|
||||
|
||||
//Flags used by the C compiler during RELEASE builds.
|
||||
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
|
||||
|
||||
//Flags used by the C compiler during RELWITHDEBINFO builds.
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_DLLTOOL:FILEPATH=CMAKE_DLLTOOL-NOTFOUND
|
||||
|
||||
//Flags used by the linker during all build types.
|
||||
CMAKE_EXE_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the linker during DEBUG builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during MINSIZEREL builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during RELEASE builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during RELWITHDEBINFO builds.
|
||||
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//Enable/Disable output of compile commands during generation.
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_INSTALL_NAME_TOOL:FILEPATH=/usr/bin/install_name_tool
|
||||
|
||||
//Install path prefix, prepended onto install directories.
|
||||
CMAKE_INSTALL_PREFIX:PATH=/usr/local
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_LINKER:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/ld
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// all build types.
|
||||
CMAKE_MODULE_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// DEBUG builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// MINSIZEREL builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// RELEASE builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of modules during
|
||||
// RELWITHDEBINFO builds.
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_NM:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/nm
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_OBJCOPY:FILEPATH=CMAKE_OBJCOPY-NOTFOUND
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_OBJDUMP:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/objdump
|
||||
|
||||
//Build architectures for OSX
|
||||
CMAKE_OSX_ARCHITECTURES:STRING=
|
||||
|
||||
//Minimum OS X version to target for deployment (at runtime); newer
|
||||
// APIs weak linked. Set to empty string for default value.
|
||||
CMAKE_OSX_DEPLOYMENT_TARGET:STRING=
|
||||
|
||||
//The product will be built against the headers and libraries located
|
||||
// inside the indicated SDK.
|
||||
CMAKE_OSX_SYSROOT:PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_DESCRIPTION:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_HOMEPAGE_URL:STATIC=
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_NAME:STATIC=InvoDB
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_RANLIB:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/ranlib
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_READELF:FILEPATH=CMAKE_READELF-NOTFOUND
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during all build types.
|
||||
CMAKE_SHARED_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during DEBUG builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during MINSIZEREL builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during RELEASE builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of shared libraries
|
||||
// during RELWITHDEBINFO builds.
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//If set, runtime paths are not added when installing shared libraries,
|
||||
// but are added when building.
|
||||
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
|
||||
|
||||
//If set, runtime paths are not added when using shared libraries.
|
||||
CMAKE_SKIP_RPATH:BOOL=NO
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during all build types.
|
||||
CMAKE_STATIC_LINKER_FLAGS:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during DEBUG builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during MINSIZEREL builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during RELEASE builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=
|
||||
|
||||
//Flags used by the linker during the creation of static libraries
|
||||
// during RELWITHDEBINFO builds.
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=
|
||||
|
||||
//Path to a program.
|
||||
CMAKE_STRIP:FILEPATH=/Library/Developer/CommandLineTools/usr/bin/strip
|
||||
|
||||
//If this value is on, makefiles will be generated without the
|
||||
// .SILENT directive, and all commands will be echoed to the console
|
||||
// during the make. This is useful for debugging only. With Visual
|
||||
// Studio IDE projects all commands are done without /nologo.
|
||||
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
|
||||
|
||||
//Value Computed by CMake
|
||||
InvoDB_BINARY_DIR:STATIC=/Users/yuhangq/Documents/invodb/src
|
||||
|
||||
//Value Computed by CMake
|
||||
InvoDB_IS_TOP_LEVEL:STATIC=ON
|
||||
|
||||
//Value Computed by CMake
|
||||
InvoDB_SOURCE_DIR:STATIC=/Users/yuhangq/Documents/invodb/src
|
||||
|
||||
|
||||
########################
|
||||
# INTERNAL cache entries
|
||||
########################
|
||||
|
||||
//ADVANCED property for variable: CMAKE_ADDR2LINE
|
||||
CMAKE_ADDR2LINE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_AR
|
||||
CMAKE_AR-ADVANCED:INTERNAL=1
|
||||
//This is the directory where this CMakeCache.txt was created
|
||||
CMAKE_CACHEFILE_DIR:INTERNAL=/Users/yuhangq/Documents/invodb/src
|
||||
//Major version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
|
||||
//Minor version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MINOR_VERSION:INTERNAL=21
|
||||
//Patch version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_PATCH_VERSION:INTERNAL=4
|
||||
//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
|
||||
CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
|
||||
//Path to CMake executable.
|
||||
CMAKE_COMMAND:INTERNAL=/opt/homebrew/Cellar/cmake/3.21.4/bin/cmake
|
||||
//Path to cpack program executable.
|
||||
CMAKE_CPACK_COMMAND:INTERNAL=/opt/homebrew/Cellar/cmake/3.21.4/bin/cpack
|
||||
//Path to ctest program executable.
|
||||
CMAKE_CTEST_COMMAND:INTERNAL=/opt/homebrew/Cellar/cmake/3.21.4/bin/ctest
|
||||
//ADVANCED property for variable: CMAKE_CXX_COMPILER
|
||||
CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_COMPILER
|
||||
CMAKE_C_COMPILER-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_DLLTOOL
|
||||
CMAKE_DLLTOOL-ADVANCED:INTERNAL=1
|
||||
//Path to cache edit program executable.
|
||||
CMAKE_EDIT_COMMAND:INTERNAL=/opt/homebrew/Cellar/cmake/3.21.4/bin/ccmake
|
||||
//Executable file format
|
||||
CMAKE_EXECUTABLE_FORMAT:INTERNAL=MACHO
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
|
||||
CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
|
||||
CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
|
||||
CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1
|
||||
//Name of external makefile project generator.
|
||||
CMAKE_EXTRA_GENERATOR:INTERNAL=
|
||||
//Name of generator.
|
||||
CMAKE_GENERATOR:INTERNAL=Unix Makefiles
|
||||
//Generator instance identifier.
|
||||
CMAKE_GENERATOR_INSTANCE:INTERNAL=
|
||||
//Name of generator platform.
|
||||
CMAKE_GENERATOR_PLATFORM:INTERNAL=
|
||||
//Name of generator toolset.
|
||||
CMAKE_GENERATOR_TOOLSET:INTERNAL=
|
||||
//Source directory with the top level CMakeLists.txt file for this
|
||||
// project
|
||||
CMAKE_HOME_DIRECTORY:INTERNAL=/Users/yuhangq/Documents/invodb/src
|
||||
//ADVANCED property for variable: CMAKE_INSTALL_NAME_TOOL
|
||||
CMAKE_INSTALL_NAME_TOOL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_LINKER
|
||||
CMAKE_LINKER-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
|
||||
CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
|
||||
CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
|
||||
CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_NM
|
||||
CMAKE_NM-ADVANCED:INTERNAL=1
|
||||
//number of local generators
|
||||
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_OBJCOPY
|
||||
CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_OBJDUMP
|
||||
CMAKE_OBJDUMP-ADVANCED:INTERNAL=1
|
||||
//Platform information initialized
|
||||
CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_RANLIB
|
||||
CMAKE_RANLIB-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_READELF
|
||||
CMAKE_READELF-ADVANCED:INTERNAL=1
|
||||
//Path to CMake installation.
|
||||
CMAKE_ROOT:INTERNAL=/opt/homebrew/Cellar/cmake/3.21.4/share/cmake
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
|
||||
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
|
||||
CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
|
||||
CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_SKIP_RPATH
|
||||
CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
|
||||
CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
|
||||
CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
|
||||
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
|
||||
//ADVANCED property for variable: CMAKE_STRIP
|
||||
CMAKE_STRIP-ADVANCED:INTERNAL=1
|
||||
//uname command
|
||||
CMAKE_UNAME:INTERNAL=/usr/bin/uname
|
||||
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
|
||||
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
|
||||
|
69
src/api.cpp
Normal file
69
src/api.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
//
|
||||
// Created on 2021/9/24.
|
||||
//
|
||||
|
||||
#include "api.h"
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
using namespace Napi;
|
||||
|
||||
|
||||
void database(const CallbackInfo& info) {
|
||||
std::string filename = info[0].As<String>();
|
||||
PageManager::loadDatabase(filename.c_str());
|
||||
Collection::loadCollections();
|
||||
}
|
||||
|
||||
Boolean exists(const CallbackInfo& info) {
|
||||
std::string colName = info[0].As<String>();
|
||||
return Boolean::New(info.Env(), Collection::existsCollection(colName));
|
||||
}
|
||||
|
||||
void create(const CallbackInfo& info) {
|
||||
std::string colName = info[0].As<String>();
|
||||
Collection::createCollection(colName);
|
||||
}
|
||||
|
||||
void insert(const CallbackInfo& info) {
|
||||
std::string colName = info[0].As<String>();
|
||||
std::string json = info[1].As<String>();
|
||||
|
||||
auto j = nlohmann::json::parse(json);
|
||||
Collection::getCollection(colName).insert(j);
|
||||
}
|
||||
|
||||
Array query(const CallbackInfo& info) {
|
||||
std::string colName = info[0].As<String>();
|
||||
std::string json = info[1].As<String>();
|
||||
|
||||
auto j = nlohmann::json::parse(json);
|
||||
auto result = Collection::getCollection(colName).query(j);
|
||||
|
||||
auto res = Array::New(info.Env(), result.size());
|
||||
for(int i=0; i<result.size(); i++) {
|
||||
res.Set(i, String::New(info.Env(), result[i].dump()));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void _remove(const CallbackInfo& info) {
|
||||
std::string colName = info[0].As<String>();
|
||||
std::string json = info[1].As<String>();
|
||||
|
||||
auto j = nlohmann::json::parse(json);
|
||||
Collection::getCollection(colName).remove(j);
|
||||
}
|
||||
|
||||
Object Init(Env env, Object exports) {
|
||||
srand(time(0));
|
||||
exports.Set("database", Function::New(env, database));
|
||||
exports.Set("exists", Function::New(env, exists));
|
||||
exports.Set("create", Function::New(env, create));
|
||||
exports.Set("insert", Function::New(env, insert));
|
||||
exports.Set("query", Function::New(env, query));
|
||||
exports.Set("remove", Function::New(env, _remove));
|
||||
return exports;
|
||||
}
|
||||
NODE_API_MODULE(core, Init)
|
73
src/main.cpp
73
src/main.cpp
@ -1,69 +1,6 @@
|
||||
//
|
||||
// Created on 2021/9/24.
|
||||
//
|
||||
#include "test/test.h"
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#include <napi.h>
|
||||
|
||||
using namespace Napi;
|
||||
|
||||
|
||||
void database(const CallbackInfo& info) {
|
||||
std::string filename = info[0].As<String>();
|
||||
PageManager::loadDatabase(filename.c_str());
|
||||
Collection::loadCollections();
|
||||
}
|
||||
|
||||
Boolean exists(const CallbackInfo& info) {
|
||||
std::string colName = info[0].As<String>();
|
||||
return Boolean::New(info.Env(), Collection::existsCollection(colName));
|
||||
}
|
||||
|
||||
void create(const CallbackInfo& info) {
|
||||
std::string colName = info[0].As<String>();
|
||||
Collection::createCollection(colName);
|
||||
}
|
||||
|
||||
void insert(const CallbackInfo& info) {
|
||||
std::string colName = info[0].As<String>();
|
||||
std::string json = info[1].As<String>();
|
||||
|
||||
auto j = nlohmann::json::parse(json);
|
||||
Collection::getCollection(colName).insert(j);
|
||||
}
|
||||
|
||||
Array query(const CallbackInfo& info) {
|
||||
std::string colName = info[0].As<String>();
|
||||
std::string json = info[1].As<String>();
|
||||
|
||||
auto j = nlohmann::json::parse(json);
|
||||
auto result = Collection::getCollection(colName).query(j);
|
||||
|
||||
auto res = Array::New(info.Env(), result.size());
|
||||
for(int i=0; i<result.size(); i++) {
|
||||
res.Set(i, String::New(info.Env(), result[i].dump()));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void _remove(const CallbackInfo& info) {
|
||||
std::string colName = info[0].As<String>();
|
||||
std::string json = info[1].As<String>();
|
||||
|
||||
auto j = nlohmann::json::parse(json);
|
||||
Collection::getCollection(colName).remove(j);
|
||||
}
|
||||
|
||||
Object Init(Env env, Object exports) {
|
||||
srand(time(0));
|
||||
exports.Set("database", Function::New(env, database));
|
||||
exports.Set("exists", Function::New(env, exists));
|
||||
exports.Set("create", Function::New(env, create));
|
||||
exports.Set("insert", Function::New(env, insert));
|
||||
exports.Set("query", Function::New(env, query));
|
||||
exports.Set("remove", Function::New(env, _remove));
|
||||
return exports;
|
||||
}
|
||||
NODE_API_MODULE(core, Init)
|
||||
int main() {
|
||||
terminal();
|
||||
return 0;
|
||||
}
|
@ -9,6 +9,7 @@ Collection *col;
|
||||
|
||||
void terminal() {
|
||||
|
||||
srand(time(0));
|
||||
PageManager::loadDatabase("test.invodb");
|
||||
Collection::loadCollections();
|
||||
|
||||
@ -32,24 +33,43 @@ void terminal() {
|
||||
nlohmann::json json;
|
||||
try {
|
||||
json = nlohmann::json::parse(input);
|
||||
} catch(const char *err) {
|
||||
printf("ERROR: %s\n", err);
|
||||
} catch(...) {
|
||||
printf("ERROR: your insert input isn't a json.\n");
|
||||
continue;
|
||||
}
|
||||
col->insert(json);
|
||||
printf("You insert json: %s\n", json.dump().c_str());
|
||||
|
||||
try {
|
||||
col->insert(json);
|
||||
} catch(const char *err) {
|
||||
printf("ERROR: %s\n", err);
|
||||
} catch(...) {
|
||||
printf("ERROR: insert failed. check your input.\n");
|
||||
continue;
|
||||
}
|
||||
//printf("You insert json: %s\n", json.dump().c_str());
|
||||
|
||||
} else if(input.find("query ") == 0) {
|
||||
input = input.substr(6, input.size());
|
||||
nlohmann::json json;
|
||||
try {
|
||||
json = nlohmann::json::parse(input);
|
||||
} catch(const char *err) {
|
||||
printf("ERROR: %s\n", err);
|
||||
} catch(...) {
|
||||
printf("ERROR: your query input isn't a json.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
auto res = col->query(json);
|
||||
try {
|
||||
auto res = col->query(json);
|
||||
} catch(const char *err) {
|
||||
printf("ERROR: %s\n", err);
|
||||
} catch(...) {
|
||||
printf("ERROR: query failed. check your input.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("query result: \n");
|
||||
for(auto& j : res) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user