Skip to content

Commit 2f7b147

Browse files
authored
chore: Some Clippy fixes (#305)
* chore: Clippy fixes Signed-off-by: Anush008 <[email protected]> * refactor: &Vec<AnalyzedGraphFieldMapping> to &[AnalyzedGraphFieldMapping] Signed-off-by: Anush008 <[email protected]> * Update storages.md --------- Signed-off-by: Anush008 <[email protected]>
1 parent e5ada33 commit 2f7b147

File tree

14 files changed

+51
-49
lines changed

14 files changed

+51
-49
lines changed

docs/docs/ops/storages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ doc_embeddings.export(
3636
"doc_embeddings",
3737
cocoindex.storages.Qdrant(
3838
collection_name="cocoindex",
39-
grpc_url="http://xyz-example.cloud-region.cloud-provider.cloud.qdrant.io:6334/",
39+
grpc_url="https://xyz-example.cloud-region.cloud-provider.cloud.qdrant.io:6334/",
4040
api_key="<your-api-key-here>",
4141
),
4242
primary_key_fields=["id_field"],

src/execution/live_updater.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl FlowLiveUpdater {
202202
)
203203
.map(|(import_op, stats)| stats::SourceUpdateInfo {
204204
source_name: import_op.name.clone(),
205-
stats: (&**stats).clone(),
205+
stats: (**stats).clone(),
206206
})
207207
.collect(),
208208
}

src/execution/memoization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl EvaluationMemory {
112112
}),
113113
uuids: Mutex::new(
114114
(!options.evaluation_only)
115-
.then(|| stored_uuids)
115+
.then_some(stored_uuids)
116116
.flatten()
117117
.into_iter()
118118
.flat_map(|iter| iter.into_iter())

src/execution/row_indexer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ pub async fn update_source_row(
502502
if existing_version.should_skip(source_version, Some(update_stats)) {
503503
return Ok(SkippedOr::Skipped(existing_version));
504504
}
505-
info.memoization_info.map(|info| info.0).flatten()
505+
info.memoization_info.and_then(|info| info.0)
506506
}
507507
None => Default::default(),
508508
};

src/execution/source_indexer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl SourceIndexingContext {
177177
row_state.touched_generation = scan_generation;
178178
if row_state
179179
.source_version
180-
.should_skip(&source_version, Some(&update_stats))
180+
.should_skip(&source_version, Some(update_stats))
181181
{
182182
return None;
183183
}

src/ops/interface.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ pub struct FlowInstanceContext {
1818
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
1919
pub struct Ordinal(pub i64);
2020

21-
impl Into<i64> for Ordinal {
22-
fn into(self) -> i64 {
23-
self.0
21+
impl From<Ordinal> for i64 {
22+
fn from(val: Ordinal) -> Self {
23+
val.0
2424
}
2525
}
2626

@@ -68,10 +68,10 @@ pub struct SourceExecutorListOptions {
6868
#[async_trait]
6969
pub trait SourceExecutor: Send + Sync {
7070
/// Get the list of keys for the source.
71-
fn list<'a>(
72-
&'a self,
71+
fn list(
72+
&self,
7373
options: SourceExecutorListOptions,
74-
) -> BoxStream<'a, Result<Vec<SourceRowMetadata>>>;
74+
) -> BoxStream<'_, Result<Vec<SourceRowMetadata>>>;
7575

7676
// Get the value for the given key.
7777
async fn get_value(&self, key: &KeyValue) -> Result<Option<FieldValues>>;

src/ops/sdk.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'a> StructSchemaBuilder<'a> {
7676
}
7777
}
7878

79-
pub fn set_description(&mut self, description: impl Into<Arc<str>>) {
79+
pub fn _set_description(&mut self, description: impl Into<Arc<str>>) {
8080
self.target.description = Some(description.into());
8181
}
8282

@@ -88,12 +88,12 @@ impl<'a> StructSchemaBuilder<'a> {
8888
SchemaBuilderFieldRef(AnalyzedLocalFieldReference { fields_idx })
8989
}
9090

91-
pub fn add_struct_field<'b>(
92-
&'b mut self,
91+
pub fn _add_struct_field(
92+
&mut self,
9393
name: impl Into<FieldName>,
9494
nullable: bool,
9595
attrs: Arc<BTreeMap<String, serde_json::Value>>,
96-
) -> (StructSchemaBuilder<'b>, SchemaBuilderFieldRef) {
96+
) -> (StructSchemaBuilder<'_>, SchemaBuilderFieldRef) {
9797
let field_schema = FieldSchema::new(
9898
name.into(),
9999
EnrichedValueType {

src/ops/sources/google_drive.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl Executor {
145145
None
146146
} else if is_supported_file_type(&mime_type) {
147147
Some(SourceRowMetadata {
148-
key: KeyValue::Str(Arc::from(id)),
148+
key: KeyValue::Str(id),
149149
ordinal: file.modified_time.map(|t| t.try_into()).transpose()?,
150150
})
151151
} else {
@@ -294,10 +294,10 @@ impl<T> ResultExt<T> for google_drive3::Result<T> {
294294

295295
#[async_trait]
296296
impl SourceExecutor for Executor {
297-
fn list<'a>(
298-
&'a self,
297+
fn list(
298+
&self,
299299
options: SourceExecutorListOptions,
300-
) -> BoxStream<'a, Result<Vec<SourceRowMetadata>>> {
300+
) -> BoxStream<'_, Result<Vec<SourceRowMetadata>>> {
301301
let mut seen_ids = HashSet::new();
302302
let mut folder_ids = self.root_folder_ids.clone();
303303
let fields = format!(

src/ops/sources/local_file.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ impl Executor {
4040

4141
#[async_trait]
4242
impl SourceExecutor for Executor {
43-
fn list<'a>(
44-
&'a self,
43+
fn list(
44+
&self,
4545
options: SourceExecutorListOptions,
46-
) -> BoxStream<'a, Result<Vec<SourceRowMetadata>>> {
46+
) -> BoxStream<'_, Result<Vec<SourceRowMetadata>>> {
4747
let root_component_size = self.root_path.components().count();
4848
let mut dirs = Vec::new();
4949
dirs.push(Cow::Borrowed(&self.root_path));

src/ops/storages/neo4j.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ struct RelationshipStorageExecutor {
149149

150150
fn json_value_to_bolt_value(value: &serde_json::Value) -> Result<BoltType> {
151151
let bolt_value = match value {
152-
serde_json::Value::Null => BoltType::Null(neo4rs::BoltNull::default()),
152+
serde_json::Value::Null => BoltType::Null(neo4rs::BoltNull),
153153
serde_json::Value::Bool(v) => BoltType::Boolean(neo4rs::BoltBoolean::new(*v)),
154154
serde_json::Value::Number(v) => {
155155
if let Some(i) = v.as_i64() {
@@ -163,7 +163,7 @@ fn json_value_to_bolt_value(value: &serde_json::Value) -> Result<BoltType> {
163163
serde_json::Value::String(v) => BoltType::String(neo4rs::BoltString::new(v)),
164164
serde_json::Value::Array(v) => BoltType::List(neo4rs::BoltList {
165165
value: v
166-
.into_iter()
166+
.iter()
167167
.map(json_value_to_bolt_value)
168168
.collect::<Result<_>>()?,
169169
}),
@@ -220,7 +220,7 @@ fn basic_value_to_bolt(value: &BasicValue, schema: &BasicValueType) -> Result<Bo
220220
BasicValue::Bytes(v) => {
221221
BoltType::Bytes(neo4rs::BoltBytes::new(bytes::Bytes::from_owner(v.clone())))
222222
}
223-
BasicValue::Str(v) => BoltType::String(neo4rs::BoltString::new(&v)),
223+
BasicValue::Str(v) => BoltType::String(neo4rs::BoltString::new(v)),
224224
BasicValue::Bool(v) => BoltType::Boolean(neo4rs::BoltBoolean::new(*v)),
225225
BasicValue::Int64(v) => BoltType::Integer(neo4rs::BoltInteger::new(*v)),
226226
BasicValue::Float64(v) => BoltType::Float(neo4rs::BoltFloat::new(*v)),
@@ -242,7 +242,7 @@ fn basic_value_to_bolt(value: &BasicValue, schema: &BasicValueType) -> Result<Bo
242242
BasicValue::Vector(v) => match schema {
243243
BasicValueType::Vector(t) => BoltType::List(neo4rs::BoltList {
244244
value: v
245-
.into_iter()
245+
.iter()
246246
.map(|v| basic_value_to_bolt(v, &t.element_type))
247247
.collect::<Result<_>>()?,
248248
}),
@@ -255,9 +255,9 @@ fn basic_value_to_bolt(value: &BasicValue, schema: &BasicValueType) -> Result<Bo
255255

256256
fn value_to_bolt(value: &Value, schema: &schema::ValueType) -> Result<BoltType> {
257257
let bolt_value = match value {
258-
Value::Null => BoltType::Null(neo4rs::BoltNull::default()),
258+
Value::Null => BoltType::Null(neo4rs::BoltNull),
259259
Value::Basic(v) => match schema {
260-
ValueType::Basic(t) => basic_value_to_bolt(v, &t)?,
260+
ValueType::Basic(t) => basic_value_to_bolt(v, t)?,
261261
_ => anyhow::bail!("Non-basic type got basic value: {}", schema),
262262
},
263263
Value::Struct(v) => match schema {
@@ -267,7 +267,7 @@ fn value_to_bolt(value: &Value, schema: &schema::ValueType) -> Result<BoltType>
267267
Value::Collection(v) | Value::List(v) => match schema {
268268
ValueType::Collection(t) => BoltType::List(neo4rs::BoltList {
269269
value: v
270-
.into_iter()
270+
.iter()
271271
.map(|v| field_values_to_bolt(v.0.fields.iter(), t.row.fields.iter()))
272272
.collect::<Result<_>>()?,
273273
}),
@@ -276,7 +276,7 @@ fn value_to_bolt(value: &Value, schema: &schema::ValueType) -> Result<BoltType>
276276
Value::Table(v) => match schema {
277277
ValueType::Collection(t) => BoltType::List(neo4rs::BoltList {
278278
value: v
279-
.into_iter()
279+
.iter()
280280
.map(|(k, v)| {
281281
field_values_to_bolt(
282282
std::iter::once(&Into::<value::Value>::into(k.clone()))
@@ -632,7 +632,7 @@ impl RelationshipSetupState {
632632
spec: &RelationshipSpec,
633633
key_field_names: Vec<String>,
634634
index_options: &IndexOptions,
635-
rel_value_fields_info: &Vec<AnalyzedGraphFieldMapping>,
635+
rel_value_fields_info: &[AnalyzedGraphFieldMapping],
636636
src_label_info: &AnalyzedNodeLabelInfo,
637637
tgt_label_info: &AnalyzedNodeLabelInfo,
638638
) -> Result<Self> {
@@ -681,8 +681,7 @@ impl RelationshipSetupState {
681681
} else if existing.nodes.iter().any(|(label, existing_node)| {
682682
!self
683683
.nodes
684-
.get(label)
685-
.map_or(false, |node| node.is_compatible(existing_node))
684+
.get(label).is_some_and(|node| node.is_compatible(existing_node))
686685
}) {
687686
// If any node's key field change of some node label gone, we have to clear relationship.
688687
SetupStateCompatibility::NotCompatible
@@ -747,7 +746,7 @@ impl SetupStatusCheck {
747746
.current
748747
.as_ref()
749748
.filter(|existing_current| {
750-
desired_state.as_ref().map_or(true, |desired| {
749+
desired_state.as_ref().is_none_or(|desired| {
751750
desired.check_compatible(existing_current)
752751
== SetupStateCompatibility::NotCompatible
753752
})
@@ -793,7 +792,7 @@ impl SetupStatusCheck {
793792

794793
for (index_name, vector_index) in desired_state.vector_indexes.into_iter() {
795794
old_rel_indexes.shift_remove(&index_name);
796-
if !existing.current.as_ref().map_or(false, |c| {
795+
if !existing.current.as_ref().is_some_and(|c| {
797796
Some(&vector_index) == c.vector_indexes.get(&index_name)
798797
}) {
799798
rel_index_to_create.insert(index_name, vector_index);
@@ -807,8 +806,7 @@ impl SetupStatusCheck {
807806
.as_ref()
808807
.map(|c| {
809808
c.nodes
810-
.get(&label)
811-
.map_or(false, |existing_node| node.is_compatible(existing_node))
809+
.get(&label).is_some_and(|existing_node| node.is_compatible(existing_node))
812810
})
813811
.unwrap_or(false)
814812
{
@@ -820,8 +818,8 @@ impl SetupStatusCheck {
820818

821819
for (index_name, vector_index) in node.vector_indexes.into_iter() {
822820
old_node_indexes.shift_remove(&index_name);
823-
if !existing.current.as_ref().map_or(false, |c| {
824-
c.nodes.get(&label).map_or(false, |n| {
821+
if !existing.current.as_ref().is_some_and(|c| {
822+
c.nodes.get(&label).is_some_and(|n| {
825823
Some(&vector_index) == n.vector_indexes.get(&index_name)
826824
})
827825
}) {
@@ -1189,8 +1187,8 @@ impl StorageFactoryBase for RelationshipFactory {
11891187
let mut tgt_label_analyzer = NodeLabelAnalyzer::new(&spec, &spec.target)?;
11901188
let mut rel_value_fields_info = vec![];
11911189
for (field_idx, field_schema) in value_fields_schema.iter().enumerate() {
1192-
if !src_label_analyzer.process_field(field_idx, &field_schema)
1193-
&& !tgt_label_analyzer.process_field(field_idx, &field_schema)
1190+
if !src_label_analyzer.process_field(field_idx, field_schema)
1191+
&& !tgt_label_analyzer.process_field(field_idx, field_schema)
11941192
{
11951193
rel_value_fields_info.push(AnalyzedGraphFieldMapping {
11961194
field_idx,

0 commit comments

Comments
 (0)