diff --git a/docs/user_manual/Small_Materialized_Aggrates.md b/docs/user_manual/Small_Materialized_Aggrates.md new file mode 100644 index 0000000000000000000000000000000000000000..e13a623afb144a3f785fdfc59f3e7e880667463c --- /dev/null +++ b/docs/user_manual/Small_Materialized_Aggrates.md @@ -0,0 +1,42 @@ +# Small Materialized Aggragates + +**SMA** (**S**mall **M**aterialized **A**ggrates) is used to speed up the query process on materialized data cube in TDengine. TDengine 3.0 gives more flexibility on the SMA configurations. + +There are two kinds of SMA in TDengine: +1. Block-wise SMA +2. Time-range-wise SMA + + + +![SMA in TDengine 3.0](http://www.plantuml.com/plantuml/png/Kr1GK70eBaaiAidDp4l9JInG0D7nG4PyIMfn2HTGMa5B8TZN4SBIKd3AoK_ErYtFB4v55Wt9p4tLBKhCIqz5bN981HeACHW0) +## Block-wise SMA +Block-wise SMA is created by default when the data are committed. Since time-series data are saved as block data in files, a corresponding SMA is create when the data block is written. The default block-wise SMA includes: +1. sum(*) +2. max(*) +3. min(*) + +By default, the system will create SMA for each column except those columns with type *binary* and *nchar*. However, users can change the behavior by the keyword **NOSMA** to disable the SMA for a certain column like below: +```SQL +# create a super table with the SMA on column b disabled +create table st (ts timestamp, a int, b int NOSMA, c double) tags (tg1 binary(10), tg2 int); +``` + +## Time-range-wise SMA +In addition to the default block-wise SMA, users can create their own SMAs ondemand. Below is an example to create a SMA. +```SQL +# create a SMA every 10 minutes with SMA of sum, max and min +create sma_indx sma_10min on st (sum(*), max(*), min(*), twa(*)) interval(10m); +``` +Users can also drop a time-range-wise SMA like below: +```SQL +# drop the sma index +drop sma_index sma_5min on st; +``` +**NOTE: Creating an SMA index is a heavy operation which may take a long time and block the write operation. So create the time-range-wise SMA when creating the table or when there are not too much data.** \ No newline at end of file diff --git a/source/server/vnode/CMakeLists.txt b/source/server/vnode/CMakeLists.txt index 573cea79b5066db8e826d32378584d62abc6734d..a4a9cff002a16f990e3010e06ed4461864c1ed64 100644 --- a/source/server/vnode/CMakeLists.txt +++ b/source/server/vnode/CMakeLists.txt @@ -1,26 +1,4 @@ add_subdirectory(meta) add_subdirectory(tq) add_subdirectory(tsdb) - -aux_source_directory(src VNODE_SRC) -add_library(vnode STATIC ${VNODE_SRC}) -target_include_directories( - vnode - PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode" - private "${CMAKE_CURRENT_SOURCE_DIR}/inc" -) -target_link_libraries( - vnode - PUBLIC transport - PUBLIC meta - PUBLIC tq - PUBLIC tsdb - PUBLIC wal - PUBLIC sync - PUBLIC cjson -) - -# test -if(${BUILD_TEST}) - add_subdirectory(test) -endif(${BUILD_TEST}) \ No newline at end of file +add_subdirectory(impl) \ No newline at end of file diff --git a/source/server/vnode/impl/CMakeLists.txt b/source/server/vnode/impl/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..81744df79c008114e807052fe48fe3166caf7580 --- /dev/null +++ b/source/server/vnode/impl/CMakeLists.txt @@ -0,0 +1,22 @@ +aux_source_directory(src VNODE_SRC) +add_library(vnode STATIC ${VNODE_SRC}) +target_include_directories( + vnode + PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode" + private "${CMAKE_CURRENT_SOURCE_DIR}/inc" +) +target_link_libraries( + vnode + PUBLIC transport + PUBLIC meta + PUBLIC tq + PUBLIC tsdb + PUBLIC wal + PUBLIC sync + PUBLIC cjson +) + +# test +if(${BUILD_TEST}) + add_subdirectory(test) +endif(${BUILD_TEST}) \ No newline at end of file diff --git a/source/server/vnode/inc/vnodeCommit.h b/source/server/vnode/impl/inc/vnodeCommit.h similarity index 100% rename from source/server/vnode/inc/vnodeCommit.h rename to source/server/vnode/impl/inc/vnodeCommit.h diff --git a/source/server/vnode/inc/vnodeFile.h b/source/server/vnode/impl/inc/vnodeFile.h similarity index 100% rename from source/server/vnode/inc/vnodeFile.h rename to source/server/vnode/impl/inc/vnodeFile.h diff --git a/source/server/vnode/inc/vnodeInt.h b/source/server/vnode/impl/inc/vnodeInt.h similarity index 100% rename from source/server/vnode/inc/vnodeInt.h rename to source/server/vnode/impl/inc/vnodeInt.h diff --git a/source/server/vnode/inc/vnodeMain.h b/source/server/vnode/impl/inc/vnodeMain.h similarity index 100% rename from source/server/vnode/inc/vnodeMain.h rename to source/server/vnode/impl/inc/vnodeMain.h diff --git a/source/server/vnode/inc/vnodeMemAllocator.h b/source/server/vnode/impl/inc/vnodeMemAllocator.h similarity index 100% rename from source/server/vnode/inc/vnodeMemAllocator.h rename to source/server/vnode/impl/inc/vnodeMemAllocator.h diff --git a/source/server/vnode/inc/vnodeMgmt.h b/source/server/vnode/impl/inc/vnodeMgmt.h similarity index 100% rename from source/server/vnode/inc/vnodeMgmt.h rename to source/server/vnode/impl/inc/vnodeMgmt.h diff --git a/source/server/vnode/inc/vnodeRead.h b/source/server/vnode/impl/inc/vnodeRead.h similarity index 100% rename from source/server/vnode/inc/vnodeRead.h rename to source/server/vnode/impl/inc/vnodeRead.h diff --git a/source/server/vnode/inc/vnodeReadMsg.h b/source/server/vnode/impl/inc/vnodeReadMsg.h similarity index 100% rename from source/server/vnode/inc/vnodeReadMsg.h rename to source/server/vnode/impl/inc/vnodeReadMsg.h diff --git a/source/server/vnode/inc/vnodeWrite.h b/source/server/vnode/impl/inc/vnodeWrite.h similarity index 100% rename from source/server/vnode/inc/vnodeWrite.h rename to source/server/vnode/impl/inc/vnodeWrite.h diff --git a/source/server/vnode/inc/vnodeWriteMsg.h b/source/server/vnode/impl/inc/vnodeWriteMsg.h similarity index 100% rename from source/server/vnode/inc/vnodeWriteMsg.h rename to source/server/vnode/impl/inc/vnodeWriteMsg.h diff --git a/source/server/vnode/src/vnodeCommit.c b/source/server/vnode/impl/src/vnodeCommit.c similarity index 100% rename from source/server/vnode/src/vnodeCommit.c rename to source/server/vnode/impl/src/vnodeCommit.c diff --git a/source/server/vnode/src/vnodeFile.c b/source/server/vnode/impl/src/vnodeFile.c similarity index 100% rename from source/server/vnode/src/vnodeFile.c rename to source/server/vnode/impl/src/vnodeFile.c diff --git a/source/server/vnode/src/vnodeInt.c b/source/server/vnode/impl/src/vnodeInt.c similarity index 100% rename from source/server/vnode/src/vnodeInt.c rename to source/server/vnode/impl/src/vnodeInt.c diff --git a/source/server/vnode/src/vnodeMain.c b/source/server/vnode/impl/src/vnodeMain.c similarity index 100% rename from source/server/vnode/src/vnodeMain.c rename to source/server/vnode/impl/src/vnodeMain.c diff --git a/source/server/vnode/src/vnodeMemAllocator.c b/source/server/vnode/impl/src/vnodeMemAllocator.c similarity index 100% rename from source/server/vnode/src/vnodeMemAllocator.c rename to source/server/vnode/impl/src/vnodeMemAllocator.c diff --git a/source/server/vnode/src/vnodeMgmt.c b/source/server/vnode/impl/src/vnodeMgmt.c similarity index 100% rename from source/server/vnode/src/vnodeMgmt.c rename to source/server/vnode/impl/src/vnodeMgmt.c diff --git a/source/server/vnode/src/vnodeRead.c b/source/server/vnode/impl/src/vnodeRead.c similarity index 100% rename from source/server/vnode/src/vnodeRead.c rename to source/server/vnode/impl/src/vnodeRead.c diff --git a/source/server/vnode/src/vnodeReadMsg.c b/source/server/vnode/impl/src/vnodeReadMsg.c similarity index 100% rename from source/server/vnode/src/vnodeReadMsg.c rename to source/server/vnode/impl/src/vnodeReadMsg.c diff --git a/source/server/vnode/src/vnodeWrite.c b/source/server/vnode/impl/src/vnodeWrite.c similarity index 100% rename from source/server/vnode/src/vnodeWrite.c rename to source/server/vnode/impl/src/vnodeWrite.c diff --git a/source/server/vnode/src/vnodeWriteMsg.c b/source/server/vnode/impl/src/vnodeWriteMsg.c similarity index 100% rename from source/server/vnode/src/vnodeWriteMsg.c rename to source/server/vnode/impl/src/vnodeWriteMsg.c diff --git a/source/server/vnode/test/CMakeLists.txt b/source/server/vnode/impl/test/CMakeLists.txt similarity index 100% rename from source/server/vnode/test/CMakeLists.txt rename to source/server/vnode/impl/test/CMakeLists.txt diff --git a/source/server/vnode/test/vnodeMemAllocatorTest.cpp b/source/server/vnode/impl/test/vnodeMemAllocatorTest.cpp similarity index 100% rename from source/server/vnode/test/vnodeMemAllocatorTest.cpp rename to source/server/vnode/impl/test/vnodeMemAllocatorTest.cpp diff --git a/source/server/vnode/test/vnodeTests.cpp b/source/server/vnode/impl/test/vnodeTests.cpp similarity index 100% rename from source/server/vnode/test/vnodeTests.cpp rename to source/server/vnode/impl/test/vnodeTests.cpp