Alias RecipeId<=>u64
- Id
- 11ea27e5d8346a526190709c2e91787617063650
- Author
- Caio
- Commit time
- 2019-12-06T14:56:43+01:00
Modified crates/cantine/src/index.rs
use crate::model::{
FeaturesAggregationQuery, FeaturesAggregationResult, FeaturesCollector, FeaturesFilterFields,
- Recipe, SearchCursor, SearchQuery, Sort,
+ Recipe, RecipeId, SearchCursor, SearchQuery, Sort,
};
use tique::{
pub type CantineSearchResult = (
usize,
- Vec<u64>,
+ Vec<RecipeId>,
Option<SearchCursor>,
Option<FeaturesAggregationResult>,
);
})
}
- fn interpret_query(&self, query: &SearchQuery) -> Result<Box<dyn Query>> {
+ pub fn interpret_query(&self, query: &SearchQuery) -> Result<Box<dyn Query>> {
let mut subqueries: Vec<(Occur, Box<dyn Query>)> = Vec::new();
if let Some(fulltext) = &query.fulltext {
&self,
searcher: &Searcher,
addresses: &[SearchMarker<T>],
- ) -> Result<Vec<u64>> {
+ ) -> Result<Vec<RecipeId>> {
let mut items = Vec::with_capacity(addresses.len());
for addr in addresses.iter() {
limit: usize,
sort: Sort,
after: SearchCursor,
- ) -> Result<(usize, Vec<u64>, Option<SearchCursor>)> {
+ ) -> Result<(usize, Vec<RecipeId>, Option<SearchCursor>)> {
macro_rules! condition_from_score {
($score:expr) => {{
let after_score = $score;
Modified crates/cantine/src/model.rs
pub struct Recipe {
pub uuid: Uuid,
- pub recipe_id: u64,
+ pub recipe_id: RecipeId,
pub name: String,
pub crawl_url: String,
pub features: Features,
}
+
+pub type RecipeId = u64;
impl DatabaseRecord for Recipe {
fn get_id(&self) -> u64 {
// FIXME Saner serialization
#[derive(Serialize, Deserialize, Debug, Default)]
-pub struct SearchCursor(u64, u64);
+pub struct SearchCursor(u64, RecipeId);
impl SearchCursor {
pub const START: Self = Self(0, 0);
- pub fn new(score: u64, recipe_id: u64) -> Self {
+ pub fn new(score: u64, recipe_id: RecipeId) -> Self {
Self(score, recipe_id)
}
- pub fn from_f32(score: f32, recipe_id: u64) -> Self {
+ pub fn from_f32(score: f32, recipe_id: RecipeId) -> Self {
Self(score.to_bits() as u64, recipe_id)
}
self.0 == 0 && self.1 == 0
}
- pub fn recipe_id(&self) -> u64 {
+ pub fn recipe_id(&self) -> RecipeId {
self.1
}