Fast lint pass
cantine* is only used by me, not paying much attention to this
- Id
- da81cec553c1a5de18fb4f1fe6413fba38522d54
- Author
- Caio
- Commit time
- 2021-09-11T09:23:47+02:00
Modified cantine/Cargo.toml
memmap = "0.7"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
-tantivy = "0.15"
+tantivy = "0.16"
uuid = { version = "0.8", features = ["serde"] }
zerocopy = "0.5"
Modified cantine_derive/Cargo.toml
[dependencies]
cantine_derive_internal = { path = "./internal" }
serde = { version = "1.0" }
-tantivy = "0.15"
+tantivy = "0.16"
[dev-dependencies]
serde = { version = "1.0", features = ["derive"] }
Modified cantine/src/index.rs
move |doc| bincode::deserialize(features_reader.get_bytes(doc)).ok()
});
- Ok(searcher.search(query, &collector)?)
+ searcher.search(query, &collector)
}
fn render<T, C>(
Modified cantine/src/main.rs
use std::{convert::TryFrom, env, io, path::Path, str::FromStr, sync::Arc};
-use env_logger;
use serde::Serialize;
use tique::QueryParser;
use uuid::Uuid;
});
Ok(HttpResponse::Ok().json(SearchResult {
- total_found,
items,
- next,
+ total_found,
agg,
+ next,
}))
}
Modified cantine/src/model.rs
base64::decode_config_slice(input, URL_SAFE_NO_PAD, &mut decode_buf[..])
.map_err(|_| Error::custom("base64_decode failed"))?;
- SearchCursor::from_bytes(&decode_buf.try_into().expect("Slice has correct length"))
- .map_err(|_| Error::custom("invalid payload"))
+ SearchCursor::from_bytes(&decode_buf).map_err(|_| Error::custom("invalid payload"))
}
}
TestResult::discard()
} else {
let visitor = SearchCursorVisitor;
- visitor.visit_bytes::<serde_json::Error>(input.as_slice().try_into().unwrap());
+ visitor.visit_bytes::<serde_json::Error>(input.as_slice());
TestResult::passed()
}
}
Modified cantine/tests/index_integration.rs
-use serde_json;
-
use once_cell::sync::Lazy;
use std::cmp::Ordering;
use std::collections::{HashMap, HashSet};
Modified cantine_derive/tests/aggregation_query.rs
-use bincode;
-
use serde::{Deserialize, Serialize};
use tantivy::{query::AllQuery, schema::SchemaBuilder, Document, Index, SegmentReader};
Modified cantine/src/bin/check_sim.rs
thread::spawn,
};
-use crossbeam_channel;
use tantivy::{schema::Term, Index, Result};
use cantine::{
.flatten()
.expect("ids are valid and db is healthy");
- let mut input = Vec::new();
+ let mut input = vec![recipe.name.as_str()];
- input.push(recipe.name.as_str());
for ingredient in &recipe.ingredients {
input.push(ingredient.as_str());
}
Modified cantine/src/bin/load.rs
};
use crossbeam_channel::unbounded;
-use env_logger;
-use serde_json;
use tantivy::{self, directory::MmapDirectory, schema::SchemaBuilder, Index, Result};
let num_producers = get_usize_from_env_or(NUM_PRODUCERS, 4);
let options = LoadOptions {
- output_dir,
buffer_size,
commit_every,
num_producers,
+ output_dir,
};
load(options)
Modified cantine_derive/internal/src/lib.rs
Fields::Named(ref fields) => Ok(fields
.named
.iter()
- .filter(|field| match &field.vis {
- Visibility::Public(_) => true,
- _ => false,
- })
+ .filter(|field| matches!(&field.vis, Visibility::Public(_)))
.collect()),
_ => Err(Error::BadInput),
},
let quoted = format!("{}", &field_name);
let method = match field.schema {
- FieldType::UNSIGNED => quote!(add_u64_field),
- FieldType::SIGNED => quote!(add_i64_field),
- FieldType::FLOAT => quote!(add_f64_field),
+ FieldType::Unsigned => quote!(add_u64_field),
+ FieldType::Signed => quote!(add_i64_field),
+ FieldType::Float => quote!(add_f64_field),
};
quote_spanned! { field.span()=>
let name = field.ident;
let (from_code, query_code) = match field.schema {
- FieldType::UNSIGNED => (
+ FieldType::Unsigned => (
quote!(u64::from),
quote!(tantivy::query::RangeQuery::new_u64),
),
- FieldType::SIGNED => (
+ FieldType::Signed => (
quote!(i64::from),
quote!(tantivy::query::RangeQuery::new_i64),
),
- FieldType::FLOAT => (
+ FieldType::Float => (
quote!(f64::from),
quote!(tantivy::query::RangeQuery::new_f64),
),
}
} else {
match field.schema {
- FieldType::UNSIGNED => quote_spanned! { field.span()=>
+ FieldType::Unsigned => quote_spanned! { field.span()=>
let value = u64::from(value);
},
- FieldType::SIGNED => quote_spanned! { field.span()=>
+ FieldType::Signed => quote_spanned! { field.span()=>
let value = i64::from(value);
},
- FieldType::FLOAT => quote_spanned! { field.span()=>
+ FieldType::Float => quote_spanned! { field.span()=>
let value = f64::from(value);
},
}
};
let add_code = match field.schema {
- FieldType::UNSIGNED => quote!(doc.add_u64(self.#name, value);),
- FieldType::SIGNED => quote!(doc.add_i64(self.#name, value);),
- FieldType::FLOAT => quote!(doc.add_f64(self.#name, value);),
+ FieldType::Unsigned => quote!(doc.add_u64(self.#name, value);),
+ FieldType::Signed => quote!(doc.add_i64(self.#name, value);),
+ FieldType::Float => quote!(doc.add_f64(self.#name, value);),
};
if field.is_optional {
}
enum FieldType {
- UNSIGNED,
- SIGNED,
- FLOAT,
+ Unsigned,
+ Signed,
+ Float,
}
fn get_field_type(ty: &Type) -> Option<(FieldType, bool)> {
match ty {
Type::Path(tp) if tp.path.segments.len() == 1 => {
match tp.path.segments.first()?.ident.to_string().as_str() {
- "u64" => Some((FieldType::UNSIGNED, true)),
- "u8" | "u16" | "u32" => Some((FieldType::UNSIGNED, false)),
+ "u64" => Some((FieldType::Unsigned, true)),
+ "u8" | "u16" | "u32" => Some((FieldType::Unsigned, false)),
- "i64" => Some((FieldType::SIGNED, true)),
- "i8" | "i16" | "i32" => Some((FieldType::SIGNED, false)),
+ "i64" => Some((FieldType::Signed, true)),
+ "i8" | "i16" | "i32" => Some((FieldType::Signed, false)),
- "f64" => Some((FieldType::FLOAT, true)),
- "f32" => Some((FieldType::FLOAT, false)),
+ "f64" => Some((FieldType::Float, true)),
+ "f32" => Some((FieldType::Float, false)),
_ => None,
}
}