SteNicholas commented on code in PR #199:
URL: https://github.com/apache/paimon-cpp/pull/199#discussion_r3780977088


##########
src/paimon/core/realtime/realtime_context_impl.h:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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 <chrono>
+#include <condition_variable>
+#include <cstdint>
+#include <deque>
+#include <map>
+#include <memory>
+#include <mutex>
+#include <optional>
+#include <string>
+#include <thread>
+#include <vector>
+
+#include "paimon/realtime/realtime_context.h"
+#include "paimon/result.h"
+
+struct ArrowSchema;
+
+namespace paimon {
+
+class MemIndexer;
+class MemReadView;
+class MemoryPool;
+
+struct RealtimeMemIndexerState {
+    std::shared_ptr<MemIndexer> indexer;
+    int64_t initial_offset;
+};
+
+struct RealtimePartitionBucketView {
+    RealtimePartitionBucket partition_bucket;
+    std::shared_ptr<MemIndexer> indexer;
+    std::shared_ptr<MemReadView> read_view;
+};
+
+class RealtimeContextImpl final : public RealtimeContext {

Review Comment:
   This class is compiled under the repository-wide `-fvisibility=hidden`, but 
`realtime_context_test.cpp` and `realtime_write_inte_test.cpp` call its 
out-of-line methods while their executables link against `paimon_shared`. Those 
methods are therefore private/hidden in the shared library (for example `Cast`, 
`GetOrCreateMemIndexer`, and `ResolveReadView`), so the test link will fail 
with undefined symbols. Please either export the test-used class/symbols, link 
this implementation into those tests, or exercise it through public APIs.



##########
src/paimon/core/table/source/append_only_table_read.cpp:
##########
@@ -80,19 +104,21 @@ Result<std::unique_ptr<BatchReader>> 
AppendOnlyTableRead::CreateReader(
     ScopeGuard schema_guard([schema = c_read_schema.get()]() { 
ArrowSchemaRelease(schema); });
     MemQueryContext query_context{c_read_schema.get(), 
context_->GetPredicate(),
                                   /*enable_predicate_pushdown=*/true};
-    PAIMON_ASSIGN_OR_RAISE(
-        std::vector<std::unique_ptr<BatchReader>> memory_readers,
-        realtime_split->Indexer()->CreateQueryReaders(
-            realtime_split->ReadView(), realtime_split->CommittedOffset(), 
query_context));
+    PAIMON_ASSIGN_OR_RAISE(std::vector<std::unique_ptr<BatchReader>> 
memory_readers,
+                           memory.indexer->CreateQueryReaders(
+                               memory.read_view, 
realtime_split->CommittedOffset(), query_context));
 
     for (std::unique_ptr<BatchReader>& memory_reader : memory_readers) {
         if (context_->EnablePredicateFilter() && context_->GetPredicate()) {
             PAIMON_ASSIGN_OR_RAISE(memory_reader, PredicateBatchReader::Create(
                                                       std::move(memory_reader),
                                                       
context_->GetPredicate(), GetMemoryPool()));
         }
-        readers.push_back(std::move(memory_reader));
+        PAIMON_ASSIGN_OR_RAISE(std::unique_ptr<RealtimeReader> realtime_reader,
+                               RealtimeReader::Create(memory.read_view, 
std::move(memory_reader)));
+        readers.push_back(std::move(realtime_reader));
     }
+    
PAIMON_RETURN_NOT_OK(realtime_context_impl->ReleaseReadView(realtime_split->OpaqueTicket()));

Review Comment:
   This consumes the ticket before the public 
`TableRead::CreateReader(vector<Split>)` call has succeeded as a whole. With 
two real-time splits, split 1 can release its ticket here and split 2 can then 
fail (for example, a plugin error or ticket expiry); the vector overload 
returns an error, but retrying that failed call now fails on split 1 because 
its ticket is gone. Please make the ticket claims/consumption rollbackable 
across the vector overload, or defer consumption until all per-split readers 
have been created, and add a two-split regression test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to