mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
Show both database and documents database sizes
This commit is contained in:
parent
a4e0f3f724
commit
883a8109c8
@ -63,5 +63,8 @@ $('#docs-count').text(function(index, text) {
|
||||
|
||||
// Make the database a little bit easier to read
|
||||
$('#db-size').text(function(index, text) {
|
||||
return filesize(parseInt(text))
|
||||
let arr = text.split("+");
|
||||
let database_size = filesize(parseInt(arr[0]));
|
||||
let documents_size = filesize(parseInt(arr[1]));
|
||||
return `${database_size} + ${documents_size}`
|
||||
});
|
||||
|
@ -62,6 +62,7 @@ fn highlight_string(string: &str, words: &HashSet<String>) -> String {
|
||||
struct IndexTemplate {
|
||||
db_name: String,
|
||||
db_size: usize,
|
||||
docs_size: usize,
|
||||
docs_count: usize,
|
||||
}
|
||||
|
||||
@ -88,6 +89,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
// 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;
|
||||
let docs_size = File::open(opt.database.join("documents.mtbl"))?.metadata()?.len() as usize;
|
||||
let docs_count = index.number_of_documents();
|
||||
|
||||
// We run and wait on the HTTP server
|
||||
@ -99,6 +101,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
IndexTemplate {
|
||||
db_name: db_name.clone(),
|
||||
db_size,
|
||||
docs_size,
|
||||
docs_count: docs_count as usize,
|
||||
}
|
||||
});
|
||||
|
@ -185,9 +185,9 @@ impl Index {
|
||||
let mut stream = fst.search(&dfa).into_stream();
|
||||
while let Some(word) = stream.next() {
|
||||
let word = std::str::from_utf8(word)?;
|
||||
if let Some(right) = self.word_positions.get(rtxn, word)? {
|
||||
union_positions.union_with(&right);
|
||||
derived_words.push((word.as_bytes().to_vec(), right));
|
||||
if let Some(positions) = self.word_positions.get(rtxn, word)? {
|
||||
union_positions.union_with(&positions);
|
||||
derived_words.push((word.as_bytes().to_vec(), positions));
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
@ -206,7 +206,7 @@ impl Index {
|
||||
let number_of_attributes = self.number_of_attributes(rtxn)?.map_or(0, |n| n as u32);
|
||||
for (i, derived_words) in words.iter().enumerate() {
|
||||
let mut union_docids = RoaringBitmap::new();
|
||||
for (word, _) in derived_words {
|
||||
for (word, _positions) in derived_words {
|
||||
for attr in 0..number_of_attributes {
|
||||
let mut key = word.to_vec();
|
||||
key.extend_from_slice(&attr.to_be_bytes());
|
||||
|
@ -81,11 +81,10 @@ impl<'a> Iterator for QueryTokens<'a> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use QueryToken::{Quoted, Free};
|
||||
|
||||
#[test]
|
||||
fn one_quoted_string() {
|
||||
use QueryToken::Quoted;
|
||||
|
||||
let mut iter = QueryTokens::new("\"hello\"");
|
||||
assert_eq!(iter.next(), Some(Quoted("hello")));
|
||||
assert_eq!(iter.next(), None);
|
||||
@ -93,8 +92,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn one_pending_quoted_string() {
|
||||
use QueryToken::Quoted;
|
||||
|
||||
let mut iter = QueryTokens::new("\"hello");
|
||||
assert_eq!(iter.next(), Some(Quoted("hello")));
|
||||
assert_eq!(iter.next(), None);
|
||||
@ -102,8 +99,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn one_non_quoted_string() {
|
||||
use QueryToken::Free;
|
||||
|
||||
let mut iter = QueryTokens::new("hello");
|
||||
assert_eq!(iter.next(), Some(Free("hello")));
|
||||
assert_eq!(iter.next(), None);
|
||||
@ -111,8 +106,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn quoted_directly_followed_by_free_strings() {
|
||||
use QueryToken::{Quoted, Free};
|
||||
|
||||
let mut iter = QueryTokens::new("\"hello\"world");
|
||||
assert_eq!(iter.next(), Some(Quoted("hello")));
|
||||
assert_eq!(iter.next(), Some(Free("world")));
|
||||
@ -121,8 +114,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn free_directly_followed_by_quoted_strings() {
|
||||
use QueryToken::{Quoted, Free};
|
||||
|
||||
let mut iter = QueryTokens::new("hello\"world\"");
|
||||
assert_eq!(iter.next(), Some(Free("hello")));
|
||||
assert_eq!(iter.next(), Some(Quoted("world")));
|
||||
@ -131,8 +122,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn free_followed_by_quoted_strings() {
|
||||
use QueryToken::{Quoted, Free};
|
||||
|
||||
let mut iter = QueryTokens::new("hello \"world\"");
|
||||
assert_eq!(iter.next(), Some(Free("hello")));
|
||||
assert_eq!(iter.next(), Some(Quoted("world")));
|
||||
@ -141,8 +130,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn multiple_spaces_separated_strings() {
|
||||
use QueryToken::Free;
|
||||
|
||||
let mut iter = QueryTokens::new("hello world ");
|
||||
assert_eq!(iter.next(), Some(Free("hello")));
|
||||
assert_eq!(iter.next(), Some(Free("world")));
|
||||
@ -151,8 +138,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn multi_interleaved_quoted_free_strings() {
|
||||
use QueryToken::{Quoted, Free};
|
||||
|
||||
let mut iter = QueryTokens::new("hello \"world\" coucou \"monde\"");
|
||||
assert_eq!(iter.next(), Some(Free("hello")));
|
||||
assert_eq!(iter.next(), Some(Quoted("world")));
|
||||
@ -160,4 +145,13 @@ mod tests {
|
||||
assert_eq!(iter.next(), Some(Quoted("monde")));
|
||||
assert_eq!(iter.next(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multi_quoted_strings() {
|
||||
let mut iter = QueryTokens::new("\"hello world\" coucou \"monde est beau\"");
|
||||
assert_eq!(iter.next(), Some(Quoted("hello world")));
|
||||
assert_eq!(iter.next(), Some(Free("coucou")));
|
||||
assert_eq!(iter.next(), Some(Quoted("monde est beau")));
|
||||
assert_eq!(iter.next(), None);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<p class="heading">Database Size</p>
|
||||
<p class="title" id="db-size">{{ db_size }}</p>
|
||||
<p class="title" id="db-size">{{ db_size }} + {{ docs_size }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-item has-text-centered">
|
||||
|
Loading…
Reference in New Issue
Block a user