|
| 1 | +<!-- |
| 2 | +
|
| 3 | + Licensed to the Apache Software Foundation (ASF) under one |
| 4 | + or more contributor license agreements. See the NOTICE file |
| 5 | + distributed with this work for additional information |
| 6 | + regarding copyright ownership. The ASF licenses this file |
| 7 | + to you under the Apache License, Version 2.0 (the |
| 8 | + "License"); you may not use this file except in compliance |
| 9 | + with the License. You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | + Unless required by applicable law or agreed to in writing, |
| 14 | + software distributed under the License is distributed on an |
| 15 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | + KIND, either express or implied. See the License for the |
| 17 | + specific language governing permissions and limitations |
| 18 | + under the License. |
| 19 | +
|
| 20 | +--> |
| 21 | + |
| 22 | +# CLAUDE.md — C++ Module |
| 23 | + |
| 24 | +This file provides guidance to Claude Code (claude.ai/code) when working with the C++ module. |
| 25 | + |
| 26 | +## Build Commands |
| 27 | + |
| 28 | +```bash |
| 29 | +# Build (Release, default) |
| 30 | +bash build.sh |
| 31 | + |
| 32 | +# Build variants |
| 33 | +bash build.sh -t=Debug |
| 34 | +bash build.sh -t=RelWithDebInfo |
| 35 | +bash build.sh -a=ON # Enable AddressSanitizer |
| 36 | +bash build.sh -c=ON # Enable code coverage |
| 37 | + |
| 38 | +# Disable optional compression libraries |
| 39 | +bash build.sh --disable-snappy --disable-lz4 --disable-lzokay --disable-zlib |
| 40 | + |
| 41 | +# Or use CMake directly |
| 42 | +mkdir -p build/Release && cd build/Release |
| 43 | +cmake ../.. -DCMAKE_BUILD_TYPE=Release -DBUILD_TEST=ON |
| 44 | +make -j$(nproc) |
| 45 | + |
| 46 | +# Via Maven from repo root |
| 47 | +./mvnw clean verify -P with-cpp |
| 48 | + |
| 49 | +# Run all tests |
| 50 | +./build/Release/lib/TsFile_Test |
| 51 | + |
| 52 | +# Run specific test suite |
| 53 | +./build/Release/lib/TsFile_Test --gtest_filter=SnappyCompressorTest.* |
| 54 | +``` |
| 55 | + |
| 56 | +## Build Options (CMake) |
| 57 | + |
| 58 | +All `ON` by default unless noted: |
| 59 | + |
| 60 | +| Option | Purpose | |
| 61 | +|--------|---------| |
| 62 | +| `BUILD_TEST` | Compile tests (GTest 1.12.1, auto-downloaded) | |
| 63 | +| `ENABLE_ANTLR4` | ANTLR4 parser runtime | |
| 64 | +| `ENABLE_SNAPPY` / `ENABLE_LZ4` / `ENABLE_LZOKAY` / `ENABLE_ZLIB` | Compression libraries | |
| 65 | +| `ENABLE_THREADS` | Multi-threaded read/write via pthreads | |
| 66 | +| `ENABLE_ASAN` | AddressSanitizer (`OFF` by default) | |
| 67 | +| `ENABLE_SIMDE` | SIMD Everywhere (`OFF` by default) | |
| 68 | + |
| 69 | +## Source Structure |
| 70 | + |
| 71 | +``` |
| 72 | +cpp/src/ |
| 73 | +├── common/ # Core types: Schema, Tablet, DeviceId, TsBlock, allocators, config |
| 74 | +├── compress/ # Compression: Snappy, LZ4, LZOKAY, Zlib (factory pattern) |
| 75 | +├── encoding/ # Encoding: Plain, TS2Diff, Gorilla, Dictionary, RLE, Zigzag, SPRINTZ |
| 76 | +├── file/ # File I/O: TsFileIOReader/Writer, RestorableTsFileIOWriter |
| 77 | +├── reader/ # Read path: TsFileReader, QueryExecutor, filters, result sets |
| 78 | +├── writer/ # Write path: TsFileWriter, TsFileTableWriter, ChunkWriter, PageWriter |
| 79 | +├── parser/ # ANTLR4 path parser (grammars + generated code) |
| 80 | +├── cwrapper/ # C language bindings (used by Python module) |
| 81 | +└── utils/ # Utilities: error codes, date handling, fault injection |
| 82 | +``` |
| 83 | + |
| 84 | +## Architecture Notes |
| 85 | + |
| 86 | +- **C++11** standard, targets CMake 3.11+ |
| 87 | +- Dual data model: **tree-view** (`TsFileTreeWriter/Reader`) and **table-view** (`TsFileTableWriter`, `TableQueryExecutor`) |
| 88 | +- Parallel column encoding in table write path, controlled by `ENABLE_THREADS` |
| 89 | +- Third-party libraries are bundled under `third_party/` (ANTLR4, Snappy, LZ4, LZOKAY, Zlib, SIMDe) |
| 90 | +- `cwrapper/` provides the C API that the Python module binds to via Cython |
| 91 | + |
| 92 | +## Code Style |
| 93 | + |
| 94 | +- **Formatter**: clang-format (Google style), configured in `.clang-format` |
| 95 | + |
| 96 | +## Testing |
| 97 | + |
| 98 | +- **Framework**: Google Test 1.12.1 (auto-downloaded during build, or supply `third_party/googletest-release-1.12.1.zip`) |
| 99 | +- Tests in `cpp/test/`, mirroring `src/` structure |
| 100 | +- Test discovery via `gtest_discover_tests()` |
| 101 | + |
| 102 | +## License Header |
| 103 | + |
| 104 | +Every new file must include the Apache License 2.0 header at the top. For C/C++ files, use the `/* */` block comment style. See any existing `.h` or `.cc` file for the exact wording. |
| 105 | + |
| 106 | +## Git Commit |
| 107 | + |
| 108 | +- Do NOT add `Co-Authored-By` trailer to commit messages. |
0 commit comments