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 {
}
impl <I, V>Index<I, V> {
pub async fn new(file_name: &str) -> Result<Index<I, V>> {
impl <K, V>Index<K, V> {
pub async fn new(file_name: &str) -> Result<Index<K, V>> {
todo!()
}
pub async fn connect(file_name: &str) -> Result<Index<I, V>> {
pub async fn connect(file_name: &str) -> Result<Index<K, V>> {
todo!()
}
// 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!()
}
// Loads the index into memory
pub async fn wake() -> Result<Index<I, V>> {
pub async fn wake() -> Result<Index<K, V>> {
todo!()
}
pub async fn insert() -> Result<()>
where I: Encode, V: Encode
where K: Encode, V: Encode
{
todo!()
}
pub async fn lookup(&mut self, k: I) -> Result<Option<V>>
where I: Encode + Decode,
pub async fn lookup(&mut self, k: K) -> Result<Option<V>>
where K: Encode + Decode,
{
todo!()
}
pub async fn delete(&mut self, k: I) -> Result<Option<V>> {
pub async fn delete(&mut self, k: K) -> Result<Option<V>> {
todo!()
}
}

View file

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