Skip to content

Commit

Permalink
Remove unused datastore traits
Browse files Browse the repository at this point in the history
We previously anticipated factoring the database in such a way that
the typed vs untyped distinctions, and the transactional vs not,
semantics would be more visible. We have not used these distinctions
and no longer need to expose these traits.
  • Loading branch information
kulakowski committed Aug 8, 2023
1 parent dec2955 commit b4b5adf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 109 deletions.
108 changes: 0 additions & 108 deletions crates/core/src/db/datastore/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,24 +316,10 @@ pub struct TxData {
pub(crate) records: Vec<TxRecord>,
}

pub trait Blob {
fn view(&self) -> &[u8];
}

pub trait Data: Into<ProductValue> {
fn view(&self) -> &ProductValue;
}

pub trait BlobRow: Send + Sync {
type TableId: Copy;
type RowId: Copy;

type Blob: Blob;
type BlobRef: Clone;

fn blob_to_owned(&self, blob_ref: Self::BlobRef) -> Self::Blob;
}

pub trait DataRow: Send + Sync {
type RowId: Copy;

Expand All @@ -358,100 +344,6 @@ pub trait MutTx {
fn commit_mut_tx(&self, tx: Self::MutTxId) -> Result<Option<TxData>>;
}

pub trait Blobstore: BlobRow {
type Iter<'a>: Iterator<Item = Self::BlobRef>
where
Self: 'a;

fn iter_blobs(&self, table_id: TableId) -> Result<Self::Iter<'_>>;

fn get_blob(&self, table_id: TableId, row_id: Self::RowId) -> Result<Option<Self::BlobRef>>;
}

pub trait MutBlobstore: Blobstore {
fn delete_blob(&self, table_id: TableId, row_id: Self::RowId) -> Result<()>;

fn insert_blob(&self, table_id: TableId, row: &[u8]) -> Result<Self::RowId>;
}

pub trait Datastore: DataRow {
type Iter<'a>: Iterator<Item = Self::DataRef>
where
Self: 'a;

type IterByColRange<'a, R: RangeBounds<AlgebraicValue>>: Iterator<Item = Self::DataRef>
where
Self: 'a;

type IterByColEq<'a>: Iterator<Item = Self::DataRef>
where
Self: 'a;

fn iter(&self, table_id: TableId) -> Result<Self::Iter<'_>>;

fn iter_by_col_range<R: RangeBounds<AlgebraicValue>>(
&self,
table_id: TableId,
col_id: ColId,
range: R,
) -> Result<Self::IterByColRange<'_, R>>;

fn iter_by_col_eq<'a>(
&'a self,
table_id: TableId,
col_id: ColId,
value: &'a AlgebraicValue,
) -> Result<Self::IterByColEq<'a>>;

fn get(&self, table_id: TableId, row_id: Self::RowId) -> Result<Option<Self::DataRef>>;
}

pub trait MutDatastore: Datastore {
fn delete(&self, table_id: TableId, row_id: Self::RowId) -> Result<()>;

fn insert(&self, table_id: TableId, row: ProductValue) -> Result<Self::RowId>;
}

pub trait TxBlobstore: BlobRow + Tx {
type Iter<'a>: Iterator<Item = Self::BlobRef>
where
Self: 'a;

fn iter_blobs_tx<'a>(&'a self, tx: &'a Self::TxId, table_id: TableId) -> Result<Self::Iter<'a>>;

fn get_blob_tx<'a>(
&'a self,
tx: &'a Self::TxId,
table_id: TableId,
row_id: Self::RowId,
) -> Result<Option<Self::BlobRef>>;
}

pub trait MutTxBlobstore: TxBlobstore + MutTx {
fn iter_blobs_mut_tx<'a>(&'a self, tx: &'a Self::MutTxId, table_id: TableId) -> Result<Self::Iter<'a>>;

fn get_blob_mut_tx<'a>(
&'a self,
tx: &'a Self::MutTxId,
table_id: TableId,
row_id: Self::RowId,
) -> Result<Option<Self::BlobRef>>;

fn delete_blob_mut_tx<'a>(
&'a self,
tx: &'a mut Self::MutTxId,
table_id: TableId,
row_id: Self::RowId,
) -> Result<()>;

fn insert_blob_mut_tx<'a>(
&'a self,
tx: &'a mut Self::MutTxId,
table_id: TableId,
row: &[u8],
) -> Result<Self::RowId>;
}

pub trait TxDatastore: DataRow + Tx {
type Iter<'a>: Iterator<Item = Self::DataRef>
where
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/db/relational_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl RelationalDB {
last_commit_offset = Some(commit.commit_offset);
for transaction in commit.transactions {
transaction_offset += 1;
// NOTE: Although I am creating a blobstore transaction in a
// NOTE: Although I am creating a datastore transaction in a
// one to one fashion for each message log transaction, this
// is just to reduce memory usage while inserting. We don't
// really care about inserting these transactionally as long
Expand Down

0 comments on commit b4b5adf

Please sign in to comment.