store/index: remove unused get_key_by_uuid and node_count
Speculative helpers that were never called. Easy to re-add if needed. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
5877fd857a
commit
c9b51c941e
1 changed files with 1 additions and 19 deletions
|
|
@ -8,7 +8,7 @@
|
||||||
// To read a node: lookup offset in redb, seek in capnp file, deserialize.
|
// To read a node: lookup offset in redb, seek in capnp file, deserialize.
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use redb::{Database, ReadableDatabase, ReadableTable, ReadableTableMetadata, TableDefinition};
|
use redb::{Database, ReadableDatabase, ReadableTable, TableDefinition};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
// Table definitions - nodes maps key to byte offset in capnp log
|
// Table definitions - nodes maps key to byte offset in capnp log
|
||||||
|
|
@ -59,17 +59,6 @@ pub fn contains_key(db: &Database, key: &str) -> Result<bool> {
|
||||||
Ok(table.get(key)?.is_some())
|
Ok(table.get(key)?.is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get key by uuid from redb.
|
|
||||||
pub fn get_key_by_uuid(db: &Database, uuid: &[u8; 16]) -> Result<Option<String>> {
|
|
||||||
let txn = db.begin_read()?;
|
|
||||||
let table = txn.open_table(UUID_TO_KEY)?;
|
|
||||||
|
|
||||||
match table.get(uuid.as_slice())? {
|
|
||||||
Some(key) => Ok(Some(key.value().to_string())),
|
|
||||||
None => Ok(None),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove a node from the index.
|
/// Remove a node from the index.
|
||||||
pub fn remove_node(db: &Database, key: &str, uuid: &[u8; 16]) -> Result<()> {
|
pub fn remove_node(db: &Database, key: &str, uuid: &[u8; 16]) -> Result<()> {
|
||||||
let txn = db.begin_write()?;
|
let txn = db.begin_write()?;
|
||||||
|
|
@ -84,13 +73,6 @@ pub fn remove_node(db: &Database, key: &str, uuid: &[u8; 16]) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Count nodes in the index.
|
|
||||||
pub fn node_count(db: &Database) -> Result<u64> {
|
|
||||||
let txn = db.begin_read()?;
|
|
||||||
let table = txn.open_table(NODES)?;
|
|
||||||
Ok(table.len()?)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Collect all keys from the index.
|
/// Collect all keys from the index.
|
||||||
pub fn all_keys(db: &Database) -> Result<Vec<String>> {
|
pub fn all_keys(db: &Database) -> Result<Vec<String>> {
|
||||||
let txn = db.begin_read()?;
|
let txn = db.begin_read()?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue