mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-31 02:40:01 +00:00
Move the documents MTBL database inside the Index
This commit is contained in:
@ -9,7 +9,6 @@ use std::time::Instant;
|
||||
|
||||
use askama_warp::Template;
|
||||
use heed::EnvOpenOptions;
|
||||
use oxidized_mtbl::Reader;
|
||||
use serde::Deserialize;
|
||||
use slice_group_by::StrGroupBy;
|
||||
use structopt::StructOpt;
|
||||
@ -99,22 +98,13 @@ async fn main() -> anyhow::Result<()> {
|
||||
.open(&opt.database)?;
|
||||
|
||||
// Open the LMDB database.
|
||||
let index = Index::new(&env)?;
|
||||
|
||||
// Open the documents MTBL database.
|
||||
let path = opt.database.join("documents.mtbl");
|
||||
let file = File::open(path)?;
|
||||
let mmap = unsafe { memmap::Mmap::map(&file)? };
|
||||
let mmap = TransitiveArc(Arc::new(mmap));
|
||||
let documents = Reader::new(mmap)?;
|
||||
let index = Index::new(&env, &opt.database)?;
|
||||
|
||||
// Retrieve the database the file stem (w/o the extension),
|
||||
// the disk file size and the number of documents in the database.
|
||||
let db_name = opt.database.file_stem().and_then(|s| s.to_str()).unwrap_or("").to_string();
|
||||
let db_size = File::open(opt.database.join("data.mdb"))?.metadata()?.len() as usize;
|
||||
|
||||
// Retrieve the documents count.
|
||||
let docs_count = documents.metadata().count_entries;
|
||||
let docs_count = index.number_of_documents();
|
||||
|
||||
// We run and wait on the HTTP server
|
||||
|
||||
@ -198,7 +188,6 @@ async fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
let env_cloned = env.clone();
|
||||
let documents_cloned = documents.clone();
|
||||
let disable_highlighting = opt.disable_highlighting;
|
||||
let query_route = warp::filters::method::post()
|
||||
.and(warp::path!("query"))
|
||||
@ -213,13 +202,10 @@ async fn main() -> anyhow::Result<()> {
|
||||
if let Some(headers) = index.headers(&rtxn).unwrap() {
|
||||
// We write the headers
|
||||
body.extend_from_slice(headers);
|
||||
let documents = index.documents(documents_ids).unwrap();
|
||||
|
||||
for id in documents_ids {
|
||||
let id_bytes = id.to_be_bytes();
|
||||
let content = documents_cloned.clone().get(&id_bytes).unwrap();
|
||||
let content = content.expect(&format!("could not find document {}", id));
|
||||
for (_id, content) in documents {
|
||||
let content = std::str::from_utf8(content.as_ref()).unwrap();
|
||||
|
||||
let content = if disable_highlighting {
|
||||
Cow::from(content)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user