w41ter commented on code in PR #54084:
URL: https://github.com/apache/doris/pull/54084#discussion_r2244213933


##########
cloud/src/meta-store/txn_kv.cpp:
##########
@@ -731,6 +731,107 @@ TxnErrorCode 
Transaction::batch_get(std::vector<std::optional<std::string>>* res
     return TxnErrorCode::TXN_OK;
 }
 
+TxnErrorCode Transaction::batch_scan(
+        std::vector<std::optional<std::pair<std::string, std::string>>>* res,
+        const std::vector<std::string>& keys, const BatchGetOptions& opts) {
+    struct FDBFutureDelete {
+        void operator()(FDBFuture* future) { fdb_future_destroy(future); }
+    };
+
+    res->clear();
+    if (keys.empty()) {
+        return TxnErrorCode::TXN_OK;
+    }
+
+    StopWatch sw;
+    auto stop_watcher = [&sw](int*) { g_bvar_txn_kv_range_get << 
sw.elapsed_us(); };
+    std::unique_ptr<int, decltype(stop_watcher)> defer((int*)0x01, 
std::move(stop_watcher));
+
+    size_t num_keys = keys.size();
+    res->reserve(keys.size());
+    g_bvar_txn_kv_get_count_normalized << keys.size();
+    std::vector<std::unique_ptr<FDBFuture, FDBFutureDelete>> futures;
+    futures.reserve(opts.concurrency);
+
+    fdb_bool_t snapshot = opts.snapshot ? 1 : 0;
+    fdb_bool_t reverse = opts.reverse ? 1 : 0;
+    for (size_t i = 0; i < num_keys; i += opts.concurrency) {
+        size_t batch_size = std::min(i + opts.concurrency, num_keys);
+        for (size_t j = i; j < batch_size; j++) {
+            const auto& key = keys[j];
+            FDBFuture* fut;
+            if (reverse) {
+                fut = fdb_transaction_get_range(
+                        txn_, FDB_KEYSEL_FIRST_GREATER_THAN((uint8_t*)"", 0),

Review Comment:
   These are implementation details, that should not be exposed; the 
explanation in the function comments is enough.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to