Skip to content

Commit 97af248

Browse files
authored
Fix more clippy warnings. (#183)
1 parent 9978132 commit 97af248

File tree

11 files changed

+55
-49
lines changed

11 files changed

+55
-49
lines changed

src/base/value.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl<T: Into<BasicValue>> From<Vec<T>> for BasicValue {
334334
}
335335

336336
impl BasicValue {
337-
pub fn to_key(self) -> Result<KeyValue> {
337+
pub fn into_key(self) -> Result<KeyValue> {
338338
let result = match self {
339339
BasicValue::Bytes(v) => KeyValue::Bytes(v),
340340
BasicValue::Str(v) => KeyValue::Str(v),
@@ -473,13 +473,13 @@ impl<VS> Value<VS> {
473473
matches!(self, Value::Null)
474474
}
475475

476-
pub fn to_key(self) -> Result<KeyValue> {
476+
pub fn into_key(self) -> Result<KeyValue> {
477477
let result = match self {
478-
Value::Basic(v) => v.to_key()?,
478+
Value::Basic(v) => v.into_key()?,
479479
Value::Struct(v) => KeyValue::Struct(
480480
v.fields
481481
.into_iter()
482-
.map(|v| v.to_key())
482+
.map(|v| v.into_key())
483483
.collect::<Result<Vec<_>>>()?,
484484
),
485485
Value::Null | Value::Collection(_) | Value::Table(_) | Value::List(_) => {
@@ -661,7 +661,7 @@ where
661661
})
662662
}
663663

664-
pub fn from_json<'a>(value: serde_json::Value, fields_schema: &[FieldSchema]) -> Result<Self> {
664+
pub fn from_json(value: serde_json::Value, fields_schema: &[FieldSchema]) -> Result<Self> {
665665
match value {
666666
serde_json::Value::Array(v) => {
667667
if v.len() != fields_schema.len() {
@@ -821,7 +821,7 @@ where
821821
})?,
822822
&key_field.value_type.typ,
823823
)?
824-
.to_key()?;
824+
.into_key()?;
825825
let values = FieldValues::from_json_values(
826826
fields_iter.zip(field_vals_iter),
827827
)?;
@@ -839,7 +839,7 @@ where
839839
)?),
840840
&key_field.value_type.typ,
841841
)?
842-
.to_key()?;
842+
.into_key()?;
843843
let values = FieldValues::from_json_object(v, fields_iter)?;
844844
Ok((key, values.into()))
845845
}

src/builder/analyzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::{BTreeMap, HashSet};
22
use std::sync::Mutex;
3-
use std::{collections::HashMap, future::Future, pin::Pin, sync::Arc, u32};
3+
use std::{collections::HashMap, future::Future, pin::Pin, sync::Arc};
44

55
use super::plan::*;
66
use crate::execution::db_tracking_setup;

src/builder/flow_builder.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,11 @@ impl FlowBuilder {
408408
flow_ctx: &self.flow_inst_context,
409409
};
410410
let mut root_data_scope = self.root_data_scope.lock().unwrap();
411-
let _ = analyzer_ctx
411+
412+
let analyzed = analyzer_ctx
412413
.analyze_source_op(&mut root_data_scope, source_op.clone(), None, None)
413414
.into_py_result()?;
415+
std::mem::drop(analyzed);
414416

415417
let result =
416418
Self::last_field_to_data_slice(&root_data_scope, self.root_data_scope_ref.clone())
@@ -498,7 +500,10 @@ impl FlowBuilder {
498500
op: spec,
499501
}),
500502
};
501-
let _ = analyzer_ctx.analyze_reactive_op(scope, &reactive_op, parent_scopes)?;
503+
504+
let analyzed =
505+
analyzer_ctx.analyze_reactive_op(scope, &reactive_op, parent_scopes)?;
506+
std::mem::drop(analyzed);
502507

503508
reactive_ops.push(reactive_op);
504509
let result = Self::last_field_to_data_slice(scope.data, common_scope.clone())
@@ -537,7 +542,11 @@ impl FlowBuilder {
537542
collector_name: collector.name.clone(),
538543
}),
539544
};
540-
let _ = analyzer_ctx.analyze_reactive_op(scope, &reactive_op, parent_scopes)?;
545+
546+
let analyzed =
547+
analyzer_ctx.analyze_reactive_op(scope, &reactive_op, parent_scopes)?;
548+
std::mem::drop(analyzed);
549+
541550
reactive_ops.push(reactive_op);
542551
Ok(())
543552
},

src/execution/evaluator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ async fn evaluate_op_scope(
325325
.fingerprinter
326326
.clone()
327327
.with(&input_values)?
328-
.to_fingerprint();
328+
.into_fingerprint();
329329
Some(cache.get(
330330
key,
331331
&op.function_exec_info.output_type,
@@ -426,7 +426,7 @@ async fn evaluate_op_scope(
426426
Ok(())
427427
}
428428

429-
pub async fn evaluate_source_entry<'a>(
429+
pub async fn evaluate_source_entry(
430430
plan: &ExecutionPlan,
431431
source_op_idx: usize,
432432
schema: &schema::DataSchema,

src/execution/indexer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ async fn precommit_source_tracking_info(
222222
let curr_fp = Some(
223223
Fingerprinter::default()
224224
.with(&field_values)?
225-
.to_fingerprint(),
225+
.into_fingerprint(),
226226
);
227227

228228
let existing_target_keys = target_info.existing_keys_info.remove(&primary_key_json);
@@ -437,7 +437,7 @@ pub async fn evaluation_cache_on_existing_data(
437437
))
438438
}
439439

440-
pub async fn update_source_entry<'a>(
440+
pub async fn update_source_entry(
441441
plan: &ExecutionPlan,
442442
source_op_idx: usize,
443443
schema: &schema::DataSchema,

src/execution/memoization.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ impl EvaluationCache {
133133
}
134134
}
135135

136-
pub async fn evaluate_with_cell<'a, Fut>(
137-
cell: Option<&'a CacheEntryCell>,
136+
pub async fn evaluate_with_cell<Fut>(
137+
cell: Option<&CacheEntryCell>,
138138
compute: impl FnOnce() -> Fut,
139-
) -> Result<Cow<'a, value::Value>>
139+
) -> Result<Cow<'_, value::Value>>
140140
where
141141
Fut: Future<Output = Result<value::Value>>,
142142
{

src/ops/factory_bases.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ pub struct ResolvedOpArg {
2626

2727
pub trait ResolvedOpArgExt: Sized {
2828
fn expect_type(self, expected_type: &ValueType) -> Result<Self>;
29-
fn value<'a>(&self, args: &'a Vec<value::Value>) -> Result<&'a value::Value>;
30-
fn take_value(&self, args: &mut Vec<value::Value>) -> Result<value::Value>;
29+
fn value<'a>(&self, args: &'a [value::Value]) -> Result<&'a value::Value>;
30+
fn take_value(&self, args: &mut [value::Value]) -> Result<value::Value>;
3131
}
3232

3333
impl ResolvedOpArgExt for ResolvedOpArg {
@@ -43,7 +43,7 @@ impl ResolvedOpArgExt for ResolvedOpArg {
4343
Ok(self)
4444
}
4545

46-
fn value<'a>(&self, args: &'a Vec<value::Value>) -> Result<&'a value::Value> {
46+
fn value<'a>(&self, args: &'a [value::Value]) -> Result<&'a value::Value> {
4747
if self.idx >= args.len() {
4848
api_bail!(
4949
"Two few arguments, {} provided, expected at least {} for `{}`",
@@ -55,7 +55,7 @@ impl ResolvedOpArgExt for ResolvedOpArg {
5555
Ok(&args[self.idx])
5656
}
5757

58-
fn take_value(&self, args: &mut Vec<value::Value>) -> Result<value::Value> {
58+
fn take_value(&self, args: &mut [value::Value]) -> Result<value::Value> {
5959
if self.idx >= args.len() {
6060
api_bail!(
6161
"Two few arguments, {} provided, expected at least {} for `{}`",
@@ -73,15 +73,15 @@ impl ResolvedOpArgExt for Option<ResolvedOpArg> {
7373
self.map(|arg| arg.expect_type(expected_type)).transpose()
7474
}
7575

76-
fn value<'a>(&self, args: &'a Vec<value::Value>) -> Result<&'a value::Value> {
76+
fn value<'a>(&self, args: &'a [value::Value]) -> Result<&'a value::Value> {
7777
Ok(self
7878
.as_ref()
7979
.map(|arg| arg.value(args))
8080
.transpose()?
8181
.unwrap_or(&value::Value::Null))
8282
}
8383

84-
fn take_value(&self, args: &mut Vec<value::Value>) -> Result<value::Value> {
84+
fn take_value(&self, args: &mut [value::Value]) -> Result<value::Value> {
8585
Ok(self
8686
.as_ref()
8787
.map(|arg| arg.take_value(args))

src/ops/storages/postgres.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,10 @@ fn key_value_fields_iter<'a>(
4646

4747
fn convertible_to_pgvector(vec_schema: &VectorTypeSchema) -> bool {
4848
if vec_schema.dimension.is_some() {
49-
match &*vec_schema.element_type {
50-
BasicValueType::Float32 => true,
51-
BasicValueType::Float64 => true,
52-
BasicValueType::Int64 => true,
53-
_ => false,
54-
}
49+
matches!(
50+
*vec_schema.element_type,
51+
BasicValueType::Float32 | BasicValueType::Float64 | BasicValueType::Int64
52+
)
5553
} else {
5654
false
5755
}
@@ -468,8 +466,8 @@ pub struct SetupState {
468466
impl SetupState {
469467
fn new(
470468
table_id: &TableId,
471-
key_fields_schema: &Vec<FieldSchema>,
472-
value_fields_schema: &Vec<FieldSchema>,
469+
key_fields_schema: &[FieldSchema],
470+
value_fields_schema: &[FieldSchema],
473471
index_options: &IndexOptions,
474472
) -> Self {
475473
Self {

src/py/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ pub fn value_from_py_object<'py>(
199199
.into_iter()
200200
.map(|v| {
201201
let mut iter = v.fields.into_iter();
202-
let key = iter.next().unwrap().to_key().into_py_result()?;
202+
let key = iter.next().unwrap().into_key().into_py_result()?;
203203
Ok((
204204
key,
205205
value::ScopeValue(value::FieldValues {

src/setup/states.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/// Concepts:
2+
/// - Resource: some setup that needs to be tracked and maintained.
3+
/// - Setup State: current state of a resource.
4+
/// - Staging Change: states changes that may not be really applied yet.
5+
/// - Combined Setup State: Setup State + Staging Change.
6+
/// - Status Check: information about changes that are being applied / need to be applied.
7+
///
8+
/// Resource hierarchy:
9+
/// - [resource: setup metadata table] /// - Flow
10+
/// - [resource: metadata]
11+
/// - [resource: tracking table]
12+
/// - Target
13+
/// - [resource: target-specific stuff]
114
use anyhow::Result;
215
use axum::async_trait;
316
use indenter::indented;
@@ -15,20 +28,6 @@ use crate::execution::db_tracking_setup;
1528

1629
const INDENT: &str = " ";
1730

18-
/// Concepts:
19-
/// - Resource: some setup that needs to be tracked and maintained.
20-
/// - Setup State: current state of a resource.
21-
/// - Staging Change: states changes that may not be really applied yet.
22-
/// - Combined Setup State: Setup State + Staging Change.
23-
/// - Status Check: information about changes that are being applied / need to be applied.
24-
///
25-
/// Resource hierarchy:
26-
/// - [resource: setup metadata table] /// - Flow
27-
/// - [resource: metadata]
28-
/// - [resource: tracking table]
29-
/// - Target
30-
/// - [resource: target-specific stuff]
31-
3231
pub trait StateMode: Clone + Copy {
3332
type State<T: Debug + Clone>: Debug + Clone;
3433
type DefaultState<T: Debug + Clone + Default>: Debug + Clone + Default;

0 commit comments

Comments
 (0)