[spectro] log_time must be in ascending order

This commit is contained in:
Timothy Stack 2016-05-02 22:59:04 -07:00
parent 834fea5f73
commit a4deaa1e8b
4 changed files with 24 additions and 3 deletions

View File

@ -201,7 +201,13 @@ public:
tv.tv_sec = -1;
tv.tv_usec = -1;
}
this->dls_time_column.push_back(tv);
if (!this->dls_time_column.empty() && tv < this->dls_time_column.back()) {
this->dls_time_column_index = -1;
this->dls_time_column.clear();
}
else {
this->dls_time_column.push_back(tv);
}
}
this->dls_rows.back().push_back(colstr);

View File

@ -2606,7 +2606,7 @@ public:
this->dsvs_column_index = dls.column_name_to_index(this->dsvs_colname);
if (!dls.has_log_time_column()) {
this->dsvs_error_msg = "no 'log_time' column found, unable to create spectrogram";
this->dsvs_error_msg = "no 'log_time' column found or not in ascending order, unable to create spectrogram";
return;
}

View File

@ -258,6 +258,12 @@ bool operator<(time_t left, const struct timeval &right) {
return left < right.tv_sec;
};
inline
bool operator<(const struct timeval &left, const struct timeval &right) {
return left.tv_sec < right.tv_sec ||
((left.tv_sec == right.tv_usec) && (left.tv_usec < right.tv_usec));
};
struct date_time_scanner {
date_time_scanner() : dts_keep_base_tz(false),
dts_local_time(false),

View File

@ -77,7 +77,7 @@ run_test ${lnav_test} -n \
${test_dir}/logfile_access_log.0
check_error_output "spectrogram worked without log_time?" <<EOF
error: no 'log_time' column found, unable to create spectrogram
error: no 'log_time' column found or not in ascending order, unable to create spectrogram
EOF
run_test ${lnav_test} -n \
@ -98,6 +98,15 @@ check_error_output "spectrogram worked with non-numeric column?" <<EOF
error: column is not numeric -- c_ip
EOF
run_test ${lnav_test} -n \
-c ';select log_time,sc_bytes from access_log order by log_time desc' \
-c ':spectrogram sc_bytes' \
${test_dir}/logfile_access_log.0
check_error_output "spectrogram worked with unordered log_time?" <<EOF
error: no 'log_time' column found or not in ascending order, unable to create spectrogram
EOF
run_test ${lnav_test} -n \
-c ";select log_time,log_actual_time from syslog_log" \