[db] use arena allocator for db results

... and continue to tweak cylon
This commit is contained in:
Timothy Stack 2022-07-23 21:42:22 -07:00
parent ff44e37f7e
commit 66853a70ca
13 changed files with 171 additions and 128 deletions

View File

@ -373,6 +373,25 @@ struct string_fragment {
};
}
template<typename A>
const char* to_c_str(A allocator) const
{
auto* retval = allocator.allocate(this->length() + 1);
memcpy(retval, this->data(), this->length());
retval[this->length()] = '\0';
return retval;
}
template<typename A>
string_fragment to_owned(A allocator) const
{
return string_fragment{
this->template to_c_str(allocator),
0,
this->length(),
};
}
const char* sf_string;
int sf_begin;
int sf_end;

View File

@ -95,10 +95,7 @@ column_namer::add_column(const string_fragment& in_name)
while (this->existing_name(retval)) {
if (num == 0) {
auto* mem = this->cn_alloc.allocate(retval.length() + 1);
memcpy(mem, retval.data(), retval.length());
mem[retval.length()] = '\0';
auto counter_name = string_fragment{mem, 0, retval.length()};
auto counter_name = retval.to_owned(this->cn_alloc);
this->cn_name_counters[counter_name] = num;
}
@ -110,10 +107,7 @@ column_namer::add_column(const string_fragment& in_name)
num += 1;
}
auto* mem = this->cn_alloc.allocate(retval.length() + 1);
memcpy(mem, retval.data(), retval.length());
mem[retval.length()] = '\0';
retval = string_fragment{mem, 0, retval.length()};
retval = retval.to_owned(this->cn_alloc);
this->cn_names.emplace_back(retval);
return retval;

View File

@ -74,6 +74,15 @@ struct bind_visitor {
SQLITE_TRANSIENT);
}
void operator()(const string_fragment& str) const
{
sqlite3_bind_text(this->bv_stmt,
this->bv_index,
str.data(),
str.length(),
SQLITE_TRANSIENT);
}
void operator()(null_value_t) const
{
sqlite3_bind_null(this->bv_stmt, this->bv_index);
@ -418,6 +427,9 @@ execute_sql(exec_context& ec, const std::string& sql, std::string& alt_msg)
auto val_as_str = fmt::to_string(bval.second);
auto sql_type = bval.second.match(
[](const std::string&) { return SQLITE_TEXT; },
[](const string_fragment&) {
return SQLITE_TEXT;
},
[](int64_t) { return SQLITE_INTEGER; },
[](null_value_t) { return SQLITE_NULL; },
[](double) { return SQLITE_FLOAT; });
@ -868,17 +880,35 @@ sql_callback(exec_context& ec, sqlite3_stmt* stmt)
set_vars = true;
}
for (lpc = 0; lpc < ncols; lpc++) {
const char* value = (const char*) sqlite3_column_text(stmt, lpc);
auto* raw_value = sqlite3_column_value(stmt, lpc);
auto value_type = sqlite3_value_type(raw_value);
scoped_value_t value;
auto& hm = dls.dls_headers[lpc];
switch (value_type) {
case SQLITE_INTEGER:
value = (int64_t) sqlite3_value_int64(raw_value);
break;
case SQLITE_FLOAT:
value = sqlite3_value_double(raw_value);
break;
case SQLITE_NULL:
value = null_value_t{};
break;
default:
value = string_fragment{
sqlite3_value_text(raw_value),
0,
sqlite3_value_bytes(raw_value),
};
break;
}
dls.push_column(value);
if ((hm.hm_column_type == SQLITE_TEXT
|| hm.hm_column_type == SQLITE_NULL)
&& hm.hm_sub_type == 0)
{
sqlite3_value* raw_value = sqlite3_column_value(stmt, lpc);
switch (sqlite3_value_type(raw_value)) {
switch (value_type) {
case SQLITE_TEXT:
hm.hm_column_type = SQLITE_TEXT;
hm.hm_sub_type = sqlite3_value_subtype(raw_value);
@ -891,21 +921,10 @@ sql_callback(exec_context& ec, sqlite3_stmt* stmt)
}
auto& vars = ec.ec_local_vars.top();
switch (hm.hm_column_type) {
case SQLITE_INTEGER:
vars[hm.hm_name]
= (int64_t) sqlite3_column_int64(stmt, lpc);
break;
case SQLITE_FLOAT:
vars[hm.hm_name] = sqlite3_column_double(stmt, lpc);
break;
case SQLITE_NULL:
vars[hm.hm_name] = null_value_t{};
break;
default:
vars[hm.hm_name] = std::string(value);
break;
if (value.is<string_fragment>()) {
value = value.get<string_fragment>().to_string();
}
vars[hm.hm_name] = value;
}
}

View File

@ -158,28 +158,40 @@ db_label_source::push_header(const std::string& colstr,
}
void
db_label_source::push_column(const char* colstr)
db_label_source::push_column(const scoped_value_t& sv)
{
view_colors& vc = view_colors::singleton();
auto& vc = view_colors::singleton();
int index = this->dls_rows.back().size();
auto& hm = this->dls_headers[index];
double num_value = 0.0;
size_t value_len;
if (colstr == nullptr) {
colstr = NULL_STR;
} else {
colstr = strdup(colstr);
if (colstr == nullptr) {
throw "out of memory";
}
}
value_len = strlen(colstr);
auto col_sf = sv.match(
[](const std::string& str) { return string_fragment{str}; },
[this](const string_fragment& sf) {
return sf.to_owned(*this->dls_allocator);
},
[this](int64_t i) {
fmt::memory_buffer buf;
fmt::format_to(std::back_inserter(buf), FMT_STRING("{}"), i);
return string_fragment{buf.data(), 0, (int) buf.size()}.to_owned(
*this->dls_allocator);
},
[this](double d) {
fmt::memory_buffer buf;
fmt::format_to(std::back_inserter(buf), FMT_STRING("{}"), d);
return string_fragment{buf.data(), 0, (int) buf.size()}.to_owned(
*this->dls_allocator);
},
[](null_value_t) { return string_fragment{NULL_STR}; });
if (index == this->dls_time_column_index) {
date_time_scanner dts;
struct timeval tv;
if (!dts.convert_to_timeval(colstr, -1, nullptr, tv)) {
if (!dts.convert_to_timeval(
col_sf.data(), col_sf.length(), nullptr, tv)) {
tv.tv_sec = -1;
tv.tv_usec = -1;
}
@ -193,23 +205,27 @@ db_label_source::push_column(const char* colstr)
}
}
this->dls_rows.back().push_back(colstr);
this->dls_headers[index].hm_column_size
this->dls_rows.back().push_back(col_sf.data());
hm.hm_column_size
= std::max(this->dls_headers[index].hm_column_size,
utf8_string_length(colstr, value_len).unwrapOr(value_len));
(size_t) utf8_string_length(col_sf.data(), col_sf.length())
.unwrapOr(col_sf.length()));
if (colstr != nullptr && this->dls_headers[index].hm_graphable) {
if (sscanf(colstr, "%lf", &num_value) != 1) {
num_value = 0.0;
if ((sv.is<int64_t>() || sv.is<double>())
&& this->dls_headers[index].hm_graphable)
{
if (sv.is<int64_t>()) {
this->dls_chart.add_value(hm.hm_name, sv.get<int64_t>());
} else {
this->dls_chart.add_value(hm.hm_name, sv.get<double>());
}
this->dls_chart.add_value(this->dls_headers[index].hm_name, num_value);
} else if (value_len > 2
&& ((colstr[0] == '{' && colstr[value_len - 1] == '}')
|| (colstr[0] == '[' && colstr[value_len - 1] == ']')))
} else if (col_sf.length() > 2
&& ((col_sf.startswith("{") && col_sf.endswith("}"))
|| (col_sf.startswith("[") && col_sf.startswith("]"))))
{
json_ptr_walk jpw;
if (jpw.parse(colstr, value_len) == yajl_status_ok
if (jpw.parse(col_sf.data(), col_sf.length()) == yajl_status_ok
&& jpw.complete_parse() == yajl_status_ok)
{
for (auto& jpw_value : jpw.jpw_values) {
@ -231,16 +247,10 @@ db_label_source::clear()
{
this->dls_chart.clear();
this->dls_headers.clear();
for (size_t row = 0; row < this->dls_rows.size(); row++) {
for (size_t col = 0; col < this->dls_rows[row].size(); col++) {
if (this->dls_rows[row][col] != NULL_STR) {
free((void*) this->dls_rows[row][col]);
}
}
}
this->dls_rows.clear();
this->dls_time_column.clear();
this->dls_cell_width.clear();
this->dls_allocator = std::make_unique<ArenaAlloc::Alloc<char>>(64 * 1024);
}
nonstd::optional<size_t>

View File

@ -36,7 +36,9 @@
#include <sqlite3.h>
#include "ArenaAlloc/arenaalloc.h"
#include "hist_source.hh"
#include "shlex.resolver.hh"
#include "textview_curses.hh"
class db_label_source
@ -77,7 +79,7 @@ public:
void push_header(const std::string& colstr, int type, bool graphable);
void push_column(const char* colstr);
void push_column(const scoped_value_t& sv);
void clear();
@ -118,6 +120,8 @@ public:
std::vector<size_t> dls_cell_width;
int dls_time_column_index{-1};
nonstd::optional<size_t> dls_time_column_invalidated_at;
std::unique_ptr<ArenaAlloc::Alloc<char>> dls_allocator{
std::make_unique<ArenaAlloc::Alloc<char>>(64 * 1024)};
static const char* NULL_STR;
};

View File

@ -448,7 +448,7 @@ acos(*num*)
.. code-block:: custsqlite
;SELECT acos(0.2)
1.36943840600457
1.3694384060045657
**See Also**
:ref:`abs`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -472,7 +472,7 @@ acosh(*num*)
.. code-block:: custsqlite
;SELECT acosh(1.2)
0.622362503714779
0.6223625037147786
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -496,7 +496,7 @@ asin(*num*)
.. code-block:: custsqlite
;SELECT asin(0.2)
0.201357920790331
0.2013579207903308
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -520,7 +520,7 @@ asinh(*num*)
.. code-block:: custsqlite
;SELECT asinh(0.2)
0.198690110349241
0.19869011034924142
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -544,7 +544,7 @@ atan(*num*)
.. code-block:: custsqlite
;SELECT atan(0.2)
0.197395559849881
0.19739555984988078
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -569,7 +569,7 @@ atan2(*y*, *x*)
.. code-block:: custsqlite
;SELECT degrees(atan2(5, 5))
45.0
45
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -593,7 +593,7 @@ atanh(*num*)
.. code-block:: custsqlite
;SELECT atanh(0.2)
0.202732554054082
0.2027325540540822
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -618,7 +618,7 @@ atn2(*y*, *x*)
.. code-block:: custsqlite
;SELECT degrees(atn2(5, 5))
45.0
45
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -650,8 +650,8 @@ avg(*X*)
;SELECT ex_procname, avg(ex_duration) FROM lnav_example_log GROUP BY ex_procname
ex_procname avg(ex_duration)
gw 5.0
hw 2.0
gw 5
hw 2
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -969,7 +969,7 @@ degrees(*radians*)
.. code-block:: custsqlite
;SELECT degrees(pi())
180.0
180
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -1763,21 +1763,21 @@ julianday(*timestring*, *modifier*)
.. code-block:: custsqlite
;SELECT julianday('2017-01-02T03:04:05')
2457755.62783565
2457755.627835648
To get the julian day from the timestamp '2017-01-02T03:04:05' plus one minute:
.. code-block:: custsqlite
;SELECT julianday('2017-01-02T03:04:05', '+1 minute')
2457755.62853009
2457755.6285300925
To get the julian day from the timestamp 1491341842:
.. code-block:: custsqlite
;SELECT julianday(1491341842, 'unixepoch')
2457848.40094907
2457848.400949074
**See Also**
:ref:`date`, :ref:`datetime`, :ref:`humanize_duration`, :ref:`strftime`, :ref:`time`, :ref:`timediff`, :ref:`timeslice`
@ -2016,7 +2016,7 @@ log(*x*)
.. code-block:: custsqlite
;SELECT log(8)
2.07944154167984
2.0794415416798357
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -2040,7 +2040,7 @@ log10(*x*)
.. code-block:: custsqlite
;SELECT log10(100)
2.0
2
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -2397,7 +2397,7 @@ pi()
.. code-block:: custsqlite
;SELECT pi()
3.14159265358979
3.141592653589793
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -2422,7 +2422,7 @@ power(*base*, *exp*)
.. code-block:: custsqlite
;SELECT power(2, 3)
8.0
8
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -2538,7 +2538,7 @@ radians(*degrees*)
.. code-block:: custsqlite
;SELECT radians(180)
3.14159265358979
3.141592653589793
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`, :ref:`total`
@ -2906,7 +2906,7 @@ round(*num*, *\[digits\]*)
.. code-block:: custsqlite
;SELECT round(123.456)
123.0
123
To round the number 123.456 to a precision of 1:
@ -3406,14 +3406,14 @@ timediff(*time1*, *time2*)
.. code-block:: custsqlite
;SELECT timediff('2017-02-03T04:05:06', '2017-02-03T04:05:00')
6.0
6
To get the difference between relative timestamps:
.. code-block:: custsqlite
;SELECT timediff('today', 'yesterday')
86400.0
86400
**See Also**
:ref:`date`, :ref:`datetime`, :ref:`humanize_duration`, :ref:`julianday`, :ref:`strftime`, :ref:`time`, :ref:`timeslice`
@ -3482,7 +3482,7 @@ total(*X*)
.. code-block:: custsqlite
;SELECT total(ex_duration) FROM lnav_example_log
17.0
17
**See Also**
:ref:`abs`, :ref:`acos`, :ref:`acosh`, :ref:`asin`, :ref:`asinh`, :ref:`atan2`, :ref:`atan`, :ref:`atanh`, :ref:`atn2`, :ref:`avg`, :ref:`ceil`, :ref:`degrees`, :ref:`exp`, :ref:`floor`, :ref:`log10`, :ref:`log`, :ref:`max`, :ref:`min`, :ref:`pi`, :ref:`power`, :ref:`radians`, :ref:`round`, :ref:`sign`, :ref:`square`, :ref:`sum`

View File

@ -1409,9 +1409,13 @@ UPDATE lnav_views_echo
ago = humanize::time::point::from_tv(
{(time_t) session_data.sd_save_time, 0})
.as_time_ago();
lnav_data.ld_rl_view->set_value(
("restored session from " ANSI_BOLD_START) + ago
+ (ANSI_NORM "; press Ctrl-R to reset session"));
auto um = lnav::console::user_message::ok(
attr_line_t("restored session from ")
.append(lnav::roles::number(ago))
.append("; press ")
.append("CTRL-R"_symbol)
.append(" to reset session"));
lnav_data.ld_rl_view->set_attr_value(um.to_attr_line());
}
lnav_data.ld_session_loaded = true;

View File

@ -864,13 +864,9 @@ external_log_format::scan(logfile& lf,
auto opid_iter = sbc.sbc_opids.find(opid_sf);
if (opid_iter == sbc.sbc_opids.end()) {
auto* opid_mem
= sbc.sbc_allocator.allocate(opid_sf.length() + 1);
memcpy(opid_mem, opid_sf.data(), opid_sf.length());
opid_mem[opid_sf.length()] = '\0';
auto opid_copy = opid_sf.to_owned(sbc.sbc_allocator);
auto otr = opid_time_range{log_tv, log_tv};
sbc.sbc_opids.emplace(
string_fragment{opid_mem, 0, opid_sf.length()}, otr);
sbc.sbc_opids.emplace(opid_copy, otr);
} else {
opid_iter->second.otr_end = log_tv;
}

View File

@ -40,8 +40,8 @@
#include "mapbox/variant.hpp"
struct null_value_t {};
using scoped_value_t
= mapbox::util::variant<std::string, int64_t, double, null_value_t>;
using scoped_value_t = mapbox::util::
variant<std::string, string_fragment, int64_t, double, null_value_t>;
namespace fmt {
template<>
@ -51,6 +51,7 @@ struct formatter<scoped_value_t> : formatter<std::string> {
{
auto retval
= sv.match([](std::string str) { return str; },
[](string_fragment sf) { return sf.to_string(); },
[](null_value_t) { return std::string("<NULL>"); },
[](int64_t value) { return fmt::to_string(value); },
[](double value) { return fmt::to_string(value); });

View File

@ -46,10 +46,6 @@ status_field::set_value(std::string value)
scrub_ansi_string(value, sa);
this->sf_value.with_string(value);
if (this->sf_cylon) {
this->do_cylon();
}
}
void
@ -62,10 +58,9 @@ status_field::do_cylon()
auto cycle_pos = (this->sf_cylon_pos % (4 + this->sf_width * 2)) - 2;
auto start = cycle_pos < this->sf_width
? cycle_pos
: (this->sf_width - (cycle_pos - this->sf_width));
: (this->sf_width - (cycle_pos - this->sf_width) - 1);
auto stop = std::min(start + 3, this->sf_width);
struct line_range lr(std::max(start, 0L), stop);
log_debug("cylon %d:%d %d", lr.lr_start, lr.lr_end, this->sf_width);
auto& vc = view_colors::singleton();
sa.emplace_back(lr,
@ -123,6 +118,9 @@ statusview_curses::do_update()
struct line_range lr(0, sf.get_width());
int x;
if (sf.is_cylon()) {
sf.do_cylon();
}
auto val = sf.get_value();
if (!this->sc_enabled) {
for (auto& sa : val.get_attrs()) {
@ -139,8 +137,6 @@ statusview_curses::do_update()
}
}
}
} else if (sf.is_cylon()) {
sf.do_cylon();
}
if (sf.get_left_pad() > 0) {
val.insert(0, sf.get_left_pad(), ' ');

View File

@ -1,3 +1,3 @@
log_line log_part log_time log_idle_msecs log_level log_mark log_comment log_tags log_filters col_0 col_1
0 <NULL> 2021-05-19 08:00:01.000 0 info 0 <NULL> <NULL> <NULL> 1.0 /abc/def
2 <NULL> 2021-05-19 08:00:03.000 2000 info 0 <NULL> <NULL> <NULL> 3.0 /ghi/jkl
0 <NULL> 2021-05-19 08:00:01.000 0 info 0 <NULL> <NULL> <NULL> 1 /abc/def
2 <NULL> 2021-05-19 08:00:03.000 2000 info 0 <NULL> <NULL> <NULL> 3 /ghi/jkl

View File

@ -1,4 +1,4 @@
log_line log_part  log_time log_idle_msecs log_level log_mark log_comment log_tags log_filters match_index user pid cpu_pct mem_pct vsz rss tty stat start_time cpu_time  cmd  cmd_name cmd_args 
 0  <NULL> 2022-06-02 00:01:01.000  0 info   0  <NULL>  <NULL>  <NULL>  1 root  2  0.0  0.0  0  0 ?  S  Jun01  0:00  [kthreadd] [kthreadd]  
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  1 root  2  0.0  0.0  0  0 ?  S  Jun01  0:00  [kthreadd] [kthreadd]  
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  1 root  2  0.0  0.0  0  0 ?  S  Jun01  0:00  [kthreadd] [kthreadd]   
 0  <NULL> 2022-06-02 00:01:01.000  0 info   0  <NULL>  <NULL>  <NULL>  1 root  2  0  0  0  0 ?  S  Jun01  0:00  [kthreadd] [kthreadd]  
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  1 root  2  0  0  0  0 ?  S  Jun01  0:00  [kthreadd] [kthreadd]  
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  1 root  2  0  0  0  0 ?  S  Jun01  0:00  [kthreadd] [kthreadd]   

View File

@ -1,24 +1,24 @@
log_line log_part  log_time log_idle_msecs log_level log_mark log_comment log_tags log_filters match_index user pid cpu_pct mem_pct  vsz rss tty stat start_time cpu_time  cmd  cmd_name  cmd_args 
 0  <NULL> 2022-06-02 00:01:01.000  0 info   0  <NULL>  <NULL>  <NULL>  0 root  1  0.0  0.0 158392 7792 ?  Ss  Jun01  0:14  /lib/systemd/systemd --switched-root --system --deserialize 16 /lib/systemd/systemd  --switched-root --system --deserialize 16 
0 <NULL> 2022-06-02 00:01:01.000 0 info 0 <NULL> <NULL> <NULL> 1 root 2 0.0 0.0 0 0 ? S Jun01 0:00 [kthreadd] [kthreadd]
 0  <NULL> 2022-06-02 00:01:01.000  0 info   0  <NULL>  <NULL>  <NULL>  2 root  3  0.0  0.0  0  0 ?  I<  Jun01  0:00  [rcu_gp]  [rcu_gp]   
0 <NULL> 2022-06-02 00:01:01.000 0 info 0 <NULL> <NULL> <NULL> 3 root 4 0.0 0.0 0 0 ? I< Jun01 0:00 [rcu_par_gp] [rcu_par_gp]
 0  <NULL> 2022-06-02 00:01:01.000  0 info   0  <NULL>  <NULL>  <NULL>  4 root  6  0.0  0.0  0  0 ?  I<  Jun01  0:00  [kworker/0:0H-kblockd]  [kworker/0:0H-kblockd]  
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  0 root  1  0.0  0.0 158392 7792 ?  Ss  Jun01  0:14  /lib/systemd/systemd --switched-root --system --deserialize 16 /lib/systemd/systemd  --switched-root --system --deserialize 16
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  1 root  2  0.0  0.0  0  0 ?  S  Jun01  0:00  [kthreadd]  [kthreadd]   
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL> <NULL> <NULL> 2 root 3 0.0 0.0 0 0 ? I< Jun01 0:00 [rcu_gp] [rcu_gp]
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  3 root  4  0.0  0.0  0  0 ?  I<  Jun01  0:00  [rcu_par_gp]  [rcu_par_gp]   
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL> <NULL> <NULL> 4 root 6 0.0 0.0 0 0 ? I< Jun01 0:00 [kworker/0:0H-kblockd] [kworker/0:0H-kblockd]
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  5 root  8  0.0  0.0  0  0 ?  I<  Jun01  0:00  [mm_percpu_wq]  [mm_percpu_wq]   
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL> <NULL> <NULL> 6 root 9 0.0 0.0 0 0 ? S Jun01 0:00 [ksoftirqd/0] [ksoftirqd/0]
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  7 root  10  0.0  0.0  0  0 ?  I  Jun01  0:23  [rcu_sched]  [rcu_sched]   
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL> <NULL> <NULL> 8 root 11 0.0 0.0 0 0 ? I Jun01 0:00 [rcu_bh] [rcu_bh]
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  9 root  12  0.0  0.0  0  0 ?  S  Jun01  0:00  [migration/0]  [migration/0]   
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL> <NULL> <NULL> 10 root 14 0.0 0.0 0 0 ? S Jun01 0:00 [cpuhp/0] [cpuhp/0]
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  0 root  1  0.0  0.0 158392 7792 ?  Ss  Jun01  0:14  /lib/systemd/systemd --switched-root --system --deserialize 16 /lib/systemd/systemd  --switched-root --system --deserialize 16 
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL> <NULL> <NULL> 1 root 2 0.0 0.0 0 0 ? S Jun01 0:00 [kthreadd] [kthreadd]
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  2 root  3  0.0  0.0  0  0 ?  I<  Jun01  0:00  [rcu_gp]  [rcu_gp]   
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL> <NULL> <NULL> 3 root 4 0.0 0.0 0 0 ? I< Jun01 0:00 [rcu_par_gp] [rcu_par_gp]
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  4 root  6  0.0  0.0  0  0 ?  I<  Jun01  0:00  [kworker/0:0H-kblockd]  [kworker/0:0H-kblockd]  
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL> <NULL> <NULL> 5 root 8 0.0 0.0 0 0 ? I< Jun01 0:00 [mm_percpu_wq] [mm_percpu_wq]
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  6 root  9  0.0  0.0  0  0 ?  S  Jun01  0:00  [ksoftirqd/0]  [ksoftirqd/0]   
 0  <NULL> 2022-06-02 00:01:01.000  0 info   0  <NULL>  <NULL>  <NULL>  0 root  1  0  0 158392 7792 ?  Ss  Jun01  0:14  /lib/systemd/systemd --switched-root --system --deserialize 16 /lib/systemd/systemd  --switched-root --system --deserialize 16 
0 <NULL> 2022-06-02 00:01:01.000 0 info 0 <NULL> <NULL> <NULL> 1 root 2 0 0 0 0 ? S Jun01 0:00 [kthreadd] [kthreadd]
 0  <NULL> 2022-06-02 00:01:01.000  0 info   0  <NULL>  <NULL>  <NULL>  2 root  3  0  0  0  0 ?  I<  Jun01  0:00  [rcu_gp]  [rcu_gp]   
0 <NULL> 2022-06-02 00:01:01.000 0 info 0 <NULL> <NULL> <NULL> 3 root 4 0 0 0 0 ? I< Jun01 0:00 [rcu_par_gp] [rcu_par_gp]
 0  <NULL> 2022-06-02 00:01:01.000  0 info   0  <NULL>  <NULL>  <NULL>  4 root  6  0  0  0  0 ?  I<  Jun01  0:00  [kworker/0:0H-kblockd]  [kworker/0:0H-kblockd]  
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  0 root  1  0  0 158392 7792 ?  Ss  Jun01  0:14  /lib/systemd/systemd --switched-root --system --deserialize 16 /lib/systemd/systemd  --switched-root --system --deserialize 16
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  1 root  2  0  0  0  0 ?  S  Jun01  0:00  [kthreadd]  [kthreadd]   
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL> <NULL> <NULL> 2 root 3 0 0 0 0 ? I< Jun01 0:00 [rcu_gp] [rcu_gp]
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  3 root  4  0  0  0  0 ?  I<  Jun01  0:00  [rcu_par_gp]  [rcu_par_gp]   
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL> <NULL> <NULL> 4 root 6 0 0 0 0 ? I< Jun01 0:00 [kworker/0:0H-kblockd] [kworker/0:0H-kblockd]
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  5 root  8  0  0  0  0 ?  I<  Jun01  0:00  [mm_percpu_wq]  [mm_percpu_wq]   
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL> <NULL> <NULL> 6 root 9 0 0 0 0 ? S Jun01 0:00 [ksoftirqd/0] [ksoftirqd/0]
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  7 root  10  0  0  0  0 ?  I  Jun01  0:23  [rcu_sched]  [rcu_sched]   
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL> <NULL> <NULL> 8 root 11 0 0 0 0 ? I Jun01 0:00 [rcu_bh] [rcu_bh]
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  9 root  12  0  0  0  0 ?  S  Jun01  0:00  [migration/0]  [migration/0]   
 12  <NULL> 2022-06-02 00:02:01.000  60000 info   0  <NULL> <NULL> <NULL> 10 root 14 0 0 0 0 ? S Jun01 0:00 [cpuhp/0] [cpuhp/0]
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  0 root  1  0  0 158392 7792 ?  Ss  Jun01  0:14  /lib/systemd/systemd --switched-root --system --deserialize 16 /lib/systemd/systemd  --switched-root --system --deserialize 16 
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL> <NULL> <NULL> 1 root 2 0 0 0 0 ? S Jun01 0:00 [kthreadd] [kthreadd]
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  2 root  3  0  0  0  0 ?  I<  Jun01  0:00  [rcu_gp]  [rcu_gp]   
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL> <NULL> <NULL> 3 root 4 0 0 0 0 ? I< Jun01 0:00 [rcu_par_gp] [rcu_par_gp]
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  4 root  6  0  0  0  0 ?  I<  Jun01  0:00  [kworker/0:0H-kblockd]  [kworker/0:0H-kblockd]  
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL> <NULL> <NULL> 5 root 8 0 0 0 0 ? I< Jun01 0:00 [mm_percpu_wq] [mm_percpu_wq]
 30  <NULL> 2022-06-02 00:03:01.000  60000 info   0  <NULL>  <NULL>  <NULL>  6 root  9  0  0  0  0 ?  S  Jun01  0:00  [ksoftirqd/0]  [ksoftirqd/0]