From f369728cc783493f8f6cab921b3c609d127bf6f2 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Mon, 15 Apr 2024 23:19:55 +0200 Subject: database statistics --- base/src/database.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'base/src') diff --git a/base/src/database.rs b/base/src/database.rs index 9d29adb..7755016 100644 --- a/base/src/database.rs +++ b/base/src/database.rs @@ -12,7 +12,13 @@ use jellycommon::{ use log::info; use redb::{Database, TableDefinition}; use serde::{Deserialize, Serialize}; -use std::{borrow::Borrow, fs::create_dir_all, ops::Deref, path::Path, sync::RwLock}; +use std::{ + borrow::Borrow, + fs::create_dir_all, + ops::Deref, + path::Path, + sync::{Arc, RwLock}, +}; use tantivy::{ directory::MmapDirectory, schema::{Field, Schema, FAST, INDEXED, STORED, TEXT}, @@ -32,9 +38,10 @@ pub const T_NODE_EXTENDED: TableDefinition<&str, Ser> = pub const T_NODE_IMPORT: TableDefinition<&str, Ser, Node)>>> = TableDefinition::new("node-import"); +#[derive(Clone)] pub struct DataAcid { - pub inner: redb::Database, - pub node_index: NodeIndex, + pub inner: Arc, + pub node_index: Arc, } impl DataAcid { @@ -45,8 +52,8 @@ impl DataAcid { info!("opening node index..."); let ft_node = NodeIndex::new(path).context("in node index")?; let r = Self { - inner: db, - node_index: ft_node, + inner: db.into(), + node_index: ft_node.into(), }; { -- cgit v1.2.3-70-g09d2