Repository navigation
feat(blob): read Paimon video files - #601
XiaoHongbo-Hope wants to merge 19 commits into
Conversation
Generated-by: OpenAI Codex CLI 0.172.0 (GPT-6.2 Sol)
Generated-by: OpenAI Codex CLI 0.172.0 (GPT-6.2 Sol)
There was a problem hiding this comment.
@XiaoHongbo-Hope, thanks for contribution. I left some comments for this pull request. PTAL.
Generated-by: OpenAI Codex CLI 0.172.0 (GPT-6.2 Sol)
Generated-by: OpenAI Codex CLI 0.172.0 (GPT-6.2 Sol)
Generated-by: OpenAI Codex CLI 0.172.0 (GPT-6.2 Sol)
Generated-by: OpenAI Codex CLI 0.172.0 (GPT-6.2 Sol)
Generated-by: OpenAI Codex CLI 0.172.0 (GPT-6.2 Sol)
Generated-by: OpenAI Codex CLI 0.172.0 (GPT-6.2 Sol)
There was a problem hiding this comment.
@XiaoHongbo-Hope, thanks for updates. I left inline comments on layout validation, error context, and index I/O. PTAL.
SteNicholas
left a comment
There was a problem hiding this comment.
A full-row write with a context override produced an ordinary .blob for a persisted video column. I also reproduced incorrect frame payload bytes when reading a video pack from a file slice. The inline comments include the inputs and regression coverage for these findings.
SteNicholas
left a comment
There was a problem hiding this comment.
I found two frame-reference handling issues and a gap in the legacy migration instructions. The inline comments include the observed results and the affected paths.
SteNicholas
left a comment
There was a problem hiding this comment.
I reproduced two streaming-read failures with Parquet, ORC, and Avro tables. The other two comments cover buffered file slices and index memory retained after Close().
There was a problem hiding this comment.
@XiaoHongbo-Hope, thanks for updates. I left some comments include reproducible cases for projection-dependent row counts, partition values, overlapping updates, and the writer guard. PTAL.
SteNicholas
left a comment
There was a problem hiding this comment.
I reviewed the current head across the video format, managed reads, BLOB compatibility, documentation, and tests. The inline comments include local reproductions and the affected entry points.
| file_batch_readers[file_idx] = | ||
| std::make_unique<LazyConcatBatchReader>(std::move(sources), arrow_pool_); | ||
| } else if (blob_bunch) { | ||
| // Fallback needs the value to distinguish placeholders from explicit NULLs |
There was a problem hiding this comment.
Preserve the row sequence when another video column supplies the update. I committed a video-only delta at sequence 2 with a.video containing [placeholder, NULL] and b.video supplying a frame for the first row. TableRead returned the frame in b but emitted _SEQUENCE_NUMBER = [-1, 2]. A sequence-only projection returned the same values. Field matching assigns _SEQUENCE_NUMBER to the first BLOB bunch, whose placeholder says nothing about the other columns. For a dedicated-only group, derive the sequence from the resolved updates across the bunches, including explicit NULLs. Please extend the two-column delta test so the second column supplies a frame where the first has a placeholder.
| } | ||
| std::set<int32_t> skip_map_selected_keys_filter_field_ids; | ||
| if (file_format_identifier != "blob") { | ||
| const bool is_blob_file = BlobUtils::IsBlobFile(file_meta->file_name); |
There was a problem hiding this comment.
Check the decoded .video row count against the manifest before exposing row IDs. I committed the two-row Java fixture with DataFileMeta::row_count = 1. Both _ROW_ID and video, _ROW_ID scans succeeded and returned row IDs 0 and 1. The second row ID lies outside the committed range. The planner uses the manifest count for range alignment, while the format reader uses the footer count. Compare GetNumberOfRows() with file_meta->row_count before applying row selection, and include the file path and both counts in the error.
| // No need to merge fields, just create a single file reader | ||
| // A video-only delta can contain placeholders even when it has just one file. | ||
| if (need_merge_files.size() == 1 && | ||
| (row_id_only || !BlobUtils::IsVideoFile(need_merge_files[0]->file_name))) { |
There was a problem hiding this comment.
Open row-ID-only video packs one row range at a time. In a managed split with two disjoint .video packs, a counting filesystem recorded two opens before the first _ROW_ID batch was returned. Projecting video opened only the first pack at that point. This fast path opens and decodes every singleton video group while the inner split reader is built, retaining their decoded indexes even when the caller stops after the first batch. Please keep the zero-column format projection and defer opening each group until it is consumed. The existing open-count test can cover a video-only split with _ROW_ID.
| std::array<std::vector<int64_t>, 6> indexes; | ||
| for (size_t i = 0; i < indexes.size(); ++i) { | ||
| PAIMON_ASSIGN_OR_RAISE(indexes[i], | ||
| DeltaVarintCompressor::Decompress(data.data(), index_lengths[i])); |
There was a problem hiding this comment.
Charge decoded video indexes to the caller’s memory pool. With a 4 MiB pool passed through ReaderBuilder::WithMemoryPool(), Build() accepted the one-million-run fixture. The pool recorded a 3 MiB peak and zero live bytes after opening, while the reader still held about 24 MiB of FrameRun entries. Both decompression and the retained vectors allocate outside the supplied pool. Use pool-backed storage for the decoded indexes and retained runs and video ranges, alongside the per-file size check. A limited pool that fits the encoded index but cannot fit its decoded form would cover this path.
|
|
||
| Result<BlobFormatWriter::BlobCopySource> BlobFormatWriter::OpenBlobInputStream( | ||
| std::string_view blob_data, std::optional<int32_t> element_index) { | ||
| if (VideoFrameDescriptor::HasMagic(blob_data.data(), blob_data.size())) { |
There was a problem hiding this comment.
Keep raw BLOB values that match the frame header but cannot be descriptors. AddBatch() now returns NotImplemented for the nine raw bytes 01 4d 52 46 4f 45 44 49 56. That input contains only version 1 and the magic, so it is shorter than any serialized frame descriptor. The existing different-version test cannot catch this case. Please validate the descriptor structure before rejecting a raw value here, and test the matching-version prefix alongside the genuine descriptor rejection.
| class VideoReaderBuilder : public ReaderBuilder, public BlobReadContextAwareBuilder { | ||
| public: | ||
| VideoReaderBuilder(int32_t batch_size, bool emit_placeholder_sentinel) | ||
| : batch_size_(batch_size), emit_placeholder_sentinel_(emit_placeholder_sentinel) {} | ||
|
|
||
| ReaderBuilder* WithMemoryPool(const std::shared_ptr<MemoryPool>& pool) override { | ||
| pool_ = pool; | ||
| return this; | ||
| } | ||
|
|
||
| void SetBlobReadContext(const std::shared_ptr<BlobReadContext>& context) override { | ||
| blob_context_ = context; | ||
| } | ||
|
|
||
| Result<std::unique_ptr<FileBatchReader>> Build( | ||
| const std::shared_ptr<InputStream>& input) const override { | ||
| return VideoFileBatchReader::Create(input, batch_size_, pool_, emit_placeholder_sentinel_, | ||
| blob_context_); | ||
| } | ||
|
|
||
| private: | ||
| int32_t batch_size_; | ||
| bool emit_placeholder_sentinel_; | ||
| std::shared_ptr<MemoryPool> pool_ = GetDefaultPool(); | ||
| std::shared_ptr<BlobReadContext> blob_context_; | ||
| }; | ||
|
|
||
| class VideoFileFormat : public FileFormat { | ||
| public: | ||
| explicit VideoFileFormat(bool emit_placeholder_sentinel) | ||
| : emit_placeholder_sentinel_(emit_placeholder_sentinel) {} | ||
|
|
||
| const std::string& Identifier() const override { | ||
| static const std::string identifier = "video"; | ||
| return identifier; | ||
| } | ||
|
|
||
| Result<std::unique_ptr<ReaderBuilder>> CreateReaderBuilder(int32_t batch_size) const override { | ||
| return std::make_unique<VideoReaderBuilder>(batch_size, emit_placeholder_sentinel_); | ||
| } | ||
|
|
||
| Result<std::unique_ptr<WriterBuilder>> CreateWriterBuilder(::ArrowSchema*, | ||
| int32_t) const override { | ||
| return Status::NotImplemented("video writing is not supported"); | ||
| } | ||
|
|
||
| Result<std::unique_ptr<FormatStatsExtractor>> CreateStatsExtractor( | ||
| ::ArrowSchema*) const override { | ||
| return Status::NotImplemented("video stats extraction is not supported"); | ||
| } | ||
|
|
||
| private: | ||
| bool emit_placeholder_sentinel_; | ||
| }; | ||
|
|
||
| class VideoFileFormatFactory : public FileFormatFactory { | ||
| public: | ||
| const char* Identifier() const override { | ||
| return "video"; | ||
| } | ||
|
|
||
| Result<std::unique_ptr<FileFormat>> Create( | ||
| const std::map<std::string, std::string>& options) const override { | ||
| PAIMON_ASSIGN_OR_RAISE(bool emit_placeholder_sentinel, | ||
| OptionsUtils::GetValueFromMap<bool>( | ||
| options, BlobDefs::kEmitPlaceholderSentinelKey, false)); | ||
| return std::make_unique<VideoFileFormat>(emit_placeholder_sentinel); | ||
| } | ||
| }; | ||
|
|
||
| } // namespace |
There was a problem hiding this comment.
Keep these classes in separate files—don’t lump them all into blob_file_format_factory.cpp.
| public: | ||
| static Result<std::unique_ptr<VideoFileBatchReader>> Create( | ||
| const std::shared_ptr<InputStream>& input, int32_t batch_size, | ||
| const std::shared_ptr<MemoryPool>& pool, bool emit_placeholder_sentinel, |
There was a problem hiding this comment.
could you put param pool at last?
| for (int64_t read = 0; read < size;) { | ||
| const Result<int64_t> n = input->Read(data + read, size - read, offset + read); | ||
| if (!n.ok()) { | ||
| return n.status().IsInvalid() |
There was a problem hiding this comment.
I think directly use PAIMON_ASSIGN_OR_RAISE is OK.
|
|
||
|
|
||
| # Video frame descriptor v1 with optional moov range. | ||
| 014d52464f454449561600000073333a2f2f6275636b65742fe8a786e9a2912e6d7034070000000000000063000000000000002a0000000000000000000000000000000000000000000000 |
There was a problem hiding this comment.
In the test data, directly store the single hex string line starting with 014d52...; remove the LICENSE header and comments, and simplify the decoding logic in the ReadJavaVideoFixture function (and rename it like ReadVideoFixture). Then move the file description currently in the comments into a separate README file, following the format used by other test_data directories.
| static constexpr char kExtensionTypeValue[] = "paimon.type.blob"; | ||
|
|
||
| /// Java Paimon table option naming scalar BLOB fields stored as video frames. | ||
| static constexpr char kVideoFrameFieldOption[] = "video-frame-field"; |
There was a problem hiding this comment.
Should the definition and parsing of the "video-frame-field" parameter be placed in defs.h/core_options.h?
| // No need to merge fields, just create a single file reader | ||
| // A video-only delta can contain placeholders even when it has just one file. | ||
| if (need_merge_files.size() == 1 && | ||
| (row_id_only || !BlobUtils::IsVideoFile(need_merge_files[0]->file_name))) { |
There was a problem hiding this comment.
Could we return Invalid when a read group containing only one .video file encounters a placeholder, matching the behavior for a single .blob file? The current fallback turns an unresolved placeholder into NULL. This would make a video-only streaming delta with a placeholder fail explicitly, just as a blob-only delta does today.
|
There are still some review issues under discussion, and more review comments will be added later 🫣 |
| "range read for s3://bucket/file returned"); | ||
| } | ||
|
|
||
| TEST(ObjectStoreInputStreamTest, VideoReaderOpensWithTwoRangeRequests) { |
There was a problem hiding this comment.
Could you remove VideoReaderOpensWithTwoRangeRequests and the BLOB format library dependency it adds to fs_test? ReadsJavaIndexesWithOneTailRead already checks that opening the reader reads the footer and index block in two reads.
| bool IsVideoFrame() const; | ||
|
|
||
| /// Zero-based frame ordinal, or -1 for a regular blob. | ||
| int64_t FrameIndex() const; |
There was a problem hiding this comment.
Could you expose VideoFrameDescriptor under include/paimon/data/ and remove the video-specific accessors from Blob? Video callers can parse the frame descriptor directly and open its Payload() through the existing Blob API. Blob::FromDescriptor() and ToDescriptor() can then work with BlobDescriptor alone.
Purpose
Linked issue: none.
Read scalar BLOB columns stored in Paimon
.videofiles using the six-index footer written by the Java Paimon writer. Map selected table rows to lazy frame descriptors and use the BLOB fallback path for placeholders in partial updates. Java format changeTests
Cover sparse and empty selections, Arrow batch lifetime, and malformed footers and MP4 metadata. Check the descriptor encoding and decoding against fixtures from Java Paimon. Exercise overlapping video layers through
TableReadwith placeholder fallback, explicit NULL, and_ROW_IDprojection. Cover rejection of frame descriptors in the ordinary BLOB writer and writes to configured video fields.API and Format
Blob::FromDescriptor()opens the Java-compatible frame descriptor and exposes its frame ordinal and optional MP4moovrange. The frame metadata uses an internal type, preserving the publicBlobDescriptorlayout and its serialization. Video reads emit frame descriptors even whenblob-as-descriptor=false.Documentation
Document how to access the encoded payload, the supported 29-byte footer, and the need to reimport files with the earlier five-index footer.
Generative AI tooling
Generated-by: OpenAI Codex CLI 0.172.0 (GPT-6.2 Sol)