mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-28 01:01:00 +00:00
feat: Make querying always return limited results
This commit is contained in:
committed by
Clément Renault
parent
8fab80048c
commit
0ce08c8790
@ -4,10 +4,8 @@ extern crate test;
|
||||
extern crate fst;
|
||||
extern crate raptor;
|
||||
|
||||
use std::path::Path;
|
||||
use std::{fs, env, io};
|
||||
use fst::Streamer;
|
||||
use raptor::{load_map, DocIndexMap, RankedStream, LevBuilder};
|
||||
use raptor::{load_map, RankedStream, LevBuilder};
|
||||
|
||||
#[bench]
|
||||
fn chauve_souris(b: &mut test::Bencher) {
|
||||
@ -23,7 +21,7 @@ fn chauve_souris(b: &mut test::Bencher) {
|
||||
automatons.push(lev);
|
||||
}
|
||||
|
||||
let mut stream = RankedStream::new(&map, &map.values(), automatons);
|
||||
let mut stream = RankedStream::new(&map, &map.values(), automatons, 20);
|
||||
while let Some(document_id) = stream.next() {
|
||||
test::black_box(document_id);
|
||||
}
|
||||
|
@ -2,10 +2,9 @@ extern crate env_logger;
|
||||
extern crate fst;
|
||||
extern crate raptor;
|
||||
|
||||
use std::path::Path;
|
||||
use std::{fs, env, io};
|
||||
use std::env;
|
||||
use fst::Streamer;
|
||||
use raptor::{load_map, DocIndexMap, RankedStream, LevBuilder};
|
||||
use raptor::{load_map, RankedStream, LevBuilder};
|
||||
|
||||
fn main() {
|
||||
drop(env_logger::init());
|
||||
@ -24,13 +23,9 @@ fn main() {
|
||||
automatons.push(lev);
|
||||
}
|
||||
|
||||
let mut limit: Option<usize> = env::var("RAPTOR_OUTPUT_LIMIT").ok().and_then(|x| x.parse().ok());
|
||||
let mut stream = RankedStream::new(&map, map.values(), automatons);
|
||||
let limit: Option<usize> = env::var("RAPTOR_OUTPUT_LIMIT").ok().and_then(|x| x.parse().ok());
|
||||
let mut stream = RankedStream::new(&map, map.values(), automatons, limit.unwrap_or(20));
|
||||
while let Some(document_id) = stream.next() {
|
||||
if limit == Some(0) { println!("..."); break }
|
||||
|
||||
println!("{:?}", document_id);
|
||||
|
||||
if let Some(ref mut limit) = limit { *limit -= 1 }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user