From 544b6ca6c0b2fcdedd22f44ad91c158c0e2353ae Mon Sep 17 00:00:00 2001 From: Shinichi Umegane Date: Fri, 18 Oct 2024 14:41:28 +0900 Subject: [PATCH] cleanup: clang-tidy --- src/limestone/cursor_impl.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/limestone/cursor_impl.cpp b/src/limestone/cursor_impl.cpp index d3e8908..d5b533d 100644 --- a/src/limestone/cursor_impl.cpp +++ b/src/limestone/cursor_impl.cpp @@ -87,20 +87,19 @@ void cursor_impl::validate_and_read_stream(std::optionalkey_sid() < previous_key_sid) { - LOG(ERROR) << "Key order violation in " << stream_name << ": current key_sid (" << log_entry->key_sid() - << ") is smaller than the previous key_sid (" << previous_key_sid << ")"; - THROW_LIMESTONE_EXCEPTION("Key order violation detected in " + stream_name); - } - - // Update the previous key_sid to the current one - previous_key_sid = log_entry->key_sid(); } + // Check if the key_sid is in ascending order + // TODO: Key order violation is detected here and the process is aborted. + // However, this check should be moved to an earlier point, and if the key order is invalid, + // a different processing method should be considered instead of aborting immediately. + if (!previous_key_sid.empty() && log_entry->key_sid() < previous_key_sid) { + LOG(ERROR) << "Key order violation in " << stream_name << ": current key_sid (" << log_entry->key_sid() + << ") is smaller than the previous key_sid (" << previous_key_sid << ")"; + THROW_LIMESTONE_EXCEPTION("Key order violation detected in " + stream_name); + } + + // Update the previous key_sid to the current one + previous_key_sid = log_entry->key_sid(); } // Check the validity of the entry using the lambda function