Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WriteBatch type to KvStore #3308

Closed
MarkJr94 opened this issue Mar 15, 2019 · 0 comments
Closed

Add WriteBatch type to KvStore #3308

MarkJr94 opened this issue Mar 15, 2019 · 0 comments
Assignees

Comments

@MarkJr94
Copy link
Contributor

MarkJr94 commented Mar 15, 2019

Problem

To complete integration, needs to add a WriteBatch type implementing the WriteBatch [1] interface used by blocktree. This WriteBatch will also need shared access to the write-ahead log.

The Database trait is also missing a fn commit(&self, batch: Self::WriteBatch) -> Result<()> method [2].

Proposed Solution

Implement a WriteBatch type, integrate it with the store.

'Lift' the write-ahead log directly into the KvStore, put it behind an Arc and give a clone to each WriteBatch.

Add method to to trait

[1]

pub trait IWriteBatch<D: Database> {
fn put_cf(&mut self, cf: D::ColumnFamily, key: &D::KeyRef, data: &[u8]) -> Result<()>;
}

[2]
pub trait Database: Sized + Send + Sync {
type Error: Into<Error>;
type Key: Borrow<Self::KeyRef>;
type KeyRef: ?Sized;
type ColumnFamily;
type Cursor: Cursor<Self>;
type EntryIter: Iterator<Item = Entry>;
type WriteBatch: IWriteBatch<Self>;
fn cf_handle(&self, cf: &str) -> Option<Self::ColumnFamily>;
fn get_cf(&self, cf: Self::ColumnFamily, key: &Self::KeyRef) -> Result<Option<Vec<u8>>>;
fn put_cf(&self, cf: Self::ColumnFamily, key: &Self::KeyRef, data: &[u8]) -> Result<()>;
fn delete_cf(&self, cf: Self::ColumnFamily, key: &Self::KeyRef) -> Result<()>;
fn raw_iterator_cf(&self, cf: Self::ColumnFamily) -> Result<Self::Cursor>;
fn write(&self, batch: Self::WriteBatch) -> Result<()>;
fn batch(&self) -> Result<Self::WriteBatch>;
}

@MarkJr94 MarkJr94 added this to the Grandview v0.13.0 milestone Mar 15, 2019
@MarkJr94 MarkJr94 self-assigned this Mar 15, 2019
@mark-solana mark-solana assigned mark-solana and unassigned MarkJr94 Mar 18, 2019
behzadnouri pushed a commit to behzadnouri/solana that referenced this issue Oct 25, 2024
brooksprumo added a commit to brooksprumo/solana that referenced this issue Oct 25, 2024
brooksprumo added a commit to brooksprumo/solana that referenced this issue Oct 28, 2024
ryoqun pushed a commit to ryoqun/solana that referenced this issue Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants