Server: Adds the optimize command

pull/428/head
Tpt 2 years ago committed by Thomas Tanon
parent 3d61867386
commit 23e47bcc5e
  1. 23
      server/src/main.rs

@ -192,6 +192,11 @@ enum Command {
#[arg(long)]
update_base: Option<String>,
},
/// Optimizes the database storage.
///
/// Done by default in the background when serving requests.
/// It is likely to not be useful in most of cases except if you provide a read-only SPARQL endpoint under heavy oad.
Optimize {},
}
pub fn main() -> anyhow::Result<()> {
@ -565,6 +570,15 @@ pub fn main() -> anyhow::Result<()> {
store.update(update)?;
Ok(())
}
Command::Optimize {} => {
let store = Store::open(
matches
.location
.ok_or_else(|| anyhow!("The --location argument is required"))?,
)?;
store.optimize()?;
Ok(())
}
}
}
@ -1631,7 +1645,7 @@ mod tests {
}
#[test]
fn cli_load_and_dump_graph() -> Result<()> {
fn cli_load_optimize_and_dump_graph() -> Result<()> {
let store_dir = TempDir::new()?;
let input_file = NamedTempFile::new("input.nt")?;
input_file
@ -1645,6 +1659,13 @@ mod tests {
.assert()
.success();
cli_command()?
.arg("optimize")
.arg("--location")
.arg(store_dir.path())
.assert()
.success();
let output_file = NamedTempFile::new("output.nt")?;
cli_command()?
.arg("dump")

Loading…
Cancel
Save