Refactor time type

This commit is contained in:
Dominik Werder
2024-03-21 16:10:50 +01:00
parent f52d941ca2
commit 259504aa65
17 changed files with 465 additions and 449 deletions
+3 -3
View File
@@ -58,9 +58,9 @@ async fn main_run_inner(opts: DaqIngestOpts) -> Result<(), Error> {
name: k.pg_name,
};
let scyconf = ScyllaIngestConfig::new([k.scylla_host], k.scylla_keyspace);
scywr::schema::migrate_scylla_data_schema(&scyconf, netpod::ttl::RetentionTime::Short)
.await
.map_err(Error::from_string)?;
// scywr::schema::migrate_scylla_data_schema(&scyconf, netpod::ttl::RetentionTime::Short)
// .await
// .map_err(Error::from_string)?;
match k.sub {
DbSub::Data(u) => {
use daqingest::opts::DbDataSub;
+1 -1
View File
@@ -572,7 +572,7 @@ pub async fn run(opts: CaIngestOpts, channels_config: Option<ChannelsConfig>) ->
drop(pg);
jh.await?.map_err(Error::from_string)?;
scywr::schema::migrate_scylla_data_schema(opts.scylla_config(), RetentionTime::Short)
scywr::schema::migrate_scylla_data_schema(opts.scylla_config(), 1, true, RetentionTime::Short)
.await
.map_err(Error::from_string)?;
+16 -2
View File
@@ -64,11 +64,25 @@ pub async fn active_channel_insert_hook_worker(rx: Receiver<QueryItem>, tx: Send
all.sort_unstable();
info!("Active scalar");
for (c, sid, msp, lsp, pulse, _shape_kind) in all.iter().filter(|x| x.5 == 0).take(6) {
info!("{:10} {:20} {:14} {:20} {:?}", usize::MAX - c, msp, lsp, pulse, sid);
info!(
"{:10} {:20} {:14} {:20} {:?}",
usize::MAX - c,
msp.to_u64(),
lsp.ns(),
pulse,
sid
);
}
info!("Active wave");
for (c, sid, msp, lsp, pulse, _shape_kind) in all.iter().filter(|x| x.5 == 1).take(6) {
info!("{:10} {:20} {:14} {:20} {:?}", usize::MAX - c, msp, lsp, pulse, sid);
info!(
"{:10} {:20} {:14} {:20} {:?}",
usize::MAX - c,
msp.to_u64(),
lsp.ns(),
pulse,
sid
);
}
histo.clear();
}
+10 -9
View File
@@ -10,6 +10,7 @@ use log::*;
use netpod::Database;
use netpod::ScalarType;
use netpod::Shape;
use netpod::TsMs;
use scywr::config::ScyllaIngestConfig;
use scywr::scylla::prepared_statement::PreparedStatement;
use scywr::scylla::transport::errors::QueryError;
@@ -35,8 +36,8 @@ pub async fn remove_older(
scyconf: &ScyllaIngestConfig,
) -> Result<(), Error> {
let date_cut = parse_date_str(&params.date)?;
let ts_cut = date_to_ts_ns(date_cut);
debug!("chosen date is {:?} {}", date_cut, ts_cut);
let ts_cut = TsMs::from_ns_u64(date_to_ts_ns(date_cut));
debug!("chosen date is {:?} {:?}", date_cut, ts_cut);
let (pg, _) = dbpg::conn::make_pg_client(pgconf).await?;
let scy = scywr::session::create_session(scyconf).await?;
let sql = concat!(
@@ -63,7 +64,7 @@ async fn remove_older_series(
series: u64,
scalar_type: &ScalarType,
shape: &Shape,
ts_cut: u64,
ts_cut: TsMs,
_pg: &PgClient,
scy: &ScySession,
) -> Result<(), Error> {
@@ -73,16 +74,16 @@ async fn remove_older_series(
let it = scy
.query_iter(
"select ts_msp from ts_msp where series = ? and ts_msp < ?",
(series as i64, ts_cut as i64),
(series as i64, ts_cut.to_i64()),
)
.await?;
type RowType = (i64,);
let mut it = it.into_typed::<RowType>();
while let Some(e) = it.next().await {
let row = e?;
let ts_msp = row.0 as u64;
let ts_msp = row.0;
debug!("remove ts_msp {}", ts_msp);
let res = scy.execute(&qu_delete, (series as i64, ts_msp as i64)).await?;
let res = scy.execute(&qu_delete, (series as i64, ts_msp)).await?;
{
// informative
if let Some(rows) = res.rows {
@@ -105,9 +106,9 @@ pub async fn find_older_msp(
scyconf: &ScyllaIngestConfig,
) -> Result<(), Error> {
let date_cut = parse_date_str(&params.date)?;
let ts_cut = date_to_ts_ns(date_cut);
debug!("chosen date is {:?} {}", date_cut, ts_cut);
let (pg, _) = dbpg::conn::make_pg_client(pgconf).await?;
let ts_cut = TsMs::from_ns_u64(date_to_ts_ns(date_cut));
debug!("chosen date is {:?} {:?}", date_cut, ts_cut);
let (_pg, _jh) = dbpg::conn::make_pg_client(pgconf).await?;
let scy = scywr::session::create_session(scyconf).await?;
let table_name = &params.table_name;
let cql = format!(