Skip to content

Commit 944fbc6

Browse files
committed
docs: clarify build and commit integration
1 parent ba93b5e commit 944fbc6

6 files changed

Lines changed: 116 additions & 50 deletions

File tree

docs/source/build_system.rst

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,27 @@ for data format and file system.
4848
4949
project(MyExample)
5050
51-
find_package(Arrow REQUIRED)
52-
find_package(Paimon REQUIRED)
51+
# Arrow's static package may export LZ4 under a different target name.
52+
find_package(lz4 CONFIG QUIET)
53+
if(TARGET LZ4::lz4_static AND NOT TARGET LZ4::lz4)
54+
add_library(LZ4::lz4 ALIAS LZ4::lz4_static)
55+
elseif(TARGET lz4::lz4 AND NOT TARGET LZ4::lz4)
56+
add_library(LZ4::lz4 ALIAS lz4::lz4)
57+
endif()
58+
59+
find_package(Arrow CONFIG REQUIRED)
60+
find_package(Paimon CONFIG REQUIRED)
61+
62+
if(TARGET Arrow::arrow_shared)
63+
set(PAIMON_ARROW_TARGET Arrow::arrow_shared)
64+
elseif(TARGET Arrow::arrow_static)
65+
set(PAIMON_ARROW_TARGET Arrow::arrow_static)
66+
else()
67+
message(FATAL_ERROR "No supported Arrow CMake target is available")
68+
endif()
5369
5470
add_executable(my_example my_example.cc)
55-
target_link_libraries(my_example PRIVATE Arrow::arrow_shared
71+
target_link_libraries(my_example PRIVATE ${PAIMON_ARROW_TARGET}
5672
Paimon::paimon_shared
5773
Paimon::paimon_parquet_file_format_shared
5874
Paimon::paimon_local_file_system_shared)
@@ -64,12 +80,15 @@ The directive ``find_package(Paimon REQUIRED)`` instructs CMake to locate a
6480
Paimon C++ installation on your system. If successful, it sets ``Paimon_FOUND``
6581
to true if the Paimon C++ libraries were found.
6682

67-
It also defines the following linkable imported targets:
83+
It defines the following supported imported target:
6884

6985
* ``Paimon::paimon_shared`` links to the Paimon shared libraries
70-
* ``Paimon::paimon_static`` links to the Paimon static libraries
7186

72-
In most cases, it is recommended to use the Paimon shared libraries.
87+
Static targets such as ``Paimon::paimon_static`` may also be present when
88+
Paimon is built with ``PAIMON_BUILD_STATIC=ON``. They are not currently
89+
supported as standalone installed targets because their exported link
90+
interfaces do not include every third-party dependency. Installed consumers
91+
should use the shared targets.
7392

7493
Optional plugins (built-in file formats, file systems, and index)
7594
-----------------------------------------------------------------
@@ -78,22 +97,24 @@ Paimon provides a set of built-in optional plugins that you can link to as neede
7897

7998
- File format plugins:
8099

81-
- ``Paimon::paimon_parquet_file_format_shared`` / ``Paimon::paimon_parquet_file_format_static``
82-
- ``Paimon::paimon_orc_file_format_shared`` / ``Paimon::paimon_orc_file_format_static``
83-
- ``Paimon::paimon_avro_file_format_shared`` / ``Paimon::paimon_avro_file_format_static``
84-
- ``Paimon::paimon_blob_file_format_shared`` / ``Paimon::paimon_blob_file_format_static``
100+
- ``Paimon::paimon_parquet_file_format_shared``
101+
- ``Paimon::paimon_orc_file_format_shared``
102+
- ``Paimon::paimon_avro_file_format_shared``
103+
- ``Paimon::paimon_blob_file_format_shared``
85104

86105
- File system plugins:
87106

88-
- ``Paimon::paimon_local_file_system_shared`` / ``Paimon::paimon_local_file_system_static``
89-
- ``Paimon::paimon_jindo_file_system_shared`` / ``Paimon::paimon_jindo_file_system_static``
107+
- ``Paimon::paimon_local_file_system_shared``
108+
- ``Paimon::paimon_jindo_file_system_shared``
90109

91110
- Index plugins:
92111

93-
- ``Paimon::paimon_file_index_shared`` / ``Paimon::paimon_file_index_static``
94-
- ``Paimon::paimon_lumina_index_shared`` / ``Paimon::paimon_lumina_index_static``
95-
- ``Paimon::paimon_lucene_index_shared`` / ``Paimon::paimon_lucene_index_static``
112+
- ``Paimon::paimon_file_index_shared``
113+
- ``Paimon::paimon_lumina_index_shared``
114+
- ``Paimon::paimon_lucene_index_shared``
96115

97116
.. note::
98117

99-
In most cases, it is recommended to use the shared variants of these plugins.
118+
Static plugin targets have the same installed-consumer limitation as
119+
``Paimon::paimon_static`` and should not be used as standalone imported
120+
targets.

docs/source/building.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,22 @@ require project-specific patches, so their supported source values are
159159
-Dzstd_SOURCE=BUNDLED
160160
161161
Use ``PAIMON_PACKAGE_PREFIX`` to provide one common prefix for dependencies
162-
whose own ``<Package>_ROOT`` variable is not set.
162+
whose own ``<Package>_ROOT`` variable is not set. Because the patched Arrow and
163+
ORC dependencies cannot be resolved from the system, a global ``SYSTEM`` build
164+
must override them to ``BUNDLED``:
163165

164166
.. code-block:: shell
165167
166168
cmake -B build \
167169
-DPAIMON_DEPENDENCY_SOURCE=SYSTEM \
170+
-DArrow_SOURCE=BUNDLED \
171+
-DORC_SOURCE=BUNDLED \
168172
-DPAIMON_PACKAGE_PREFIX=/opt/paimon-deps
169173
174+
All other enabled dependencies must be available as system packages or under
175+
the specified prefix. When ORC support is disabled, the ``ORC_SOURCE`` override
176+
can be omitted.
177+
170178
Package-manager-specific modes are intentionally out of scope for this first
171179
dependency source interface. They can still be used through standard CMake
172180
mechanisms such as ``CMAKE_PREFIX_PATH`` or ``CMAKE_TOOLCHAIN_FILE``, while

docs/source/user_guide/write.rst

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
1818
Write
1919
=====
20-
Batch writing requires the compute engine to pre-bucket data (bucket), using the
21-
same bucketing strategy as Paimon to ensure correct ``Scan`` behavior, and to
22-
specify the target ``partition``. Data should be accumulated into ``RecordBatch``
23-
and written to Paimon.
20+
Batch writing requires the compute engine to specify the target ``partition``.
21+
For fixed-bucket tables, the engine must also assign a valid bucket to every
22+
``RecordBatch``. In unaware-bucket and postpone-bucket modes, the writer can
23+
resolve the bucket automatically when it is omitted.
2424

2525
Paimon C++ uses Apache Arrow as the :ref:`in-memory columnar format<memory-format>`
2626
to more efficiently support writing to disk columnar formats such as ORC,
@@ -33,7 +33,6 @@ Parquet, and Avro, thereby improving write throughput.
3333

3434
Not supported in the current scope:
3535
- Changelog
36-
- Indexes
3736

3837
Bucketing Modes
3938
---------------
@@ -56,9 +55,15 @@ RecordBatch Construction
5655

5756
- The compute engine must:
5857

59-
- Apply the Paimon-consistent bucketing function to each row prior to batching.
6058
- Assign the correct ``partition`` for each row.
61-
- Group rows into Arrow ``RecordBatch`` per partition-bucket combination to minimize writer state changes and I/O overhead.
59+
- In fixed-bucket mode, apply the Paimon-consistent bucketing function, set a
60+
bucket in ``[0, bucket)``, and group rows into Arrow ``RecordBatch`` objects
61+
per partition-bucket combination.
62+
63+
- In unaware-bucket mode (append table with ``bucket = -1``), an omitted bucket
64+
is resolved to ``0``.
65+
- In postpone-bucket mode (primary-key table with ``bucket = -2``), an omitted
66+
bucket is resolved to ``-2``.
6267

6368
- Recommended practices:
6469

@@ -122,26 +127,27 @@ produce a correct ``Snapshot``, which commonly includes (but is not limited to):
122127

123128
.. note::
124129

125-
Current C++ scope supports Append and PK tables. Changelog is out of
126-
scope and should not be emitted in ``CommitMessage`` until
127-
explicitly supported.
130+
The C++ writer supports Append and PK tables and can produce
131+
``CommitMessage`` objects for both. ``FileStoreCommit`` currently executes
132+
local commits only for append-only tables on non-object-store file systems.
133+
PK and object-store commit messages must be sent to an external control
134+
plane. Changelog is out of scope and should not be emitted in
135+
``CommitMessage`` until explicitly supported.
128136

129137
Serialization and Deserialization
130138
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131139

132-
- Binary Format:
133-
- The binary payload must strictly conform to Java Paimon’s ``CommitMessage`` encoding.
134-
- Version tags or schema identifiers should be included to enable forwards/backwards compatibility and safe upgrades.
135-
136-
- Serialization API:
137-
- Provide a function to serialize the writer’s commit state into a byte buffer (or stream) consumable by Java Paimon.
138-
139-
- Deserialization API:
140-
- Provide a function to parse a Java-produced ``CommitMessage`` binary payload back into C++ commit structures for verification, replay, and testing.
141-
142-
- Validation:
143-
- Include conformance tests to assert that C++ serialized payloads are accepted by Java Paimon.
144-
- Include round-trip tests to ensure C++ can parse Java-produced payloads and vice versa for supported message versions.
140+
- **Binary format:** The binary payload must strictly conform to Java Paimon's
141+
``CommitMessage`` encoding. It does not contain a version tag, so callers
142+
must transport ``CommitMessage::CurrentVersion()`` separately and supply it
143+
when deserializing.
144+
- **Serialization API:** Use ``CommitMessage::Serialize`` for one message or
145+
``CommitMessage::SerializeList`` for a list.
146+
- **Deserialization API:** Use ``CommitMessage::Deserialize`` or
147+
``CommitMessage::DeserializeList`` with the separately supplied
148+
serialization version.
149+
- **Validation:** Conformance and round-trip tests must verify compatibility
150+
with Java Paimon for supported message versions.
145151

146152
Operational Flow
147153
~~~~~~~~~~~~~~~~~~~~~~~
@@ -155,12 +161,15 @@ Operational Flow
155161

156162
3. Each writer invokes ``PrepareCommit``, which:
157163
- Aggregates per-writer state into a ``CommitMessage``.
158-
- Serializes the message into a Java-compatible binary payload.
164+
- Returns ``CommitMessage`` objects; it does not serialize them.
159165

160-
4. The compute engine gathers ``CommitMessages`` from all writers.
166+
4. The compute engine gathers ``CommitMessage`` objects from all writers. For
167+
cross-process transport, it explicitly calls ``Serialize`` or
168+
``SerializeList`` and carries ``CurrentVersion()`` alongside the payload.
161169

162-
5. The compute engine issues a ``Commit`` request to the control plane with the
163-
collected messages, resulting in a new ``Snapshot``.
170+
5. For a supported local append-table commit, the engine passes the objects to
171+
``FileStoreCommit``. For PK tables or object-store paths, it sends the
172+
serialized payload and version to an external control plane.
164173

165-
6. The coordinator validates the messages, updates manifests/metadata, and
166-
finalizes the snapshot atomically.
174+
6. The local committer or external coordinator validates the messages, updates
175+
manifests/metadata, and finalizes the snapshot atomically.

examples/CMakeLists.txt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,40 @@ project(example)
2020

2121
set(CMAKE_CXX_STANDARD 17)
2222

23+
# Arrow's static export refers to LZ4::lz4, while some lz4 packages export a
24+
# differently named target. Define a compatibility alias before loading Arrow.
25+
find_package(lz4 CONFIG QUIET)
26+
if(TARGET LZ4::lz4_static AND NOT TARGET LZ4::lz4)
27+
add_library(LZ4::lz4 ALIAS LZ4::lz4_static)
28+
elseif(TARGET lz4::lz4 AND NOT TARGET LZ4::lz4)
29+
add_library(LZ4::lz4 ALIAS lz4::lz4)
30+
endif()
31+
2332
find_package(Arrow CONFIG REQUIRED)
2433
find_package(Paimon CONFIG REQUIRED)
2534

35+
if(TARGET Arrow::arrow_shared)
36+
set(PAIMON_EXAMPLE_ARROW_TARGET Arrow::arrow_shared)
37+
elseif(TARGET Arrow::arrow_static)
38+
set(PAIMON_EXAMPLE_ARROW_TARGET Arrow::arrow_static)
39+
else()
40+
message(FATAL_ERROR "Neither Arrow::arrow_shared nor Arrow::arrow_static is available")
41+
endif()
42+
2643
add_executable(read_write_demo read_write_demo.cpp)
2744
add_executable(clean_demo clean_demo.cpp)
2845

2946
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed ${CMAKE_EXE_LINKER_FLAGS}")
3047

3148
target_link_libraries(read_write_demo
32-
PRIVATE Arrow::arrow_shared
49+
PRIVATE ${PAIMON_EXAMPLE_ARROW_TARGET}
3350
Paimon::paimon_shared
3451
Paimon::paimon_parquet_file_format_shared
3552
Paimon::paimon_orc_file_format_shared
3653
Paimon::paimon_local_file_system_shared)
3754

3855
target_link_libraries(clean_demo
39-
PRIVATE Arrow::arrow_shared
56+
PRIVATE ${PAIMON_EXAMPLE_ARROW_TARGET}
4057
Paimon::paimon_shared
4158
Paimon::paimon_parquet_file_format_shared
4259
Paimon::paimon_orc_file_format_shared

include/paimon/commit_message.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ namespace paimon {
3232
class CommitMessageSerializer;
3333
class MemoryPool;
3434

35-
/// Commit message for partition and bucket. Support Serialize and Deserialize, compatible with java
36-
/// version.
35+
/// Commit message for partition and bucket. Supports serialization and deserialization compatible
36+
/// with the Java version.
37+
///
38+
/// @note Serialized payloads do not embed their serialization version. Transport
39+
/// `CurrentVersion()` alongside the payload and pass it explicitly to `Deserialize()` or
40+
/// `DeserializeList()`.
3741
// TODO(yonghao.fyh): to add some statistics of write (e.g., write bytes)
3842
class PAIMON_EXPORT CommitMessage {
3943
public:
@@ -44,13 +48,15 @@ class PAIMON_EXPORT CommitMessage {
4448

4549
/// Serializes a single commit message to a binary string format.
4650
/// The serialized format is compatible with the Java version of Paimon.
51+
/// The serialization version is not included in the returned payload.
4752
/// @param commit_message The commit message to serialize.
4853
/// @param pool Memory pool for memory allocation during serialization.
4954
/// @return Result containing the serialized string data, or an error if serialization fails.
5055
static Result<std::string> Serialize(const std::shared_ptr<CommitMessage>& commit_message,
5156
const std::shared_ptr<MemoryPool>& pool);
5257

5358
/// Serializes a list of commit messages to a binary string format.
59+
/// The serialization version is not included in the returned payload.
5460
/// @param commit_messages Vector of commit messages to serialize.
5561
/// @param pool Memory pool for memory allocation during serialization.
5662
/// @return Result containing the serialized string data, or an error if serialization fails.

include/paimon/file_store_commit.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ class CommitMessage;
4343
///
4444
/// The `FileStoreCommit` class provides interfaces for committing changes, expiring old snapshots,
4545
/// dropping partitions, and retrieving commit metrics.
46+
///
47+
/// @note Local commit execution currently supports append-only tables on non-object-store file
48+
/// systems. `Create()` returns `NotImplemented` for primary-key tables and object-store paths.
49+
/// Primary-key writers can still produce `CommitMessage` objects; those messages must be committed
50+
/// by an external control plane.
4651
class PAIMON_EXPORT FileStoreCommit {
4752
public:
4853
/// Create an instance of `FileStoreCommit`.

0 commit comments

Comments
 (0)