Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[ISSUE #2029]💫Implement PopBufferMergeService#get_latest_offset #2030

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use cheetah_string::CheetahString;
use dashmap::DashMap;
use rocketmq_common::common::broker::broker_config::BrokerConfig;
use rocketmq_common::common::key_builder::KeyBuilder;
use rocketmq_common::common::pop_ack_constants::PopAckConstants;
use rocketmq_common::utils::data_converter::DataConverter;
use rocketmq_common::TimeUtils::get_current_millis;
Expand Down Expand Up @@ -167,8 +168,31 @@
true
}

pub fn get_latest_offset(&self, _lock_key: &str) -> i64 {
unimplemented!("Not implemented yet");
#[inline]
pub fn get_latest_offset(&self, lock_key: &CheetahString) -> i64 {
let queue = self.commit_offsets.get(lock_key);
if let Some(queue) = queue {
let queue = queue.value();
let queue = queue.get_queue();
if queue.is_empty() {
return -1;
}
let point = queue.back().unwrap();
point.get_next_begin_offset()

Check warning on line 181 in rocketmq-broker/src/processor/processor_service/pop_buffer_merge_service.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-broker/src/processor/processor_service/pop_buffer_merge_service.rs#L172-L181

Added lines #L172 - L181 were not covered by tests
} else {
-1

Check warning on line 183 in rocketmq-broker/src/processor/processor_service/pop_buffer_merge_service.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-broker/src/processor/processor_service/pop_buffer_merge_service.rs#L183

Added line #L183 was not covered by tests
}
}

Check warning on line 185 in rocketmq-broker/src/processor/processor_service/pop_buffer_merge_service.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-broker/src/processor/processor_service/pop_buffer_merge_service.rs#L185

Added line #L185 was not covered by tests

pub fn get_latest_offset_full(
&self,
topic: &CheetahString,
group: &CheetahString,
queue_id: i32,
) -> i64 {
self.get_latest_offset(&CheetahString::from_string(KeyBuilder::build_polling_key(
topic, group, queue_id,
)))

Check warning on line 195 in rocketmq-broker/src/processor/processor_service/pop_buffer_merge_service.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-broker/src/processor/processor_service/pop_buffer_merge_service.rs#L187-L195

Added lines #L187 - L195 were not covered by tests
}

pub fn clear_offset_queue(&self, _lock_key: &str) {
Expand Down
Loading