diff --git a/Makefile b/Makefile
index 1decc8b01b..cbd6007a22 100644
--- a/Makefile
+++ b/Makefile
@@ -61,8 +61,8 @@ quoted_perl_command = $(subst ','\'',$(perl_command))
# `make install-shared`, `make static_lib`, `make install-static` or
# `make install`
-# Set the default DEBUG_LEVEL to 1
-DEBUG_LEVEL?=1
+# Set the default DEBUG_LEVEL to 2
+DEBUG_LEVEL?=2
# OBJ_DIR is where the object files reside. Default to the current directory
OBJ_DIR?=.
@@ -120,7 +120,7 @@ endif
ifeq (${DISABLE_JEMALLOC},1)
ifeq (${ROCKSDB_DISABLE_JEMALLOC},)
export_ROCKSDB_DISABLE_JEMALLOC := export ROCKSDB_DISABLE_JEMALLOC=1;
- export ROCKSDB_DISABLE_JEMALLOC = 1
+ export ROCKSDB_DISABLE_JEMALLOC = 1
endif
endif
@@ -244,9 +244,15 @@ endif
# interfaces/internal abstractions, like in the iterator hierarchy. It works
# better when combined with profile-guided optimizations (not currently
# supported natively in Makefile).
+OPTION_jemalloc := jemalloc-$(if $(filter 1,${DISABLE_JEMALLOC}),0,1)
+OPTION_dyna_tls := dyna_tls-$(if $(filter 1,${TOPLING_USE_DYNAMIC_TLS}),1,0)
+OPTION_lto := lto-0
ifeq ($(USE_LTO), 1)
- CXXFLAGS += -flto
- LDFLAGS += -flto=auto -fuse-linker-plugin
+ ifeq (${DEBUG_LEVEL},0)
+ CXXFLAGS += -flto
+ LDFLAGS += -flto=auto -fuse-linker-plugin
+ OPTION_lto := lto-$(if $(filter 1,${USE_LTO}),1,0)
+ endif
endif
# `COERCE_CONTEXT_SWITCH=1` will inject spurious wakeup and
@@ -389,7 +395,7 @@ endif
TOPLING_LIB_OBJECTS = $(addprefix ${TOPLING_CORE_DIR}/, ${TOPLING_LIB_OBJ_LIST_VAR})
LDFLAGS += ${TOPLING_CORE_LD_LIBS_EXTRA}
-ifneq ($(filter auto_all_tests check check_0 watch-log gen_parallel_tests %_test %_test2 jtest, $(MAKECMDGOALS)),)
+ifneq ($(filter auto_all_tests check check_0 watch-log gen_parallel_tests %_test %_test2 jtest %_test.o %_test2.o, $(MAKECMDGOALS)),)
MAKE_UNIT_TEST ?= 1
endif
ifeq (${MAKE_UNIT_TEST},1)
@@ -406,6 +412,15 @@ endif
ORIG_OBJ_DIR := ${OBJ_DIR}
OBJ_DIR := ${BUILD_PREFIX}${OBJ_DIR}/v${ROCKSDB_FULL_VERSION}
+# COMPILER is in ignored
+TRIAL_urldir := toplingdb/gpl-trial/${OPTION_lto}-${OPTION_jemalloc}-${OPTION_dyna_tls}/${UNAME_MachineSystem}-bmi2-${WITH_BMI2}/${BUILD_TYPE_SIG}
+ifeq (${PLATFORM},OS_LINUX)
+LINUX_NAME := $(shell source /etc/os-release; echo $$ID)
+ifeq (${LINUX_NAME},centos)
+TRIAL_urldir := ${TRIAL_urldir}/$(shell source /etc/os-release; echo $$ID$$VERSION_ID)
+endif
+endif
+
# 1. we define ROCKSDB_DISABLE_ZSTD=1 on build_detect_platform.
# 2. zstd lib is included in libterark-zbs
# 3. we alway use ZSTD
@@ -432,33 +447,24 @@ ifndef WITH_TOPLING_ROCKS
cd topling-rocks; \
git submodule update --init --recursive \
)
- endif
- ifeq (,$(wildcard sideplugin/topling-rocks))
- WITH_TOPLING_ROCKS := 0
else
- WITH_TOPLING_ROCKS := 1
+ ifeq (,$(wildcard sideplugin/topling-rocks/src/table/top_patent_algo.cc))
+ dummy := $(shell rm -rf sideplugin/topling-rocks)
+ endif
endif
+ # default 1
+ WITH_TOPLING_ROCKS := 1
endif
ifeq (${WITH_TOPLING_ROCKS},1)
-ifeq (,$(wildcard sideplugin/topling-rocks))
- # topling specific: just for people who has permission to topling-rocks
- dummy := $(shell set -e -x; \
- cd sideplugin; \
- git clone ${GIT_TOPLING_ROCKS}; \
- cd topling-rocks; \
- git submodule update --init --recursive \
- )
-else
+ifneq (,$(wildcard sideplugin/topling-rocks))
ifneq (${UPDATE_REPO},0)
ifeq (${MAKE_RESTARTS},)
dummy := $(shell set -ex; cd sideplugin/topling-rocks && git pull)
endif
endif
endif
-ifeq (,$(wildcard sideplugin/topling-rocks/src/table/top_zip_table_builder.cc))
- $(error WITH_TOPLING_ROCKS=1 but repo sideplugin/topling-rocks is broken)
-endif
+CXXFLAGS += -DHAS_TOPLING_ROCKS
endif
ifeq (,$(wildcard sideplugin/cspp-memtable))
@@ -611,13 +617,14 @@ endif # WITH_TOPLING_DCOMPACT
ifeq (${WITH_TOPLING_ROCKS},1)
ifneq (,$(wildcard sideplugin/topling-rocks))
CXXFLAGS += -Isideplugin/topling-rocks/src
- CXXFLAGS += -DHAS_TOPLING_ROCKS
TOPLING_ROCKS_GIT_VER_SRC = ${BUILD_ROOT}/git-version-topling_rocks.cc
- EXTRA_LIB_SOURCES += \
- $(wildcard sideplugin/topling-rocks/src/table/*.cc) \
- sideplugin/topling-rocks/${TOPLING_ROCKS_GIT_VER_SRC}
-else
- $(warning NotFound sideplugin/topling-rocks, this is ok, only ToplingZipTable is disabled)
+ ifeq (,${TOPLING_ZIP_TABLE_TRIAL_DAYS})
+ EXTRA_LIB_SOURCES += $(wildcard sideplugin/topling-rocks/src/table/*.cc)
+ EXTRA_LIB_SOURCES += sideplugin/topling-rocks/${TOPLING_ROCKS_GIT_VER_SRC}
+ else
+ # no TOPLING_ROCKS_GIT_VER_SRC
+ EXTRA_LIB_SOURCES += sideplugin/topling-zip_table_reader/top_zip_table_builder.cc
+ endif
endif
endif
@@ -785,7 +792,7 @@ endif
ifeq ($(LIB_MODE),shared)
# So that binaries are executable from build location, in addition to install location
-EXEC_LDFLAGS += -Wl,-rpath -Wl,'$$ORIGIN'
+EXEC_LDFLAGS += -Wl,-rpath -Wl,'$$ORIGIN:$$ORIGIN/../lib'
endif
ifeq ($(PLATFORM), OS_MACOSX)
@@ -1033,6 +1040,9 @@ endif
# topling specific WARNING_FLAGS
WARNING_FLAGS := -Wall -Wno-shadow
ifeq "$(shell a=${COMPILER};echo $${a:0:5})" "clang"
+ CXXFLAGS := $(patsubst -flto, -flto=thin, ${CXXFLAGS})
+ LLD_LTO_FLAGS := -fuse-ld=lld -flto=thin -Wl,--thinlto-jobs=all
+ LDFLAGS := $(patsubst -flto=auto, ${LLD_LTO_FLAGS}, ${LDFLAGS})
LDFLAGS += -latomic
#$(error LDFLAGS = ${LDFLAGS})
WARNING_FLAGS += -Wno-deprecated-builtins
@@ -1100,6 +1110,12 @@ ifneq ($(PPC_LIBC_IS_GNU),0)
LIB_OBJECTS += $(patsubst %.cc, $(OBJ_DIR)/%.o, $(RANGE_TREE_SOURCES))
endif
+ifeq (${WITH_TOPLING_ROCKS},1)
+ ifeq (,$(wildcard sideplugin/topling-rocks))
+ LIB_OBJECTS += $(OBJ_DIR)/sideplugin/topling-zip_table_reader/top_zip_table_builder.o
+ endif
+endif
+
GTEST = $(OBJ_DIR)/$(GTEST_DIR)/gtest/gtest-all.o
TESTUTIL = $(OBJ_DIR)/test_util/testutil.o
TESTHARNESS = $(OBJ_DIR)/test_util/testharness.o $(TESTUTIL) $(GTEST)
@@ -2592,39 +2608,44 @@ install-headers: gen-pc
install -d $(INSTALL_LIBDIR)
install -d $(INSTALL_LIBDIR)/pkgconfig
for header_dir in `$(FIND) "include/rocksdb" -type d`; do \
- install -d $(DESTDIR)/$(PREFIX)/$$header_dir; \
+ install -d $(DESTDIR)$(PREFIX)/$$header_dir; \
done
for header in `$(FIND) "include/rocksdb" -type f -name *.h`; do \
- install -C -m 644 $$header $(DESTDIR)/$(PREFIX)/$$header; \
+ install -C -m 644 $$header $(DESTDIR)$(PREFIX)/$$header; \
done
for header in $(ROCKSDB_PLUGIN_HEADERS); do \
- install -d $(DESTDIR)/$(PREFIX)/include/rocksdb/`dirname $$header`; \
- install -C -m 644 $$header $(DESTDIR)/$(PREFIX)/include/rocksdb/$$header; \
+ install -d $(DESTDIR)$(PREFIX)/include/rocksdb/`dirname $$header`; \
+ install -C -m 644 $$header $(DESTDIR)$(PREFIX)/include/rocksdb/$$header; \
done
- install -d $(DESTDIR)/$(PREFIX)/include/topling
- install -C -m 644 sideplugin/rockside/src/topling/json.h $(DESTDIR)/$(PREFIX)/include/topling
- install -C -m 644 sideplugin/rockside/src/topling/json_fwd.h $(DESTDIR)/$(PREFIX)/include/topling
- install -C -m 644 sideplugin/rockside/src/topling/builtin_table_factory.h $(DESTDIR)/$(PREFIX)/include/topling
- install -C -m 644 sideplugin/rockside/src/topling/side_plugin_repo.h $(DESTDIR)/$(PREFIX)/include/topling
- install -C -m 644 sideplugin/rockside/src/topling/side_plugin_factory.h $(DESTDIR)/$(PREFIX)/include/topling
- install -d $(DESTDIR)/$(PREFIX)/include/terark
- install -d $(DESTDIR)/$(PREFIX)/include/terark/io
- install -d $(DESTDIR)/$(PREFIX)/include/terark/succinct
- install -d $(DESTDIR)/$(PREFIX)/include/terark/thread
- install -d $(DESTDIR)/$(PREFIX)/include/terark/util
- install -d $(DESTDIR)/$(PREFIX)/include/terark/fsa
- install -d $(DESTDIR)/$(PREFIX)/include/terark/fsa/ppi
- install -d $(DESTDIR)/$(PREFIX)/include/terark/zbs
- install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/*.hpp $(DESTDIR)/$(PREFIX)/include/terark
- install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/io/*.hpp $(DESTDIR)/$(PREFIX)/include/terark/io
- install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/succinct/*.hpp $(DESTDIR)/$(PREFIX)/include/terark/succinct
- install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/thread/*.hpp $(DESTDIR)/$(PREFIX)/include/terark/thread
- install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/util/*.hpp $(DESTDIR)/$(PREFIX)/include/terark/util
- install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/fsa/*.hpp $(DESTDIR)/$(PREFIX)/include/terark/fsa
- install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/fsa/*.inl $(DESTDIR)/$(PREFIX)/include/terark/fsa
- install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/fsa/ppi/*.hpp $(DESTDIR)/$(PREFIX)/include/terark/fsa/ppi
- install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/zbs/*.hpp $(DESTDIR)/$(PREFIX)/include/terark/zbs
- cp -ar ${TOPLING_CORE_DIR}/boost-include/boost $(DESTDIR)/$(PREFIX)/include
+ install -d $(DESTDIR)$(PREFIX)/include/topling
+ install -C -m 644 sideplugin/rockside/src/topling/json.h $(DESTDIR)$(PREFIX)/include/topling
+ install -C -m 644 sideplugin/rockside/src/topling/json_fwd.h $(DESTDIR)$(PREFIX)/include/topling
+ install -C -m 644 sideplugin/rockside/src/topling/builtin_table_factory.h $(DESTDIR)$(PREFIX)/include/topling
+ install -C -m 644 sideplugin/rockside/src/topling/side_plugin_repo.h $(DESTDIR)$(PREFIX)/include/topling
+ install -C -m 644 sideplugin/rockside/src/topling/side_plugin_factory.h $(DESTDIR)$(PREFIX)/include/topling
+ install -d $(DESTDIR)$(PREFIX)/include/terark
+ install -d $(DESTDIR)$(PREFIX)/include/terark/io
+ install -d $(DESTDIR)$(PREFIX)/include/terark/succinct
+ install -d $(DESTDIR)$(PREFIX)/include/terark/thread
+ install -d $(DESTDIR)$(PREFIX)/include/terark/util
+ install -d $(DESTDIR)$(PREFIX)/include/terark/fsa
+ install -d $(DESTDIR)$(PREFIX)/include/terark/fsa/ppi
+ install -d $(DESTDIR)$(PREFIX)/include/terark/zbs
+ install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/*.hpp $(DESTDIR)$(PREFIX)/include/terark
+ install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/io/*.hpp $(DESTDIR)$(PREFIX)/include/terark/io
+ install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/succinct/*.hpp $(DESTDIR)$(PREFIX)/include/terark/succinct
+ install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/thread/*.hpp $(DESTDIR)$(PREFIX)/include/terark/thread
+ install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/util/*.hpp $(DESTDIR)$(PREFIX)/include/terark/util
+ install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/fsa/*.hpp $(DESTDIR)$(PREFIX)/include/terark/fsa
+ install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/fsa/*.inl $(DESTDIR)$(PREFIX)/include/terark/fsa
+ install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/fsa/ppi/*.hpp $(DESTDIR)$(PREFIX)/include/terark/fsa/ppi
+ install -C -m 644 ${TOPLING_CORE_DIR}/src/terark/zbs/*.hpp $(DESTDIR)$(PREFIX)/include/terark/zbs
+ cp -ar ${TOPLING_CORE_DIR}/boost-include/boost $(DESTDIR)$(PREFIX)/include
+ install -d $(DESTDIR)$(PREFIX)/site
+ install -d $(DESTDIR)$(PREFIX)/toplingdb-conf
+ install -C -m 644 sideplugin/rockside/src/topling/web/index.html $(DESTDIR)$(PREFIX)/site
+ install -C -m 644 sideplugin/rockside/src/topling/web/style.css $(DESTDIR)$(PREFIX)/site
+ install -C -m 644 sideplugin/rockside/sample-conf/db_bench_enterprise.yaml $(DESTDIR)$(PREFIX)/toplingdb-conf
install -C -m 644 rocksdb.pc $(INSTALL_LIBDIR)/pkgconfig/rocksdb.pc
install-static: $(LIBRARY) static_lib
@@ -2634,6 +2655,9 @@ install-static: $(LIBRARY) static_lib
install-shared: $(SHARED4) shared_lib
install -d $(INSTALL_LIBDIR)
install -C -m 755 $(SHARED4) $(INSTALL_LIBDIR)
+ifeq ($(STRIP_DEBUG_INFO),1)
+ $(STRIP_CMD) $(INSTALL_LIBDIR)/$(SHARED4)
+endif
ln -fs $(SHARED4) $(INSTALL_LIBDIR)/$(SHARED3)
ln -fs $(SHARED4) $(INSTALL_LIBDIR)/$(SHARED2)
ln -fs $(SHARED4) $(INSTALL_LIBDIR)/$(SHARED1)
@@ -2643,10 +2667,17 @@ install: install-${LIB_MODE}
install-dev-static: install-headers install-static
install-dev-shared: install-headers install-shared
install-dev: install-dev-${LIB_MODE}
+upload-trial: ${OBJ_DIR}/sideplugin/topling-zip_table_reader/top_zip_table_builder.o
+ ossutil cp --region=cn-qingdao -f \
+ $(OBJ_DIR)/sideplugin/topling-zip_table_reader/top_zip_table_builder.o \
+ oss://topling-tools/${TRIAL_urldir}/
install-dcompact: install dcompact_worker
install -d $(DESTDIR)$(PREFIX)/bin
install -C -m 755 sideplugin/topling-dcompact/tools/dcompact/${ORIG_OBJ_DIR}/dcompact_worker.exe $(DESTDIR)$(PREFIX)/bin
+ifeq ($(STRIP_DEBUG_INFO),1)
+ $(STRIP_CMD) $(DESTDIR)$(PREFIX)/bin/dcompact_worker.exe
+endif
install-tools: install tools
mkdir -p $(DESTDIR)$(PREFIX)/bin
@@ -3284,10 +3315,18 @@ ${BUILD_ROOT}/lib_static/libterark-zbs-${COMPILER}-${BUILD_TYPE_SIG}.a:
+make -C ${TOPLING_CORE_DIR} core fsa zbs
ifeq (${WITH_TOPLING_ROCKS},1)
-ifneq (,$(wildcard sideplugin/topling-rocks))
+ifneq (,$(wildcard sideplugin/topling-rocks/src/table/top_patent_algo.cc))
sideplugin/topling-rocks/${TOPLING_ROCKS_GIT_VER_SRC}: \
+ sideplugin/topling-rocks/Makefile \
$(shell find sideplugin/topling-rocks/{src,tools} -name '*.cc' -o -name '*.h')
+make -C sideplugin/topling-rocks ${TOPLING_ROCKS_GIT_VER_SRC}
+sideplugin/topling-zip_table_reader/top_zip_table_builder.cc: sideplugin/topling-rocks/${TOPLING_ROCKS_GIT_VER_SRC}
+else
+${OBJ_DIR}/sideplugin/topling-zip_table_reader/top_zip_table_builder.o:
+ @mkdir -p $(dir $@)
+ @cd $(dir $@) && \
+ wget https://topling-tools.oss-cn-qingdao.aliyuncs.com/${TRIAL_urldir}/top_zip_table_builder.o || \
+ echo 'Download top_zip_table_builder fail, add WITH_TOPLING_ROCKS=0 to make command and try again'
endif
endif
diff --git a/README-zh_cn.md b/README-zh_cn.md
index 9be6c5e326..267458e2a3 100644
--- a/README-zh_cn.md
+++ b/README-zh_cn.md
@@ -4,7 +4,7 @@ ToplingDB 由[北京拓扑岭科技有限公司](https://topling.cn)开发与维
## 快速开始
ToplingDB 需要 C++17,推荐 gcc 8.3 以上,或者 clang 也行。
-ToplingDB 比 RocksDB 快得多,您可以自己快速验证:
+ToplingDB 比 RocksDB 快得多,您可以自己快速验证,[下载 ToplingDB 企业版](https://topling-tools.oss-cn-qingdao.aliyuncs.com/toplingdb-8.10-trail90.tgz),或者自己编译:
### Compile & run db_bench
```bash
sudo yum -y install git libaio-devel gcc-c++ gflags-devel zlib-devel bzip2-devel libcurl-devel liburing-devel snappy-devel jemalloc-devel
@@ -15,7 +15,9 @@ make -j`nproc` db_bench DEBUG_LEVEL=0
sudo make install PREFIX=/some/path # default is /usr/local
```
-以上编译命令执行后,运行 [db_bench.sh](db_bench.sh)(需要[端口 2011](https://github.com/topling/rockside/blob/master/sample-conf/db_bench_enterprise.yaml#L4 "内嵌的 http web 服务使用端口 2011")),然后使用 ToplingDB:[原生 C++](https://github.com/topling/rockside/wiki/101 "典型场景是从 rocksdb 迁移过来)"),也支持 [Java](https://github.com/topling/rockside/wiki/SidePlugin-Java-Binding "内置在本 github 仓库中") 和 [Rust](https://github.com/topling/rust-toplingdb "另外的专门的 github 仓库")。
+下载解压或者自行编译后,运行 [db_bench.sh](db_bench.sh)(需要[端口 2011](https://github.com/topling/rockside/blob/master/sample-conf/db_bench_enterprise.yaml#L4 "内嵌的 http web 服务使用端口 2011")),然后使用 ToplingDB:[原生 C++](https://github.com/topling/rockside/wiki/101 "典型场景是从 rocksdb 迁移过来)"),也支持 [Java](https://github.com/topling/rockside/wiki/SidePlugin-Java-Binding "内置在本 github 仓库中") 和 [Rust](https://github.com/topling/rust-toplingdb "另外的专门的 github 仓库")。
+
+> 自己编译开源版时会自动下载预编译的试用版(90天) ToplingZipTable,如果下载失败,可以给 `make` 传递变量 `WITH_TOPLING_ROCKS=0` 禁用它(或[联系我们](mailto:contact@topling.cn))。
## 简单介绍
ToplingDB 的子模块 **[rockside](https://github.com/topling/rockside)** 是 ToplingDB 的入口,详情参考 **[SidePlugin wiki](https://github.com/topling/rockside/wiki)**。
@@ -84,12 +86,6 @@ toplingdb
```
make -j`nproc` EXTRA_CXXFLAGS='-DROCKSDB_DYNAMIC_CREATE_CF' rocksdbjava
```
-## License
-为了兼容开源协议,下列原先禁止字节跳动使用本软件的条款从 2023-04-24 起已被删除,也就是说,字节跳动使用 ToplingDB 的行为不再是非法的,也不是无耻的。
-
-~~我们禁止字节跳动使用本软件,其它条款与上游 RocksDB 完全相同,~~ 详情参考 [LICENSE.Apache](LICENSE.Apache), [COPYING](COPYING), [LICENSE.leveldb](LICENSE.leveldb).
-
-相应 LICENSE 文件中禁止字节跳动使用本软件的条款也已经删除:[LICENSE.Apache](LICENSE.Apache), [COPYING](COPYING), [LICENSE.leveldb](LICENSE.leveldb).
以下是上游 RocksDB 的原版 README
diff --git a/README.md b/README.md
index f1220135e1..5615b66384 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ ToplingDB is developed and maintained by [Topling Inc](https://topling.cn). See
## Quick Start
ToplingDB requires C++17, gcc 8.3 or newer is recommended, clang also works.
-ToplingDB is forked form [RocksDB](https://github.com/facebook/rocksdb), much faster than RocksDB, try it by yourself:
+ToplingDB is forked form [RocksDB](https://github.com/facebook/rocksdb), much faster than RocksDB, you can [download ToplingDB Enterprise](https://topling-tools.oss-cn-qingdao.aliyuncs.com/toplingdb-8.10-trail90.tgz) or compile it by yourself:
### Compile & run db_bench
```bash
sudo yum -y install git libaio-devel gcc-c++ gflags-devel zlib-devel bzip2-devel libcurl-devel liburing-devel snappy-devel jemalloc-devel
@@ -16,7 +16,9 @@ make -j`nproc` db_bench DEBUG_LEVEL=0
sudo make install PREFIX=/some/path # default is /usr/local
```
-After compile, you can run bundled [db_bench.sh](db_bench.sh)(need [port 2011](https://github.com/topling/rockside/blob/master/sample-conf/db_bench_enterprise.yaml#L4 "use port 2011 for embeded http server")), then use ToplingDB [in C++](https://github.com/topling/sideplugin-wiki-en/wiki/101 "maybe migrate from rocksdb"), or in [Java](https://github.com/topling/sideplugin-wiki-en/wiki/SidePlugin-Java-Binding "Bundled in this repo"), [Rust](https://github.com/topling/rust-toplingdb "A seperated repo").
+After download+uncompress or compile, you can run bundled [db_bench.sh](db_bench.sh)(need [port 2011](https://github.com/topling/rockside/blob/master/sample-conf/db_bench_enterprise.yaml#L4 "use port 2011 for embeded http server")), then use ToplingDB [in C++](https://github.com/topling/sideplugin-wiki-en/wiki/101 "maybe migrate from rocksdb"), or in [Java](https://github.com/topling/sideplugin-wiki-en/wiki/SidePlugin-Java-Binding "Bundled in this repo"), [Rust](https://github.com/topling/rust-toplingdb "A seperated repo").
+
+> During compiling, precompiled ToplingZipTable(90 days trial) will be auto downloaded, if download failed, you can pass `WITH_TOPLING_ROCKS=0` to `make` to disalbe it(or [contact us](mailto:contact@topling.cn)).
## Introduction
ToplingDB's submodule **[rockside](https://github.com/topling/rockside)** is the entry point of ToplingDB, see **[SidePlugin wiki](https://github.com/topling/sideplugin-wiki-en/wiki)**.
@@ -88,16 +90,6 @@ To enable these features, add `-D${MACRO_NAME}` to var `EXTRA_CXXFLAGS`, such as
```
make -j`nproc` EXTRA_CXXFLAGS='-DROCKSDB_DYNAMIC_CREATE_CF' rocksdbjava
```
-## License
-To conform open source license, the following term of disallowing bytedance is deleted since 2023-04-24,
-that is say: bytedance using ToplingDB is no longer illeagal and is not a shame.
-
-~~We disallow bytedance using this software, other terms are identidal with
-upstream rocksdb license,~~ see [LICENSE.Apache](LICENSE.Apache), [COPYING](COPYING) and
-[LICENSE.leveldb](LICENSE.leveldb).
-
-The terms of disallowing bytedance are also deleted in [LICENSE.Apache](LICENSE.Apache), [COPYING](COPYING) and
-[LICENSE.leveldb](LICENSE.leveldb).
diff --git a/btest-trial.sh b/btest-trial.sh
new file mode 100644
index 0000000000..9f91f34c3c
--- /dev/null
+++ b/btest-trial.sh
@@ -0,0 +1,9 @@
+#!/usr/bin/bash
+
+if [ -e sideplugin/topling-rocks-bak ]; then
+ echo sideplugin/topling-rocks-bak exists >&2
+ exit 1
+fi
+mv sideplugin/{topling-rocks,topling-rocks-bak}
+make WITH_TOPLING_ROCKS=1 $@
+mv sideplugin/{topling-rocks-bak,topling-rocks}
diff --git a/build-min-dep-jni.sh b/build-min-dep-jni.sh
new file mode 100644
index 0000000000..d94fad8d92
--- /dev/null
+++ b/build-min-dep-jni.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/bash
+
+ROCKSDB_VERSION=`build_tools/version.sh full`
+
+if [ -z "${TOPLING_VERSION}" ]; then
+ GITHUB_REF=`git describe --tags --exact-match || git branch --show-current`
+ # GITHUB_REF seems like: topling-8.10.2-frocksdb-1.0, part will be ignored
+ TOPLING_VERSION=`echo ${GITHUB_REF} | sed -n 's:^topling-'${ROCKSDB_VERSION}'[-_a-z]*\([.0-9]\):\1:p'`
+ if [ -z "${TOPLING_VERSION}" ]; then
+ echo TOPLING_VERSION is not set and can not parse from HEAD ref >&2
+ exit 1
+ fi
+fi
+#ROCKSDB_JAVA_VERSION=${ROCKSDB_VERSION}-topling-${TOPLING_VERSION}-trial${TOPLING_ZIP_TABLE_TRIAL_DAYS}
+ROCKSDB_JAVA_VERSION=${ROCKSDB_VERSION}-topling-${TOPLING_VERSION}
+
+export USE_LTO=1
+export UPDATE_REPO=0
+export DEBUG_LEVEL=0
+export DISABLE_JEMALLOC=1
+export ROCKSDB_DISABLE_GFLAGS=1
+export TOPLING_USE_DYNAMIC_TLS=1
+export TOPLING_ZIP_TABLE_TRIAL_DAYS=90
+MAJOR_DOT_MINOR=`build_tools/version.sh major`.`build_tools/version.sh minor`
+
+rm -rf java/include
+rm -rf snappy* lz4* bzip2*
+rm -f libsnappy.a liblz4.a libbz2.a
+make -j60 libsnappy.a liblz4.a libbz2.a
+make rocksdbjava install-dcompact -j`nproc` BUILD_PREFIX=min-dep-jni/ \
+ PREFIX=min-dep-jni STRIP_DEBUG_INFO=1 ROCKSDB_JAR_WITH_DYNAMIC_LIBS=1
+
+patchelf --replace-needed librocksdb.so.${MAJOR_DOT_MINOR} librocksdbjni-linux64.so min-dep-jni/bin/dcompact_worker.exe
+
+cd java/target
+db_artifactId=`sed -n 's/.*\(f\?rocksdbjni\)<\/artifactId>.*/\1/p' ../pom.xml.template`
+TARGET_JAR=${db_artifactId}-${ROCKSDB_JAVA_VERSION}.jar
+mv rocksdbjni-${ROCKSDB_VERSION}-linux64.jar ${TARGET_JAR}
+rm *.sha1
+( # in sub shell
+ cd ../../min-dep-jni/bin
+ jar -uf ../../java/target/${TARGET_JAR} dcompact_worker.exe
+)
+shasum -a 1 ${TARGET_JAR} > ${TARGET_JAR}.sha1
+md5sum ${TARGET_JAR} > ${TARGET_JAR}.md5
+
+source /etc/os-release
+if [ "${ID}" = "centos" ]; then
+ ospart=/${ID}${VERSION_ID}
+fi
+#ospart # e.g. "/centos7"
+dir=toplingdb${ospart}/cn/topling/${db_artifactId}/${ROCKSDB_JAVA_VERSION}
+for file in ${TARGET_JAR}{,.sha1,.md5} ; do
+ ossutil cp --region=cn-qingdao -f $file oss://topling-tools/${dir}/
+done
+set +x
+echo ===========================================
+echo ======== Download URL
+echo ===========================================
+echo https://topling-tools.oss-cn-qingdao.aliyuncs.com/${dir}/${TARGET_JAR}
+echo https://topling-tools.oss-cn-qingdao.aliyuncs.com/${dir}/${TARGET_JAR}.sha1
+echo https://topling-tools.oss-cn-qingdao.aliyuncs.com/${dir}/${TARGET_JAR}.md5
+echo ===========================================
diff --git a/build-min-dep-release.sh b/build-min-dep-release.sh
new file mode 100644
index 0000000000..8bb12c2501
--- /dev/null
+++ b/build-min-dep-release.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/bash
+
+export USE_LTO=1
+export ROCKSDB_DISABLE_GFLAGS=1
+export TOPLING_ZIP_TABLE_TRIAL_DAYS=90
+make UPDATE_REPO=0 DEBUG_LEVEL=0 DISABLE_JEMALLOC=1 TOPLING_USE_DYNAMIC_TLS=1 -j60 libsnappy.a liblz4.a libbz2.a
+make rocksdbjava install-dcompact -j`nproc`
+ DEBUG_LEVEL=0 UPDATE_REPO=0 PREFIX=install-here \
+ DISABLE_JEMALLOC=1 TOPLING_USE_DYNAMIC_TLS=1 \
+ STRIP_DEBUG_INFO=1 ROCKSDB_JAR_WITH_DYNAMIC_LIBS=1
+
diff --git a/build-trial.sh b/build-trial.sh
new file mode 100644
index 0000000000..cbd27cc466
--- /dev/null
+++ b/build-trial.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/bash
+
+export UPDATE_REPO=0
+#export ROCKSDB_DISABLE_GFLAGS=1
+export TOPLING_ZIP_TABLE_TRIAL_DAYS=90
+MAJOR_DOT_MINOR=`build_tools/version.sh major`.`build_tools/version.sh minor`
+
+make -j60 libsnappy.a liblz4.a libbz2.a BUILD_PREFIX=bconf-0/
+GetDebugLevel=(2 0)
+for ((i=0;i<16;i++)); do
+ export DEBUG_LEVEL=${GetDebugLevel[$((i/1%2))]}
+ export USE_LTO=$((i/2%2))
+ export DISABLE_JEMALLOC=$((i/4%2))
+ export TOPLING_USE_DYNAMIC_TLS=$((i/8%2))
+ make -j`nproc` upload-trial BUILD_PREFIX=bconf-${i}/
+done
+# The last bconf-15 is release build which:
+# DEBUG_LEVEL=0,USE_LTO=1,DISABLE_JEMALLOC=1,TOPLING_USE_DYNAMIC_TLS=1
+export BUILD_PREFIX=bconf-15/
+rm -rf toplingdb-${MAJOR_DOT_MINOR}
+rm -rf librocksdb* db_bench
+rm -rf sideplugin/topling-dcompact/tools/dcompact/build
+make install-dcompact install-dev db_bench -j`nproc` \
+ PREFIX=toplingdb-${MAJOR_DOT_MINOR} STRIP_DEBUG_INFO=1
+
+install -C -m 755 db_bench toplingdb-${MAJOR_DOT_MINOR}/bin
+install -C -m 755 db_bench.sh toplingdb-${MAJOR_DOT_MINOR}
+strip toplingdb-${MAJOR_DOT_MINOR}/bin/db_bench
+sed -e 's:sideplugin/rockside/src/topling/web:site:' \
+ -e 's:sideplugin/rockside/sample-conf:toplingdb-conf:' \
+ -e 's:\./db_bench:bin/db_bench:' \
+ -e '/ulimit/iexport LD_LIBRARY_PATH=lib:$LD_LIBRARY_PATH' \
+ -i toplingdb-${MAJOR_DOT_MINOR}/db_bench.sh
+source /etc/os-release
+if [ "${ID}" = "centos" ]; then
+ ospart=-${ID}${VERSION_ID} # e.g. "-centos7"
+else
+ ospart="" # keep empty
+fi
+sdk=toplingdb-${MAJOR_DOT_MINOR}-trail${TOPLING_ZIP_TABLE_TRIAL_DAYS}${ospart}.tgz
+tar czf ${sdk} toplingdb-${MAJOR_DOT_MINOR}
+ossutil cp --region=cn-qingdao -f ${sdk} oss://topling-tools/
diff --git a/compile.sh b/compile.sh
new file mode 100644
index 0000000000..b50a735c9f
--- /dev/null
+++ b/compile.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+export SANDCASTLE=1
+export BUILD_PREFIX=../build-toplingdb/
+export PATH=/usr/local/bin:$PATH
+export CXX=clang++
+export CC=clang
+
+ROCKSDB_VERSION=`build_tools/version.sh full`
+TOPLING_CORE_DIR=sideplugin/topling-zip
+COMPILER=`bash ${TOPLING_CORE_DIR}/get-compiler-name.sh`
+WITH_BMI2=`bash ${TOPLING_CORE_DIR}/cpu_has_bmi2.sh`
+UNAME_MachineSystem=`uname -m -s | sed 's:[ /]:-:g'`
+BUILD_NAME=${UNAME_MachineSystem}-${COMPILER}-bmi2-${WITH_BMI2}
+BUILD_ROOT=build/${BUILD_NAME}
+
+dir=${BUILD_PREFIX}build/${BUILD_NAME}/dbg/v${ROCKSDB_VERSION}
+dir_ut=${BUILD_PREFIX}build-ut/${BUILD_NAME}/dbg/v${ROCKSDB_VERSION}
+DEBUG_LEVEL=2
+function map() {
+ if [[ $1 == *test*.o ]]; then
+ echo $dir_ut/$1
+ elif [[ $1 == *.o ]]; then
+ echo $dir/$1
+ else
+ echo $1
+ fi
+}
+targets=(`for i in $@;do map $i;done`)
+
+make PREFIX=/opt UPDATE_REPO=0 -j`nproc` ${targets[@]}
diff --git a/db/blob/db_blob_basic_test.cc b/db/blob/db_blob_basic_test.cc
index 1c0caba93d..617b7939fc 100644
--- a/db/blob/db_blob_basic_test.cc
+++ b/db/blob/db_blob_basic_test.cc
@@ -942,9 +942,11 @@ TEST_F(DBBlobBasicTest, MultiGetBlob_CorruptIndex) {
"Version::MultiGet::TamperWithBlobIndex", [&key](void* arg) {
KeyContext* const key_context = static_cast(arg);
assert(key_context);
+ #if defined(TOPLINGDB_WITH_TIMESTAMP)
assert(key_context->key);
+ #endif
- if (*(key_context->key) == key) {
+ if (key_context->ukey_without_ts == key) {
Slice* const blob_index = key_context->value;
assert(blob_index);
assert(!blob_index->empty());
diff --git a/db/c.cc b/db/c.cc
index 407316f7ca..d62bfbfd71 100644
--- a/db/c.cc
+++ b/db/c.cc
@@ -50,7 +50,9 @@
#include "rocksdb/write_buffer_manager.h"
#include "util/stderr_logger.h"
#include "utilities/merge_operators.h"
-#include "topling/side_plugin_repo.h"
+#include "topling/side_plugin_factory.h"
+#include "db/compaction/compaction_executor.h"
+#include "logging/logging.h"
using ROCKSDB_NAMESPACE::BackupEngine;
using ROCKSDB_NAMESPACE::BackupEngineOptions;
@@ -4544,6 +4546,10 @@ void rocksdb_readoptions_finish_pin(rocksdb_readoptions_t* opt) {
return opt->rep.FinishPin();
}
+unsigned char rocksdb_readoptions_is_in_pinning_section(rocksdb_readoptions_t* opt) {
+ return opt->rep.internal_is_in_pinning_section ? 1 : 0;
+}
+
void rocksdb_readoptions_set_async_queue_depth(rocksdb_readoptions_t* opt, size_t v) {
v = std::min(v, (size_t)1024);
opt->rep.async_queue_depth = v;
@@ -6754,6 +6760,16 @@ const char* rocksdb_pinnableslice_value(const rocksdb_pinnableslice_t* v,
return v->rep.data();
}
+struct rocksdb_stdstr_t {
+ std::string rep;
+};
+
+rocksdb_stdstr_t* rocksdb_stdstr_create(const char* str, size_t len) {
+ return new rocksdb_stdstr_t{std::string(str, len)};
+}
+
+void rocksdb_stdstr_destroy(rocksdb_stdstr_t* v) { delete v; }
+
// container to keep databases and caches in order to use
// ROCKSDB_NAMESPACE::MemoryUtil
struct rocksdb_memory_consumers_t {
@@ -7005,6 +7021,12 @@ void side_plugin_repo_import_auto_file(side_plugin_repo_t* r,
SaveError(errptr, s);
}
+void side_plugin_repo_import(side_plugin_repo_t* r,
+ const char* json_str, char** errptr) {
+ auto s = r->repo.Import(std::string(json_str));
+ SaveError(errptr, s);
+}
+
rocksdb_t* side_plugin_repo_open(side_plugin_repo_t* r,
rocksdb_column_family_handle_t*** p_cfhs, size_t* num_cf, char** errptr) {
if (p_cfhs) { // Open with column families
@@ -7070,13 +7092,280 @@ void side_plugin_repo_put_cf_options(side_plugin_repo_t* r, const char* name,
r->repo.Put(name, std::make_shared(opt->rep));
}
+bool side_plugin_db_options_update_from(rocksdb_options_t* opt, const side_plugin_repo_t* r, const char* name) {
+ return r->repo.DBOptionsUpdateFrom(&opt->rep, name);
+}
+
+bool side_plugin_cf_options_update_from(rocksdb_options_t* opt, const side_plugin_repo_t* r, const char* name) {
+ return r->repo.CFOptionsUpdateFrom(&opt->rep, name);
+}
+
void side_plugin_repo_close_all(side_plugin_repo_t* r) {
r->repo.CloseAllDB(false); // also close http
delete r;
}
+void side_plugin_repo_forget_db(side_plugin_repo_t* r, rocksdb_t* db) {
+ r->repo.CloseOneDB(db->rep, false);
+}
+
const char* rocksdb_get_name(rocksdb_t* p) {
return p->rep->GetName().c_str();
}
+} // end extern "C"
+
+#define DoPrintLog(...) \
+ info_log ? ROCKS_LOG_INFO(info_log, __VA_ARGS__) \
+ : (void)fprintf(stderr, __VA_ARGS__)
+#define PrintLog(level, fmt, ...) \
+ do { if (SidePluginRepo::DebugLevel() >= level) \
+ DoPrintLog("%s: " fmt "\n", \
+ TERARK_PP_SmartForPrintf(rocksdb::StrDateTimeNow(), ## __VA_ARGS__)); \
+ } while (0)
+#define TRAC(...) PrintLog(4, "TRAC: " __VA_ARGS__)
+#define DEBG(...) PrintLog(3, "DEBG: " __VA_ARGS__)
+#define INFO(...) PrintLog(2, "INFO: " __VA_ARGS__)
+#define WARN(...) PrintLog(1, "WARN: " __VA_ARGS__)
+
+namespace ROCKSDB_NAMESPACE {
+
+template
+static void* get_ffi_obj(const FFI_BridgeObject* bridge) {
+ // existing rocksdb bridge class consitently name ffi_obj as state_.
+ // bridge itself is always const.
+ return bridge->state_;
+}
+
+using terark::llong;
+template
+struct FFI_SerDe : public DcompactSerDeFunc