This is an automated email from the ASF dual-hosted git repository.

lucasfang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new b822f1cc feat(realtime): add Lumina vector index support (#583)
b822f1cc is described below

commit b822f1cc53185a5b5bf12dfc0189699dedcbeeb8
Author: lxy <[email protected]>
AuthorDate: Mon Nov 23 16:42:43 2026 +0800

    feat(realtime): add Lumina vector index support (#583)
---
 docs/source/user_guide/realtime.rst                |  33 +-
 include/paimon/realtime/index/realtime_index.h     |   4 +-
 .../realtime/index/realtime_index_read_source.h    |   3 +-
 src/paimon/CMakeLists.txt                          |   1 +
 .../core/operation/internal_read_context.cpp       |   1 +
 .../realtime/arrow_deduplicate_realtime_store.cpp  |  20 +-
 .../realtime/arrow_deduplicate_realtime_store.h    |   4 +
 .../arrow_deduplicate_realtime_store_test.cpp      |  29 ++
 src/paimon/core/realtime/arrow_realtime_store.cpp  |   7 +-
 .../realtime/index/hash/hash_realtime_index.cpp    |   2 +-
 .../core/realtime/index/hash/hash_realtime_index.h |   2 +-
 .../realtime/index/realtime_index_evaluator.cpp    |  15 +-
 .../core/realtime/index/realtime_index_evaluator.h |  10 +-
 .../core/realtime/index/realtime_index_test.cpp    |  20 +-
 .../core/realtime/precise_realtime_index_read.cpp  |   5 +-
 .../core/realtime/precise_realtime_index_read.h    |   2 +-
 src/paimon/core/realtime/realtime_utils.cpp        | 120 +++++
 src/paimon/core/realtime/realtime_utils.h          |  93 +---
 src/paimon/core/table/source/table_read_test.cpp   |  53 +++
 src/paimon/core/table/source/topk_batch_reader.cpp |  14 +-
 src/paimon/indexer/lumina/CMakeLists.txt           |   3 +
 src/paimon/indexer/lumina/lumina_api_test.cpp      |   4 +-
 src/paimon/indexer/lumina/lumina_file_index.cpp    |   4 +-
 src/paimon/indexer/lumina/lumina_global_index.cpp  |   4 +-
 .../indexer/lumina/lumina_global_index_test.cpp    |   4 +-
 src/paimon/indexer/lumina/lumina_index_options.cpp |  36 ++
 src/paimon/indexer/lumina/lumina_index_options.h   |   3 +
 .../indexer/lumina/lumina_index_searcher.cpp       |   4 +-
 src/paimon/indexer/lumina/lumina_memory_pool.h     |  22 +-
 .../indexer/lumina/lumina_realtime_index.cpp       | 212 +++++++++
 src/paimon/indexer/lumina/lumina_realtime_index.h  | 108 +++++
 .../lumina/lumina_realtime_index_factory.cpp       |  53 +++
 .../indexer/lumina/lumina_realtime_index_factory.h |  33 +-
 .../indexer/lumina/lumina_realtime_index_test.cpp  | 500 +++++++++++++++++++++
 .../testing/mock/mock_search_realtime_index.cpp    |   2 +-
 .../testing/mock/mock_search_realtime_index.h      |   2 +-
 test/inte/realtime_write_inte_test.cpp             | 166 ++++++-
 37 files changed, 1432 insertions(+), 166 deletions(-)

diff --git a/docs/source/user_guide/realtime.rst 
b/docs/source/user_guide/realtime.rst
index b3245414..4b4479a9 100644
--- a/docs/source/user_guide/realtime.rst
+++ b/docs/source/user_guide/realtime.rst
@@ -437,6 +437,34 @@ filtering. Keep predicate fields in the read schema and 
enable
 In-memory and disk indexes are configured independently. Use
 ``file-index.<type>.columns`` to enable indexes for committed files.
 
+Real-time Vector Search
+~~~~~~~~~~~~~~~~~~~~~~
+
+Build with ``-DPAIMON_ENABLE_LUMINA=ON`` to enable real-time Lumina vector 
search.
+For Lumina options and limits, see ``docs/api/Streamer.md`` and 
``docs/reference``
+in the Lumina release package.
+
+.. code-block:: text
+
+   realtime.index.lumina.columns = embedding
+   realtime.index.lumina.embedding.index.type = bruteforce
+   realtime.index.lumina.embedding.index.dimension = 2
+   realtime.index.lumina.embedding.distance.metric = l2
+   realtime.index.lumina.embedding.encoding.type = rawf32
+
+Queries over both memory and disk require ``realtime.index.lumina.columns`` and
+``file-index.lumina.columns``, each with its own per-column options. Keep 
dimension
+and distance metric consistent; other options can differ.
+
+Use ``ReadContextBuilder::EnablePreciseFileIndexEvaluate(true)`` with
+``SetVectorSearch()``. Keep scalar predicate fields in the read projection and
+project ``_embedding_INDEX_SCORE`` for scores. Scalar filters, including those
+without indexes, and committed or pending DVs are applied before vector TopK.
+
+The table reader returns global TopK across the disk files and memory segments
+in all splits supplied to ``TableRead::CreateReader()``.
+Real-time vector tag predicates are unsupported.
+
 Implementation by Mode
 ----------------------
 
@@ -634,8 +662,9 @@ Current restrictions include:
 * Native tables on the main branch with fixed positive bucket counts and full
   write schemas only.
 * Process-local batch union scans only. Streaming scans, limit pushdown,
-  global-index result splits, vector/full-text search, and count-only real-time
-  readers are unsupported.
+  global-index result splits, and count-only real-time readers are unsupported.
+  Precise index evaluation and Lumina vector search support append and append
+  deduplicate modes; primary-key real-time search is unsupported.
 * PK mode supports deduplicate with default delete handling, or partial update
   with deletion vectors disabled and its existing delete and sequence-group
   options. Both require ascending sequence order and 
``changelog-producer=none``. Custom
diff --git a/include/paimon/realtime/index/realtime_index.h 
b/include/paimon/realtime/index/realtime_index.h
index 0a3717dd..7c25b37b 100644
--- a/include/paimon/realtime/index/realtime_index.h
+++ b/include/paimon/realtime/index/realtime_index.h
@@ -29,6 +29,7 @@
 struct ArrowArray;
 
 namespace paimon {
+class MemoryPool;
 class RealtimeIndexReader;
 
 /// Append-only in-memory index for one field, supporting one writer and 
concurrent readers.
@@ -40,8 +41,9 @@ class PAIMON_EXPORT RealtimeIndex {
     virtual Status AddBatch(::ArrowArray* batch) = 0;
 
     /// Creates a reader for [begin, end), sharing postings without copying.
+    /// The pool belongs to the query and is used for reader/search 
allocations.
     virtual Result<std::shared_ptr<RealtimeIndexReader>> CreateReader(
-        const OffsetRange& offset_range) const = 0;
+        const OffsetRange& offset_range, const std::shared_ptr<MemoryPool>& 
pool) const = 0;
 
     virtual uint64_t GetMemoryUsage() const = 0;
 };
diff --git a/include/paimon/realtime/index/realtime_index_read_source.h 
b/include/paimon/realtime/index/realtime_index_read_source.h
index d78b9c59..0fdcad81 100644
--- a/include/paimon/realtime/index/realtime_index_read_source.h
+++ b/include/paimon/realtime/index/realtime_index_read_source.h
@@ -41,8 +41,9 @@ class PAIMON_EXPORT RealtimeIndexReadSource {
 
     /// Returns readers bound to this source's offset range. A missing field 
has no readers.
     /// Readers must not expose writes published after the pinned snapshot.
+    /// The pool belongs to the query, rather than the retained index.
     virtual Result<std::vector<std::shared_ptr<RealtimeIndexReader>>> 
CreateIndexReaders(
-        const std::string& field_name) const = 0;
+        const std::string& field_name, const std::shared_ptr<MemoryPool>& 
pool) const = 0;
 };
 
 /// Optional capability for precise real-time filtering and search. Ordinary 
query reads do not
diff --git a/src/paimon/CMakeLists.txt b/src/paimon/CMakeLists.txt
index 8556e97f..60fc81ed 100644
--- a/src/paimon/CMakeLists.txt
+++ b/src/paimon/CMakeLists.txt
@@ -453,6 +453,7 @@ set(PAIMON_CORE_SRCS
     core/realtime/realtime_snapshot_offsets.cpp
     core/realtime/realtime_store_read_pipeline.cpp
     core/realtime/realtime_primary_key_writer.cpp
+    core/realtime/realtime_utils.cpp
     core/postpone/postpone_bucket_writer.cpp
     core/schema/arrow_schema_validator.cpp
     core/schema/schema_manager.cpp
diff --git a/src/paimon/core/operation/internal_read_context.cpp 
b/src/paimon/core/operation/internal_read_context.cpp
index be0f7a91..75f33565 100644
--- a/src/paimon/core/operation/internal_read_context.cpp
+++ b/src/paimon/core/operation/internal_read_context.cpp
@@ -47,6 +47,7 @@
 #include "paimon/core/realtime/realtime_utils.h"
 #include "paimon/core/schema/arrow_schema_validator.h"
 #include "paimon/core/schema/schema_manager.h"
+#include "paimon/core/utils/branch_manager.h"
 #include "paimon/core/utils/nested_projection_utils.h"
 #include "paimon/predicate/compound_predicate.h"
 #include "paimon/predicate/full_text_search.h"
diff --git a/src/paimon/core/realtime/arrow_deduplicate_realtime_store.cpp 
b/src/paimon/core/realtime/arrow_deduplicate_realtime_store.cpp
index 1ba1698a..9e1c26c8 100644
--- a/src/paimon/core/realtime/arrow_deduplicate_realtime_store.cpp
+++ b/src/paimon/core/realtime/arrow_deduplicate_realtime_store.cpp
@@ -259,8 +259,8 @@ class ArrowDeduplicateRealtimeStore::IndexReadSource final 
: public RealtimeInde
     }
 
     Result<std::vector<std::shared_ptr<RealtimeIndexReader>>> 
CreateIndexReaders(
-        const std::string& field_name) const override {
-        return source_->CreateIndexReaders(field_name);
+        const std::string& field_name, const std::shared_ptr<MemoryPool>& 
pool) const override {
+        return source_->CreateIndexReaders(field_name, pool);
     }
 
  private:
@@ -336,6 +336,7 @@ Result<std::shared_ptr<arrow::StructArray>> 
ArrowDeduplicateRealtimeStore::Extra
 Result<std::shared_ptr<const KeyOffsetLookup>>
 ArrowDeduplicateRealtimeStore::AcquireKeyOffsetLookup() {
     std::lock_guard<std::mutex> lock(mutex_);
+    PAIMON_RETURN_NOT_OK(CheckUsableLocked());
     if (!building_key_index_) {
         return Status::Invalid("deduplicate building key-offset index is not 
initialized");
     }
@@ -351,6 +352,13 @@ ArrowDeduplicateRealtimeStore::AcquireKeyOffsetLookup() {
     return std::shared_ptr<const KeyOffsetLookup>(new 
CompositeKeyOffsetLookup(std::move(lookups)));
 }
 
+Status ArrowDeduplicateRealtimeStore::CheckUsableLocked() const {
+    if (write_failed_) {
+        return Status::Invalid("deduplicate store cannot be reused after a 
write failure");
+    }
+    return Status::OK();
+}
+
 Status ArrowDeduplicateRealtimeStore::EnsureMutableDeletionBitmap() {
     if (pending_offset_deletions_.use_count() != 1) {
         pending_offset_deletions_ = 
std::make_shared<RoaringBitmap64>(*pending_offset_deletions_);
@@ -376,6 +384,7 @@ Status ArrowDeduplicateRealtimeStore::WriteAndLookup(
         checked_pointer_cast<arrow::Int64Array>(raw_offsets);
 
     std::lock_guard<std::mutex> lock(mutex_);
+    PAIMON_RETURN_NOT_OK(CheckUsableLocked());
     if (!building_key_index_) {
         return Status::Invalid("deduplicate building key-offset index is not 
initialized");
     }
@@ -383,6 +392,8 @@ Status ArrowDeduplicateRealtimeStore::WriteAndLookup(
         return Status::Invalid("real-time offset ranges must be ordered and 
non-overlapping");
     }
     PAIMON_RETURN_NOT_OK(EnsureMutableDeletionBitmap());
+    // Mark failure before releasing the store lock.
+    ScopeGuard failure_guard([this]() { write_failed_ = true; });
     *pending_offset_deletions_ |= previous_offsets;
 
     arrow::BooleanBuilder add_selection(arrow_pool_.get());
@@ -438,6 +449,7 @@ Status ArrowDeduplicateRealtimeStore::WriteAndLookup(
     } else {
         building_offset_range_ = OffsetRange(building_offset_range_->begin, 
offset_range.end);
     }
+    failure_guard.Release();
     return Status::OK();
 }
 
@@ -463,6 +475,7 @@ ArrowDeduplicateRealtimeStore::SealCurrentSegment(bool 
allow_spill) {
     RoaringBitmap64 row_offsets;
     {
         std::lock_guard<std::mutex> lock(mutex_);
+        PAIMON_RETURN_NOT_OK(CheckUsableLocked());
         if (!building_offset_range_) {
             return std::optional<std::shared_ptr<RealtimeSegmentHandle>>();
         }
@@ -533,6 +546,7 @@ ArrowDeduplicateRealtimeStore::CreateCommitReaders(
 
 Result<std::shared_ptr<RealtimeReadView>> 
ArrowDeduplicateRealtimeStore::AcquireReadView() {
     std::lock_guard<std::mutex> lock(mutex_);
+    PAIMON_RETURN_NOT_OK(CheckUsableLocked());
     PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<RealtimeReadView> delegate_view,
                            delegate_->AcquireReadView());
     std::optional<OffsetRange> range;
@@ -599,6 +613,7 @@ 
ArrowDeduplicateRealtimeStore::RetireCommittedOffsetAndLookup(
     auto retired = std::make_shared<RetiredReadView>();
     {
         std::lock_guard<std::mutex> lock(mutex_);
+        PAIMON_RETURN_NOT_OK(CheckUsableLocked());
         auto* two_phase = 
dynamic_cast<TwoPhaseSealableRealtimeStore*>(delegate_.get());
         if (two_phase) {
             PAIMON_ASSIGN_OR_RAISE(retired->delegate_view,
@@ -631,6 +646,7 @@ 
ArrowDeduplicateRealtimeStore::RetireCommittedOffsetAndLookup(
 Status ArrowDeduplicateRealtimeStore::AttachCommittedKeyOffsetLookup(
     const std::shared_ptr<const KeyOffsetLookup>& committed_lookup) {
     std::lock_guard<std::mutex> lock(mutex_);
+    PAIMON_RETURN_NOT_OK(CheckUsableLocked());
     if (committed_key_lookup_ && committed_key_lookup_ != committed_lookup) {
         return Status::Invalid(
             "committed key-offset lookup is already attached to deduplicate 
store");
diff --git a/src/paimon/core/realtime/arrow_deduplicate_realtime_store.h 
b/src/paimon/core/realtime/arrow_deduplicate_realtime_store.h
index 7de69cec..968c1075 100644
--- a/src/paimon/core/realtime/arrow_deduplicate_realtime_store.h
+++ b/src/paimon/core/realtime/arrow_deduplicate_realtime_store.h
@@ -127,6 +127,9 @@ class ArrowDeduplicateRealtimeStore final : public 
RealtimeStore {
 
     Result<std::shared_ptr<arrow::StructArray>> ExtractKeys(
         const std::shared_ptr<arrow::StructArray>& data) const;
+    // Requires mutex_. A failed write may leave partial DV/index updates 
before the context
+    // is invalidated. Reject new views and mutations during that window.
+    Status CheckUsableLocked() const;
     Status EnsureMutableDeletionBitmap();
     Result<std::optional<std::shared_ptr<RealtimeSegmentHandle>>> 
SealCurrentSegment(
         bool allow_spill);
@@ -141,6 +144,7 @@ class ArrowDeduplicateRealtimeStore final : public 
RealtimeStore {
     // Serializes seal attempts only; writes never acquire this mutex during 
spill I/O.
     std::mutex seal_mutex_;
     mutable std::mutex mutex_;
+    bool write_failed_ = false;
     std::shared_ptr<MutableKeyOffsetIndex> building_key_index_;
     std::shared_ptr<const KeyOffsetLookup> committed_key_lookup_;
     std::vector<SealedState> sealed_states_;
diff --git a/src/paimon/core/realtime/arrow_deduplicate_realtime_store_test.cpp 
b/src/paimon/core/realtime/arrow_deduplicate_realtime_store_test.cpp
index 92c2b9c8..33222259 100644
--- a/src/paimon/core/realtime/arrow_deduplicate_realtime_store_test.cpp
+++ b/src/paimon/core/realtime/arrow_deduplicate_realtime_store_test.cpp
@@ -436,6 +436,35 @@ TEST_F(ArrowDeduplicateRealtimeStoreTest, 
TestLastWriteWinsAndReadViewIsSnapshot
     ASSERT_EQ(OffsetRange(1, 5), segment.value()->GetOffsetRange());
 }
 
+TEST_F(ArrowDeduplicateRealtimeStoreTest, 
TestWriteFailureRejectsNewViewsAndPreservesPinnedView) {
+    ASSERT_OK(store_->WriteAndLookup(MakeBatch(R"([[0, 1, "old"]])"),
+                                     {RecordBatch::RowKind::INSERT}, 
OffsetRange(0, 1),
+                                     RoaringBitmap64()));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeReadView> pinned_view, 
store_->AcquireReadView());
+    auto replacement = MakeBatch(R"([[1, 1, "new"]])");
+    RoaringBitmap64 previous_offsets;
+    previous_offsets.Add(0);
+
+    // The delegate rejects the empty range after the deduplicate state has 
changed.
+    ASSERT_NOK_WITH_MSG(store_->WriteAndLookup(replacement, 
{RecordBatch::RowKind::UPDATE_AFTER},
+                                               OffsetRange(1, 1), 
previous_offsets),
+                        "real-time offset range is invalid");
+    ASSERT_NOK_WITH_MSG(store_->AcquireReadView(), "after a write failure");
+    ASSERT_NOK_WITH_MSG(store_->AcquireKeyOffsetLookup(), "after a write 
failure");
+    ASSERT_NOK_WITH_MSG(store_->SealForCommit(), "after a write failure");
+    ASSERT_NOK_WITH_MSG(store_->FreezeBuildingSegment(), "after a write 
failure");
+    ASSERT_NOK_WITH_MSG(store_->RetireCommittedOffsetAndLookup(1, 
empty_lookup_),
+                        "after a write failure");
+    ASSERT_NOK_WITH_MSG(store_->AttachCommittedKeyOffsetLookup(empty_lookup_),
+                        "after a write failure");
+    ASSERT_NOK_WITH_MSG(store_->WriteAndLookup(replacement, 
{RecordBatch::RowKind::UPDATE_AFTER},
+                                               OffsetRange(1, 2), 
previous_offsets),
+                        "after a write failure");
+    ASSERT_NOK_WITH_MSG(store_->AcquireReadView(), "after a write failure");
+    ASSERT_OK_AND_ASSIGN(std::vector<int64_t> offsets, 
ReadOffsets(pinned_view));
+    ASSERT_EQ((std::vector<int64_t>{0}), offsets);
+}
+
 TEST_F(ArrowDeduplicateRealtimeStoreTest, 
TestHashPostingsCombineWithPinnedDvWithoutIndexCopies) {
     ASSERT_OK_AND_ASSIGN(
         delegate_, ArrowRealtimeStore::Create(schema_, 
RealtimeStoreMode::APPEND_ONLY,
diff --git a/src/paimon/core/realtime/arrow_realtime_store.cpp 
b/src/paimon/core/realtime/arrow_realtime_store.cpp
index 298ac476..85d95662 100644
--- a/src/paimon/core/realtime/arrow_realtime_store.cpp
+++ b/src/paimon/core/realtime/arrow_realtime_store.cpp
@@ -585,7 +585,8 @@ class ArrowRealtimeStore::AppendQueryBatchReader : public 
BatchReader {
                     RealtimeIndexEvaluator::Evaluate(
                         segment->GetIndex(), predicate_,
                         OffsetRange(std::max(segment_range.begin, 
offset_range_.begin),
-                                    std::min(segment_range.end, 
offset_range_.end))));
+                                    std::min(segment_range.end, 
offset_range_.end)),
+                        memory_pool_));
                 if (indexed) {
                     if (candidates_) {
                         *candidates_ &= *indexed;
@@ -802,12 +803,12 @@ class ArrowRealtimeStore::IndexReadSource final : public 
RealtimeIndexReadSource
     }
 
     Result<std::vector<std::shared_ptr<RealtimeIndexReader>>> 
CreateIndexReaders(
-        const std::string& field_name) const override {
+        const std::string& field_name, const std::shared_ptr<MemoryPool>& 
pool) const override {
         std::vector<std::shared_ptr<RealtimeIndexReader>> readers;
         if (segment_->GetIndex()) {
             for (const auto& index : 
segment_->GetIndex()->FindIndexes(field_name)) {
                 PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<RealtimeIndexReader> 
reader,
-                                       index->CreateReader(offset_range_));
+                                       index->CreateReader(offset_range_, 
pool));
                 if (reader) {
                     readers.push_back(std::move(reader));
                 }
diff --git a/src/paimon/core/realtime/index/hash/hash_realtime_index.cpp 
b/src/paimon/core/realtime/index/hash/hash_realtime_index.cpp
index 552d5e29..a105a25a 100644
--- a/src/paimon/core/realtime/index/hash/hash_realtime_index.cpp
+++ b/src/paimon/core/realtime/index/hash/hash_realtime_index.cpp
@@ -196,7 +196,7 @@ Status HashRealtimeIndex::AddBatch(::ArrowArray* batch) {
 }
 
 Result<std::shared_ptr<RealtimeIndexReader>> HashRealtimeIndex::CreateReader(
-    const OffsetRange& offset_range) const {
+    const OffsetRange& offset_range, const std::shared_ptr<MemoryPool>&) const 
{
     if (offset_range.begin < 0 || offset_range.begin > offset_range.end) {
         return Status::Invalid("real-time index query offset range is 
invalid");
     }
diff --git a/src/paimon/core/realtime/index/hash/hash_realtime_index.h 
b/src/paimon/core/realtime/index/hash/hash_realtime_index.h
index 44ae0b2d..3b92d156 100644
--- a/src/paimon/core/realtime/index/hash/hash_realtime_index.h
+++ b/src/paimon/core/realtime/index/hash/hash_realtime_index.h
@@ -52,7 +52,7 @@ class HashRealtimeIndex final : public RealtimeIndex,
     Status AddBatch(::ArrowArray* batch) override;
 
     Result<std::shared_ptr<RealtimeIndexReader>> CreateReader(
-        const OffsetRange& offset_range) const override;
+        const OffsetRange& offset_range, const std::shared_ptr<MemoryPool>& 
pool) const override;
 
     uint64_t GetMemoryUsage() const override;
 
diff --git a/src/paimon/core/realtime/index/realtime_index_evaluator.cpp 
b/src/paimon/core/realtime/index/realtime_index_evaluator.cpp
index e0c6b380..8157fff3 100644
--- a/src/paimon/core/realtime/index/realtime_index_evaluator.cpp
+++ b/src/paimon/core/realtime/index/realtime_index_evaluator.cpp
@@ -34,7 +34,7 @@ namespace paimon {
 
 Result<std::optional<RoaringBitmap64>> RealtimeIndexEvaluator::Evaluate(
     const std::shared_ptr<RealtimeIndexSet>& indexes, const 
std::shared_ptr<Predicate>& predicate,
-    const OffsetRange& offset_range) {
+    const OffsetRange& offset_range, const std::shared_ptr<MemoryPool>& pool) {
     if (offset_range.begin < 0 || offset_range.begin > offset_range.end) {
         return Status::Invalid("real-time index query offset range is 
invalid");
     }
@@ -51,23 +51,24 @@ Result<std::optional<RoaringBitmap64>> 
RealtimeIndexEvaluator::Evaluate(
         if (!compound || compound->Children().empty()) {
             return Status::Invalid("invalid or empty real-time index compound 
predicate");
         }
-        return EvaluateCompound(indexes, compound, offset_range);
+        return EvaluateCompound(indexes, compound, offset_range, pool);
     }
     const std::shared_ptr<LeafPredicate> leaf = 
std::dynamic_pointer_cast<LeafPredicate>(predicate);
     if (!leaf) {
         return std::optional<RoaringBitmap64>();
     }
-    return EvaluateLeaf(indexes, leaf, offset_range);
+    return EvaluateLeaf(indexes, leaf, offset_range, pool);
 }
 
 Result<std::optional<RoaringBitmap64>> 
RealtimeIndexEvaluator::EvaluateCompound(
     const std::shared_ptr<RealtimeIndexSet>& indexes,
-    const std::shared_ptr<CompoundPredicate>& compound, const OffsetRange& 
offset_range) {
+    const std::shared_ptr<CompoundPredicate>& compound, const OffsetRange& 
offset_range,
+    const std::shared_ptr<MemoryPool>& pool) {
     const Function::Type function = compound->GetFunction().GetType();
     std::optional<RoaringBitmap64> result;
     for (const std::shared_ptr<Predicate>& child : compound->Children()) {
         PAIMON_ASSIGN_OR_RAISE(std::optional<RoaringBitmap64> candidates,
-                               Evaluate(indexes, child, offset_range));
+                               Evaluate(indexes, child, offset_range, pool));
         if (!candidates) {
             if (function == Function::Type::OR) {
                 return std::optional<RoaringBitmap64>();
@@ -90,12 +91,12 @@ Result<std::optional<RoaringBitmap64>> 
RealtimeIndexEvaluator::EvaluateCompound(
 
 Result<std::optional<RoaringBitmap64>> RealtimeIndexEvaluator::EvaluateLeaf(
     const std::shared_ptr<RealtimeIndexSet>& indexes, const 
std::shared_ptr<LeafPredicate>& leaf,
-    const OffsetRange& offset_range) {
+    const OffsetRange& offset_range, const std::shared_ptr<MemoryPool>& pool) {
     std::optional<RoaringBitmap64> result;
     for (const std::shared_ptr<RealtimeIndex>& index :
          indexes->FindIndexes(leaf->FieldName(), leaf->GetFieldType())) {
         PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<RealtimeIndexReader> reader,
-                               index->CreateReader(offset_range));
+                               index->CreateReader(offset_range, pool));
         if (!reader) {
             continue;
         }
diff --git a/src/paimon/core/realtime/index/realtime_index_evaluator.h 
b/src/paimon/core/realtime/index/realtime_index_evaluator.h
index f749c0dc..9c6485b2 100644
--- a/src/paimon/core/realtime/index/realtime_index_evaluator.h
+++ b/src/paimon/core/realtime/index/realtime_index_evaluator.h
@@ -29,6 +29,7 @@
 namespace paimon {
 class CompoundPredicate;
 class LeafPredicate;
+class MemoryPool;
 class Predicate;
 class RealtimeIndexSet;
 
@@ -39,16 +40,19 @@ class RealtimeIndexEvaluator {
 
     static Result<std::optional<RoaringBitmap64>> Evaluate(
         const std::shared_ptr<RealtimeIndexSet>& indexes,
-        const std::shared_ptr<Predicate>& predicate, const OffsetRange& 
offset_range);
+        const std::shared_ptr<Predicate>& predicate, const OffsetRange& 
offset_range,
+        const std::shared_ptr<MemoryPool>& pool);
 
  private:
     static Result<std::optional<RoaringBitmap64>> EvaluateCompound(
         const std::shared_ptr<RealtimeIndexSet>& indexes,
-        const std::shared_ptr<CompoundPredicate>& compound, const OffsetRange& 
offset_range);
+        const std::shared_ptr<CompoundPredicate>& compound, const OffsetRange& 
offset_range,
+        const std::shared_ptr<MemoryPool>& pool);
 
     static Result<std::optional<RoaringBitmap64>> EvaluateLeaf(
         const std::shared_ptr<RealtimeIndexSet>& indexes,
-        const std::shared_ptr<LeafPredicate>& leaf, const OffsetRange& 
offset_range);
+        const std::shared_ptr<LeafPredicate>& leaf, const OffsetRange& 
offset_range,
+        const std::shared_ptr<MemoryPool>& pool);
 };
 
 }  // namespace paimon
diff --git a/src/paimon/core/realtime/index/realtime_index_test.cpp 
b/src/paimon/core/realtime/index/realtime_index_test.cpp
index 8ae7152a..57b62307 100644
--- a/src/paimon/core/realtime/index/realtime_index_test.cpp
+++ b/src/paimon/core/realtime/index/realtime_index_test.cpp
@@ -75,7 +75,7 @@ class RealtimeIndexTest : public testing::Test {
 
     Result<std::optional<RoaringBitmap64>> Evaluate(const 
std::shared_ptr<Predicate>& predicate,
                                                     const OffsetRange& range) 
const {
-        return RealtimeIndexEvaluator::Evaluate(index_, predicate, range);
+        return RealtimeIndexEvaluator::Evaluate(index_, predicate, range, 
GetDefaultPool());
     }
 
     Status Add(const std::string& json, const OffsetRange& range) const {
@@ -240,9 +240,9 @@ TEST_F(RealtimeIndexTest, 
FieldReadersBindIndependentRangesAndShareAppendOnlyPos
     std::shared_ptr<RealtimeIndex> key_index = std::move(key_indexes[0]);
     ASSERT_NE(key_index, value_indexes[0]);
     ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> first,
-                         key_index->CreateReader(OffsetRange(10, 14)));
+                         key_index->CreateReader(OffsetRange(10, 14), 
GetDefaultPool()));
     ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> second,
-                         key_index->CreateReader(OffsetRange(20, 21)));
+                         key_index->CreateReader(OffsetRange(20, 21), 
GetDefaultPool()));
     ASSERT_OK(Add(R"([[25, 1, "d"]])", OffsetRange(25, 26)));
     ASSERT_OK_AND_ASSIGN(std::optional<RoaringBitmap64> candidates,
                          first->VisitEqual(Literal(int64_t{1})));
@@ -252,7 +252,7 @@ TEST_F(RealtimeIndexTest, 
FieldReadersBindIndependentRangesAndShareAppendOnlyPos
     ASSERT_TRUE(candidates.has_value());
     ASSERT_EQ(RoaringBitmap64::From({20}), *candidates);
     ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> later,
-                         key_index->CreateReader(OffsetRange(25, 26)));
+                         key_index->CreateReader(OffsetRange(25, 26), 
GetDefaultPool()));
     ASSERT_OK_AND_ASSIGN(candidates, later->VisitEqual(Literal(int64_t{1})));
     ASSERT_TRUE(candidates.has_value());
     ASSERT_EQ(RoaringBitmap64::From({25}), *candidates);
@@ -261,10 +261,10 @@ TEST_F(RealtimeIndexTest, 
FieldReadersBindIndependentRangesAndShareAppendOnlyPos
     ASSERT_EQ(RoaringBitmap64::From({10}), *candidates);
     ASSERT_OK_AND_ASSIGN(candidates, 
first->VisitGreaterThan(Literal(int64_t{0})));
     ASSERT_FALSE(candidates.has_value());
-    ASSERT_NOK(key_index->CreateReader(OffsetRange(-1, 20)));
-    ASSERT_NOK(key_index->CreateReader(OffsetRange(20, 10)));
+    ASSERT_NOK(key_index->CreateReader(OffsetRange(-1, 20), GetDefaultPool()));
+    ASSERT_NOK(key_index->CreateReader(OffsetRange(20, 10), GetDefaultPool()));
     ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> empty,
-                         key_index->CreateReader(OffsetRange(10, 10)));
+                         key_index->CreateReader(OffsetRange(10, 10), 
GetDefaultPool()));
     ASSERT_OK_AND_ASSIGN(candidates, empty->VisitEqual(Literal(int64_t{1})));
     ASSERT_TRUE(candidates.has_value());
     ASSERT_TRUE(candidates->IsEmpty());
@@ -325,7 +325,7 @@ TEST_F(RealtimeIndexTest, 
FactoryAcceptsOnlyOneIndexedFieldAndReaderNeedsNoField
     ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndex> index,
                          RealtimeIndexFactory::Get("hash", &c_schema, {}, 
GetDefaultPool()));
     ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader,
-                         index->CreateReader(OffsetRange(0, 10)));
+                         index->CreateReader(OffsetRange(0, 10), 
GetDefaultPool()));
     ASSERT_OK_AND_ASSIGN(std::optional<RoaringBitmap64> candidates,
                          reader->VisitEqual(Literal(int64_t{1})));
     ASSERT_TRUE(candidates.has_value());
@@ -343,7 +343,7 @@ TEST_F(RealtimeIndexTest, 
FactoryAcceptsOnlyOneIndexedFieldAndReaderNeedsNoField
     ASSERT_TRUE(arrow::ExportArray(*data, &batch).ok());
     ScopeGuard batch_guard([&batch]() { ArrowArrayRelease(&batch); });
     ASSERT_OK(index->AddBatch(&batch));
-    ASSERT_OK_AND_ASSIGN(reader, index->CreateReader(OffsetRange(11, 31)));
+    ASSERT_OK_AND_ASSIGN(reader, index->CreateReader(OffsetRange(11, 31), 
GetDefaultPool()));
     ASSERT_OK_AND_ASSIGN(candidates, reader->VisitEqual(Literal(int64_t{1})));
     ASSERT_TRUE(candidates.has_value());
     ASSERT_EQ(RoaringBitmap64::From({30}), *candidates);
@@ -369,7 +369,7 @@ TEST_F(RealtimeIndexTest, IndexesTimeField) {
     ASSERT_OK(index->AddBatch(&batch));
 
     ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader,
-                         index->CreateReader(OffsetRange(0, 41)));
+                         index->CreateReader(OffsetRange(0, 41), 
GetDefaultPool()));
     ASSERT_OK_AND_ASSIGN(std::optional<RoaringBitmap64> candidates,
                          reader->VisitEqual(Literal(FieldType::TIME, 
45296123)));
     ASSERT_TRUE(candidates.has_value());
diff --git a/src/paimon/core/realtime/precise_realtime_index_read.cpp 
b/src/paimon/core/realtime/precise_realtime_index_read.cpp
index ca5ce9a1..c131b7d8 100644
--- a/src/paimon/core/realtime/precise_realtime_index_read.cpp
+++ b/src/paimon/core/realtime/precise_realtime_index_read.cpp
@@ -230,8 +230,9 @@ class RealtimeSourceRead {
         const std::string& field_name) {
         auto found = readers_.find(field_name);
         if (found == readers_.end()) {
-            
PAIMON_ASSIGN_OR_RAISE(std::vector<std::shared_ptr<RealtimeIndexReader>> 
readers,
-                                   source_->CreateIndexReaders(field_name));
+            PAIMON_ASSIGN_OR_RAISE(
+                std::vector<std::shared_ptr<RealtimeIndexReader>> readers,
+                source_->CreateIndexReaders(field_name, 
context_->GetMemoryPool()));
             for (const auto& reader : readers) {
                 if (!reader) {
                     return Status::Invalid("Real-time source returned a null 
index reader");
diff --git a/src/paimon/core/realtime/precise_realtime_index_read.h 
b/src/paimon/core/realtime/precise_realtime_index_read.h
index 9ef9f51b..4c8c7e2a 100644
--- a/src/paimon/core/realtime/precise_realtime_index_read.h
+++ b/src/paimon/core/realtime/precise_realtime_index_read.h
@@ -27,7 +27,7 @@ namespace paimon {
 class InternalReadContext;
 
 /// Executes the same precise predicate/search plan as file reads, using 
pinned real-time offsets.
-/// TopK is source-local, matching the existing file-local search contract.
+/// Each source supplies TopK candidates; the table reader selects and sorts 
the global TopK.
 class PreciseRealtimeIndexRead {
  public:
     PreciseRealtimeIndexRead() = delete;
diff --git a/src/paimon/core/realtime/realtime_utils.cpp 
b/src/paimon/core/realtime/realtime_utils.cpp
new file mode 100644
index 00000000..89e1102b
--- /dev/null
+++ b/src/paimon/core/realtime/realtime_utils.cpp
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "paimon/core/realtime/realtime_utils.h"
+
+#include "arrow/api.h"
+#include "paimon/common/table/special_fields.h"
+#include "paimon/core/io/file_index_options.h"
+#include "paimon/core/schema/arrow_schema_validator.h"
+#include "paimon/core/utils/branch_manager.h"
+#include "paimon/file_index/file_indexer.h"
+#include "paimon/file_index/file_indexer_factory.h"
+#include "paimon/macros.h"
+#include "paimon/status.h"
+
+namespace paimon {
+
+Status RealtimeUtils::ValidateBranch(const std::string& branch) {
+    if (!BranchManager::IsMainBranch(BranchManager::NormalizeBranch(branch))) {
+        return Status::Invalid("real-time operations only support the main 
branch");
+    }
+    return Status::OK();
+}
+
+Result<int32_t> RealtimeUtils::GetDeduplicateKeyPosition(
+    const std::shared_ptr<arrow::Schema>& schema,
+    const std::vector<std::string>& deduplicate_key_fields) {
+    if (!schema) {
+        return Status::Invalid("real-time deduplicate schema must not be 
null");
+    }
+    // TODO(xinyu.lxy): Support multiple user-defined deduplicate key fields. 
This requires
+    // composite-key projection and serialization in the configured field 
order.
+    if (deduplicate_key_fields.size() != 1) {
+        return Status::Invalid(
+            "real-time deduplicate currently requires exactly one deduplicate 
key field");
+    }
+    const int32_t key_position = 
schema->GetFieldIndex(deduplicate_key_fields[0]);
+    if (key_position < 0) {
+        return Status::Invalid("real-time deduplicate key field does not 
exist: ",
+                               deduplicate_key_fields[0]);
+    }
+    return key_position;
+}
+
+Status RealtimeUtils::ValidateOffsetField(const 
std::shared_ptr<arrow::Schema>& schema) {
+    if (!schema) {
+        return Status::Invalid("real-time schema must not be null");
+    }
+    const std::shared_ptr<arrow::Field> offset_field =
+        schema->GetFieldByName(SpecialFields::RealtimeOffset().Name());
+    if (!offset_field || offset_field->type()->id() != arrow::Type::INT64 ||
+        offset_field->nullable()) {
+        return Status::Invalid("real-time schema requires non-null int64 
_REALTIME_OFFSET");
+    }
+    return Status::OK();
+}
+
+Status RealtimeUtils::ValidateDeduplicateSchema(
+    const std::shared_ptr<arrow::Schema>& schema,
+    const std::vector<std::string>& deduplicate_key_fields) {
+    PAIMON_RETURN_NOT_OK(ValidateOffsetField(schema));
+    PAIMON_ASSIGN_OR_RAISE(int32_t key_position,
+                           GetDeduplicateKeyPosition(schema, 
deduplicate_key_fields));
+    const std::shared_ptr<arrow::Field>& key_field = 
schema->field(key_position);
+    if (key_field->name() == SpecialFields::RealtimeOffset().Name()) {
+        return Status::Invalid("real-time offset field cannot be used as the 
deduplicate key");
+    }
+    if (key_field->nullable()) {
+        return Status::Invalid("real-time deduplicate key field must be 
non-null: ",
+                               key_field->name());
+    }
+    if (ArrowSchemaValidator::IsNestedType(key_field->type())) {
+        return Status::Invalid("real-time deduplicate key field must not be 
nested: ",
+                               key_field->name());
+    }
+    return Status::OK();
+}
+
+Status RealtimeUtils::ValidateDeduplicateFileIndex(const CoreOptions& options) 
{
+    if (!options.FileIndexReadEnabled()) {
+        return Status::Invalid(
+            "real-time deduplicate mode requires 
'file-index.read.enabled=true'");
+    }
+    PAIMON_ASSIGN_OR_RAISE(FileIndexOptions file_indexes,
+                           FileIndexOptions::FromCoreOptions(options));
+    const std::string& offset_name = SpecialFields::RealtimeOffset().Name();
+    for (const FileIndexDefinition& definition : file_indexes.Definitions()) {
+        if (definition.column_name != offset_name) {
+            continue;
+        }
+        PAIMON_ASSIGN_OR_RAISE(std::unique_ptr<FileIndexer> indexer,
+                               FileIndexerFactory::Get(definition.index_type, 
definition.options));
+        if (indexer && indexer->SupportsExactPredicate(Function::Type::IN, 
FieldType::BIGINT) &&
+            indexer->SupportsExactPredicate(Function::Type::NOT_IN, 
FieldType::BIGINT)) {
+            return Status::OK();
+        }
+    }
+    return Status::Invalid(
+        "real-time deduplicate mode requires an index supporting exact BIGINT 
IN and NOT_IN "
+        "row positions on ",
+        offset_name);
+}
+
+}  // namespace paimon
diff --git a/src/paimon/core/realtime/realtime_utils.h 
b/src/paimon/core/realtime/realtime_utils.h
index 6b28a04c..a8c15d45 100644
--- a/src/paimon/core/realtime/realtime_utils.h
+++ b/src/paimon/core/realtime/realtime_utils.h
@@ -25,14 +25,9 @@
 #include <vector>
 
 #include "arrow/api.h"
-#include "paimon/common/table/special_fields.h"
 #include "paimon/core/core_options.h"
-#include "paimon/core/io/file_index_options.h"
-#include "paimon/core/schema/arrow_schema_validator.h"
-#include "paimon/core/utils/branch_manager.h"
-#include "paimon/file_index/file_indexer.h"
-#include "paimon/file_index/file_indexer_factory.h"
 #include "paimon/result.h"
+#include "paimon/visibility.h"
 
 namespace paimon {
 
@@ -41,92 +36,18 @@ class RealtimeUtils {
     RealtimeUtils() = delete;
     ~RealtimeUtils() = delete;
 
-    static Status ValidateBranch(const std::string& branch) {
-        if 
(!BranchManager::IsMainBranch(BranchManager::NormalizeBranch(branch))) {
-            return Status::Invalid("real-time operations only support the main 
branch");
-        }
-        return Status::OK();
-    }
+    static Status ValidateBranch(const std::string& branch);
 
     static Result<int32_t> GetDeduplicateKeyPosition(
         const std::shared_ptr<arrow::Schema>& schema,
-        const std::vector<std::string>& deduplicate_key_fields) {
-        if (!schema) {
-            return Status::Invalid("real-time deduplicate schema must not be 
null");
-        }
-        // TODO(xinyu.lxy): Support multiple user-defined deduplicate key 
fields. This requires
-        // composite-key projection and serialization in the configured field 
order.
-        if (deduplicate_key_fields.size() != 1) {
-            return Status::Invalid(
-                "real-time deduplicate currently requires exactly one 
deduplicate key field");
-        }
-        const int32_t key_position = 
schema->GetFieldIndex(deduplicate_key_fields[0]);
-        if (key_position < 0) {
-            return Status::Invalid("real-time deduplicate key field does not 
exist: ",
-                                   deduplicate_key_fields[0]);
-        }
-        return key_position;
-    }
+        const std::vector<std::string>& deduplicate_key_fields);
 
-    static Status ValidateOffsetField(const std::shared_ptr<arrow::Schema>& 
schema) {
-        if (!schema) {
-            return Status::Invalid("real-time schema must not be null");
-        }
-        const std::shared_ptr<arrow::Field> offset_field =
-            schema->GetFieldByName(SpecialFields::RealtimeOffset().Name());
-        if (!offset_field || offset_field->type()->id() != arrow::Type::INT64 
||
-            offset_field->nullable()) {
-            return Status::Invalid("real-time schema requires non-null int64 
_REALTIME_OFFSET");
-        }
-        return Status::OK();
-    }
+    PAIMON_EXPORT static Status ValidateOffsetField(const 
std::shared_ptr<arrow::Schema>& schema);
 
-    static Status ValidateDeduplicateSchema(
-        const std::shared_ptr<arrow::Schema>& schema,
-        const std::vector<std::string>& deduplicate_key_fields) {
-        PAIMON_RETURN_NOT_OK(ValidateOffsetField(schema));
-        PAIMON_ASSIGN_OR_RAISE(int32_t key_position,
-                               GetDeduplicateKeyPosition(schema, 
deduplicate_key_fields));
-        const std::shared_ptr<arrow::Field>& key_field = 
schema->field(key_position);
-        if (key_field->name() == SpecialFields::RealtimeOffset().Name()) {
-            return Status::Invalid("real-time offset field cannot be used as 
the deduplicate key");
-        }
-        if (key_field->nullable()) {
-            return Status::Invalid("real-time deduplicate key field must be 
non-null: ",
-                                   key_field->name());
-        }
-        if (ArrowSchemaValidator::IsNestedType(key_field->type())) {
-            return Status::Invalid("real-time deduplicate key field must not 
be nested: ",
-                                   key_field->name());
-        }
-        return Status::OK();
-    }
+    static Status ValidateDeduplicateSchema(const 
std::shared_ptr<arrow::Schema>& schema,
+                                            const std::vector<std::string>& 
deduplicate_key_fields);
 
-    static Status ValidateDeduplicateFileIndex(const CoreOptions& options) {
-        if (!options.FileIndexReadEnabled()) {
-            return Status::Invalid(
-                "real-time deduplicate mode requires 
'file-index.read.enabled=true'");
-        }
-        PAIMON_ASSIGN_OR_RAISE(FileIndexOptions file_indexes,
-                               FileIndexOptions::FromCoreOptions(options));
-        const std::string& offset_name = 
SpecialFields::RealtimeOffset().Name();
-        for (const FileIndexDefinition& definition : 
file_indexes.Definitions()) {
-            if (definition.column_name != offset_name) {
-                continue;
-            }
-            PAIMON_ASSIGN_OR_RAISE(
-                std::unique_ptr<FileIndexer> indexer,
-                FileIndexerFactory::Get(definition.index_type, 
definition.options));
-            if (indexer && indexer->SupportsExactPredicate(Function::Type::IN, 
FieldType::BIGINT) &&
-                indexer->SupportsExactPredicate(Function::Type::NOT_IN, 
FieldType::BIGINT)) {
-                return Status::OK();
-            }
-        }
-        return Status::Invalid(
-            "real-time deduplicate mode requires an index supporting exact 
BIGINT IN and NOT_IN "
-            "row positions on ",
-            offset_name);
-    }
+    static Status ValidateDeduplicateFileIndex(const CoreOptions& options);
 };
 
 }  // namespace paimon
diff --git a/src/paimon/core/table/source/table_read_test.cpp 
b/src/paimon/core/table/source/table_read_test.cpp
index 62560e3b..46c5b844 100644
--- a/src/paimon/core/table/source/table_read_test.cpp
+++ b/src/paimon/core/table/source/table_read_test.cpp
@@ -29,13 +29,16 @@
 #include <vector>
 
 #include "arrow/api.h"
+#include "arrow/ipc/json_simple.h"
 #include "arrow/type.h"
 #include "gtest/gtest.h"
 #include "paimon/catalog/identifier.h"
 #include "paimon/catalog/table.h"
 #include "paimon/common/catalog/catalog_context.h"
 #include "paimon/common/data/binary_row.h"
+#include "paimon/common/reader/concat_batch_reader.h"
 #include "paimon/common/reader/reader_utils.h"
+#include "paimon/common/utils/arrow/mem_utils.h"
 #include "paimon/core/core_options.h"
 #include "paimon/core/io/data_file_meta.h"
 #include "paimon/core/operation/abstract_split_read.h"
@@ -45,6 +48,7 @@
 #include "paimon/core/table/source/append_only_table_read.h"
 #include "paimon/core/table/source/data_split_impl.h"
 #include "paimon/core/table/source/key_value_table_read.h"
+#include "paimon/core/table/source/topk_batch_reader.h"
 #include "paimon/defs.h"
 #include "paimon/fs/local/local_file_system.h"
 #include "paimon/predicate/full_text_match.h"
@@ -57,6 +61,7 @@
 #include "paimon/status.h"
 #include "paimon/table/format/format_table.h"
 #include "paimon/table/source/table_scan.h"
+#include "paimon/testing/mock/mock_file_batch_reader.h"
 #include "paimon/testing/mock/mock_search_file_index.h"
 #include "paimon/testing/utils/binary_row_generator.h"
 #include "paimon/testing/utils/counting_reader_file_system.h"
@@ -263,6 +268,54 @@ TEST(TableReadTest, TestRootTopKEmptyInput) {
     ASSERT_TRUE(BatchReader::IsEofBatch(eof));
 }
 
+TEST(TableReadTest, TestRootTopKCombinesDifferentFieldNullability) {
+    const std::string score_name = "_embedding_INDEX_SCORE";
+    auto pool = GetArrowPool(GetDefaultPool());
+    for (bool project_score : {false, true}) {
+        SCOPED_TRACE(project_score);
+        std::vector<std::unique_ptr<BatchReader>> readers;
+        for (bool nullable : {false, true}) {
+            auto items = arrow::list(arrow::field(
+                "item", arrow::struct_({arrow::field("value", arrow::int64(), 
nullable)}),
+                nullable));
+            auto type = arrow::struct_({arrow::field("id", arrow::int64(), 
nullable),
+                                        arrow::field("items", items),
+                                        arrow::field(score_name, 
arrow::float32(), nullable)});
+            auto data = arrow::ipc::internal::json::ArrayFromJSON(
+                type, nullable ? "[[3,null,3],[4,[],2]]" : 
"[[1,[[10]],4],[2,[[20],[21]],1]]");
+            ASSERT_TRUE(data.ok()) << data.status().ToString();
+            
readers.push_back(std::make_unique<MockFileBatchReader>(data.ValueOrDie(), 
type, 1));
+        }
+        arrow::FieldVector fields{
+            arrow::field("id", arrow::int64(), /*nullable=*/false),
+            arrow::field(
+                "items",
+                arrow::list(arrow::field(
+                    "item",
+                    arrow::struct_({arrow::field("value", arrow::int64(), 
/*nullable=*/false)}),
+                    /*nullable=*/false)))};
+        if (project_score) {
+            fields.push_back(arrow::field(score_name, arrow::float32()));
+        }
+        auto reader = std::make_unique<TopKBatchReader>(
+            std::make_unique<ConcatBatchReader>(std::move(readers), pool), 
score_name,
+            TopKBatchReader::ScoreOrder::ASCENDING, /*limit=*/3, 
/*batch_size=*/1,
+            arrow::schema(fields), pool);
+        ASSERT_OK_AND_ASSIGN(std::shared_ptr<arrow::ChunkedArray> actual,
+                             
ReadResultCollector::CollectResult(std::move(reader)));
+        ASSERT_NE(nullptr, actual);
+        fields[0] = fields[0]->WithNullable(true);
+        fields[1] = arrow::field(
+            "items", arrow::list(arrow::struct_({arrow::field("value", 
arrow::int64())})));
+        auto expected = arrow::ipc::internal::json::ArrayFromJSON(
+            arrow::struct_(fields), project_score ? 
"[[2,[[20],[21]],1],[4,[],2],[3,null,3]]"
+                                                  : 
"[[2,[[20],[21]]],[4,[]],[3,null]]");
+        ASSERT_TRUE(expected.ok()) << expected.status().ToString();
+        
ASSERT_TRUE(actual->Equals(std::make_shared<arrow::ChunkedArray>(expected.ValueOrDie())))
+            << actual->ToString();
+    }
+}
+
 TEST(TableReadTest, TestRootTopKRejectsFallbackBranch) {
     const std::string path = GetDataDir() + "/orc/append_09.db/append_09";
     for (bool vector_search : {false, true}) {
diff --git a/src/paimon/core/table/source/topk_batch_reader.cpp 
b/src/paimon/core/table/source/topk_batch_reader.cpp
index 2cd083b8..8bfe9fb7 100644
--- a/src/paimon/core/table/source/topk_batch_reader.cpp
+++ b/src/paimon/core/table/source/topk_batch_reader.cpp
@@ -35,6 +35,7 @@
 #include "paimon/common/utils/checked_cast.h"
 #include "paimon/common/utils/fields_comparator.h"
 #include "paimon/core/operation/internal_read_context.h"
+#include "paimon/core/utils/nested_projection_utils.h"
 #include "paimon/predicate/full_text_search.h"
 #include "paimon/predicate/vector_search.h"
 
@@ -139,9 +140,16 @@ Status TopKBatchReader::ReadTopK() {
             continue;
         }
         auto values = checked_pointer_cast<arrow::StructArray>(array);
-        PAIMON_ASSIGN_OR_RAISE(values, 
ArrowUtils::FlattenUnresolvableDictionaries(
-                                           values, read_type_, pool_.get(),
-                                           
/*preserve_layout_recoverable_dictionaries=*/false));
+        // Align nested nullability across sources while retaining implicit 
columns.
+        const auto& logical_type = checked_cast<const 
arrow::StructType&>(*read_type_);
+        arrow::FieldVector fields = values->struct_type()->fields();
+        for (auto& field : fields) {
+            auto logical_field = logical_type.GetFieldByName(field->name());
+            field = logical_field ? logical_field : field->WithNullable(true);
+        }
+        PAIMON_ASSIGN_OR_RAISE(array, 
NestedProjectionUtils::AlignArrayToReadType(
+                                          values, 
arrow::struct_(std::move(fields)), pool_.get()));
+        values = checked_pointer_cast<arrow::StructArray>(array);
         auto scores =
             
std::dynamic_pointer_cast<arrow::FloatArray>(values->GetFieldByName(score_name_));
         if (!scores) {
diff --git a/src/paimon/indexer/lumina/CMakeLists.txt 
b/src/paimon/indexer/lumina/CMakeLists.txt
index 280956e7..8b57b22e 100644
--- a/src/paimon/indexer/lumina/CMakeLists.txt
+++ b/src/paimon/indexer/lumina/CMakeLists.txt
@@ -25,6 +25,8 @@ if(PAIMON_ENABLE_LUMINA)
         lumina_index_accumulator.cpp
         lumina_index_options.cpp
         lumina_index_searcher.cpp
+        lumina_realtime_index.cpp
+        lumina_realtime_index_factory.cpp
         lumina_tag_utils.cpp)
     add_paimon_lib(paimon_lumina_index
                    SOURCES
@@ -50,6 +52,7 @@ if(PAIMON_ENABLE_LUMINA)
                         lumina_file_index_test.cpp
                         lumina_file_io_test.cpp
                         lumina_global_index_test.cpp
+                        lumina_realtime_index_test.cpp
                         EXTRA_INCLUDES
                         ${LUMINA_INCLUDE_DIR}
                         STATIC_LINK_LIBS
diff --git a/src/paimon/indexer/lumina/lumina_api_test.cpp 
b/src/paimon/indexer/lumina/lumina_api_test.cpp
index 8b7b6a48..3ea43d70 100644
--- a/src/paimon/indexer/lumina/lumina_api_test.cpp
+++ b/src/paimon/indexer/lumina/lumina_api_test.cpp
@@ -36,7 +36,7 @@ class LuminaInterfaceTest : public ::testing::Test {
                        const std::vector<::lumina::core::vector_id_t>& 
row_ids) const {
         auto fs = std::make_shared<LocalFileSystem>();
         std::shared_ptr<MemoryPool> paimon_pool = GetMemoryPool();
-        auto pool = std::make_shared<LuminaMemoryPool>(paimon_pool);
+        auto pool = std::make_shared<LuminaMemoryPool>(/*track_memory=*/false, 
paimon_pool);
         ::lumina::core::MemoryResourceConfig memory_resource(pool.get());
         {  // create writer
             ::lumina::api::BuilderOptions builder_options;
@@ -74,7 +74,7 @@ class LuminaInterfaceTest : public ::testing::Test {
         ASSERT_EQ(expected_row_ids.size(), expected_distances.size());
         auto fs = std::make_shared<LocalFileSystem>();
         std::shared_ptr<MemoryPool> paimon_pool = GetMemoryPool();
-        auto pool = std::make_shared<LuminaMemoryPool>(paimon_pool);
+        auto pool = std::make_shared<LuminaMemoryPool>(/*track_memory=*/false, 
paimon_pool);
         ::lumina::core::MemoryResourceConfig memory_resource(pool.get());
         {
             // create reader
diff --git a/src/paimon/indexer/lumina/lumina_file_index.cpp 
b/src/paimon/indexer/lumina/lumina_file_index.cpp
index 2308bd7a..e5d24d7d 100644
--- a/src/paimon/indexer/lumina/lumina_file_index.cpp
+++ b/src/paimon/indexer/lumina/lumina_file_index.cpp
@@ -191,7 +191,7 @@ Result<std::shared_ptr<FileIndexWriter>> 
LuminaFileIndexer::CreateWriter(
     PAIMON_RETURN_NOT_OK(LuminaTagUtils::ValidateTagFields(*struct_type, 
tag_fields));
     PAIMON_ASSIGN_OR_RAISE(::lumina::api::BuilderOptions builder_options,
                            LuminaIndexOptions::CreateBuilderOptions(options_));
-    auto lumina_pool = std::make_shared<LuminaMemoryPool>(pool);
+    auto lumina_pool = 
std::make_shared<LuminaMemoryPool>(/*track_memory=*/false, pool);
     return std::make_shared<LuminaFileIndexWriter>(schema->field(0)->name(), 
std::move(struct_type),
                                                    index_info, 
std::move(builder_options),
                                                    std::move(tag_fields), 
std::move(lumina_pool));
@@ -210,7 +210,7 @@ Result<std::shared_ptr<FileIndexReader>> 
LuminaFileIndexer::CreateReader(
     PAIMON_ASSIGN_OR_RAISE(LuminaIndexInfo index_info, 
LuminaIndexOptions::GetIndexInfo(options_));
     PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<OffsetInputStream> artifact_input,
                            OffsetInputStream::Create(input_stream, length, 
start));
-    auto lumina_pool = std::make_shared<LuminaMemoryPool>(pool);
+    auto lumina_pool = 
std::make_shared<LuminaMemoryPool>(/*track_memory=*/false, pool);
     PAIMON_ASSIGN_OR_RAISE(
         std::unique_ptr<LuminaIndexSearcher> searcher,
         LuminaIndexSearcher::Open(options_, index_info, artifact_input, 
lumina_pool));
diff --git a/src/paimon/indexer/lumina/lumina_global_index.cpp 
b/src/paimon/indexer/lumina/lumina_global_index.cpp
index f544e871..b46348ae 100644
--- a/src/paimon/indexer/lumina/lumina_global_index.cpp
+++ b/src/paimon/indexer/lumina/lumina_global_index.cpp
@@ -82,7 +82,7 @@ Result<std::shared_ptr<GlobalIndexWriter>> 
LuminaGlobalIndex::CreateWriter(
             return Status::Invalid("Lumina checkpoint requires a 
checkpoint-capable file writer");
         }
     }
-    auto lumina_pool = std::make_shared<LuminaMemoryPool>(pool);
+    auto lumina_pool = 
std::make_shared<LuminaMemoryPool>(/*track_memory=*/false, pool);
     return std::make_shared<LuminaIndexWriter>(
         field_name, arrow_type, dimension, file_writer, 
std::move(builder_options),
         ::lumina::api::IOOptions(), lumina_options, std::move(tag_fields), 
checkpoint_file_manager,
@@ -128,7 +128,7 @@ Result<std::shared_ptr<GlobalIndexReader>> 
LuminaGlobalIndex::CreateReader(
     PAIMON_ASSIGN_OR_RAISE(LuminaIndexReader::IndexInfo index_info,
                            LuminaIndexReader::GetIndexInfo(io_meta));
 
-    auto lumina_pool = std::make_shared<LuminaMemoryPool>(pool);
+    auto lumina_pool = 
std::make_shared<LuminaMemoryPool>(/*track_memory=*/false, pool);
     auto lumina_options =
         OptionsUtils::FetchOptionsWithPrefix(LuminaDefines::kOptionKeyPrefix, 
options_);
     // get input stream and open index
diff --git a/src/paimon/indexer/lumina/lumina_global_index_test.cpp 
b/src/paimon/indexer/lumina/lumina_global_index_test.cpp
index 9e2020d6..a6d6c6bb 100644
--- a/src/paimon/indexer/lumina/lumina_global_index_test.cpp
+++ b/src/paimon/indexer/lumina/lumina_global_index_test.cpp
@@ -554,7 +554,7 @@ TEST_F(LuminaGlobalIndexTest, TestResumeFromCheckpoint) {
             .Set(::lumina::core::kEncodingType, 
::lumina::core::kEncodingRawf32)
             .Set(::lumina::core::kExtensionCkptThreshold, 
static_cast<int64_t>(1))
             .Set(::lumina::core::kExtensionCkptCount, static_cast<int64_t>(1));
-        LuminaMemoryPool lumina_pool(pool_);
+        LuminaMemoryPool lumina_pool(/*track_memory=*/false, pool_);
         ::lumina::core::MemoryResourceConfig memory_resource(&lumina_pool);
         auto builder_result =
             ::lumina::api::LuminaBuilder::Create(builder_options, 
memory_resource);
@@ -672,7 +672,7 @@ TEST_F(LuminaGlobalIndexTest, 
TestBuildFailureDiscardsCheckpointAndRetries) {
         .Set(::lumina::core::kEncodingType, ::lumina::core::kEncodingRawf32)
         .Set(::lumina::core::kExtensionCkptThreshold, static_cast<int64_t>(1))
         .Set(::lumina::core::kExtensionCkptCount, static_cast<int64_t>(1));
-    LuminaMemoryPool lumina_pool(pool_);
+    LuminaMemoryPool lumina_pool(/*track_memory=*/false, pool_);
     ::lumina::core::MemoryResourceConfig memory_resource(&lumina_pool);
     auto builder_result = 
::lumina::api::LuminaBuilder::Create(builder_options, memory_resource);
     ASSERT_TRUE(builder_result.IsOk()) << builder_result.GetStatus().Message();
diff --git a/src/paimon/indexer/lumina/lumina_index_options.cpp 
b/src/paimon/indexer/lumina/lumina_index_options.cpp
index 526982fb..adf7c82b 100644
--- a/src/paimon/indexer/lumina/lumina_index_options.cpp
+++ b/src/paimon/indexer/lumina/lumina_index_options.cpp
@@ -18,6 +18,7 @@
 
 #include "paimon/indexer/lumina/lumina_index_options.h"
 
+#include <set>
 #include <unordered_map>
 
 #include "fmt/format.h"
@@ -71,6 +72,41 @@ Result<::lumina::api::BuilderOptions> 
LuminaIndexOptions::CreateBuilderOptions(
     return builder_options;
 }
 
+Result<::lumina::api::StreamerOptions> 
LuminaIndexOptions::CreateStreamerOptions(
+    const std::map<std::string, std::string>& lumina_options) {
+    // TODO(xinyu.lxy): Use NormalizeStreamerOptions when Lumina exposes it. 
Convert types here;
+    // leave option value validation and backend support checks to 
LuminaStreamer::Create.
+    static const std::set<std::string> integer_keys = {"index.dimension",
+                                                       
"bruteforce.streamer.capacity",
+                                                       
"bruteforce.streamer.rows_per_block",
+                                                       
"flatnsw.streamer.capacity",
+                                                       
"flatnsw.streamer.rows_per_block",
+                                                       
"flatnsw.build.ef_construction",
+                                                       
"flatnsw.build.neighbor_count"};
+    static const std::set<std::string> double_keys = 
{"flatnsw.build.slack_pruning_factor",
+                                                      
"extension.build.tag.max_range_label_ratio",
+                                                      
"extension.build.tag.min_range_label_ratio"};
+    ::lumina::api::StreamerOptions options;
+    for (const auto& [key, value] : lumina_options) {
+        if (integer_keys.count(key)) {
+            PAIMON_ASSIGN_OR_RAISE(int64_t parsed,
+                                   
OptionsUtils::GetValueFromMap<int64_t>(lumina_options, key));
+            options.Set(key, parsed);
+        } else if (double_keys.count(key)) {
+            PAIMON_ASSIGN_OR_RAISE(double parsed,
+                                   
OptionsUtils::GetValueFromMap<double>(lumina_options, key));
+            options.Set(key, parsed);
+        } else if (key == ::lumina::core::kEnableExperimental) {
+            PAIMON_ASSIGN_OR_RAISE(bool parsed,
+                                   
OptionsUtils::GetValueFromMap<bool>(lumina_options, key));
+            options.Set(key, parsed);
+        } else {
+            options.Set(key, value);
+        }
+    }
+    return options;
+}
+
 bool LuminaIndexOptions::IsCheckpointEnabled(
     const std::map<std::string, std::string>& lumina_options) {
     return 
lumina_options.count(std::string(::lumina::core::kExtensionCkptThreshold)) != 0 
||
diff --git a/src/paimon/indexer/lumina/lumina_index_options.h 
b/src/paimon/indexer/lumina/lumina_index_options.h
index 1c3cc355..c1156b57 100644
--- a/src/paimon/indexer/lumina/lumina_index_options.h
+++ b/src/paimon/indexer/lumina/lumina_index_options.h
@@ -52,6 +52,9 @@ class LuminaIndexOptions {
     static Result<::lumina::api::BuilderOptions> CreateBuilderOptions(
         const std::map<std::string, std::string>& lumina_options);
 
+    static Result<::lumina::api::StreamerOptions> CreateStreamerOptions(
+        const std::map<std::string, std::string>& lumina_options);
+
     static bool IsCheckpointEnabled(const std::map<std::string, std::string>& 
lumina_options);
 
     static Result<::lumina::api::SearcherOptions> CreateSearcherOptions(
diff --git a/src/paimon/indexer/lumina/lumina_index_searcher.cpp 
b/src/paimon/indexer/lumina/lumina_index_searcher.cpp
index 33d4e86f..9949e2d7 100644
--- a/src/paimon/indexer/lumina/lumina_index_searcher.cpp
+++ b/src/paimon/indexer/lumina/lumina_index_searcher.cpp
@@ -79,8 +79,8 @@ Result<::lumina::api::LuminaSearcher::SearchResult> 
LuminaIndexSearcher::Search(
     PAIMON_ASSIGN_OR_RAISE(::lumina::api::SearchOptions search_options,
                            
LuminaIndexOptions::CreateSearchOptions(*vector_search, index_info_));
     ::lumina::api::Query query(vector_search->query.data(), 
vector_search->query.size());
-    LuminaMemoryPool session_pool(vector_search->pool ? vector_search->pool
-                                                      : 
pool_->GetPaimonPool());
+    LuminaMemoryPool session_pool(
+        /*track_memory=*/false, vector_search->pool ? vector_search->pool : 
pool_->GetPaimonPool());
 
     if (vector_search->predicate) {
         if (!searcher_with_tag_) {
diff --git a/src/paimon/indexer/lumina/lumina_memory_pool.h 
b/src/paimon/indexer/lumina/lumina_memory_pool.h
index e5dcee9d..58bc3545 100644
--- a/src/paimon/indexer/lumina/lumina_memory_pool.h
+++ b/src/paimon/indexer/lumina/lumina_memory_pool.h
@@ -18,6 +18,8 @@
 
 #pragma once
 
+#include <atomic>
+#include <cstdint>
 #include <memory>
 #include <memory_resource>
 
@@ -25,7 +27,8 @@
 namespace paimon::lumina {
 class LuminaMemoryPool : public std::pmr::memory_resource {
  public:
-    explicit LuminaMemoryPool(const std::shared_ptr<MemoryPool>& pool) : 
pool_(pool) {}
+    explicit LuminaMemoryPool(bool track_memory, const 
std::shared_ptr<MemoryPool>& pool)
+        : pool_(pool), track_memory_(track_memory) {}
 
     ~LuminaMemoryPool() override = default;
 
@@ -36,17 +39,30 @@ class LuminaMemoryPool : public std::pmr::memory_resource {
         return pool_;
     }
 
+    /// Bytes currently allocated through this resource, excluding other users 
of the same pool.
+    /// Returns zero when memory tracking is disabled.
+    uint64_t GetMemoryUsage() const {
+        return track_memory_ ? memory_usage_.load(std::memory_order_relaxed) : 
0;
+    }
+
  private:
     void* do_allocate(std::size_t bytes, std::size_t alignment) override {
         static const size_t min_alignment = alignof(std::max_align_t);
         if (alignment < min_alignment) {
             alignment = min_alignment;
         }
-        return pool_->Malloc(bytes, alignment);
+        void* ptr = pool_->Malloc(bytes, alignment);
+        if (track_memory_) {
+            memory_usage_.fetch_add(bytes, std::memory_order_relaxed);
+        }
+        return ptr;
     }
 
     void do_deallocate(void* p, std::size_t bytes, std::size_t alignment) 
override {
         pool_->Free(p, bytes, alignment);
+        if (track_memory_) {
+            memory_usage_.fetch_sub(bytes, std::memory_order_relaxed);
+        }
     }
 
     bool do_is_equal(const std::pmr::memory_resource& other) const noexcept 
override {
@@ -55,5 +71,7 @@ class LuminaMemoryPool : public std::pmr::memory_resource {
 
  private:
     std::shared_ptr<MemoryPool> pool_;
+    const bool track_memory_;
+    std::atomic<uint64_t> memory_usage_{0};
 };
 }  // namespace paimon::lumina
diff --git a/src/paimon/indexer/lumina/lumina_realtime_index.cpp 
b/src/paimon/indexer/lumina/lumina_realtime_index.cpp
new file mode 100644
index 00000000..4eacf058
--- /dev/null
+++ b/src/paimon/indexer/lumina/lumina_realtime_index.cpp
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "paimon/indexer/lumina/lumina_realtime_index.h"
+
+#include <algorithm>
+#include <cmath>
+#include <limits>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "arrow/api.h"
+#include "arrow/c/bridge.h"
+#include "lumina/core/Constants.h"
+#include "paimon/common/utils/arrow/status_utils.h"
+#include "paimon/common/utils/checked_cast.h"
+#include "paimon/core/realtime/realtime_utils.h"
+#include "paimon/indexer/lumina/lumina_memory_pool.h"
+#include "paimon/indexer/lumina/lumina_utils.h"
+
+namespace paimon::lumina {
+
+LuminaRealtimeIndex::LuminaRealtimeIndex(
+    std::shared_ptr<arrow::Schema> schema, LuminaIndexInfo index_info,
+    std::unique_ptr<::lumina::extensions::StreamWithFilterExtension> filter,
+    std::unique_ptr<::lumina::api::LuminaStreamer> streamer, 
std::unique_ptr<LuminaMemoryPool> pool)
+    : schema_(std::move(schema)),
+      index_info_(std::move(index_info)),
+      pool_(std::move(pool)),
+      filter_(std::move(filter)),
+      streamer_(std::move(streamer)) {}
+
+LuminaRealtimeIndex::~LuminaRealtimeIndex() = default;
+
+Result<std::shared_ptr<LuminaRealtimeIndex>> LuminaRealtimeIndex::Create(
+    const std::shared_ptr<arrow::Schema>& schema,
+    const std::map<std::string, std::string>& lumina_options,
+    const std::shared_ptr<MemoryPool>& pool) {
+    if (!pool) {
+        return Status::Invalid("Lumina realtime index requires a memory pool");
+    }
+    PAIMON_RETURN_NOT_OK(RealtimeUtils::ValidateOffsetField(schema));
+    if (schema->num_fields() != 2 || schema->field(1)->type()->id() != 
arrow::Type::LIST ||
+        
checked_pointer_cast<arrow::ListType>(schema->field(1)->type())->value_type()->id()
 !=
+            arrow::Type::FLOAT) {
+        return Status::Invalid("Lumina realtime index requires [offset, 
LIST<FLOAT>]");
+    }
+    if 
(lumina_options.count(std::string(::lumina::core::kExtensionTagSchema))) {
+        return Status::NotImplemented("Lumina realtime tags are not 
supported");
+    }
+    PAIMON_ASSIGN_OR_RAISE(LuminaIndexInfo info, 
LuminaIndexOptions::GetIndexInfo(lumina_options));
+    PAIMON_ASSIGN_OR_RAISE(::lumina::api::StreamerOptions streamer_options,
+                           
LuminaIndexOptions::CreateStreamerOptions(lumina_options));
+    auto lumina_pool = 
std::make_unique<LuminaMemoryPool>(/*track_memory=*/true, pool);
+    auto filter = 
std::make_unique<::lumina::extensions::StreamWithFilterExtension>();
+    PAIMON_ASSIGN_OR_RAISE_FROM_LUMINA(
+        ::lumina::api::LuminaStreamer native_streamer,
+        ::lumina::api::LuminaStreamer::Create(
+            streamer_options, 
::lumina::core::MemoryResourceConfig(lumina_pool.get())));
+    auto streamer = 
std::make_unique<::lumina::api::LuminaStreamer>(std::move(native_streamer));
+    PAIMON_RETURN_NOT_OK_FROM_LUMINA(streamer->Attach(*filter));
+    return std::shared_ptr<LuminaRealtimeIndex>(new LuminaRealtimeIndex(
+        schema, std::move(info), std::move(filter), std::move(streamer), 
std::move(lumina_pool)));
+}
+
+Status LuminaRealtimeIndex::AddBatch(::ArrowArray* batch) {
+    if (!batch || !batch->release) {
+        return Status::Invalid("Lumina realtime batch is null or released");
+    }
+    PAIMON_ASSIGN_OR_RAISE_FROM_ARROW(std::shared_ptr<arrow::Array> imported,
+                                      arrow::ImportArray(batch, 
arrow::struct_(schema_->fields())));
+    if (write_failed_) {
+        return Status::Invalid("Lumina realtime index cannot write after an 
insertion failure");
+    }
+    PAIMON_RETURN_NOT_OK_FROM_ARROW(imported->ValidateFull());
+    const auto data = checked_pointer_cast<arrow::StructArray>(imported);
+    const auto offsets = 
checked_pointer_cast<arrow::Int64Array>(data->field(0));
+    const auto vectors = 
checked_pointer_cast<arrow::ListArray>(data->field(1));
+    const auto values = 
checked_pointer_cast<arrow::FloatArray>(vectors->values());
+    if (data->null_count() != 0 || offsets->null_count() != 0) {
+        return Status::Invalid("Lumina realtime rows and offsets must not be 
null");
+    }
+    for (int64_t row = 0; row < data->length(); ++row) {
+        if (vectors->IsNull(row)) {
+            continue;
+        }
+        if (vectors->value_length(row) != 
static_cast<int64_t>(index_info_.dimension)) {
+            return Status::Invalid("Lumina realtime vector dimension 
mismatch");
+        }
+        for (int64_t pos = vectors->value_offset(row); pos < 
vectors->value_offset(row + 1);
+             ++pos) {
+            if (values->IsNull(pos) || !std::isfinite(values->Value(pos))) {
+                return Status::Invalid(
+                    "Lumina realtime vector elements must be finite non-null 
floats");
+            }
+        }
+    }
+    for (int64_t row = 0; row < data->length(); ++row) {
+        if (vectors->IsNull(row)) {
+            continue;
+        }
+        const Status status = LuminaToPaimonStatus(streamer_->Insert(
+            values->raw_values() + vectors->value_offset(row), 
offsets->Value(row)));
+        if (!status.ok()) {
+            write_failed_ = true;
+            return status;
+        }
+    }
+    return Status::OK();
+}
+
+Result<std::shared_ptr<RealtimeIndexReader>> LuminaRealtimeIndex::CreateReader(
+    const OffsetRange& offset_range, const std::shared_ptr<MemoryPool>& pool) 
const {
+    if (offset_range.begin < 0 || offset_range.begin > offset_range.end) {
+        return Status::Invalid("Lumina realtime query offset range is 
invalid");
+    }
+    if (!pool) {
+        return Status::Invalid("Lumina realtime reader requires a query memory 
pool");
+    }
+    return std::shared_ptr<RealtimeIndexReader>(
+        std::make_shared<LuminaRealtimeIndexReader>(shared_from_this(), 
offset_range, pool));
+}
+
+uint64_t LuminaRealtimeIndex::GetMemoryUsage() const {
+    return pool_->GetMemoryUsage();
+}
+
+LuminaRealtimeIndexReader::LuminaRealtimeIndexReader(
+    std::shared_ptr<const LuminaRealtimeIndex> index, const OffsetRange& 
offset_range,
+    const std::shared_ptr<MemoryPool>& pool)
+    : index_(std::move(index)), offset_range_(offset_range), pool_(pool) {}
+
+bool LuminaRealtimeIndexReader::SupportsSearch(SearchType search_type) const {
+    return search_type == SearchType::VECTOR_SEARCH;
+}
+
+Result<std::shared_ptr<ScoredRealtimeIndexResult>> 
LuminaRealtimeIndexReader::VisitVectorSearch(
+    const std::shared_ptr<VectorSearch>& vector_search) {
+    if (!vector_search || vector_search->field_name != 
index_->schema_->field(1)->name() ||
+        vector_search->limit <= 0) {
+        return Status::Invalid("invalid Lumina realtime vector search field or 
limit");
+    }
+    if (vector_search->predicate) {
+        return Status::NotImplemented("Lumina realtime tags are not 
supported");
+    }
+    for (float value : vector_search->query) {
+        if (!std::isfinite(value)) {
+            return Status::Invalid("Lumina realtime query vector must contain 
finite floats");
+        }
+    }
+    PAIMON_ASSIGN_OR_RAISE(
+        ::lumina::api::SearchOptions options,
+        LuminaIndexOptions::CreateSearchOptions(*vector_search, 
index_->index_info_));
+    if (offset_range_.Empty()) {
+        return ScoredRealtimeIndexResult::Create(RoaringBitmap64(), {});
+    }
+    auto filter = [range = offset_range_,
+                   user_filter = 
vector_search->pre_filter](::lumina::core::vector_id_t offset) {
+        return offset >= static_cast<uint64_t>(range.begin) &&
+               offset < static_cast<uint64_t>(range.end) &&
+               (!user_filter || user_filter(static_cast<int64_t>(offset)));
+    };
+    ::lumina::api::Query query(vector_search->query.data(), 
vector_search->query.size());
+    // Use the search session pool when provided, otherwise the reader's query 
pool.
+    LuminaMemoryPool session_pool(/*track_memory=*/false,
+                                  vector_search->pool ? vector_search->pool : 
pool_);
+    PAIMON_ASSIGN_OR_RAISE_FROM_LUMINA(
+        ::lumina::api::SearchResult hits,
+        index_->filter_->SearchWithFilter(query, std::move(filter), options, 
session_pool));
+    std::sort(hits.topk.begin(), hits.topk.end(),
+              [](const auto& left, const auto& right) { return left.id < 
right.id; });
+    RoaringBitmap64 offsets;
+    std::vector<float> scores;
+    scores.reserve(hits.topk.size());
+    int64_t previous = -1;
+    for (const auto& hit : hits.topk) {
+        if (hit.id > 
static_cast<uint64_t>(std::numeric_limits<int64_t>::max())) {
+            return Status::Invalid("Lumina returned an out-of-range realtime 
offset");
+        }
+        const auto offset = static_cast<int64_t>(hit.id);
+        if (offset < offset_range_.begin || offset >= offset_range_.end || 
offset <= previous) {
+            return Status::Invalid("Lumina returned invalid or duplicate 
realtime offsets");
+        }
+        offsets.Add(offset);
+        scores.push_back(hit.distance);
+        previous = offset;
+    }
+    return ScoredRealtimeIndexResult::Create(std::move(offsets), 
std::move(scores));
+}
+
+// TODO(xinyu.lxy): Dump the memory index with offset-to-(file, row-id) 
remapping when Lumina
+// supports exporting the index structure, excluding skipped rows and 
respecting file rolling.
+
+}  // namespace paimon::lumina
diff --git a/src/paimon/indexer/lumina/lumina_realtime_index.h 
b/src/paimon/indexer/lumina/lumina_realtime_index.h
new file mode 100644
index 00000000..1af00b33
--- /dev/null
+++ b/src/paimon/indexer/lumina/lumina_realtime_index.h
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#pragma once
+
+#include <cstdint>
+#include <map>
+#include <memory>
+#include <string>
+
+#include "lumina/api/LuminaStreamer.h"
+#include "lumina/extensions/SearchWithFilterExtension.h"
+#include "paimon/indexer/lumina/lumina_index_options.h"
+#include "paimon/realtime/index/realtime_index.h"
+#include "paimon/realtime/index/realtime_index_reader.h"
+
+namespace arrow {
+class Schema;
+}  // namespace arrow
+
+namespace paimon {
+class MemoryPool;
+}  // namespace paimon
+
+namespace paimon::lumina {
+
+class LuminaRealtimeIndexReader;
+class LuminaMemoryPool;
+
+/// Append-only vector index with one writer and concurrent readers.
+/// Insert IDs and SearchResult.topk[].id are realtime offsets.
+class LuminaRealtimeIndex final : public RealtimeIndex,
+                                  public 
std::enable_shared_from_this<LuminaRealtimeIndex> {
+ public:
+    /// Options use native Lumina keys such as index.dimension.
+    static Result<std::shared_ptr<LuminaRealtimeIndex>> Create(
+        const std::shared_ptr<arrow::Schema>& schema,
+        const std::map<std::string, std::string>& lumina_options,
+        const std::shared_ptr<MemoryPool>& pool);
+
+    ~LuminaRealtimeIndex() override;
+
+    /// Consumes [_REALTIME_OFFSET, vector]. Validates the whole batch before 
inserting.
+    /// The caller guarantees unique, increasing offsets and publishes query 
ranges only after
+    /// successful writes. An insertion failure disables subsequent writes.
+    Status AddBatch(::ArrowArray* batch) override;
+
+    Result<std::shared_ptr<RealtimeIndexReader>> CreateReader(
+        const OffsetRange& offset_range, const std::shared_ptr<MemoryPool>& 
pool) const override;
+
+    /// Bytes currently allocated by this streamer's Lumina memory resource.
+    uint64_t GetMemoryUsage() const override;
+
+ private:
+    friend class LuminaRealtimeIndexReader;
+    LuminaRealtimeIndex(std::shared_ptr<arrow::Schema> schema, LuminaIndexInfo 
index_info,
+                        
std::unique_ptr<::lumina::extensions::StreamWithFilterExtension> filter,
+                        std::unique_ptr<::lumina::api::LuminaStreamer> 
streamer,
+                        std::unique_ptr<LuminaMemoryPool> pool);
+
+    std::shared_ptr<arrow::Schema> schema_;
+    LuminaIndexInfo index_info_;
+    bool write_failed_ = false;
+    // Destroy the streamer before its attached extension and memory resource.
+    std::unique_ptr<LuminaMemoryPool> pool_;
+    std::unique_ptr<::lumina::extensions::StreamWithFilterExtension> filter_;
+    std::unique_ptr<::lumina::api::LuminaStreamer> streamer_;
+};
+
+/// Shares the streamer while restricting every search to [begin, end).
+/// Later appends cannot make offsets outside this range visible. Approximate 
search results
+/// within the range may vary as the graph grows; this reader does not 
snapshot the graph.
+class LuminaRealtimeIndexReader final : public RealtimeIndexReader {
+ public:
+    LuminaRealtimeIndexReader(std::shared_ptr<const LuminaRealtimeIndex> index,
+                              const OffsetRange& offset_range,
+                              const std::shared_ptr<MemoryPool>& pool);
+
+    bool SupportsSearch(SearchType search_type) const override;
+
+    /// pre_filter receives realtime offsets and runs before TopK selection. 
Must be thread-safe.
+    /// Vector predicates (tags) are not supported.
+    Result<std::shared_ptr<ScoredRealtimeIndexResult>> VisitVectorSearch(
+        const std::shared_ptr<VectorSearch>& vector_search) override;
+
+ private:
+    std::shared_ptr<const LuminaRealtimeIndex> index_;
+    OffsetRange offset_range_;
+    std::shared_ptr<MemoryPool> pool_;
+};
+
+}  // namespace paimon::lumina
diff --git a/src/paimon/indexer/lumina/lumina_realtime_index_factory.cpp 
b/src/paimon/indexer/lumina/lumina_realtime_index_factory.cpp
new file mode 100644
index 00000000..de07f70c
--- /dev/null
+++ b/src/paimon/indexer/lumina/lumina_realtime_index_factory.cpp
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "paimon/indexer/lumina/lumina_realtime_index_factory.h"
+
+#include "arrow/api.h"
+#include "arrow/c/bridge.h"
+#include "paimon/common/utils/arrow/status_utils.h"
+#include "paimon/common/utils/options_utils.h"
+#include "paimon/indexer/lumina/lumina_realtime_index.h"
+
+namespace paimon::lumina {
+
+const char LuminaRealtimeIndexFactory::IDENTIFIER[] = "lumina-realtime";
+
+Result<std::shared_ptr<RealtimeIndex>> LuminaRealtimeIndexFactory::Create(
+    ::ArrowSchema* write_schema, const std::map<std::string, std::string>& 
options,
+    const std::shared_ptr<MemoryPool>& pool) const {
+    if (!write_schema || !write_schema->release) {
+        return Status::Invalid("Lumina realtime factory requires a schema");
+    }
+    PAIMON_ASSIGN_OR_RAISE_FROM_ARROW(std::shared_ptr<arrow::Schema> schema,
+                                      arrow::ImportSchema(write_schema));
+    if (schema->num_fields() != 2) {
+        return Status::Invalid("Lumina realtime factory requires offset and 
one vector field");
+    }
+    const std::string prefix = "realtime.index.lumina." + 
schema->field(1)->name() + ".";
+    const std::map<std::string, std::string> column_options =
+        OptionsUtils::FetchOptionsWithPrefix(prefix, options);
+    PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<RealtimeIndex> index,
+                           LuminaRealtimeIndex::Create(schema, column_options, 
pool));
+    return index;
+}
+
+REGISTER_PAIMON_FACTORY(LuminaRealtimeIndexFactory);
+
+}  // namespace paimon::lumina
diff --git a/include/paimon/realtime/index/realtime_index.h 
b/src/paimon/indexer/lumina/lumina_realtime_index_factory.h
similarity index 53%
copy from include/paimon/realtime/index/realtime_index.h
copy to src/paimon/indexer/lumina/lumina_realtime_index_factory.h
index 0a3717dd..8ea03b7c 100644
--- a/include/paimon/realtime/index/realtime_index.h
+++ b/src/paimon/indexer/lumina/lumina_realtime_index_factory.h
@@ -19,31 +19,26 @@
 
 #pragma once
 
-#include <cstdint>
+#include <map>
 #include <memory>
+#include <string>
 
-#include "paimon/realtime/offset_range.h"
-#include "paimon/result.h"
-#include "paimon/visibility.h"
+#include "paimon/realtime/index/realtime_index_factory.h"
 
-struct ArrowArray;
+namespace paimon::lumina {
 
-namespace paimon {
-class RealtimeIndexReader;
-
-/// Append-only in-memory index for one field, supporting one writer and 
concurrent readers.
-class PAIMON_EXPORT RealtimeIndex {
+/// Creates column indexes configured by 
realtime.index.lumina.<column>.<option>.
+class LuminaRealtimeIndexFactory final : public RealtimeIndexFactory {
  public:
-    virtual ~RealtimeIndex() = default;
-
-    /// Consumes [_REALTIME_OFFSET, field] with increasing offsets.
-    virtual Status AddBatch(::ArrowArray* batch) = 0;
+    static const char IDENTIFIER[];
 
-    /// Creates a reader for [begin, end), sharing postings without copying.
-    virtual Result<std::shared_ptr<RealtimeIndexReader>> CreateReader(
-        const OffsetRange& offset_range) const = 0;
+    const char* Identifier() const override {
+        return IDENTIFIER;
+    }
 
-    virtual uint64_t GetMemoryUsage() const = 0;
+    Result<std::shared_ptr<RealtimeIndex>> Create(
+        ::ArrowSchema* write_schema, const std::map<std::string, std::string>& 
options,
+        const std::shared_ptr<MemoryPool>& pool) const override;
 };
 
-}  // namespace paimon
+}  // namespace paimon::lumina
diff --git a/src/paimon/indexer/lumina/lumina_realtime_index_test.cpp 
b/src/paimon/indexer/lumina/lumina_realtime_index_test.cpp
new file mode 100644
index 00000000..efea4955
--- /dev/null
+++ b/src/paimon/indexer/lumina/lumina_realtime_index_test.cpp
@@ -0,0 +1,500 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "paimon/indexer/lumina/lumina_realtime_index.h"
+
+#include <atomic>
+#include <future>
+#include <limits>
+#include <map>
+#include <memory>
+#include <optional>
+#include <string>
+#include <thread>
+#include <vector>
+
+#include "arrow/api.h"
+#include "arrow/c/bridge.h"
+#include "arrow/c/helpers.h"
+#include "arrow/ipc/json_simple.h"
+#include "gtest/gtest.h"
+#include "paimon/common/table/special_fields.h"
+#include "paimon/common/utils/arrow/status_utils.h"
+#include "paimon/common/utils/checked_cast.h"
+#include "paimon/common/utils/scope_guard.h"
+#include "paimon/indexer/lumina/lumina_memory_pool.h"
+#include "paimon/memory/memory_pool.h"
+#include "paimon/predicate/predicate_builder.h"
+#include "paimon/realtime/index/realtime_index_factory.h"
+#include "paimon/testing/utils/testharness.h"
+
+namespace paimon::lumina::test {
+
+TEST(LuminaMemoryPoolTest, TracksAllocationsSeparatelyForSharedPool) {
+    std::shared_ptr<MemoryPool> pool = GetMemoryPool();
+    LuminaMemoryPool first(/*track_memory=*/true, pool);
+    LuminaMemoryPool second(/*track_memory=*/true, pool);
+    void* first_ptr = first.allocate(64);
+    ScopeGuard first_guard([&]() { first.deallocate(first_ptr, 64); });
+    void* second_ptr = second.allocate(128);
+    ScopeGuard second_guard([&]() { second.deallocate(second_ptr, 128); });
+    ASSERT_EQ(64, first.GetMemoryUsage());
+    ASSERT_EQ(128, second.GetMemoryUsage());
+    ASSERT_EQ(192, pool->CurrentUsage());
+    {
+        LuminaMemoryPool untracked(/*track_memory=*/false, pool);
+        void* ptr = untracked.allocate(32);
+        ScopeGuard guard([&]() { untracked.deallocate(ptr, 32); });
+        ASSERT_EQ(0, untracked.GetMemoryUsage());
+        ASSERT_EQ(224, pool->CurrentUsage());
+    }
+    ASSERT_EQ(192, pool->CurrentUsage());
+    {
+        void* extra = first.allocate(32);
+        ScopeGuard extra_guard([&]() { first.deallocate(extra, 32); });
+        ASSERT_EQ(96, first.GetMemoryUsage());
+    }
+    ASSERT_EQ(64, first.GetMemoryUsage());
+    ASSERT_EQ(128, second.GetMemoryUsage());
+}
+
+class LuminaRealtimeIndexTest : public ::testing::TestWithParam<std::string> {
+ protected:
+    void SetUp() override {
+        options_ = {{"index.type", GetParam()},
+                    {"index.dimension", "2"},
+                    {"distance.metric", "l2"},
+                    {"encoding.type", "rawf32"}};
+        ASSERT_OK_AND_ASSIGN(index_, LuminaRealtimeIndex::Create(schema_, 
options_, pool_));
+    }
+
+    Result<std::shared_ptr<arrow::StructArray>> MakeBatch(const std::string& 
json) const {
+        PAIMON_ASSIGN_OR_RAISE_FROM_ARROW(
+            std::shared_ptr<arrow::Array> batch,
+            
arrow::ipc::internal::json::ArrayFromJSON(arrow::struct_(schema_->fields()), 
json));
+        return checked_pointer_cast<arrow::StructArray>(batch);
+    }
+
+    Status AddArray(const std::shared_ptr<arrow::Array>& array) {
+        ArrowArray batch;
+        PAIMON_RETURN_NOT_OK_FROM_ARROW(arrow::ExportArray(*array, &batch));
+        ScopeGuard guard([&batch]() { ArrowArrayRelease(&batch); });
+        return index_->AddBatch(&batch);
+    }
+
+    Status Add(const std::string& json) {
+        PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<arrow::StructArray> batch, 
MakeBatch(json));
+        return AddArray(batch);
+    }
+
+    Result<std::shared_ptr<RealtimeIndexReader>> Reader(int64_t begin, int64_t 
end) const {
+        return index_->CreateReader(OffsetRange(begin, end), query_pool_);
+    }
+
+    static Result<std::shared_ptr<RealtimeIndex>> CreateConfiguredIndex(
+        const std::shared_ptr<arrow::Schema>& schema,
+        const std::map<std::string, std::string>& options,
+        const std::shared_ptr<MemoryPool>& pool) {
+        ArrowSchema c_schema;
+        PAIMON_RETURN_NOT_OK_FROM_ARROW(arrow::ExportSchema(*schema, 
&c_schema));
+        ScopeGuard guard([&]() { ArrowSchemaRelease(&c_schema); });
+        return RealtimeIndexFactory::Get("lumina", &c_schema, options, pool);
+    }
+
+    std::shared_ptr<VectorSearch> Search(int32_t limit) const {
+        return std::make_shared<VectorSearch>(
+            "embedding", limit, std::vector<float>{0.0f, 0.0f}, nullptr, 
nullptr,
+            VectorSearch::DistanceType::EUCLIDEAN, std::map<std::string, 
std::string>{});
+    }
+
+    void Check(const std::shared_ptr<ScoredRealtimeIndexResult>& result,
+               const RoaringBitmap64& offsets, const std::vector<float>& 
scores) const {
+        ASSERT_TRUE(result);
+        ASSERT_EQ(offsets, result->GetRowPositions());
+        ASSERT_EQ(scores.size(), result->GetScores().size());
+        for (size_t i = 0; i < scores.size(); ++i) {
+            ASSERT_NEAR(scores[i], result->GetScores()[i], 1e-5);
+        }
+    }
+
+    std::shared_ptr<MemoryPool> pool_ = GetMemoryPool();
+    std::shared_ptr<MemoryPool> query_pool_ = GetMemoryPool();
+    std::shared_ptr<arrow::Schema> schema_ =
+        arrow::schema({arrow::field(SpecialFields::RealtimeOffset().Name(), 
arrow::int64(), false),
+                       arrow::field("embedding", 
arrow::list(arrow::float32()))});
+    std::map<std::string, std::string> options_;
+    std::shared_ptr<LuminaRealtimeIndex> index_;
+};
+
+TEST_P(LuminaRealtimeIndexTest, FactoryUsesOnlyTheRequestedColumnOptions) {
+    const std::map<std::string, std::string> options{
+        {"realtime.index.lumina.columns", "embedding,other"},
+        {"realtime.index.lumina.embedding.index.type", GetParam()},
+        {"realtime.index.lumina.embedding.index.dimension", "2"},
+        {"realtime.index.lumina.embedding.distance.metric", "l2"},
+        {"realtime.index.lumina.embedding.encoding.type", "rawf32"},
+        {"realtime.index.lumina.other.index.type", GetParam()},
+        {"realtime.index.lumina.other.index.dimension", "3"},
+        {"realtime.index.lumina.other.distance.metric", "l2"},
+        {"realtime.index.lumina.other.encoding.type", "rawf32"},
+        {"lumina.index.dimension", "invalid"},
+        {"file-index.lumina.embedding.index.dimension", "invalid"}};
+    for (const std::string name : {"embedding", "other"}) {
+        const int32_t dimension = name == "embedding" ? 2 : 3;
+        auto schema = arrow::schema({schema_->field(0), 
schema_->field(1)->WithName(name)});
+        ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndex> index,
+                             CreateConfiguredIndex(schema, options, pool_));
+        const std::string json = dimension == 2 ? "[[0,[1,0]]]" : 
"[[0,[1,0,0]]]";
+        auto data =
+            
arrow::ipc::internal::json::ArrayFromJSON(arrow::struct_(schema->fields()), 
json);
+        ASSERT_TRUE(data.ok()) << data.status().ToString();
+        ArrowArray batch;
+        ASSERT_TRUE(arrow::ExportArray(*data.ValueOrDie(), &batch).ok());
+        ScopeGuard guard([&]() { ArrowArrayRelease(&batch); });
+        ASSERT_OK(index->AddBatch(&batch));
+        ASSERT_EQ(nullptr, batch.release);
+        ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader,
+                             index->CreateReader(OffsetRange(0, 1), 
query_pool_));
+        auto search = std::make_shared<VectorSearch>(
+            name, 1, std::vector<float>(dimension, 0.0f), nullptr, nullptr,
+            VectorSearch::DistanceType::EUCLIDEAN, std::map<std::string, 
std::string>{});
+        ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                             reader->VisitVectorSearch(search));
+        Check(result, RoaringBitmap64::From({0}), {1});
+        search->query.resize(dimension + 1);
+        ASSERT_NOK(reader->VisitVectorSearch(search));
+    }
+    auto missing_options = options;
+    missing_options.erase("realtime.index.lumina.embedding.index.dimension");
+    ASSERT_NOK(CreateConfiguredIndex(schema_, missing_options, pool_));
+    ASSERT_NOK(RealtimeIndexFactory::Get("lumina", nullptr, options, pool_));
+}
+
+TEST_P(LuminaRealtimeIndexTest, 
ReportsVectorSearchCapabilityThroughBaseInterface) {
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 0));
+    
EXPECT_TRUE(reader->SupportsSearch(IndexReaderCapabilities::SearchType::VECTOR_SEARCH));
+    
EXPECT_FALSE(reader->SupportsSearch(IndexReaderCapabilities::SearchType::FULL_TEXT_SEARCH));
+    
EXPECT_FALSE(reader->SupportsSearch(IndexReaderCapabilities::SearchType::FULL_TEXT_MATCH));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(Search(/*limit=*/1)));
+    Check(result, RoaringBitmap64(), {});
+    std::shared_ptr<RealtimeIndexResult> base_result = result;
+    EXPECT_TRUE(base_result->GetRowPositions().IsEmpty());
+    ASSERT_NOK(reader->VisitFullTextSearch(nullptr));
+    ASSERT_NOK(reader->VisitFullTextMatch(nullptr, /*needs_scores=*/true));
+}
+
+TEST_P(LuminaRealtimeIndexTest, SearchesAppendedBatchesWithSparse64BitOffsets) 
{
+    ASSERT_OK(Add("[[2, [3, 0]], [8, [1, 0]]]"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 9));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64::From({2, 8}), {9, 1});
+    ASSERT_OK(Add("[[4294967300, [2, 0]]]"));
+    ASSERT_OK_AND_ASSIGN(reader, Reader(0, 4294967301));
+    ASSERT_OK_AND_ASSIGN(result, 
reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64::From({2, 8, 4294967300}), {9, 1, 4});
+}
+
+TEST_P(LuminaRealtimeIndexTest, 
AppliesOffsetBoundsAndDeletionFilterBeforeTopK) {
+    ASSERT_OK(Add("[[0, [0, 0]], [2, [1, 0]], [4, [2, 0]], [6, [3, 0]], [8, 
[4, 0]]]"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(2, 8));
+    auto search = Search(2);
+    const RoaringBitmap64 deleted = RoaringBitmap64::From({2});
+    search->pre_filter = [deleted](int64_t offset) { return 
!deleted.Contains(offset); };
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(search));
+    Check(result, RoaringBitmap64::From({4, 6}), {4, 9});
+    search->pre_filter = [](int64_t) { return false; };
+    ASSERT_OK_AND_ASSIGN(result, reader->VisitVectorSearch(search));
+    Check(result, RoaringBitmap64(), {});
+}
+
+TEST_P(LuminaRealtimeIndexTest, KeepsReaderBoundsAcrossAppends) {
+    ASSERT_OK(Add("[[1, [1, 0]], [3, [2, 0]]]"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(1, 4));
+    ASSERT_OK(Add("[[4, [0, 0]], [7, [0.5, 0]]]"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(Search(1)));
+    Check(result, RoaringBitmap64::From({1}), {1});
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> newer, Reader(4, 
8));
+    ASSERT_OK_AND_ASSIGN(result, newer->VisitVectorSearch(Search(1)));
+    Check(result, RoaringBitmap64::From({4}), {0});
+}
+
+TEST_P(LuminaRealtimeIndexTest, HandlesNullVectorsAndSlicedBatches) {
+    ASSERT_OK(Add("[[0, null], [1, null]]"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 2));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64(), {});
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<arrow::StructArray> batch,
+                         MakeBatch("[[2, [9, 9]], [3, null], [5, [2, 0]], [9, 
[1, 0]]]"));
+    ASSERT_OK(AddArray(batch->Slice(1, 3)));
+    ASSERT_OK_AND_ASSIGN(reader, Reader(0, 10));
+    ASSERT_OK_AND_ASSIGN(result, 
reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64::From({5, 9}), {4, 1});
+}
+
+TEST_P(LuminaRealtimeIndexTest, EmptyIndexAndEmptyRanges) {
+    ASSERT_OK(Add("[]"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 5));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64(), {});
+    ASSERT_OK(Add("[[0, [0, 0]]]"));
+    ASSERT_OK_AND_ASSIGN(reader, Reader(0, 0));
+    ASSERT_OK_AND_ASSIGN(result, 
reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64(), {});
+    ASSERT_OK_AND_ASSIGN(reader, Reader(2, 3));
+    ASSERT_OK_AND_ASSIGN(result, 
reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64(), {});
+    ASSERT_NOK(index_->CreateReader(OffsetRange(-1, 1), query_pool_));
+    ASSERT_NOK(index_->CreateReader(OffsetRange(2, 1), query_pool_));
+}
+
+TEST_P(LuminaRealtimeIndexTest, RejectsNullRowsAndOffsets) {
+    ASSERT_OK(Add("[[1, [1, 0]]]"));
+    for (const std::string json : {"[[null, [0, 0]]]", "[null]"}) {
+        ASSERT_NOK(Add(json)) << json;
+    }
+    ASSERT_OK(Add("[[2, null]]"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 10));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64::From({1}), {1});
+}
+
+TEST_P(LuminaRealtimeIndexTest, ValidatesWholeBatchBeforeInsertingVectors) {
+    for (const std::string json :
+         {"[[0, [0, 0]], [1, [1]]]", "[[0, [0, 0]], [1, [1, null]]]",
+          "[[0, [0, 0]], [1, [NaN, 0]]]", "[[0, [0, 0]], [1, [Infinity, 
0]]]"}) {
+        ASSERT_NOK(Add(json)) << json;
+    }
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 10));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64(), {});
+    ASSERT_OK(Add("[[0, [1, 0]], [1, [2, 0]]]"));
+    ASSERT_OK_AND_ASSIGN(result, 
reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64::From({0, 1}), {1, 4});
+}
+
+TEST_P(LuminaRealtimeIndexTest, RejectsInvalidQueriesAndUnsupportedTags) {
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 10));
+    ASSERT_NOK(reader->VisitVectorSearch(nullptr));
+    auto search = Search(/*limit=*/10);
+    search->field_name = "missing";
+    ASSERT_NOK(reader->VisitVectorSearch(search));
+    search = Search(0);
+    ASSERT_NOK(reader->VisitVectorSearch(search));
+    search = Search(-1);
+    ASSERT_NOK(reader->VisitVectorSearch(search));
+    search = Search(/*limit=*/10);
+    search->query = {0};
+    ASSERT_NOK(reader->VisitVectorSearch(search));
+    search->query = {0, std::numeric_limits<float>::infinity()};
+    ASSERT_NOK(reader->VisitVectorSearch(search));
+    search = Search(/*limit=*/10);
+    search->distance_type = VectorSearch::DistanceType::COSINE;
+    ASSERT_NOK(reader->VisitVectorSearch(search));
+    search = Search(/*limit=*/10);
+    search->options = {{"lumina.index.type", "diskann"}};
+    ASSERT_NOK(reader->VisitVectorSearch(search));
+    search = Search(/*limit=*/10);
+    search->predicate = PredicateBuilder::Equal(0, "tag", FieldType::INT, 
Literal(int32_t{1}));
+    ASSERT_NOK_WITH_MSG(reader->VisitVectorSearch(search), "tags are not 
supported");
+    ASSERT_OK_AND_ASSIGN(std::optional<RoaringBitmap64> candidates, 
reader->VisitIsNull());
+    ASSERT_FALSE(candidates.has_value());
+}
+
+TEST_P(LuminaRealtimeIndexTest, RejectsInvalidSchemasAndOptions) {
+    ASSERT_NOK(LuminaRealtimeIndex::Create(nullptr, options_, pool_));
+    ASSERT_NOK(LuminaRealtimeIndex::Create(schema_, options_, nullptr));
+    for (const auto& schema :
+         {arrow::schema({schema_->field(1), schema_->field(0)}), 
arrow::schema({schema_->field(0)}),
+          arrow::schema(
+              {schema_->field(0), schema_->field(1), arrow::field("tag", 
arrow::int32())}),
+          arrow::schema({schema_->field(0), arrow::field("embedding", 
arrow::float32())}),
+          arrow::schema(
+              {schema_->field(0), arrow::field("embedding", 
arrow::list(arrow::float64()))}),
+          arrow::schema({schema_->field(0)->WithName("other_offset"), 
schema_->field(1)}),
+          arrow::schema(
+              {schema_->field(0), 
schema_->field(1)->WithName(schema_->field(0)->name())}),
+          arrow::schema({schema_->field(0)->WithNullable(true), 
schema_->field(1)})}) {
+        ASSERT_NOK(LuminaRealtimeIndex::Create(schema, options_, pool_));
+    }
+    for (int64_t dimension : {int64_t{0}, int64_t{-1}, int64_t{1} << 33}) {
+        auto options = options_;
+        options["index.dimension"] = std::to_string(dimension);
+        ASSERT_NOK(LuminaRealtimeIndex::Create(schema_, options, pool_));
+    }
+    auto options = options_;
+    options["index.type"] = "diskann";
+    ASSERT_NOK(LuminaRealtimeIndex::Create(schema_, options, pool_));
+    options = options_;
+    options["encoding.type"] = "fp16";
+    ASSERT_NOK(LuminaRealtimeIndex::Create(schema_, options, pool_));
+    options = options_;
+    options["extension.build.tag.tag_schema"] = "[]";
+    ASSERT_NOK_WITH_MSG(LuminaRealtimeIndex::Create(schema_, options, pool_),
+                        "tags are not supported");
+    ASSERT_NOK(index_->AddBatch(nullptr));
+    ArrowArray released{};
+    ASSERT_NOK(index_->AddBatch(&released));
+}
+
+TEST_P(LuminaRealtimeIndexTest, ParsesStringStreamerOptions) {
+    options_[GetParam() + ".streamer.rows_per_block"] = "64";
+    options_["index.enable_experimental"] = "false";
+    if (GetParam() == "flatnsw") {
+        options_["flatnsw.build.neighbor_count"] = "16";
+        options_["flatnsw.build.ef_construction"] = "32";
+        options_["flatnsw.build.slack_pruning_factor"] = "1.25";
+    }
+    ASSERT_OK_AND_ASSIGN(index_, LuminaRealtimeIndex::Create(schema_, 
options_, pool_));
+    ASSERT_OK(Add("[[0, [1, 0]]]"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 1));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64::From({0}), {1});
+
+    for (const std::string& key :
+         {std::string("index.dimension"), 
std::string("index.enable_experimental"),
+          GetParam() + ".streamer.capacity", GetParam() + 
".streamer.rows_per_block"}) {
+        auto options = options_;
+        options[key] = "invalid";
+        ASSERT_NOK(LuminaRealtimeIndex::Create(schema_, options, pool_)) << 
key;
+    }
+    if (GetParam() == "flatnsw") {
+        options_["flatnsw.build.slack_pruning_factor"] = "invalid";
+        ASSERT_NOK(LuminaRealtimeIndex::Create(schema_, options_, pool_));
+    }
+}
+
+TEST_P(LuminaRealtimeIndexTest, 
UsesNativeOptionsWithoutDefaultingDistanceMetric) {
+    options_["distance.metric"] = "cosine";
+    ASSERT_OK_AND_ASSIGN(index_, LuminaRealtimeIndex::Create(schema_, 
options_, pool_));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 1));
+    auto search = Search(/*limit=*/10);
+    ASSERT_NOK(reader->VisitVectorSearch(search));
+    search->distance_type = VectorSearch::DistanceType::COSINE;
+    search->query = {1, 0};
+    ASSERT_OK(reader->VisitVectorSearch(search));
+
+    options_.erase("distance.metric");
+    ASSERT_NOK(LuminaRealtimeIndex::Create(schema_, options_, pool_));
+}
+
+TEST_P(LuminaRealtimeIndexTest, 
InsertionFailureKeepsPinnedRangeAndDisablesWrites) {
+    options_[GetParam() + ".streamer.capacity"] = "2";
+    ASSERT_OK_AND_ASSIGN(index_, LuminaRealtimeIndex::Create(schema_, 
options_, pool_));
+    ASSERT_OK(Add("[[0, [2, 0]]]"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 1));
+    ASSERT_NOK(Add("[[1, [0, 0]], [2, [1, 0]]]"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(Search(1)));
+    Check(result, RoaringBitmap64::From({0}), {4});
+    ASSERT_NOK_WITH_MSG(Add("[[3, [3, 0]]]"), "cannot write after an insertion 
failure");
+}
+
+TEST_P(LuminaRealtimeIndexTest, SearchUsesSessionPoolAndFallsBackToReaderPool) 
{
+    ASSERT_OK(Add("[[0, [1, 0]], [2, [2, 0]]]"));
+    const uint64_t index_memory = index_->GetMemoryUsage();
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 3));
+    const uint64_t reader_usage = query_pool_->CurrentUsage();
+    const uint64_t reader_peak = query_pool_->MaxMemoryUsage();
+    std::shared_ptr<MemoryPool> session_pool = GetMemoryPool();
+    auto search = Search(/*limit=*/10);
+    search->pool = session_pool;
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(search));
+    Check(result, RoaringBitmap64::From({0, 2}), {1, 4});
+    // Session allocations are backend-dependent; a search may use no pool 
memory.
+    ASSERT_EQ(0, session_pool->CurrentUsage());
+    ASSERT_EQ(reader_peak, query_pool_->MaxMemoryUsage());
+    ASSERT_EQ(reader_usage, query_pool_->CurrentUsage());
+    ASSERT_EQ(index_memory, index_->GetMemoryUsage());
+    ASSERT_EQ(index_memory, pool_->CurrentUsage());
+
+    search->pool.reset();
+    ASSERT_OK_AND_ASSIGN(result, reader->VisitVectorSearch(search));
+    Check(result, RoaringBitmap64::From({0, 2}), {1, 4});
+    ASSERT_EQ(reader_usage, query_pool_->CurrentUsage());
+    ASSERT_EQ(index_memory, index_->GetMemoryUsage());
+    ASSERT_EQ(index_memory, pool_->CurrentUsage());
+    ASSERT_NOK_WITH_MSG(index_->CreateReader(OffsetRange(0, 3), nullptr),
+                        "requires a query memory pool");
+}
+
+TEST_P(LuminaRealtimeIndexTest, ReaderPinsIndexAndMemoryAccountingIsPerIndex) {
+    void* unrelated = pool_->Malloc(1024);
+    ScopeGuard guard([&]() { pool_->Free(unrelated, 1024); });
+    const uint64_t memory_before = index_->GetMemoryUsage();
+    ASSERT_OK(Add("[[0, [1, 0]], [2, [2, 0]]]"));
+    ASSERT_GT(index_->GetMemoryUsage(), memory_before);
+    ASSERT_EQ(index_->GetMemoryUsage() + 1024, pool_->CurrentUsage());
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 3));
+    index_.reset();
+    ASSERT_GT(pool_->CurrentUsage(), 1024);
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<ScoredRealtimeIndexResult> result,
+                         reader->VisitVectorSearch(Search(/*limit=*/10)));
+    Check(result, RoaringBitmap64::From({0, 2}), {1, 4});
+    reader.reset();
+    ASSERT_EQ(1024, pool_->CurrentUsage());
+}
+
+TEST_P(LuminaRealtimeIndexTest, ConcurrentReadersWithSingleWriter) {
+    ASSERT_OK(Add("[[0, [1, 0]]]"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeIndexReader> reader, 
Reader(0, 1));
+    std::promise<void> start;
+    std::shared_future<void> ready = start.get_future().share();
+    std::atomic<int32_t> searches{0};
+    std::atomic<bool> finished{false};
+    auto read = [&]() {
+        ready.wait();
+        do {
+            auto result = reader->VisitVectorSearch(Search(1));
+            EXPECT_TRUE(result.ok());
+            if (result.ok()) {
+                Check(result.value(), RoaringBitmap64::From({0}), {1});
+            }
+            searches.fetch_add(1);
+        } while (!finished.load());
+    };
+    std::thread first(read);
+    std::thread second(read);
+    start.set_value();
+    // Keep the readers running for the whole sequence of append operations.
+    while (searches.load() < 2) {
+        std::this_thread::yield();
+    }
+    for (int64_t offset = 1; offset <= 64; ++offset) {
+        EXPECT_OK(Add("[[" + std::to_string(offset) + ", [0, 0]]]"));
+    }
+    finished.store(true);
+    first.join();
+    second.join();
+    ASSERT_GE(searches.load(), 2);
+}
+
+INSTANTIATE_TEST_SUITE_P(Backends, LuminaRealtimeIndexTest,
+                         ::testing::Values("bruteforce", "flatnsw"));
+
+}  // namespace paimon::lumina::test
diff --git a/src/paimon/testing/mock/mock_search_realtime_index.cpp 
b/src/paimon/testing/mock/mock_search_realtime_index.cpp
index 7e82457f..6f4184af 100644
--- a/src/paimon/testing/mock/mock_search_realtime_index.cpp
+++ b/src/paimon/testing/mock/mock_search_realtime_index.cpp
@@ -51,7 +51,7 @@ Status MockRealtimeIndex::AddBatch(::ArrowArray* batch) {
 }
 
 Result<std::shared_ptr<RealtimeIndexReader>> MockRealtimeIndex::CreateReader(
-    const OffsetRange& offset_range) const {
+    const OffsetRange& offset_range, const std::shared_ptr<MemoryPool>&) const 
{
     if (offset_range.begin < 0 || offset_range.begin > offset_range.end) {
         return Status::Invalid("Invalid mock real-time index reader bounds");
     }
diff --git a/src/paimon/testing/mock/mock_search_realtime_index.h 
b/src/paimon/testing/mock/mock_search_realtime_index.h
index d6def8d2..a5651f75 100644
--- a/src/paimon/testing/mock/mock_search_realtime_index.h
+++ b/src/paimon/testing/mock/mock_search_realtime_index.h
@@ -44,7 +44,7 @@ class MockRealtimeIndex final : public RealtimeIndex {
     Status AddBatch(::ArrowArray* batch) override;
 
     Result<std::shared_ptr<RealtimeIndexReader>> CreateReader(
-        const OffsetRange& offset_range) const override;
+        const OffsetRange& offset_range, const std::shared_ptr<MemoryPool>& 
pool) const override;
 
     uint64_t GetMemoryUsage() const override;
 
diff --git a/test/inte/realtime_write_inte_test.cpp 
b/test/inte/realtime_write_inte_test.cpp
index 5dcaf7d7..9dfa489f 100644
--- a/test/inte/realtime_write_inte_test.cpp
+++ b/test/inte/realtime_write_inte_test.cpp
@@ -6782,7 +6782,8 @@ class RealtimePreciseIndexInteTest : public 
RealtimeWriteInteTest {
             schema_ = arrow::schema(fields_);
             options_[Options::DELETION_VECTORS_ENABLED] = "true";
             options_[Options::REALTIME_DEDUPLICATE_KEY_FIELDS] = "id";
-            options_["file-index.bitmap.columns"] = 
SpecialFields::RealtimeOffset().Name();
+            options_.try_emplace("file-index.bitmap.columns",
+                                 SpecialFields::RealtimeOffset().Name());
         }
         CreateTable(/*partition_keys=*/{});
     }
@@ -6912,6 +6913,10 @@ class RealtimePreciseIndexInteTest : public 
RealtimeWriteInteTest {
         PAIMON_ASSIGN_OR_RAISE(std::unique_ptr<ReadContext> context, 
builder.Finish());
         PAIMON_ASSIGN_OR_RAISE(std::unique_ptr<TableRead> read,
                                TableRead::Create(std::move(context)));
+        if (options_.count("realtime.index.inte-mock-vector.columns") == 0 &&
+            options_.count("realtime.index.inte-mock-text.columns") == 0) {
+            return read->CreateReader(plan->Splits());
+        }
         std::vector<std::shared_ptr<Split>> splits;
         for (const auto& split : plan->Splits()) {
             PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<Split> indexed, 
WithSearchIndexes(split));
@@ -6947,6 +6952,10 @@ class RealtimePreciseIndexInteTest : public 
RealtimeWriteInteTest {
         ASSERT_NO_FATAL_FAILURE(CheckSearchResult(std::move(reader), query, 
expected_json));
     }
 
+#ifdef PAIMON_ENABLE_LUMINA
+    void CheckLuminaDeduplicateSearch(const std::string& index_type);
+#endif
+
     std::shared_ptr<MockSearchState> vector_state_;
     std::shared_ptr<MockSearchState> text_state_;
     std::map<std::string, MockSearchFileIndex::ScoredRows> disk_rankings_;
@@ -7056,6 +7065,39 @@ TEST_F(RealtimePreciseIndexInteTest, 
TestVectorSearchAcrossDiskSealedAndBuilding
     ASSERT_OK(PrepareAndClose(writer.get()));
 }
 
+TEST_F(RealtimePreciseIndexInteTest, 
TestOrcAndMemoryTopKWithNonNullableListElements) {
+    options_[Options::FILE_FORMAT] = "orc";
+    fields_.back() = arrow::field(
+        "embedding", arrow::list(arrow::field("item", arrow::float32(), 
/*nullable=*/false)));
+    schema_ = arrow::schema(fields_);
+    CreateSearchTable(/*deduplicate=*/false);
+    ASSERT_FALSE(HasFatalFailure());
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeContext> context, 
RealtimeContext::Create());
+    ASSERT_OK_AND_ASSIGN(std::unique_ptr<FileStoreWrite> writer, 
CreateRealtimeWriter(context));
+    vector_state_->ranked = {{0, 0.5f}, {1, 0.75f}};
+    ASSERT_OK(WriteSearchBatch(R"([[0,1,"disk","p0",[1]]])", {}, 
writer.get()));
+    ASSERT_OK_AND_ASSIGN(std::vector<RealtimeCommitProgress> progress,
+                         
writer->PrepareCommitWithProgress(/*commit_identifier=*/0));
+    ASSERT_NO_FATAL_FAILURE(SetDiskRanking(progress, {{0, 0.5f}}));
+    ASSERT_OK_AND_ASSIGN(int64_t snapshot, Commit(progress, 
/*commit_identifier=*/0));
+    ASSERT_OK(writer->RefreshCommittedSnapshot(snapshot));
+    ASSERT_OK(WriteSearchBatch(R"([[1,2,"memory","p0",[2]]])", {}, 
writer.get()));
+
+    SearchQuery query{{"id", "embedding", "_embedding_INDEX_SCORE"}, nullptr, 
Vector(2), nullptr};
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Plan> plan, CreatePlan(context, 
nullptr));
+    ASSERT_OK_AND_ASSIGN(std::unique_ptr<BatchReader> reader,
+                         CreateSearchReader(plan, context, query));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<arrow::ChunkedArray> actual,
+                         
ReadResultCollector::CollectResult(std::move(reader)));
+    ASSERT_NE(nullptr, actual);
+    auto expected = arrow::ipc::internal::json::ArrayFromJSON(actual->type(),
+                                                              
R"([[0,2,[2],0.75],[0,1,[1],0.5]])");
+    ASSERT_TRUE(expected.ok()) << expected.status().ToString();
+    
ASSERT_TRUE(actual->Equals(std::make_shared<arrow::ChunkedArray>(expected.ValueOrDie())))
+        << actual->ToString();
+    ASSERT_OK(PrepareAndClose(writer.get()));
+}
+
 TEST_F(RealtimePreciseIndexInteTest, TestDeduplicateMemoryDvBeforeVectorTopK) {
     CreateSearchTable(/*deduplicate=*/true);
     ASSERT_FALSE(HasFatalFailure());
@@ -7132,9 +7174,7 @@ TEST_F(RealtimePreciseIndexInteTest, 
TestCommittedAndRealtimeDiskDvBeforeVectorT
     ASSERT_OK(writer->Close());
 }
 
-// TODO(lisizhuo.lsz): Re-enable after fixing field nullability mismatches 
between disk and
-// real-time readers that prevent concatenating TopK candidates.
-TEST_F(RealtimePreciseIndexInteTest, 
DISABLED_TestPinnedSearchBoundsAndDvSurviveCommitAndRefresh) {
+TEST_F(RealtimePreciseIndexInteTest, 
TestPinnedSearchBoundsAndDvSurviveCommitAndRefresh) {
     CreateSearchTable(/*deduplicate=*/true);
     ASSERT_FALSE(HasFatalFailure());
     ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeContext> context, 
RealtimeContext::Create());
@@ -7198,9 +7238,7 @@ TEST_F(RealtimePreciseIndexInteTest, 
DISABLED_TestPinnedSearchBoundsAndDvSurvive
     ASSERT_OK(writer->Close());
 }
 
-// TODO(lisizhuo.lsz): Re-enable after fixing field nullability mismatches 
between disk and
-// real-time readers that prevent concatenating TopK candidates.
-TEST_F(RealtimePreciseIndexInteTest, 
DISABLED_TestScoreProjectionAcrossBatchSizes) {
+TEST_F(RealtimePreciseIndexInteTest, TestScoreProjectionAcrossBatchSizes) {
     CreateSearchTable(/*deduplicate=*/false);
     ASSERT_FALSE(HasFatalFailure());
     ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeContext> context, 
RealtimeContext::Create());
@@ -7360,9 +7398,7 @@ TEST_F(RealtimePreciseIndexInteTest, 
TestFullyDeletedSourcesDoNotHideRemainingSe
     ASSERT_OK(writer->Close());
 }
 
-// TODO(lisizhuo.lsz): Re-enable after fixing field nullability mismatches 
between disk and
-// real-time readers that prevent concatenating TopK candidates.
-TEST_F(RealtimePreciseIndexInteTest, 
DISABLED_TestFullTextOrUnindexedScalarAcrossDiskAndMemory) {
+TEST_F(RealtimePreciseIndexInteTest, 
TestFullTextOrUnindexedScalarAcrossDiskAndMemory) {
     CreateSearchTable(/*deduplicate=*/false);
     ASSERT_FALSE(HasFatalFailure());
     ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeContext> context, 
RealtimeContext::Create());
@@ -7416,6 +7452,116 @@ TEST_F(RealtimePreciseIndexInteTest, 
DISABLED_TestFullTextOrUnindexedScalarAcros
     ASSERT_OK(PrepareAndClose(writer.get()));
 }
 
+#ifdef PAIMON_ENABLE_LUMINA
+void RealtimePreciseIndexInteTest::CheckLuminaDeduplicateSearch(const 
std::string& index_type) {
+    options_.erase("realtime.index.inte-mock-vector.columns");
+    options_.erase("realtime.index.inte-mock-text.columns");
+    options_[Options::FILE_INDEX_READ_ENABLED] = "true";
+    options_["realtime.index.hash.columns"] = "payload";
+    options_["realtime.index.lumina.columns"] = "embedding";
+    options_["file-index.bitmap.columns"] = "_REALTIME_OFFSET,payload";
+    options_["file-index.lumina.columns"] = "embedding";
+    for (const std::string prefix :
+         {"realtime.index.lumina.embedding.", "file-index.lumina.embedding."}) 
{
+        options_[prefix + "index.type"] = index_type;
+        options_[prefix + "index.dimension"] = "2";
+        options_[prefix + "distance.metric"] = "l2";
+        options_[prefix + "encoding.type"] = "rawf32";
+    }
+    CreateSearchTable(/*deduplicate=*/true);
+    ASSERT_FALSE(HasFatalFailure());
+
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<RealtimeContext> context, 
RealtimeContext::Create());
+    ASSERT_OK_AND_ASSIGN(std::unique_ptr<FileStoreWrite> writer, 
CreateRealtimeWriter(context));
+    ASSERT_OK(WriteSearchBatch(R"([
+        [0,1,"keep","keep",[0,0]], [1,2,"keep","keep",[1,0]],
+        [2,3,"drop","keep",[2,0]], [3,4,"keep","drop",[3,0]],
+        [4,5,"keep","keep",[4,0]], [5,6,"keep","keep",[5,0]]
+    ])",
+                               {}, writer.get()));
+    ASSERT_OK_AND_ASSIGN(std::vector<RealtimeCommitProgress> initial,
+                         
writer->PrepareCommitWithProgress(/*commit_identifier=*/0));
+    ASSERT_OK_AND_ASSIGN(int64_t initial_snapshot, Commit(initial, 
/*commit_identifier=*/0));
+    ASSERT_OK(writer->RefreshCommittedSnapshot(initial_snapshot));
+
+    // Persist a file DV for the closest disk vector.
+    ASSERT_OK(WriteSearchBatch(R"([[6,1,"keep","keep",[0,0]]])", 
{RecordBatch::RowKind::DELETE},
+                               writer.get()));
+    ASSERT_OK_AND_ASSIGN(std::vector<RealtimeCommitProgress> deletion,
+                         
writer->PrepareCommitWithProgress(/*commit_identifier=*/1));
+    ASSERT_OK_AND_ASSIGN(int64_t deleted_snapshot, Commit(deletion, 
/*commit_identifier=*/1));
+    ASSERT_OK(writer->RefreshCommittedSnapshot(deleted_snapshot));
+
+    // Updating id=2 adds a pending offset DV for the next-closest disk vector.
+    ASSERT_OK(WriteSearchBatch(R"([
+        [7,2,"keep","keep",[6,0]], [8,7,"keep","keep",[0,0]],
+        [9,8,"drop","keep",[0.5,0]], [10,9,"keep","drop",[1,0]],
+        [11,10,"keep","keep",[7,0]], [12,11,"keep","keep",[8,0]]
+    ])",
+                               {}, writer.get()));
+    ASSERT_OK(writer->Seal());
+    // Delete the nearest sealed vector and leave a scalar-mismatching 
building vector.
+    ASSERT_OK(WriteSearchBatch(R"([
+        [13,7,"keep","keep",[0,0]], [14,12,"drop","keep",[0.25,0]]
+    ])",
+                               {RecordBatch::RowKind::DELETE, 
RecordBatch::RowKind::INSERT},
+                               writer.get()));
+
+    auto indexed = EqualString("payload", "keep");
+    auto unindexed = EqualString("pt", "keep");
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Predicate> predicate,
+                         PredicateBuilder::And({indexed, unindexed}));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Plan> plan, CreatePlan(context, 
predicate));
+    auto vector = std::make_shared<VectorSearch>(
+        "embedding", /*limit=*/1, std::vector<float>{0.0f, 0.0f}, nullptr, 
nullptr,
+        VectorSearch::DistanceType::EUCLIDEAN, std::map<std::string, 
std::string>{});
+    if (index_type == "flatnsw") {
+        vector->options["lumina.flatnsw.search.ef_search"] = "64";
+    }
+    SearchQuery query{
+        {"id", "payload", "pt", "_embedding_INDEX_SCORE"}, predicate, vector, 
nullptr};
+    // Top1 is selected globally across disk, sealed and building sources.
+    const std::string expected = R"([[0,5,"keep","keep",16]])";
+    ASSERT_NO_FATAL_FAILURE(CheckSearch(plan, context, query, expected));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Plan> indexed_plan, 
CreatePlan(context, indexed));
+    SearchQuery indexed_query = query;
+    indexed_query.predicate = indexed;
+    ASSERT_NO_FATAL_FAILURE(
+        CheckSearch(indexed_plan, context, indexed_query, 
R"([[0,9,"keep","drop",1]])"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Plan> unindexed_plan, 
CreatePlan(context, unindexed));
+    SearchQuery unindexed_query = query;
+    unindexed_query.predicate = unindexed;
+    ASSERT_NO_FATAL_FAILURE(
+        CheckSearch(unindexed_plan, context, unindexed_query, 
R"([[0,12,"drop","keep",0.0625]])"));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Plan> pinned, CreatePlan(context, 
predicate));
+
+    // The same query must keep its results while memory data is committed to 
disk.
+    ASSERT_OK_AND_ASSIGN(std::vector<RealtimeCommitProgress> update,
+                         
writer->PrepareCommitWithProgress(/*commit_identifier=*/2));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Plan> prepared, CreatePlan(context, 
predicate));
+    ASSERT_NO_FATAL_FAILURE(CheckSearch(prepared, context, query, expected));
+    ASSERT_OK_AND_ASSIGN(int64_t updated_snapshot, Commit(update, 
/*commit_identifier=*/2));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Plan> committed, CreatePlan(context, 
predicate));
+    ASSERT_NO_FATAL_FAILURE(CheckSearch(committed, context, query, expected));
+    ASSERT_OK(writer->RefreshCommittedSnapshot(updated_snapshot));
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Plan> refreshed, CreatePlan(context, 
predicate));
+    ASSERT_NO_FATAL_FAILURE(CheckSearch(refreshed, context, query, expected));
+    ASSERT_NO_FATAL_FAILURE(CheckSearch(pinned, context, query, expected));
+    ASSERT_OK(writer->Close());
+    ASSERT_OK_AND_ASSIGN(std::shared_ptr<Plan> disk_only,
+                         CreatePlan(/*realtime_context=*/nullptr, predicate));
+    ASSERT_NO_FATAL_FAILURE(CheckSearch(disk_only, nullptr, query, expected));
+}
+
+TEST_F(RealtimePreciseIndexInteTest, 
TestLuminaBruteforceDeduplicateScalarVectorSearch) {
+    CheckLuminaDeduplicateSearch("bruteforce");
+}
+
+TEST_F(RealtimePreciseIndexInteTest, 
TestLuminaFlatnswDeduplicateScalarVectorSearch) {
+    CheckLuminaDeduplicateSearch("flatnsw");
+}
+#endif
+
 // TODO(xinyu.lxy): Refactor the real-time hash index tests.
 class RealtimeHashIndexInteTest : public RealtimeWriteInteTest {
  protected:

Reply via email to