Skip to content

Commit

Permalink
Undo some unnecessary changes; Minor refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkrodrigues committed Nov 24, 2023
1 parent fc65297 commit 772fc56
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions components/core/src/LogSurgeonReader.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "LogSurgeonReader.hpp"

LogSurgeonReader::LogSurgeonReader (ReaderInterface& reader_interface)
LogSurgeonReader::LogSurgeonReader(ReaderInterface& reader_interface)
: m_reader_interface(reader_interface) {
read = [this] (char* buf, size_t count, size_t& read_to) -> log_surgeon::ErrorCode {
read = [this](char* buf, size_t count, size_t& read_to) -> log_surgeon::ErrorCode {
m_reader_interface.read(buf, count, read_to);
if (read_to == 0) {
return log_surgeon::ErrorCode::EndOfFile;
}
return log_surgeon::ErrorCode::Success;
};
}
}
6 changes: 4 additions & 2 deletions components/core/src/LogSurgeonReader.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#ifndef LOG_SURGEON_READER_HPP
#define LOG_SURGEON_READER_HPP

#include <log_surgeon/Reader.hpp>

#include "ReaderInterface.hpp"

/*
* Wrapper providing a read function that works with the parsers in log_surgeon.
*/
class LogSurgeonReader : public log_surgeon::Reader {
public:
LogSurgeonReader (ReaderInterface& reader_interface);
LogSurgeonReader(ReaderInterface& reader_interface);

private:
ReaderInterface& m_reader_interface;
};

#endif //LOG_SURGEON_READER_HPP
#endif // LOG_SURGEON_READER_HPP
3 changes: 0 additions & 3 deletions components/core/src/ReaderInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@

// C++ standard libraries
#include <cstddef>
#include <memory>
#include <string>

// Project headers
#include "Defs.h"
#include "ErrorCode.hpp"
#include "TraceableException.hpp"

#include <log_surgeon/Reader.hpp>

class ReaderInterface {
public:
// Types
Expand Down
13 changes: 8 additions & 5 deletions components/core/src/streaming_archive/writer/Archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,16 @@ namespace streaming_archive::writer {
void Archive::write_msg_using_schema (LogEventView const& log_view) {
epochtime_t timestamp = 0;
TimestampPattern* timestamp_pattern = nullptr;
if (log_view.get_log_output_buffer()->has_timestamp()) {
auto const& log_output_buffer = log_view.get_log_output_buffer();
if (log_output_buffer->has_timestamp()) {
size_t start;
size_t end;
timestamp_pattern = (TimestampPattern*) TimestampPattern::search_known_ts_patterns(
log_view.get_log_output_buffer()->get_mutable_token(0).to_string(), timestamp,
start, end);
timestamp_pattern = (TimestampPattern*)TimestampPattern::search_known_ts_patterns(
log_output_buffer->get_mutable_token(0).to_string(),
timestamp,
start,
end
);
if (m_old_ts_pattern != timestamp_pattern) {
change_ts_pattern(timestamp_pattern);
m_old_ts_pattern = timestamp_pattern;
Expand All @@ -291,7 +295,6 @@ namespace streaming_archive::writer {
m_logtype_dict_entry.clear();
size_t num_uncompressed_bytes = 0;
// Timestamp is included in the uncompressed message size
auto const& log_output_buffer = log_view.get_log_output_buffer();
uint32_t start_pos = log_output_buffer->get_token(0).m_start_pos;
if (timestamp_pattern == nullptr) {
start_pos = log_output_buffer->get_token(1).m_start_pos;
Expand Down
4 changes: 2 additions & 2 deletions components/core/tests/test-ParserWithUserSchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ TEST_CASE("Test error for missing schema file", "[LALR1Parser][SchemaParser]") {
std::string file_name = boost::filesystem::weakly_canonical(file_path).string();
REQUIRE_THROWS_WITH(
generate_schema_ast(file_path),
"Failed to read '" + file_path
+ "', error_code=" + std::to_string(static_cast<int>(log_surgeon::ErrorCode::FileNotFound))
"Failed to read '" + file_path + "', error_code="
+ std::to_string(static_cast<int>(log_surgeon::ErrorCode::FileNotFound))
);
}

Expand Down

0 comments on commit 772fc56

Please sign in to comment.