map: Increase the SmallVec size

This commit is contained in:
Kerollmops 2018-04-22 18:28:08 +02:00
parent c371fb56b7
commit f851227ed4
No known key found for this signature in database
GPG key ID: 016ACC0DC3ADC318
3 changed files with 15 additions and 17 deletions

View file

@ -53,7 +53,8 @@ fn main() {
let description = product.ft.split_whitespace().filter(|&s| s != "Description");
let words = title.chain(description)
.filter(|&s| s.chars().any(|c| c.is_alphabetic())) // remove that ?
.filter(|&s| !common_words.contains(s));
.filter(|&s| !common_words.contains(s))
.map(|s| s.to_lowercase());
for word in words {
builder.insert(word, product.product_id);
@ -64,6 +65,7 @@ fn main() {
let values = File::create("values.vecs").unwrap();
let (map, values) = builder.build(map, values).unwrap();
// just to check if the dump is valid
let map = unsafe { MultiMap::from_paths("map.fst", "values.vecs").unwrap() };
// let mut stream = map.stream();

View file

@ -13,7 +13,7 @@ use tokio_minihttp::{Request, Response, Http};
use tokio_proto::TcpServer;
use tokio_service::Service;
use raptor::{MultiMapBuilder, MultiMap};
use raptor::MultiMap;
struct MainService {
map: MultiMap,
@ -30,13 +30,14 @@ impl Service for MainService {
let url = format!("http://raptor.net{}", request.path());
let url = url::Url::parse(&url).unwrap();
let mut resp = Response::new();
if let Some((_, key)) = url.query_pairs().find(|&(ref k, _)| k == "query") {
let values = self.map.get(&*key);
println!("{:?}", values);
let key = key.to_lowercase();
let values = self.map.get(&key).map(|a| &a[..10]);
resp.body(&format!("{:?}", values));
}
let mut resp = Response::new();
resp.body("Hello, world!");
future::ok(resp)
}
}
@ -51,12 +52,7 @@ fn main() {
// closure, make it global.
// It will permit the server to be multithreaded.
let mut builder = MultiMapBuilder::new();
builder.insert("foo", 12);
builder.insert("foo", 13);
builder.insert("bar", 10);
let map = builder.build_memory().unwrap();
let map = unsafe { MultiMap::from_paths("map.fst", "values.vecs").unwrap() };
println!("Called Fn here !");