read-write distinction in the tx API

main
Ziyang Hu 2 years ago
parent eb608fe548
commit bf165c22f7

@ -122,7 +122,7 @@ where
}
fn transact(&self) -> Result<SessionTx> {
let ret = SessionTx {
tx: Box::new(self.db.transact()?),
tx: Box::new(self.db.transact(false)?),
mem_store_id: Default::default(),
relation_store_id: self.relation_store_id.clone(),
};
@ -130,7 +130,7 @@ where
}
fn transact_write(&self) -> Result<SessionTx> {
let ret = SessionTx {
tx: Box::new(self.db.transact()?),
tx: Box::new(self.db.transact(true)?),
mem_store_id: Default::default(),
relation_store_id: self.relation_store_id.clone(),
};
@ -716,7 +716,7 @@ where
LARGEST_UTF_CHAR,
)))])
.encode_as_key(RelationId::SYSTEM);
let tx = self.db.transact()?;
let tx = self.db.transact(false)?;
let mut collected = vec![];
for kv_res in tx.range_scan_raw(&lower, &upper) {
let (k_slice, v_slice) = kv_res?;

@ -13,7 +13,7 @@ pub(crate) mod tikv;
pub trait Storage {
type Tx: StoreTx;
fn transact(&self) -> Result<Self::Tx>;
fn transact(&self, write: bool) -> Result<Self::Tx>;
fn del_range(&self, lower: &[u8], upper: &[u8]) -> Result<()>;
fn range_compact(&self, lower: &[u8], upper: &[u8]) -> Result<()>;
}

@ -90,7 +90,7 @@ impl RocksDbStorage {
impl Storage for RocksDbStorage {
type Tx = RocksDbTx;
fn transact(&self) -> Result<Self::Tx> {
fn transact(&self, _write: bool) -> Result<Self::Tx> {
let db_tx = self.db.transact().set_snapshot(true).start();
Ok(RocksDbTx { db_tx })
}

@ -34,7 +34,7 @@ const DEL_MARKER: u8 = 0;
impl Storage for SledStorage {
type Tx = SledTx;
fn transact(&self) -> Result<Self::Tx> {
fn transact(&self, _write: bool) -> Result<Self::Tx> {
Ok(SledTx {
db: self.db.clone(),
changes: Default::default(),

Loading…
Cancel
Save