Add which columns are indexable to store header

This commit is contained in:
Yuriy Dupyn 2024-02-04 19:00:50 +01:00
parent 4c0f91ad33
commit f2c17d2e66
5 changed files with 100 additions and 46 deletions

View file

@ -72,10 +72,6 @@ pub trait PrimitiveCursor<T> {
Ok(file_position)
}
async fn seek_to_start_of_data(&mut self) -> Result<FilePosition> {
self.seek_to(StoreHeader::SIZE as u64).await
}
// Seeks from current position by offset and returns new file position
async fn seek_by(&mut self, offset: i64) -> Result<FilePosition> {
let file_position = self.file().seek(SeekFrom::Current(offset)).await?;
@ -98,6 +94,10 @@ pub trait PrimitiveCursor<T> {
pub trait CursorWithStoreHeader<T>: PrimitiveCursor<T> {
fn header(&self) -> &StoreHeader;
async fn seek_to_start_of_data(&mut self) -> Result<FilePosition> {
self.seek_to(StoreHeader::size(self.header().number_of_columns) as u64).await
}
async fn read_entry_header(&mut self) -> Result<EntryHeaderWithDataSize> {
let number_of_columns: usize = self.header().number_of_columns;
let mut header_bytes: Vec<u8> = vec![0; EntryHeaderWithDataSize::size(number_of_columns)];
@ -349,7 +349,7 @@ impl <'cursor, T> WriteCursor<'cursor, T>
Ok(cursor)
}
pub async fn connect<'header: 'cursor>(path_to_rows: &str, header: &'header mut StoreHeader) -> Result<Self>
pub async fn connect<'header: 'cursor, 'indexes: 'cursor>(path_to_rows: &str, header: &'header mut StoreHeader, indexes: &'indexes mut Vec<Option<Index<T, FilePosition>>>) -> Result<Self>
where T: Send
{
let file: File =
@ -363,7 +363,7 @@ impl <'cursor, T> WriteCursor<'cursor, T>
header,
file,
data_type: PhantomData::<T>,
indexes: todo!(),
indexes,
eof_file_position: 0,
};
@ -485,7 +485,8 @@ impl <'cursor, T> WriteCursor<'cursor, T>
number_of_columns: self.header.number_of_columns,
deleted_count: 0,
total_count: 0,
primary_column: self.header.primary_column
primary_column: self.header.primary_column,
indexed_columns: todo!()
};
// Creates a new cursor to the intermediate file in which we'll dump the live entries.