git-hulk commented on code in PR #2040:
URL: https://github.com/apache/kvrocks/pull/2040#discussion_r1466255671


##########
src/storage/iterator.cc:
##########
@@ -164,4 +164,124 @@ void SubKeyIterator::Reset() {
   if (iter_) iter_.reset();
 }
 
+rocksdb::Status WALBatchExtractor::PutCF(uint32_t column_family_id, const 
Slice &key, const Slice &value) {
+  if (slot_ != -1) {
+    if (slot_ != ExtractSlotId(key)) {
+      return rocksdb::Status::OK();
+    }
+  }

Review Comment:
   ```suggestion
     if (slot_ != -1 && slot_ != ExtractSlotId(key)) {
       return rocksdb::Status::OK();
     }
   ```



##########
src/storage/iterator.cc:
##########
@@ -164,4 +164,124 @@ void SubKeyIterator::Reset() {
   if (iter_) iter_.reset();
 }
 
+rocksdb::Status WALBatchExtractor::PutCF(uint32_t column_family_id, const 
Slice &key, const Slice &value) {
+  if (slot_ != -1) {
+    if (slot_ != ExtractSlotId(key)) {
+      return rocksdb::Status::OK();
+    }
+  }
+  items_.emplace_back(WALItem::Type::kTypePut, column_family_id, 
key.ToString(), value.ToString());
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status WALBatchExtractor::DeleteCF(uint32_t column_family_id, const 
rocksdb::Slice &key) {
+  if (slot_ != -1) {
+    if (slot_ != ExtractSlotId(key)) {
+      return rocksdb::Status::OK();
+    }
+  }

Review Comment:
   ```suggestion
     if (slot_ != -1 && slot_ != ExtractSlotId(key)) {
       return rocksdb::Status::OK();
     }
   ```



##########
src/storage/iterator.cc:
##########
@@ -164,4 +164,124 @@ void SubKeyIterator::Reset() {
   if (iter_) iter_.reset();
 }
 
+rocksdb::Status WALBatchExtractor::PutCF(uint32_t column_family_id, const 
Slice &key, const Slice &value) {
+  if (slot_ != -1) {
+    if (slot_ != ExtractSlotId(key)) {
+      return rocksdb::Status::OK();
+    }
+  }
+  items_.emplace_back(WALItem::Type::kTypePut, column_family_id, 
key.ToString(), value.ToString());
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status WALBatchExtractor::DeleteCF(uint32_t column_family_id, const 
rocksdb::Slice &key) {
+  if (slot_ != -1) {
+    if (slot_ != ExtractSlotId(key)) {
+      return rocksdb::Status::OK();
+    }
+  }
+  items_.emplace_back(WALItem::Type::kTypeDelete, column_family_id, 
key.ToString(), std::string{});
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status WALBatchExtractor::DeleteRangeCF(uint32_t column_family_id, 
const rocksdb::Slice &begin_key,
+                                                 const rocksdb::Slice 
&end_key) {
+  items_.emplace_back(WALItem::Type::kTypeDeleteRange, column_family_id, 
begin_key.ToString(), end_key.ToString());
+  return rocksdb::Status::OK();
+}
+
+void WALBatchExtractor::LogData(const rocksdb::Slice &blob) {
+  items_.emplace_back(WALItem::Type::kTypeLogData, 0, blob.ToString(), 
std::string{});
+};
+
+void WALBatchExtractor::Clear() { items_.clear(); }
+
+WALBatchExtractor::Iter WALBatchExtractor::GetIter() { return Iter(&items_); }
+
+bool WALBatchExtractor::Iter::Valid() { return items_ && cur_ < 
items_->size(); }
+
+void WALBatchExtractor::Iter::Next() { cur_++; }
+
+WALItem WALBatchExtractor::Iter::Value() { return (*items_)[cur_]; }

Review Comment:
   Should we check the cur_ is out of the index here?



##########
src/storage/iterator.cc:
##########
@@ -164,4 +164,124 @@ void SubKeyIterator::Reset() {
   if (iter_) iter_.reset();
 }
 
+rocksdb::Status WALBatchExtractor::PutCF(uint32_t column_family_id, const 
Slice &key, const Slice &value) {
+  if (slot_ != -1) {
+    if (slot_ != ExtractSlotId(key)) {
+      return rocksdb::Status::OK();
+    }
+  }
+  items_.emplace_back(WALItem::Type::kTypePut, column_family_id, 
key.ToString(), value.ToString());
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status WALBatchExtractor::DeleteCF(uint32_t column_family_id, const 
rocksdb::Slice &key) {
+  if (slot_ != -1) {
+    if (slot_ != ExtractSlotId(key)) {
+      return rocksdb::Status::OK();
+    }
+  }
+  items_.emplace_back(WALItem::Type::kTypeDelete, column_family_id, 
key.ToString(), std::string{});
+  return rocksdb::Status::OK();
+}
+
+rocksdb::Status WALBatchExtractor::DeleteRangeCF(uint32_t column_family_id, 
const rocksdb::Slice &begin_key,
+                                                 const rocksdb::Slice 
&end_key) {
+  items_.emplace_back(WALItem::Type::kTypeDeleteRange, column_family_id, 
begin_key.ToString(), end_key.ToString());

Review Comment:
   Should we check if the begin_key and end_key are in the same slot when the 
slot != -1



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