Skip to content

Commit 651f4af

Browse files
committed
restore non-performance files to develop; merge B-category overlaps
The squash carried implicit reverts of every develop commit landed between the old branch base (e3cdf87) and current HEAD (2a864c5) — typo fixes (21988e7), the get_timeseries_metadata N+1 optimization (324acba), the TS_2DIFF float/double overflow-page fix (2a864c5), the 2.3.1 release-prep poms, and several regression tests in develop's reader/writer test suites. This commit: - restores 16 files the optimization branch never touched - 3-way merges 15 files both sides modified, keeping develop's typo fixes / N+1 optimization / TS_2DIFF overflow bitmaps / regression tests on top of the read/write batch optimization changes - keeps the small Windows-only compile fix in query_by_row_performance_test.cc and the zlib-1.2.13 -> 1.3.1 bump - restores the cpp/CMakeLists.txt TSFILE_OPTIMIZATION_FLAGS knob while keeping -O3 -march=native -flto as the Linux/macOS Release default
1 parent 991b852 commit 651f4af

69 files changed

Lines changed: 1927 additions & 193 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

RELEASE_NOTES.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@
1818
under the License.
1919
2020
-->
21+
# Apache TsFile 2.3.1
22+
23+
## New Features
24+
25+
- Added scripts to convert CSV, Parquet and Arrow formats to TsFile.
26+
- Adapted TsFile for the MSVC compiler.
27+
28+
## Bugs
29+
30+
- Fixed the issue that the format conversion scripts did not support date and timestamp data types.
31+
- Fixed garbled characters when using Chinese table names in the conversion scripts.
32+
- Fixed the issue where TsFile displayed empty when converting with uppercase column names.
33+
2134
# Apache TsFile 2.3.0
2235

2336
## New Features
@@ -187,7 +200,7 @@
187200
* Added accountable function to measurementSchema by @Caideyipi in #509
188201
* Correct the retained size calculation for BinaryColumn and BinaryColumnBuilder by @JackieTien97 in #514
189202
* add switch to disable native lz4 (#480) by @jt2594838 in #515
190-
* Correct the memroy calculation of BinaryColumnBuilder by @JackieTien97 in #530
203+
* Correct the memory calculation of BinaryColumnBuilder by @JackieTien97 in #530
191204
* Fetch max tsblock line number each time from TSFileConfig by @JackieTien97 in #535
192205
* Support set default compression by data type & Bump org.apache.commons:commons-lang3 from 3.15.0 to 3.18.0 by @jt2594838 in #547
193206
* Avoid calculating shallow size of map by @shuwenwei in #566

cpp/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ cpp/src/
9292
## Code Style
9393

9494
- **Formatter**: clang-format (Google style), configured in `.clang-format`
95+
- After modifying C++ code, run from the repo root to format: `./mvnw spotless:apply -P with-cpp`
9596

9697
## Testing
9798

cpp/CMakeLists.txt

100644100755
Lines changed: 74 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ endif ()
3232
set(TsFile_CPP_VERSION 2.2.1.dev)
3333

3434
if (MSVC)
35-
# MSVC has no /std:c++11 flag; pin the closest supported standard mode.
35+
# MSVC does not provide a /std:c++11 flag; C++11 is its implicit baseline.
36+
# The lowest explicitly settable standard is /std:c++14. Without this flag,
37+
# the default varies by VS version (VS2017+ defaults to C++14 mode with some
38+
# C++17 extensions), so we pin it explicitly for reproducibility.
3639
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} /W3 /utf-8 /EHsc /bigobj /Zc:__cplusplus /std:c++14")
3740
add_definitions(-DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS
3841
-D_SCL_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
42+
# Export all symbols of the tsfile shared library automatically so that
43+
# consumers do not need __declspec(dllexport) annotations.
3944
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
4045
else ()
4146
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -Wall")
@@ -46,6 +51,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
4651
endif ()
4752

4853
message("cmake using: USE_CPP11=${USE_CPP11}")
54+
# MSVC has no /std:c++11; CMake maps this to the closest supported standard
55+
# (C++14 default on MSVC), which compiles the C++11 codebase fine.
4956
set(CMAKE_CXX_STANDARD 11)
5057
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
5158
if (NOT MSVC)
@@ -73,6 +80,13 @@ if (${COV_ENABLED})
7380
message("add_definitions -DCOV_ENABLED=1")
7481
endif ()
7582

83+
option(ENABLE_MEM_STAT "Enable memory status" ON)
84+
85+
if (ENABLE_MEM_STAT)
86+
add_definitions(-DENABLE_MEM_STAT)
87+
message("add_definitions -DENABLE_MEM_STAT")
88+
endif ()
89+
7690

7791
if (NOT CMAKE_BUILD_TYPE)
7892
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
@@ -91,25 +105,46 @@ else ()
91105
endif ()
92106

93107
message("CMAKE BUILD TYPE " ${CMAKE_BUILD_TYPE})
94-
if (NOT MSVC)
95-
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
96-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
97-
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
98-
# -flto + MinGW gcc + statically-linked antlr4_static produces
99-
# unresolved-reference errors at link time (LTO intermediate objects
100-
# can't see the .a's vtable thunks). -march=native is also a poor
101-
# default for CI binaries shipped to other machines. Keep both on
102-
# Linux/macOS where the optimization actually pays off.
103-
if (MINGW OR WIN32)
104-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
105-
else ()
106-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -flto")
108+
# Keep optimization policy external by default (caller/toolchain/CMake defaults).
109+
set(TSFILE_OPTIMIZATION_FLAGS ""
110+
CACHE STRING
111+
"Optional extra optimization flags for tsfile-cpp (e.g. -O3). Empty means inherit caller defaults.")
112+
if (TSFILE_OPTIMIZATION_FLAGS)
113+
# Apply after CMake defaults for each config so explicit optimization can
114+
# override default -O flags in Release/RelWithDebInfo/Debug/MinSizeRel.
115+
set(CMAKE_CXX_FLAGS_DEBUG
116+
"${CMAKE_CXX_FLAGS_DEBUG} ${TSFILE_OPTIMIZATION_FLAGS}")
117+
set(CMAKE_CXX_FLAGS_RELEASE
118+
"${CMAKE_CXX_FLAGS_RELEASE} ${TSFILE_OPTIMIZATION_FLAGS}")
119+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
120+
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${TSFILE_OPTIMIZATION_FLAGS}")
121+
set(CMAKE_CXX_FLAGS_MINSIZEREL
122+
"${CMAKE_CXX_FLAGS_MINSIZEREL} ${TSFILE_OPTIMIZATION_FLAGS}")
123+
message("cmake using: TSFILE_OPTIMIZATION_FLAGS=${TSFILE_OPTIMIZATION_FLAGS}")
124+
else ()
125+
message("cmake using: TSFILE_OPTIMIZATION_FLAGS=<inherit>")
126+
# MSVC provides sensible per-configuration optimization flags by default; the
127+
# GCC-style flags below would be rejected by cl.exe, so skip them on MSVC.
128+
if (NOT MSVC)
129+
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
130+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
131+
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
132+
# -flto + MinGW gcc + statically-linked antlr4_static produces
133+
# unresolved-reference errors at link time (LTO intermediate objects
134+
# can't see the .a's vtable thunks). -march=native is also a poor
135+
# default for CI binaries shipped to other machines. Keep both on
136+
# Linux/macOS where the optimization actually pays off.
137+
if (MINGW OR WIN32)
138+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
139+
else ()
140+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -flto")
141+
endif ()
142+
elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
143+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g")
144+
elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
145+
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -ffunction-sections -fdata-sections -Os")
146+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
107147
endif ()
108-
elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
109-
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O2 -g")
110-
elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
111-
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -ffunction-sections -fdata-sections -Os")
112-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
113148
endif ()
114149
endif ()
115150
message("CMAKE DEBUG: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
@@ -120,11 +155,22 @@ option(ENABLE_ASAN "Enable Address Sanitizer" OFF)
120155
if (ENABLE_ASAN)
121156
message("Address Sanitizer is enabled.")
122157
if (MSVC)
158+
# MSVC ships AddressSanitizer; it requires Visual Studio 2019 16.9 or
159+
# newer (MSVC_VERSION >= 1928). Only the address sanitizer is available
160+
# (there is no UndefinedBehaviorSanitizer for MSVC).
123161
if (MSVC_VERSION LESS 1928)
124162
message(FATAL_ERROR
125163
"ENABLE_ASAN requires MSVC 19.28+ (Visual Studio 2019 16.9); "
126164
"detected MSVC_VERSION=${MSVC_VERSION}.")
127165
endif ()
166+
# /fsanitize=address is incompatible with the /RTC* runtime checks that
167+
# CMake injects into Debug builds, and with incremental linking. Strip
168+
# /RTC* from the per-config flags and force non-incremental linking.
169+
#
170+
# ASan also needs debug info: /Zi (compile) + /DEBUG (link). Without it
171+
# MSVC emits warning C5072 ("ASAN enabled without debug information
172+
# emission"), which the bundled googletest build promotes to an error
173+
# via /WX in Release builds, and ASan reports lose symbol/line info.
128174
add_compile_options(/fsanitize=address /Zi)
129175
foreach (flagsVar
130176
CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG
@@ -135,19 +181,6 @@ if (ENABLE_ASAN)
135181
elseif (NOT WIN32)
136182
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined -fno-omit-frame-pointer")
137183

138-
# -flto + libstdc++ <regex> produces spurious ODR-violation reports
139-
# under ASan (globals like __classnames / __collatenames in
140-
# bits/regex.tcc show up once per LTO partition).
141-
#
142-
# -march=native lets gcc autovectorize tight byte-stride loops
143-
# (e.g. Int64Packer::unpack_8values) into AVX2 32-byte gathers
144-
# that overread by up to one SIMD lane past the end of the input
145-
# buffer; the read sits inside ASan's redzone and ASan traps it
146-
# as SEGV. The non-vectorized scalar code is correct, so just
147-
# drop the aggressive flags whenever ASan is on.
148-
string(REGEX REPLACE "(^| )-flto( |$)" " " CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
149-
string(REGEX REPLACE "(^| )-march=native( |$)" " " CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
150-
151184
if (NOT APPLE)
152185
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libasan")
153186
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined -static-libasan -static-libubsan")
@@ -198,10 +231,6 @@ if (ENABLE_ZLIB)
198231
add_definitions(-DENABLE_GZIP)
199232
endif()
200233

201-
option(ENABLE_SIMD "Enable SIMD acceleration via SIMDe" ON)
202-
message("cmake using: ENABLE_SIMD=${ENABLE_SIMD}")
203-
set(ENABLE_SIMDE ${ENABLE_SIMD} CACHE BOOL "Enable SIMDe (SIMD Everywhere)" FORCE)
204-
205234
option(ENABLE_THREADS "Enable multi-threaded read/write (requires pthreads)" ON)
206235
message("cmake using: ENABLE_THREADS=${ENABLE_THREADS}")
207236

@@ -211,11 +240,11 @@ if (ENABLE_THREADS)
211240
link_libraries(Threads::Threads)
212241
endif()
213242

214-
option(ENABLE_MEM_STAT "Enable per-module memory allocation statistics" ON)
215-
message("cmake using: ENABLE_MEM_STAT=${ENABLE_MEM_STAT}")
243+
option(ENABLE_SIMDE "Enable SIMDe (SIMD Everywhere)" OFF)
244+
message("cmake using: ENABLE_SIMDE=${ENABLE_SIMDE}")
216245

217-
if (ENABLE_MEM_STAT)
218-
add_definitions(-DENABLE_MEM_STAT)
246+
if (ENABLE_SIMDE)
247+
add_definitions(-DENABLE_SIMDE)
219248
endif()
220249

221250
# All libs will be stored here, including libtsfile, compress-encoding lib.
@@ -231,12 +260,15 @@ set(THIRD_PARTY_INCLUDE ${PROJECT_BINARY_DIR}/third_party)
231260

232261
set(SAVED_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
233262
if (MSVC)
263+
# MSVC does not provide a /std:c++11 flag; C++11 is its implicit baseline.
264+
# The lowest explicitly settable standard is /std:c++14. Without this flag,
265+
# the default varies by VS version (VS2017+ defaults to C++14 mode with some
266+
# C++17 extensions), so we pin it explicitly for reproducibility.
234267
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} /W3 /utf-8 /EHsc /bigobj /Zc:__cplusplus /std:c++14")
235268
else ()
236269
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -Wall -std=c++11")
237270
endif ()
238271
add_subdirectory(third_party)
239-
set(CMAKE_CXX_FLAGS "${SAVED_CXX_FLAGS}")
240272

241273
add_subdirectory(src)
242274
if (BUILD_TEST)
@@ -248,11 +280,5 @@ else()
248280
message("BUILD_TEST is OFF, skipping test directory")
249281
endif ()
250282

251-
option(BUILD_EXAMPLES "Build examples (requires Arrow/Parquet)" OFF)
252-
if (BUILD_EXAMPLES)
253-
add_subdirectory(examples)
254-
endif()
283+
add_subdirectory(examples)
255284

256-
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/experiment/CMakeLists.txt")
257-
add_subdirectory(experiment)
258-
endif()

cpp/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ then
149149
cd build/minsizerel
150150
else
151151
echo ""
152-
echo "unknow build type: ${build_type}, valid build types(case intensive): Debug, Release, RelWithDebInfo, MinSizeRel"
152+
echo "unknown build type: ${build_type}, valid build types(case insensitive): Debug, Release, RelWithDebInfo, MinSizeRel"
153153
echo ""
154154
exit 1
155155
fi

cpp/examples/CMakeLists.txt

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,33 @@ message("Running in examples directory")
2222

2323
if (NOT MSVC)
2424
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
25+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
2526
endif ()
2627

27-
# TsFile include dirs
28+
# TsFile include dir
2829
set(SDK_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/../src/)
29-
include_directories(${SDK_INCLUDE_DIR})
30+
message("SDK_INCLUDE_DIR: ${SDK_INCLUDE_DIR}")
31+
32+
# TsFile shared object dir
33+
set(SDK_LIB_DIR_RELEASE ${PROJECT_SOURCE_DIR}/../build/Release/lib)
34+
message("SDK_LIB_DIR_RELEASE: ${SDK_LIB_DIR_RELEASE}")
35+
36+
set(SDK_LIB_DIR_DEBUG ${PROJECT_SOURCE_DIR}/../build/Debug/lib)
37+
message("SDK_LIB_DIR_DEBUG: ${SDK_LIB_DIR_DEBUG}")
3038
include_directories(${PROJECT_SOURCE_DIR}/../third_party/antlr4-cpp-runtime-4/runtime/src)
3139

32-
if (NOT MSVC)
33-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
40+
set(BUILD_TYPE "Release")
41+
include_directories(${SDK_INCLUDE_DIR})
42+
43+
if (DEFINED TSFILE_OPTIMIZATION_FLAGS AND NOT "${TSFILE_OPTIMIZATION_FLAGS}" STREQUAL "")
44+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TSFILE_OPTIMIZATION_FLAGS}")
45+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TSFILE_OPTIMIZATION_FLAGS}")
46+
message("examples using: TSFILE_OPTIMIZATION_FLAGS=${TSFILE_OPTIMIZATION_FLAGS}")
47+
else ()
48+
message("examples using: TSFILE_OPTIMIZATION_FLAGS=<inherit>")
49+
if (NOT MSVC)
50+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
51+
endif ()
3452
endif ()
3553

3654
# Arrow + Parquet are required (for bench_read)

cpp/examples/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ target_link_libraries(your_target ${TSFILE_LIB})
5555

5656
Note: Set ${SDK_LIB} to your TSFile library directory.
5757

58+
### Optional Optimization Control
59+
60+
By default, `tsfile-cpp` inherits optimization settings from the caller/toolchain.
61+
If you want to override optimization for `tsfile-cpp`, pass
62+
`TSFILE_OPTIMIZATION_FLAGS` during configure:
63+
64+
Leave `TSFILE_OPTIMIZATION_FLAGS` empty to keep inherited behavior.
65+
5866
## 3. Implementation Examples
5967

6068
### Directory Structure

cpp/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<parent>
2323
<groupId>org.apache.tsfile</groupId>
2424
<artifactId>tsfile-parent</artifactId>
25-
<version>2.2.1-SNAPSHOT</version>
25+
<version>2.3.2-SNAPSHOT</version>
2626
</parent>
2727
<artifactId>tsfile-cpp</artifactId>
2828
<packaging>pom</packaging>
@@ -99,8 +99,8 @@
9999
plugin's generate goal throw an NPE.
100100
-->
101101
</options>
102-
<sourcePath/>
103-
<targetPath/>
102+
<sourcePath />
103+
<targetPath />
104104
</configuration>
105105
</execution>
106106
<!-- Compile the test code -->

0 commit comments

Comments
 (0)