cyb70289 commented on code in PR #13245:
URL: https://github.com/apache/arrow/pull/13245#discussion_r884444944
##########
cpp/src/arrow/ipc/reader.cc:
##########
@@ -1121,6 +1121,29 @@ class ARROW_EXPORT SelectiveIpcFileRecordBatchGenerator {
int index_;
};
+struct AtomicReadStats {
+ std::atomic<int64_t> num_messages{0};
+ std::atomic<int64_t> num_record_batches{0};
+ std::atomic<int64_t> num_dictionary_batches{0};
+ std::atomic<int64_t> num_dictionary_deltas{0};
+ std::atomic<int64_t> num_replaced_dictionaries{0};
+
+ /// \brief Capture a copy of the current counters
+ ///
+ /// It's possible to get inconsistent values. For example, if
+ /// this method is called in the middle of a read you might have
+ /// a case where num_messages != num_record_batches + num_dictionary_batches
+ ReadStats poll() const {
+ ReadStats stats;
+ stats.num_messages = num_messages.load();
Review Comment:
Nit: also use `memory_order_relaxed`?
##########
cpp/src/arrow/ipc/reader.cc:
##########
@@ -1121,6 +1121,29 @@ class ARROW_EXPORT SelectiveIpcFileRecordBatchGenerator {
int index_;
};
+struct AtomicReadStats {
Review Comment:
Can we move this struct inside `RecordBatchFileReaderImpl`?
##########
cpp/src/arrow/ipc/reader.cc:
##########
@@ -1121,6 +1121,29 @@ class ARROW_EXPORT SelectiveIpcFileRecordBatchGenerator {
int index_;
};
+struct AtomicReadStats {
+ std::atomic<int64_t> num_messages{0};
+ std::atomic<int64_t> num_record_batches{0};
+ std::atomic<int64_t> num_dictionary_batches{0};
+ std::atomic<int64_t> num_dictionary_deltas{0};
+ std::atomic<int64_t> num_replaced_dictionaries{0};
+
+ /// \brief Capture a copy of the current counters
+ ///
+ /// It's possible to get inconsistent values. For example, if
+ /// this method is called in the middle of a read you might have
+ /// a case where num_messages != num_record_batches + num_dictionary_batches
+ ReadStats poll() const {
+ ReadStats stats;
+ stats.num_messages = num_messages.load();
Review Comment:
Nit: also use `memory_order_relaxed`?
--
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]