Skip to content

Commit

Permalink
unify the variable name to wal_location.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Oct 10, 2022
1 parent fc61f9c commit dcea234
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion analytic_engine/src/instance/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl Instance {
read_ctx: &ReadContext,
) -> Result<()> {
let read_req = ReadRequest {
location: table_data.wal_location(),
wal_location: table_data.wal_location(),
start: ReadBoundary::Min,
end: ReadBoundary::Max,
};
Expand Down
2 changes: 1 addition & 1 deletion analytic_engine/src/meta/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl MetaUpdateLogStore for RegionWal {
async fn scan(&self, start: ReadBoundary, end: ReadBoundary) -> Result<Self::Iter> {
let ctx = ReadContext::default();
let read_req = ReadRequest {
location: self.wal_location,
wal_location: self.wal_location,
start,
end,
};
Expand Down
2 changes: 1 addition & 1 deletion analytic_engine/src/wal_synchronizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ struct SynchronizeState {
impl SynchronizeState {
pub fn read_req(&self) -> ReadRequest {
ReadRequest {
location: self.wal_location,
wal_location: self.wal_location,
start: ReadBoundary::Excluded(self.last_synced_seq.load(Ordering::Relaxed)),
end: ReadBoundary::Max,
}
Expand Down
10 changes: 5 additions & 5 deletions wal/src/kv_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,22 +523,22 @@ impl LogEncoding {
/// LogBatchEncoder which are used to encode specify payloads.
#[derive(Debug)]
pub struct LogBatchEncoder {
location: WalLocation,
wal_location: WalLocation,
log_encoding: LogEncoding,
}

impl LogBatchEncoder {
/// Create LogBatchEncoder with specific region_id.
pub fn create(location: WalLocation) -> Self {
pub fn create(wal_location: WalLocation) -> Self {
Self {
location,
wal_location,
log_encoding: LogEncoding::newest(),
}
}

/// Consume LogBatchEncoder and encode single payload to LogWriteBatch.
pub fn encode(self, payload: &impl Payload) -> manager::Result<LogWriteBatch> {
let mut write_batch = LogWriteBatch::new(self.location);
let mut write_batch = LogWriteBatch::new(self.wal_location);
let mut buf = BytesMut::new();
self.log_encoding
.encode_value(&mut buf, payload)
Expand All @@ -562,7 +562,7 @@ impl LogBatchEncoder {
where
&'a I: Into<P>,
{
let mut write_batch = LogWriteBatch::new(self.location);
let mut write_batch = LogWriteBatch::new(self.wal_location);
let mut buf = BytesMut::new();
for raw_payload in raw_payload_batch.iter() {
self.log_encoding
Expand Down
4 changes: 2 additions & 2 deletions wal/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl ReadBoundary {
#[derive(Debug, Clone)]
pub struct ReadRequest {
/// WalLocation of the wal to read
pub location: WalLocation,
pub wal_location: WalLocation,
// TODO(yingwen): Or just rename to ReadBound?
/// Start bound
pub start: ReadBoundary,
Expand All @@ -235,7 +235,7 @@ pub struct ReadRequest {
#[derive(Debug, Clone)]
pub struct ScanRequest {
/// WalLocation of the wal to read
pub location: WalLocation,
pub wal_location: WalLocation,
}

pub type ScanContext = ReadContext;
Expand Down
2 changes: 1 addition & 1 deletion wal/src/rocks_impl/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ impl WalManager for RocksImpl {
ctx: &ReadContext,
req: &ReadRequest,
) -> Result<BatchLogIteratorAdapter> {
let blocking_iter = if let Some(region) = self.region(req.location.table_id) {
let blocking_iter = if let Some(region) = self.region(req.wal_location.table_id) {
region.read(ctx, req)?
} else {
let iter = DBIterator::new(self.db.clone(), ReadOptions::default());
Expand Down
2 changes: 1 addition & 1 deletion wal/src/table_kv_impl/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ impl<T: TableKv> NamespaceInner<T> {
// buckets.
let buckets = self.list_buckets();

let region_id = req.location.table_id;
let region_id = req.wal_location.table_id;
if let Some(region) = self.get_or_open_region(region_id).await? {
region
.read_log(&self.table_kv, buckets, ctx, req)
Expand Down
42 changes: 21 additions & 21 deletions wal/src/tests/read_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ async fn check_write_batch_with_read_request<B: WalBuilder>(
async fn check_write_batch<B: WalBuilder>(
env: &TestEnv<B>,
wal: WalManagerRef,
location: WalLocation,
wal_location: WalLocation,
max_seq: SequenceNumber,
payload_batch: &[TestPayload],
) {
let read_req = ReadRequest {
location,
wal_location,
start: ReadBoundary::Included(max_seq + 1 - payload_batch.len() as u64),
end: ReadBoundary::Included(max_seq),
};
Expand All @@ -44,26 +44,26 @@ async fn check_write_batch<B: WalBuilder>(
async fn simple_read_write_with_wal<B: WalBuilder>(
env: impl Deref<Target = TestEnv<B>>,
wal: WalManagerRef,
location: WalLocation,
wal_location: WalLocation,
) {
let (payload_batch, write_batch) = env.build_log_batch(wal.clone(), location, 0, 10).await;
let (payload_batch, write_batch) = env.build_log_batch(wal.clone(), wal_location, 0, 10).await;
let seq = wal
.write(&env.write_ctx, &write_batch)
.await
.expect("should succeed to write");

check_write_batch(&env, wal, location, seq, &payload_batch).await
check_write_batch(&env, wal, wal_location, seq, &payload_batch).await
}

async fn simple_read_write<B: WalBuilder>(env: &TestEnv<B>, location: WalLocation) {
async fn simple_read_write<B: WalBuilder>(env: &TestEnv<B>, wal_location: WalLocation) {
let wal = env.build_wal().await;
// Empty region has 0 sequence num.
let last_seq = wal.sequence_num(location).await.unwrap();
let last_seq = wal.sequence_num(wal_location).await.unwrap();
assert_eq!(0, last_seq);

simple_read_write_with_wal(env, wal.clone(), location).await;
simple_read_write_with_wal(env, wal.clone(), wal_location).await;

let last_seq = wal.sequence_num(location).await.unwrap();
let last_seq = wal.sequence_num(wal_location).await.unwrap();
assert_eq!(10, last_seq);

wal.close_gracefully().await.unwrap();
Expand All @@ -72,22 +72,22 @@ async fn simple_read_write<B: WalBuilder>(env: &TestEnv<B>, location: WalLocatio
/// Test the read with different kinds of boundaries.
async fn read_with_boundary<B: WalBuilder>(env: &TestEnv<B>) {
let wal = env.build_wal().await;
let location = WalLocation::new(0, 0);
let (payload_batch, write_batch) = env.build_log_batch(wal.clone(), location, 0, 10).await;
let wal_location = WalLocation::new(0, 0);
let (payload_batch, write_batch) = env.build_log_batch(wal.clone(), wal_location, 0, 10).await;
let end_seq = wal
.write(&env.write_ctx, &write_batch)
.await
.expect("should succeed to write");

let last_seq = wal.sequence_num(location).await.unwrap();
let last_seq = wal.sequence_num(wal_location).await.unwrap();
assert_eq!(end_seq, last_seq);

let start_seq = end_seq + 1 - write_batch.entries.len() as u64;

// [min, max]
{
let read_req = ReadRequest {
location,
wal_location,
start: ReadBoundary::Min,
end: ReadBoundary::Max,
};
Expand All @@ -98,7 +98,7 @@ async fn read_with_boundary<B: WalBuilder>(env: &TestEnv<B>) {
// [0, 10]
{
let read_req = ReadRequest {
location,
wal_location,
start: ReadBoundary::Included(start_seq),
end: ReadBoundary::Included(end_seq),
};
Expand All @@ -109,7 +109,7 @@ async fn read_with_boundary<B: WalBuilder>(env: &TestEnv<B>) {
// (0, 10]
{
let read_req = ReadRequest {
location,
wal_location,
start: ReadBoundary::Excluded(start_seq),
end: ReadBoundary::Included(end_seq),
};
Expand All @@ -121,7 +121,7 @@ async fn read_with_boundary<B: WalBuilder>(env: &TestEnv<B>) {
// [0, 10)
{
let read_req = ReadRequest {
location,
wal_location,
start: ReadBoundary::Included(start_seq),
end: ReadBoundary::Excluded(end_seq),
};
Expand All @@ -139,7 +139,7 @@ async fn read_with_boundary<B: WalBuilder>(env: &TestEnv<B>) {
// (0, 10)
{
let read_req = ReadRequest {
location,
wal_location,
start: ReadBoundary::Excluded(start_seq),
end: ReadBoundary::Excluded(end_seq),
};
Expand Down Expand Up @@ -213,7 +213,7 @@ async fn reopen<B: WalBuilder>(env: &TestEnv<B>) {
assert_eq!(seq, last_seq);

let read_req = ReadRequest {
location: WalLocation::new(table_id, table_id),
wal_location: WalLocation::new(table_id, table_id),
start: ReadBoundary::Included(seq + 1 - write_batch.entries.len() as u64),
end: ReadBoundary::Included(seq),
};
Expand Down Expand Up @@ -342,7 +342,7 @@ async fn simple_write_delete<B: WalBuilder>(env: &TestEnv<B>) {
.await
.expect("should succeed to delete");
let read_req = ReadRequest {
location: WalLocation::new(table_id, table_id),
wal_location: WalLocation::new(table_id, table_id),
start: ReadBoundary::Min,
end: ReadBoundary::Max,
};
Expand Down Expand Up @@ -387,7 +387,7 @@ async fn write_delete_half<B: WalBuilder>(env: &TestEnv<B>) {
.await
.expect("should succeed to delete");
let read_req = ReadRequest {
location: WalLocation::new(table_id, table_id),
wal_location: WalLocation::new(table_id, table_id),
start: ReadBoundary::Min,
end: ReadBoundary::Max,
};
Expand Down Expand Up @@ -439,7 +439,7 @@ async fn write_delete_multiple_regions<B: WalBuilder>(env: &TestEnv<B>) {
.await
.expect("should succeed to delete");
let read_req = ReadRequest {
location: WalLocation::new(table_id_1, table_id_1),
wal_location: WalLocation::new(table_id_1, table_id_1),
start: ReadBoundary::Min,
end: ReadBoundary::Max,
};
Expand Down

0 comments on commit dcea234

Please sign in to comment.