Repository navigation
Conversation
|
Thanks for opening a pull request! If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project. Then could you also rename the pull request title in the following format? or See also: |
1b78a5c to
d563ce0
Compare
|
Thanks @prtkgaur -- it is super exciting to see this movement. Unfortunately, I am not familiar with the C/C++ codebase to give this a realistic review. I started the CI checks on this PR and had some comments about the testing. |
| std::string tarball_path = std::string(__FILE__); | ||
| tarball_path = tarball_path.substr(0, tarball_path.find_last_of("/\\")); | ||
| tarball_path = tarball_path.substr(0, tarball_path.find_last_of("/\\")); | ||
| tarball_path += "/arrow/cpp/submodules/parquet-testing/data/floatingpoint_data.tar.gz"; |
There was a problem hiding this comment.
@Reviewer the data sits in the parquet-testing submodule
apache/parquet-testing#100
|
|
||
| // Unsafe resize without initialization - use only when you will immediately | ||
| // overwrite the memory (e.g., before memcpy). Only safe for POD types. | ||
| void UnsafeResize(size_t n) { |
There was a problem hiding this comment.
Using this over resize gave us around 2-3% performance improvement
0c035b7 to
1cb0852
Compare
|
Talked offline and wanted to capture notes on high-level changes:
|
35f1ad7 to
0908342
Compare
Thanks for the feedback @emkornfield. We have addressed
|
|
|
|
|
||
| // Slow path: partial read - decode to intermediate buffer | ||
| // ALP Bit unpacker needs batches of 64 | ||
| if (needs_decode_) { |
There was a problem hiding this comment.
TODO(prateek) : check with Antoine and other reviewers if there is a way to relax this constraint. Though this has negligible impact on performance.
There was a problem hiding this comment.
Please check cpp/src/arrow/util/alp/ALP_Encoding_Specification_terse.md for a more terse spec of the encoding.
There was a problem hiding this comment.
Also this file will be removed once the spec in parquet format repository is merged.
|
|
||
| ## 2. Data Layout | ||
|
|
||
| ALP encoding consists of a page-level header followed by one or more encoded vectors. Each vector contains up to 1024 elements. |
There was a problem hiding this comment.
Replace 1024 with the constant specified in AlpConstant file.
1b08599 to
f5f5011
Compare
clang cannot attach a tparam to a member template declared in its class, so the doc build rejects it.
The marker on a class does not reach a member template, so the Windows link could not find the instantiations.
CompressVector takes int32_t, so passing a size_t narrows and clang rejects it with -Wshorten-64-to-32 under -Werror.
Their definitions live in implementation files, so a separate test executable cannot reach them across a shared library without the marker.
The index is 64-bit, so MSVC warns that a 32-bit shift may have been meant as 64-bit, and the CI build treats that as an error.
arrow_reader_writer_test.cc has a DoRoundtrip with defaulted trailing parameters, so a four-argument call matched both helpers once a unity build compiled the two files together.
AlpEncodedVectorInfo is exported, so binding a reference to its static constexpr kStoredSize needs an out-of-line definition the library does not provide, and the Windows GCC link fails. GetStoredSize returns it by value. The FOR info class is a template and is instantiated locally, so it is unaffected.
An empty vector's data() may be null, and memcpy and memset must not be passed a null pointer even for a zero length. A vector with no exceptions, or with bit width zero, reached that case, which the sanitizer build reports as fatal. The encoded form and decoded values are unchanged.
The bounds admitted the largest float below 2^31 and the largest double below 2^63. Fast rounding can carry a value up one ulp, to exactly 2^31 or 2^63, which the integer types cannot hold. Those two values now become exceptions and still round-trip exactly.
The ALP conformance file is already on parquet-testing main, so Arrow picks it up on any routine bump. The tests skip until the pin moves.
The pipeline flowchart in alp_internal.h becomes a paragraph, the page layout is drawn once instead of three times, subscripts and arrows are spelled in ASCII, and the test section headings use Arrow's single rule. Comments only.
Some comments described what the code used to do rather than what the test pins, such as the misaligned exception arrays that LoadView copies into aligned storage. Others restated the code below them. Comments only.
Split the ALP implementation into constants, metadata, compression, sampler, and codec units. Simplify the internal APIs and update the CMake/Meson build integration. Remove the separate writer opt-in flag. ALP is selected explicitly with Encoding::ALP while dictionary encoding is disabled. Harden encoding and decoding: - validate page headers, vector metadata, offset chains, bit widths, element counts, and exception positions; - reject pages that leave ALP values unconsumed after all levels are read; - reuse pool-backed scratch buffers and cache partially decoded vectors; - use typed power-of-ten constants for exact decode semantics; - emit a valid header-only page for all-null input. Rework the ALP tests around the production APIs, remove redundant cases, and add malformed-input, boundary, exception, and all-null coverage. Move the end-to-end tests to arrow_encoding_test.cc and enable real parquet-testing interoperability coverage. Update the submodule pin, benchmarks, and C++ documentation.
The layout tables for AlpInfo, AlpForInfo and the serialized vector were lost when alp_internal.h was split. They now sit next to the classes they describe. The old ForInfo table gave 6 and 10 bytes; the real sizes are 5 and 9, a frame of reference plus a bit width with no padding.
AlpEncoder's static_assert fires only when the template is instantiated, and for an unsupported physical type the factories throw before that, so test the throw for the six other types. Also restores the note about falling back to PLAIN, since ALP expands a few of the paper's datasets and the writer never declines it.
No write path selects ALP, so a column carries it only where encoding() names it.
Move the decode target restriction from requires clauses to static assertions, so an invalid target stays a compile-time error without the constraint appearing in exported symbol names. GCC can then match the explicit instantiations, and Clang shared builds resolve the same symbols.
619c39b to
2fb0c5f
Compare
Done. The new failure looks unrelated to my change. |
|
@github-actions crossbow submit -g cpp |
|
Revision: 2fb0c5f Submitted crossbow builds: ursacomputing/crossbow @ actions-1ee1f44348 |
|
The two failed crossbow builds are related. Could you please fix them @prtkgaur? |
kStoredSize is int64_t, so subtracting it from a size_t yields int64_t wherever size_t is 32 bits. Inside the span's braced initializer that is a narrowing conversion, which broke the i386 and Emscripten builds.
|
@github-actions crossbow submit -g cpp |
|
@prtkgaur I tried totrigger it but if it still comes up with failures might be worth a try to see if you have permissions. |
|
Revision: e2275a1 Submitted crossbow builds: ursacomputing/crossbow @ actions-f3bf07b14a |
Thanks @emkornfield. Don't see that failure in the latest report. The only failing thing now Is unrelated to this change. |
Co-authored-by: Dhirhan Kanesalingam dhirhan17@gmail.com
With help from : @emkornfield, @wgtmac
Rationale for this change
Adaptive Lossless Floating-Point (ALP)
is designed for floating-point data that commonly represents decimal values.
For these workloads, ALP can provide better compression and faster decoding
than general-purpose compression or existing Parquet encodings.
This PR adds ALP support for Parquet
FLOATandDOUBLEcolumns in the ArrowC++ implementation.
Specification
AlpEncoding.md(merged through Add ALP support proposal parquet-format#539; currently in Preview)
What changes are included in this PR?
This PR adds:
FLOATandDOUBLE.ALP is opt-in on the write path. It is used only when the writer explicitly
selects
Encoding::ALPand dictionary encoding is disabled. Arrow does notcurrently select ALP automatically based on the input data.
Are these changes tested?
Yes. Test coverage includes:
parquet-testing.FLOATandDOUBLEround trips.Are there any user-facing changes?
Yes. Arrow C++ can read Parquet pages encoded with ALP. Writers can explicitly
select ALP for supported floating-point columns.
ALP requires reader support and is not selected automatically, so existing
writer behavior remains unchanged unless users opt in.