Skip to content

Commit 54b41f1

Browse files
committed
Add timestamp support u64::MAX
Signed-off-by: yongman <[email protected]>
1 parent 027a7df commit 54b41f1

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/timestamp.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,24 @@ pub trait TimestampExt: Sized {
2525

2626
impl TimestampExt for Timestamp {
2727
fn version(&self) -> u64 {
28+
if self.physical == i64::MAX && self.logical == i64::MAX {
29+
return u64::MAX;
30+
}
31+
2832
((self.physical << PHYSICAL_SHIFT_BITS) + self.logical)
2933
.try_into()
3034
.expect("Overflow converting timestamp to version")
3135
}
3236

3337
fn from_version(version: u64) -> Self {
38+
if version == u64::MAX {
39+
return Self {
40+
physical: i64::MAX,
41+
logical: i64::MAX,
42+
suffix_bits: 0,
43+
};
44+
}
45+
3446
let version = version as i64;
3547
Self {
3648
physical: version >> PHYSICAL_SHIFT_BITS,
@@ -41,7 +53,7 @@ impl TimestampExt for Timestamp {
4153
}
4254

4355
fn try_from_version(version: u64) -> Option<Self> {
44-
if version == 0 {
56+
if version == 0 || (version >= i64::MAX as u64 && version != u64::MAX) {
4557
None
4658
} else {
4759
Some(Self::from_version(version))

src/transaction/client.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,11 @@ impl Client {
276276
Ok(res)
277277
}
278278

279-
fn new_transaction(&self, timestamp: Timestamp, options: TransactionOptions) -> Transaction {
279+
pub fn new_transaction(
280+
&self,
281+
timestamp: Timestamp,
282+
options: TransactionOptions,
283+
) -> Transaction {
280284
let logger = self.logger.new(o!("child" => 1));
281285
Transaction::new(timestamp, self.pd.clone(), options, logger)
282286
}

0 commit comments

Comments
 (0)