MCPcopy Create free account
hub / github.com/apache/kvrocks / ParseWriteBatch

Method ParseWriteBatch

utils/kvrocks2redis/parser.cc:169–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169Status Parser::ParseWriteBatch(const std::string &batch_string) {
170 rocksdb::WriteBatch write_batch(batch_string);
171 WriteBatchExtractor write_batch_extractor(slot_id_encoded_, -1, true);
172
173 auto db_status = write_batch.Iterate(&write_batch_extractor);
174 if (!db_status.ok())
175 return {Status::NotOK, fmt::format("failed to iterate over the write batch: {}", db_status.ToString())};
176
177 auto resp_commands = write_batch_extractor.GetRESPCommands();
178 for (const auto &iter : *resp_commands) {
179 auto s = writer_->Write(iter.first, iter.second);
180 if (!s.IsOK()) {
181 ERROR("Failed to write to AOF from the write batch. Error: {}", s.Msg());
182 }
183 }
184
185 return Status::OK();
186}

Callers 1

incrementBatchLoopMethod · 0.80

Calls 5

GetRESPCommandsMethod · 0.80
ToStringMethod · 0.45
WriteMethod · 0.45
IsOKMethod · 0.45
MsgMethod · 0.45

Tested by

no test coverage detected