This commit is contained in:
Yuriy Dupyn 2024-02-02 20:45:18 +01:00
parent 3076bcd83e
commit 85ef52dfb4
2 changed files with 13 additions and 9 deletions

View file

@ -31,38 +31,38 @@ pub struct Index<K, V> {
pub struct IndexHeader { pub struct IndexHeader {
} }
impl <I, V>Index<I, V> { impl <K, V>Index<K, V> {
pub async fn new(file_name: &str) -> Result<Index<I, V>> { pub async fn new(file_name: &str) -> Result<Index<K, V>> {
todo!() todo!()
} }
pub async fn connect(file_name: &str) -> Result<Index<I, V>> { pub async fn connect(file_name: &str) -> Result<Index<K, V>> {
todo!() todo!()
} }
// Saves the in-memory index to disk and deallocates. // Saves the in-memory index to disk and deallocates.
pub async fn sleep() -> Result<Index<I, V>> { pub async fn sleep() -> Result<Index<K, V>> {
todo!() todo!()
} }
// Loads the index into memory // Loads the index into memory
pub async fn wake() -> Result<Index<I, V>> { pub async fn wake() -> Result<Index<K, V>> {
todo!() todo!()
} }
pub async fn insert() -> Result<()> pub async fn insert() -> Result<()>
where I: Encode, V: Encode where K: Encode, V: Encode
{ {
todo!() todo!()
} }
pub async fn lookup(&mut self, k: I) -> Result<Option<V>> pub async fn lookup(&mut self, k: K) -> Result<Option<V>>
where I: Encode + Decode, where K: Encode + Decode,
{ {
todo!() todo!()
} }
pub async fn delete(&mut self, k: I) -> Result<Option<V>> { pub async fn delete(&mut self, k: K) -> Result<Option<V>> {
todo!() todo!()
} }
} }

View file

@ -22,6 +22,8 @@ pub type FilePosition = u64;
pub struct Store<T> { pub struct Store<T> {
table_folder: String, table_folder: String,
file: File, file: File,
// primary_index: Vec<Index<T, FilePosition>>>,
// indexes: Vec<Option<Index<T, HashSet<FilePosition>>>>,
header: StoreHeader, header: StoreHeader,
data_type: PhantomData<T>, data_type: PhantomData<T>,
@ -189,6 +191,8 @@ impl <T>Store<T> {
}; };
let encoded_header: Vec<u8> = header.encode()?; let encoded_header: Vec<u8> = header.encode()?;
// Index::new<T, FilePosition>(format!("rows", primary_column.to_string()))
let mut store = Self { let mut store = Self {
table_folder: table_folder.to_string(), table_folder: table_folder.to_string(),
file, file,