Skip to content

Commit

Permalink
Run cargo fix (#11)
Browse files Browse the repository at this point in the history
Run cargo fix #2
  • Loading branch information
varunu28 authored Dec 31, 2023
1 parent d0f4950 commit d18ec61
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 194 deletions.
12 changes: 3 additions & 9 deletions src/concurrency/concurrency_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,9 @@ impl ConcurrencyManager {
}

mod test {
use std::thread;

use tokio::{
sync::{
mpsc::{self, channel, Receiver, Sender},
Mutex,
},
time::{self, Duration},
};




#[tokio::test]
async fn test_select() {
Expand Down
8 changes: 4 additions & 4 deletions src/db/db.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{
collections::HashMap,
future::Future,
sync::{Arc, Mutex, RwLock},
sync::{Arc, RwLock},
};

use serde::{de::DeserializeOwned, Serialize};
Expand Down Expand Up @@ -277,8 +277,8 @@ impl InternalDB {

pub async fn read_without_txn<T: DeserializeOwned>(
&self,
key: &str,
timestamp: Timestamp,
_key: &str,
_timestamp: Timestamp,
) -> T {
todo!()
}
Expand Down Expand Up @@ -311,7 +311,7 @@ impl InternalDB {
metadata: request_metadata,
request_union: txn_request,
};
let response = self
let _response = self
.executor
.execute_request_with_concurrency_retries(request)
.await;
Expand Down
67 changes: 26 additions & 41 deletions src/db/db_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ mod test {

// simple tests that involve writes and reads
mod single_txn_simple_test {
use std::sync::Arc;


use crate::db::db::{Timestamp, DB};


#[tokio::test]
async fn two_writes_with_different_keys() {
Expand Down Expand Up @@ -43,11 +43,11 @@ mod test {
mod write_read {
mod uncommitted_intent_has_lower_timestamp {

use std::sync::Arc;


use tokio::time::{self, sleep, Duration};


use crate::db::db::{Timestamp, DB};


#[tokio::test]
async fn read_waits_for_uncommitted_write() {
Expand Down Expand Up @@ -76,9 +76,9 @@ mod test {
// A read running into an uncommitted intent with a higher timestamp ignores the
// intent and does not need to wait.
mod uncommitted_intent_has_higher_timestamp {
use std::sync::Arc;


use crate::db::db::{Timestamp, DB};


#[tokio::test]
async fn ignores_intent_with_higher_timestamp() {
Expand All @@ -100,15 +100,9 @@ mod test {
// A write running into a committed value with a higher tiestamp will bump its timestamp.
mod write_write {
mod run_into_uncommitted_intent {
use std::sync::Arc;

use crate::{
db::db::{CommitTxnResult, Timestamp, DB},
hlc::{
clock::{Clock, ManualClock},
timestamp::Timestamp as HLCTimestamp,
},
};




#[tokio::test]
async fn write_waits_for_uncommitted_write() {
Expand Down Expand Up @@ -152,15 +146,9 @@ mod test {
}

mod run_into_committed_intent {
use std::sync::Arc;

use crate::{
db::db::{CommitTxnResult, Timestamp, DB},
hlc::{
clock::{Clock, ManualClock},
timestamp::Timestamp as HLCTimestamp,
},
};




#[tokio::test]
async fn bump_write_timestamp_before_committing() {
Expand Down Expand Up @@ -209,9 +197,9 @@ mod test {
* the writeTimestamp is bumped
*/
mod read_write {
use std::sync::Arc;


use crate::db::db::{CommitTxnResult, Timestamp, DB};


#[tokio::test]
async fn bump_write_timestamp_before_committing() {
Expand Down Expand Up @@ -247,14 +235,14 @@ mod test {
}

mod read_refresh {
use std::sync::Arc;


use tokio::time::{self, sleep, Duration};


mod read_refresh_success {
use std::sync::Arc;


use crate::db::db::{CommitTxnResult, Timestamp, DB};


#[tokio::test]
async fn read_refresh_from_write_write_conflict() {
Expand Down Expand Up @@ -290,9 +278,9 @@ mod test {
// Advancing a transaction read timestamp from ta to tb is possible
// if we can prove that none of the data
mod read_refresh_failure {
use std::sync::Arc;


use crate::db::db::{CommitTxnResult, Timestamp, DB};


#[tokio::test]
async fn read_refresh_failure() {
Expand Down Expand Up @@ -334,7 +322,7 @@ mod test {
}

mod abort_txn {
use crate::db::db::{Timestamp, DB};


#[tokio::test]
async fn read_write_after_abort_transaction() {
Expand All @@ -359,12 +347,9 @@ mod test {
}

mod deadlock {
use std::sync::Arc;


use crate::{
db::db::{CommitTxnResult, Timestamp, DB},
storage::str_to_key,
};


#[tokio::test]
async fn conflicting_writes() {
Expand Down Expand Up @@ -470,9 +455,9 @@ mod test {
}

mod run_txn {
use std::sync::Arc;


use crate::db::db::{Timestamp, DB};


#[tokio::test]
async fn reading_its_txn_own_write() {
Expand Down
4 changes: 1 addition & 3 deletions src/db/request_queue.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::{
sync::{
mpsc::{self},
Arc,
},
thread,
};

use tokio::{
Expand Down Expand Up @@ -85,7 +83,7 @@ impl TaskQueue {
metadata: request_metadata,
request_union: txn_request,
};
let response = executor_cloned
let _response = executor_cloned
.execute_request_with_concurrency_retries(request)
.await
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions src/execute/executor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::{Arc, RwLock};

use tokio::sync::mpsc::Sender;
use uuid::Uuid;


use crate::{
concurrency::concurrency_manager::{ConcurrencyManager, Guard, SequenceReqError},
Expand Down Expand Up @@ -118,7 +118,7 @@ impl Executor {
// If the txn has aborted, remove the txn record
}

pub async fn execute_write_request(&self, request: &Request, guard: &Guard) -> ResponseResult {
pub async fn execute_write_request(&self, request: &Request, _guard: &Guard) -> ResponseResult {
// finds the max read timestamp from timestamp oracle for the spans
// and bump the write timestamp if necessary
let spans = request
Expand Down Expand Up @@ -154,7 +154,7 @@ impl Executor {
pub async fn execute_read_only_request(
&self,
request: &Request,
guard: &Guard,
_guard: &Guard,
) -> ResponseResult {
let result = request
.request_union
Expand Down
13 changes: 5 additions & 8 deletions src/execute/request.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{
collections::{HashMap, HashSet},
default,
collections::{HashSet},
};

use async_trait::async_trait;
Expand All @@ -10,16 +9,14 @@ use uuid::Uuid;
use crate::{
db::db::TxnLink,
hlc::timestamp::Timestamp,
latch_manager::latch_interval_btree::{NodeKey, Range},
latch_manager::latch_interval_btree::{Range},
lock_table::lock_table::{AbortUpdateLock, CommitUpdateLock, UpdateLock},
storage::{
mvcc::{KVStore, MVCCGetParams, WriteIntentError},
mvcc::{MVCCGetParams},
mvcc_key::{create_intent_key, MVCCKey},
str_to_key,
txn::{TransactionStatus, Txn, TxnIntent, TxnMetadata},
txn::{TransactionStatus, TxnIntent},
Key, Value,
},
StorageResult,
};

use super::executor::Executor;
Expand Down Expand Up @@ -64,7 +61,7 @@ pub enum RequestUnion {
}

// TODO: Does this need a timestamp in there?
pub type SpanSet<K: NodeKey> = Vec<Range<K>>;
pub type SpanSet<K> = Vec<Range<K>>;

pub fn dedupe_spanset(v: &mut SpanSet<Key>) {
// note the Copy constraint
Expand Down
14 changes: 4 additions & 10 deletions src/interval/interval_tree.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::ops::Deref;


use crate::{
hlc::timestamp::Timestamp,
llrb::llrb::{NodeKey, NodeValue, RbTree, NIL},
};

Expand Down Expand Up @@ -106,14 +105,9 @@ impl<K: NodeKey, V: NodeValue> IntervalTree<K, V> {
mod tests {

mod get_overlap {
use std::{
borrow::{Borrow, BorrowMut},
cell::RefCell,
ops::Deref,
rc::{Rc, Weak},
};

use crate::interval::interval_tree::{IntervalTree, RangeValue, Test};




#[test]
fn test_overlap() {
Expand Down
13 changes: 5 additions & 8 deletions src/latch_manager/latch_interval_btree.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use std::{
borrow::{Borrow, BorrowMut},
cell::RefCell,
rc::Rc,
borrow::{Borrow},
sync::{Arc, Mutex, RwLock, Weak},
};

use tokio::{
sync::mpsc::{self, channel, Receiver, Sender},
time::{self, Duration},
sync::mpsc::{self, Receiver, Sender},
};

use crate::storage::{mvcc_key::MVCCKey, Key};
Expand Down Expand Up @@ -149,7 +146,7 @@ impl<K: NodeKey> Node<K> {
let mut keys = internal.keys.write().unwrap();
keys[idx] = new_key;
}
Node::Leaf(leaf) => {
Node::Leaf(_leaf) => {
panic!("Currently don't support updating key for leaf node")
}
}
Expand Down Expand Up @@ -619,7 +616,7 @@ impl<K: NodeKey> LeafNode<K> {
*/
pub fn steal_from_right_leaf_sibling(
&self,
key_to_delete: &K,
_key_to_delete: &K,
right_latch_node: LatchNode<K>,
parent: &InternalNode<K>,
edge_idx: usize,
Expand Down Expand Up @@ -647,7 +644,7 @@ impl<K: NodeKey> LeafNode<K> {

pub fn steal_from_left_leaf_sibling(
&self,
key_to_delete: &K,
_key_to_delete: &K,
left_latch_node: LatchNode<K>,
parent: &InternalNode<K>,
edge_idx: usize,
Expand Down
Loading

0 comments on commit d18ec61

Please sign in to comment.