Skip to content

Commit

Permalink
remove useless log and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LindaSummer committed Jun 20, 2024
1 parent fae2097 commit 1c89a9c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 200 deletions.
26 changes: 0 additions & 26 deletions src/commands/cmd_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,17 @@
*
*/

#include <glog/logging.h>

#include <cstdint>
#include <limits>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>

#include "command_parser.h"
#include "commander.h"
#include "error_constants.h"
#include "event_util.h"
#include "server/redis_reply.h"
#include "server/server.h"
#include "status.h"
#include "time_util.h"
#include "types/redis_stream.h"
#include "types/redis_stream_base.h"

namespace redis {

Expand Down Expand Up @@ -374,23 +366,19 @@ class CommandAutoClaim : public Commander {
key_name_ = GET_OR_RET(parser.TakeStr());
group_name_ = GET_OR_RET(parser.TakeStr());
consumer_name_ = GET_OR_RET(parser.TakeStr());
LOG(INFO) << "key_name: " << key_name_ << " group_name: " << group_name_ << " consumer_name: " << consumer_name_;
{
auto s = parser.TakeInt<uint64_t>();
if (!s.IsOK()) {
return {Status::RedisParseErr, "Invalid min-idle-time argument for XAUTOCLAIM"};
}
options_.min_idle_time_ms = s.GetValue();
LOG(INFO) << "Min-idle-time: " << options_.min_idle_time_ms;
}
{
auto start_str = GET_OR_RET(parser.TakeStr());
if (!start_str.empty() && start_str.front() == '(') {
options_.exclude_start = true;
start_str = start_str.substr(1);
LOG(INFO) << "excluded start: true";
}
LOG(INFO) << "Start string: " << start_str;
if (!options_.exclude_start && start_str == "-") {
options_.start_id = StreamEntryID::Minimum();
} else {
Expand All @@ -399,7 +387,6 @@ class CommandAutoClaim : public Commander {
return s;
}
}
LOG(INFO) << "Start entry: " << options_.start_id.ToString();
}

if (parser.EatEqICase("count")) {
Expand All @@ -411,12 +398,10 @@ class CommandAutoClaim : public Commander {
return {Status::RedisParseErr, "COUNT must be > 0"};
}
options_.count = count;
LOG(INFO) << "Count: " << options_.count;
}

if (parser.Good() && parser.EatEqICase("justid")) {
options_.just_id = true;
LOG(INFO) << "justid: true";
}

return Status::OK();
Expand All @@ -429,16 +414,6 @@ class CommandAutoClaim : public Commander {
if (!s.ok()) {
return {Status::RedisExecErr, s.ToString()};
}
LOG(INFO) << "AutoClaim next-claim-id: " << result.next_claim_id << ", "
<< "entries: ";
for (const auto &entry : result.entries) {
LOG(INFO) << "key: " << entry.key << ", values: ";
}
LOG(INFO) << "deleted-ids: ";
for (const auto &id : result.deleted_ids) {
LOG(INFO) << id;
}

return sendResults(conn, result, output);
}

Expand Down Expand Up @@ -473,7 +448,6 @@ class CommandAutoClaim : public Commander {
std::string group_name_;
std::string consumer_name_;
StreamAutoClaimOptions options_;
// StreamEntryID start_entry_id_;
};

class CommandXGroup : public Commander {
Expand Down
26 changes: 1 addition & 25 deletions src/types/redis_stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@

#include <rocksdb/status.h>

#include <algorithm>
#include <memory>
#include <utility>
#include <vector>

#include "db_util.h"
#include "storage/redis_db.h"
#include "storage/redis_metadata.h"
#include "time_util.h"
#include "types/redis_stream_base.h"

namespace redis {

Expand Down Expand Up @@ -550,14 +546,7 @@ rocksdb::Status Stream::AutoClaim(const Slice &stream_name, const std::string &g
}

StreamConsumerMetadata current_consumer_metadata = decodeStreamConsumerMetadataValue(get_consumer_value);
LOG(INFO) << "current consumer: " << consumer_name << " , consumer_key: " << consumer_key << ", consumer_metadata: "
<< current_consumer_metadata.pending_number << ", " << current_consumer_metadata.last_attempted_interaction_ms << ", "
<< current_consumer_metadata.last_successful_interaction_ms;

std::map<std::string, uint64_t> claimed_consumer_entity_count;

LOG(INFO) << "start_id, ms: " << options.start_id.ms << " seq: " << options.start_id.seq << ", to_string: " << options.start_id.ToString();

std::string prefix_key = internalPelKeyFromGroupAndEntryId(ns_key, metadata, group_name, options.start_id);
std::string end_key = internalPelKeyFromGroupAndEntryId(ns_key, metadata, group_name, StreamEntryID::Maximum());

Expand All @@ -569,7 +558,6 @@ rocksdb::Status Stream::AutoClaim(const Slice &stream_name, const std::string &g
read_options.iterate_lower_bound = &lower_bound;
read_options.iterate_upper_bound = &upper_bound;

// constexpr uint32_t attempts_factor = 10;
auto count = options.count;
uint64_t attempts = options.attempts_factors * count;
auto now_ms = util::GetTimeStampMS();
Expand Down Expand Up @@ -626,7 +614,6 @@ rocksdb::Status Stream::AutoClaim(const Slice &stream_name, const std::string &g
--count;

if (penl_entry.consumer_name != consumer_name) {
LOG(INFO) << "penl_entry.consumer_name: " << penl_entry.consumer_name << " consumer_name: " << consumer_name;
++total_claimed_count;
claimed_consumer_entity_count[penl_entry.consumer_name] += 1;
penl_entry.consumer_name = consumer_name;
Expand All @@ -641,9 +628,6 @@ rocksdb::Status Stream::AutoClaim(const Slice &stream_name, const std::string &g
current_consumer_metadata.pending_number += total_claimed_count;
current_consumer_metadata.last_attempted_interaction_ms = now_ms;

LOG(INFO) << "current consumer metadata: " << current_consumer_metadata.pending_number << " "
<< current_consumer_metadata.last_attempted_interaction_ms << " "
<< current_consumer_metadata.last_successful_interaction_ms;
batch->Put(stream_cf_handle_, consumer_key, encodeStreamConsumerMetadataValue(current_consumer_metadata));

for (const auto &[consumer, count] : claimed_consumer_entity_count) {
Expand All @@ -654,21 +638,13 @@ rocksdb::Status Stream::AutoClaim(const Slice &stream_name, const std::string &g
return s;
}
StreamConsumerMetadata tmp_consumer_metadata = decodeStreamConsumerMetadataValue(tmp_consumer_value);
LOG(INFO) << "tmp consumer metadata: " << tmp_consumer_metadata.pending_number << " "
<< tmp_consumer_metadata.last_attempted_interaction_ms << " "
<< tmp_consumer_metadata.last_successful_interaction_ms;
LOG(INFO) << "consumer: " << consumer << " count: " << count;
// tmp_consumer_metadata.last_attempted_interaction_ms = now_ms;
tmp_consumer_metadata.pending_number -= count;
LOG(INFO) << "tmp consumer metadata(updated): " << tmp_consumer_metadata.pending_number << " "
<< tmp_consumer_metadata.last_attempted_interaction_ms << " "
<< tmp_consumer_metadata.last_successful_interaction_ms;
batch->Put(stream_cf_handle_, tmp_consumer_key, encodeStreamConsumerMetadataValue(tmp_consumer_metadata));
}
}

bool has_next_entry = false;
for(; iter->Valid(); iter->Next()) {
for (; iter->Valid(); iter->Next()) {
if (identifySubkeyType(iter->key()) == StreamSubkeyType::StreamPelEntry) {
has_next_entry = true;
break;
Expand Down
4 changes: 1 addition & 3 deletions src/types/redis_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@

#include <rocksdb/status.h>

#include <cstdint>
#include <optional>
#include <string>
#include <vector>

#include "storage/redis_db.h"
#include "storage/redis_metadata.h"
#include "types/redis_stream_base.h"

using rocksdb::Slice;

Expand Down Expand Up @@ -58,7 +56,7 @@ class Stream : public SubKeyScanner {
const std::vector<StreamEntryID> &entry_ids, const StreamClaimOptions &options,
StreamClaimResult *result);
rocksdb::Status AutoClaim(const Slice &stream_name, const std::string &group_name, const std::string &consumer_name,
const StreamAutoClaimOptions& options, StreamAutoClaimResult *result);
const StreamAutoClaimOptions &options, StreamAutoClaimResult *result);
rocksdb::Status Len(const Slice &stream_name, const StreamLenOptions &options, uint64_t *size);
rocksdb::Status GetStreamInfo(const Slice &stream_name, bool full, uint64_t count, StreamInfo *info);
rocksdb::Status GetGroupInfo(const Slice &stream_name,
Expand Down
Loading

0 comments on commit 1c89a9c

Please sign in to comment.