mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
chore: Remove useless Fst
prefixes
This commit is contained in:
parent
5c76cd61f5
commit
593758c6d2
@ -12,7 +12,7 @@ use std::io::{BufReader, BufRead};
|
|||||||
|
|
||||||
use serde_json::from_str;
|
use serde_json::from_str;
|
||||||
|
|
||||||
use raptor::{FstMapBuilder, FstMap};
|
use raptor::{MapBuilder, Map};
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct Product {
|
struct Product {
|
||||||
@ -41,7 +41,7 @@ fn main() {
|
|||||||
set
|
set
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut builder = FstMapBuilder::new();
|
let mut builder = MapBuilder::new();
|
||||||
for line in data.lines() {
|
for line in data.lines() {
|
||||||
let line = line.unwrap();
|
let line = line.unwrap();
|
||||||
|
|
||||||
@ -65,5 +65,5 @@ fn main() {
|
|||||||
let (map, values) = builder.build(map, values).unwrap();
|
let (map, values) = builder.build(map, values).unwrap();
|
||||||
|
|
||||||
eprintln!("Checking the dump consistency...");
|
eprintln!("Checking the dump consistency...");
|
||||||
unsafe { FstMap::<u64>::from_paths("map.fst", "values.vecs").unwrap() };
|
unsafe { Map::<u64>::from_paths("map.fst", "values.vecs").unwrap() };
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,7 @@ extern crate tokio_proto;
|
|||||||
extern crate tokio_service;
|
extern crate tokio_service;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
|
||||||
use std::io;
|
use std::{io, fs};
|
||||||
use std::path::Path;
|
|
||||||
use std::fs::{self, File};
|
|
||||||
use std::io::{Read, BufReader};
|
|
||||||
|
|
||||||
use fst::Streamer;
|
use fst::Streamer;
|
||||||
use futures::future;
|
use futures::future;
|
||||||
@ -20,15 +17,15 @@ use tokio_minihttp::{Request, Response, Http};
|
|||||||
use tokio_proto::TcpServer;
|
use tokio_proto::TcpServer;
|
||||||
use tokio_service::Service;
|
use tokio_service::Service;
|
||||||
|
|
||||||
use raptor::{FstMap, OpWithStateBuilder};
|
use raptor::{Map, OpWithStateBuilder};
|
||||||
|
|
||||||
static mut MAP: Option<FstMap<u64>> = None;
|
static mut MAP: Option<Map<u64>> = None;
|
||||||
static mut LEV_BUILDER_0: Option<LevBuilder> = None;
|
static mut LEV_BUILDER_0: Option<LevBuilder> = None;
|
||||||
static mut LEV_BUILDER_1: Option<LevBuilder> = None;
|
static mut LEV_BUILDER_1: Option<LevBuilder> = None;
|
||||||
static mut LEV_BUILDER_2: Option<LevBuilder> = None;
|
static mut LEV_BUILDER_2: Option<LevBuilder> = None;
|
||||||
|
|
||||||
struct MainService<'a> {
|
struct MainService<'a> {
|
||||||
map: &'a FstMap<u64>,
|
map: &'a Map<u64>,
|
||||||
lev_builder_0: &'a LevBuilder,
|
lev_builder_0: &'a LevBuilder,
|
||||||
lev_builder_1: &'a LevBuilder,
|
lev_builder_1: &'a LevBuilder,
|
||||||
lev_builder_2: &'a LevBuilder,
|
lev_builder_2: &'a LevBuilder,
|
||||||
@ -109,7 +106,7 @@ fn main() {
|
|||||||
let map = fs::read("map.fst").unwrap();
|
let map = fs::read("map.fst").unwrap();
|
||||||
let values = fs::read("values.vecs").unwrap();
|
let values = fs::read("values.vecs").unwrap();
|
||||||
|
|
||||||
Some(FstMap::from_bytes(map, &values).unwrap())
|
Some(Map::from_bytes(map, &values).unwrap())
|
||||||
};
|
};
|
||||||
LEV_BUILDER_0 = Some(LevBuilder::new(0, false));
|
LEV_BUILDER_0 = Some(LevBuilder::new(0, false));
|
||||||
LEV_BUILDER_1 = Some(LevBuilder::new(1, false));
|
LEV_BUILDER_1 = Some(LevBuilder::new(1, false));
|
||||||
|
@ -3,16 +3,15 @@ extern crate bincode;
|
|||||||
extern crate fst;
|
extern crate fst;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
|
|
||||||
mod fst_map;
|
mod map;
|
||||||
|
|
||||||
use fst::Automaton;
|
use fst::Automaton;
|
||||||
|
|
||||||
pub use self::fst_map::{FstMap, FstMapBuilder};
|
pub use self::map::{Map, MapBuilder, Values};
|
||||||
pub use self::fst_map::{
|
pub use self::map::{
|
||||||
OpBuilder, IndexedValues,
|
OpBuilder, IndexedValues,
|
||||||
OpWithStateBuilder, IndexedValuesWithState,
|
OpWithStateBuilder, IndexedValuesWithState,
|
||||||
};
|
};
|
||||||
use self::fst_map::Values;
|
|
||||||
|
|
||||||
pub struct StreamBuilder<'m, 'v, T: 'v, A> {
|
pub struct StreamBuilder<'m, 'v, T: 'v, A> {
|
||||||
inner: fst::map::StreamBuilder<'m, A>,
|
inner: fst::map::StreamBuilder<'m, A>,
|
||||||
|
@ -9,12 +9,12 @@ use std::path::Path;
|
|||||||
use {StreamBuilder, Stream};
|
use {StreamBuilder, Stream};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FstMap<T> {
|
pub struct Map<T> {
|
||||||
inner: fst::Map,
|
inner: fst::Map,
|
||||||
values: Values<T>,
|
values: Values<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> FstMap<T> {
|
impl<T> Map<T> {
|
||||||
pub unsafe fn from_paths<P, Q>(map: P, values: Q) -> fst::Result<Self>
|
pub unsafe fn from_paths<P, Q>(map: P, values: Q) -> fst::Result<Self>
|
||||||
where
|
where
|
||||||
T: DeserializeOwned,
|
T: DeserializeOwned,
|
||||||
@ -63,11 +63,6 @@ impl<T> FstMap<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn op(&self) -> OpBuilder<T> {
|
|
||||||
// OpBuilder::new(&self.values).add(self.as_inner())
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn as_map(&self) -> &fst::Map {
|
pub fn as_map(&self) -> &fst::Map {
|
||||||
&self.inner
|
&self.inner
|
||||||
}
|
}
|
||||||
@ -114,14 +109,14 @@ impl<T> Values<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FstMapBuilder<T> {
|
pub struct MapBuilder<T> {
|
||||||
map: Vec<(String, u64)>,
|
map: Vec<(String, u64)>,
|
||||||
// This makes many memory indirections but it is only used
|
// This makes many memory indirections but it is only used
|
||||||
// at index time, not kept for query time.
|
// at index time, not kept for query time.
|
||||||
values: Vec<Vec<T>>,
|
values: Vec<Vec<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> FstMapBuilder<T> {
|
impl<T> MapBuilder<T> {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
map: Vec::new(),
|
map: Vec::new(),
|
||||||
@ -148,8 +143,8 @@ impl<T> FstMapBuilder<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_memory(self) -> fst::Result<FstMap<T>> {
|
pub fn build_in_memory(self) -> fst::Result<Map<T>> {
|
||||||
Ok(FstMap {
|
Ok(Map {
|
||||||
inner: fst::Map::from_iter(self.map)?,
|
inner: fst::Map::from_iter(self.map)?,
|
||||||
values: Values::new(self.values),
|
values: Values::new(self.values),
|
||||||
})
|
})
|
Loading…
Reference in New Issue
Block a user