Skip to content

Commit a2c9291

Browse files
committed
chore(cubestore): Upgrade DF: Remove, silence, or fix unused imports, variables, deprecation warnings
1 parent e7cccce commit a2c9291

32 files changed

+190
-259
lines changed

rust/cubestore/cubestore/src/cachestore/lazy.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub enum LazyRocksCacheStoreState {
2424
metastore_fs: Arc<dyn MetaStoreFs>,
2525
config: Arc<dyn ConfigObj>,
2626
listeners: Vec<tokio::sync::broadcast::Sender<MetaStoreEvent>>,
27+
#[allow(dead_code)] // Receiver closed on drop
2728
init_flag: Sender<bool>,
2829
},
2930
Closed {},

rust/cubestore/cubestore/src/cachestore/queue_item_payload.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl QueueItemPayload {
4141
}
4242
}
4343

44+
#[allow(unused)] // TODO upgrade DF: This is unused in pre-DF-upgrade too.
4445
#[derive(Clone, Copy, Debug)]
4546
pub(crate) enum QueueItemPayloadRocksIndex {}
4647

rust/cubestore/cubestore/src/metastore/rocks_store.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,11 @@ impl<'a> RocksSecondaryIndexValue<'a> {
271271
let expire = if expire_timestamp == 0 {
272272
None
273273
} else {
274-
Some(DateTime::<Utc>::from_naive_utc_and_offset(
275-
NaiveDateTime::from_timestamp(expire_timestamp, 0),
276-
Utc,
277-
))
274+
Some(
275+
DateTime::<Utc>::from_timestamp(expire_timestamp, 0).ok_or_else(
276+
|| CubeError::internal("timestamp out of range".to_owned()),
277+
)?,
278+
)
278279
};
279280

280281
Ok(RocksSecondaryIndexValue::HashAndTTL(&hash, expire))

rust/cubestore/cubestore/src/queryplanner/info_schema/info_schema_tables.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::metastore::table::TablePath;
2+
use crate::queryplanner::info_schema::timestamp_nanos_or_panic;
23
use crate::queryplanner::{InfoSchemaTableDef, InfoSchemaTableDefContext};
34
use crate::CubeError;
45
use async_trait::async_trait;
@@ -64,7 +65,7 @@ impl InfoSchemaTableDef for TablesInfoSchemaTableDef {
6465
.get_row()
6566
.build_range_end()
6667
.as_ref()
67-
.map(|t| t.timestamp_nanos())
68+
.map(timestamp_nanos_or_panic)
6869
})
6970
.collect::<Vec<_>>(),
7071
))
@@ -78,7 +79,7 @@ impl InfoSchemaTableDef for TablesInfoSchemaTableDef {
7879
.get_row()
7980
.seal_at()
8081
.as_ref()
81-
.map(|t| t.timestamp_nanos())
82+
.map(timestamp_nanos_or_panic)
8283
})
8384
.collect::<Vec<_>>(),
8485
))

rust/cubestore/cubestore/src/queryplanner/info_schema/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ mod system_replay_handles;
1313
mod system_snapshots;
1414
mod system_tables;
1515

16+
use chrono::{DateTime, Utc};
1617
pub use info_schema_columns::*;
1718
pub use info_schema_schemata::*;
1819
pub use info_schema_tables::*;
@@ -27,3 +28,10 @@ pub use system_queue_results::*;
2728
pub use system_replay_handles::*;
2829
pub use system_snapshots::*;
2930
pub use system_tables::*;
31+
32+
// This is a fairly arbitrary place to put this; maybe put it somewhere else (or pass up the error).
33+
pub fn timestamp_nanos_or_panic(date_time: &DateTime<Utc>) -> i64 {
34+
date_time
35+
.timestamp_nanos_opt()
36+
.expect("value can not be represented in a timestamp with nanosecond precision.")
37+
}

rust/cubestore/cubestore/src/queryplanner/info_schema/system_cache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::cachestore::CacheItem;
22
use crate::metastore::IdRow;
3+
use crate::queryplanner::info_schema::timestamp_nanos_or_panic;
34
use crate::queryplanner::{InfoSchemaTableDef, InfoSchemaTableDefContext};
45
use crate::CubeError;
56
use async_trait::async_trait;
@@ -54,7 +55,7 @@ impl InfoSchemaTableDef for SystemCacheTableDef {
5455
row.get_row()
5556
.get_expire()
5657
.as_ref()
57-
.map(|t| t.timestamp_nanos())
58+
.map(timestamp_nanos_or_panic)
5859
})
5960
.collect::<Vec<_>>(),
6061
))

rust/cubestore/cubestore/src/queryplanner/info_schema/system_chunks.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::metastore::chunks::chunk_file_name;
22
use crate::metastore::{Chunk, IdRow, MetaStoreTable};
3+
use crate::queryplanner::info_schema::timestamp_nanos_or_panic;
34
use crate::queryplanner::{InfoSchemaTableDef, InfoSchemaTableDefContext};
45
use crate::CubeError;
56
use async_trait::async_trait;
@@ -125,7 +126,7 @@ impl InfoSchemaTableDef for SystemChunksTableDef {
125126
row.get_row()
126127
.created_at()
127128
.as_ref()
128-
.map(|t| t.timestamp_nanos())
129+
.map(timestamp_nanos_or_panic)
129130
})
130131
.collect::<Vec<_>>(),
131132
))
@@ -138,7 +139,7 @@ impl InfoSchemaTableDef for SystemChunksTableDef {
138139
row.get_row()
139140
.oldest_insert_at()
140141
.as_ref()
141-
.map(|t| t.timestamp_nanos())
142+
.map(timestamp_nanos_or_panic)
142143
})
143144
.collect::<Vec<_>>(),
144145
))
@@ -151,7 +152,7 @@ impl InfoSchemaTableDef for SystemChunksTableDef {
151152
row.get_row()
152153
.deactivated_at()
153154
.as_ref()
154-
.map(|t| t.timestamp_nanos())
155+
.map(timestamp_nanos_or_panic)
155156
})
156157
.collect::<Vec<_>>(),
157158
))

rust/cubestore/cubestore/src/queryplanner/info_schema/system_jobs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::metastore::job::Job;
22
use crate::metastore::IdRow;
3+
use crate::queryplanner::info_schema::timestamp_nanos_or_panic;
34
use crate::queryplanner::{InfoSchemaTableDef, InfoSchemaTableDefContext};
45
use crate::CubeError;
56
use async_trait::async_trait;
@@ -66,7 +67,7 @@ impl InfoSchemaTableDef for SystemJobsTableDef {
6667
Box::new(|jobs| {
6768
Arc::new(TimestampNanosecondArray::from(
6869
jobs.iter()
69-
.map(|row| row.get_row().last_heart_beat().timestamp_nanos())
70+
.map(|row| timestamp_nanos_or_panic(row.get_row().last_heart_beat()))
7071
.collect::<Vec<_>>(),
7172
))
7273
}),

rust/cubestore/cubestore/src/queryplanner/info_schema/system_queue.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::cachestore::QueueAllItem;
2+
use crate::queryplanner::info_schema::timestamp_nanos_or_panic;
23
use crate::queryplanner::{InfoSchemaTableDef, InfoSchemaTableDefContext};
34
use crate::CubeError;
45
use async_trait::async_trait;
@@ -64,7 +65,7 @@ impl InfoSchemaTableDef for SystemQueueTableDef {
6465
Arc::new(TimestampNanosecondArray::from(
6566
items
6667
.iter()
67-
.map(|row| row.item.get_row().get_created().timestamp_nanos())
68+
.map(|row| timestamp_nanos_or_panic(row.item.get_row().get_created()))
6869
.collect::<Vec<_>>(),
6970
))
7071
}),
@@ -93,7 +94,7 @@ impl InfoSchemaTableDef for SystemQueueTableDef {
9394
.get_row()
9495
.get_heartbeat()
9596
.as_ref()
96-
.map(|v| v.timestamp_nanos())
97+
.map(timestamp_nanos_or_panic)
9798
})
9899
.collect::<Vec<_>>(),
99100
))
@@ -107,7 +108,7 @@ impl InfoSchemaTableDef for SystemQueueTableDef {
107108
.get_row()
108109
.get_orphaned()
109110
.as_ref()
110-
.map(|v| v.timestamp_nanos())
111+
.map(timestamp_nanos_or_panic)
111112
})
112113
.collect::<Vec<_>>(),
113114
))

rust/cubestore/cubestore/src/queryplanner/info_schema/system_queue_results.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::cachestore::QueueResult;
22
use crate::metastore::IdRow;
3+
use crate::queryplanner::info_schema::timestamp_nanos_or_panic;
34
use crate::queryplanner::{InfoSchemaTableDef, InfoSchemaTableDefContext};
45
use crate::CubeError;
56
use async_trait::async_trait;
@@ -55,7 +56,7 @@ impl InfoSchemaTableDef for SystemQueueResultsTableDef {
5556
Arc::new(TimestampNanosecondArray::from(
5657
items
5758
.iter()
58-
.map(|row| row.get_row().get_expire().timestamp_nanos())
59+
.map(|row| timestamp_nanos_or_panic(row.get_row().get_expire()))
5960
.collect::<Vec<_>>(),
6061
))
6162
}),

0 commit comments

Comments
 (0)