@@ -80,13 +80,12 @@ class ParsedBaseMetaValue : public ParsedInternalValue {
8080 uint64_t etime = DecodeFixed64 (internal_value_str->data () + offset);
8181
8282 ctime_ = (ctime & ~(1ULL << 63 ));
83- // if ctime_==ctime, means ctime_ storaged in seconds
84- if (ctime_ == ctime) {
83+ if ((ctime & (1ULL << 63 )) == 0 ) {
8584 ctime_ *= 1000 ;
8685 }
86+
8787 etime_ = (etime & ~(1ULL << 63 ));
88- // if etime_==etime, means etime_ storaged in seconds
89- if (etime == etime_) {
88+ if ((etime & (1ULL << 63 )) == 0 ) {
9089 etime_ *= 1000 ;
9190 }
9291 }
@@ -100,7 +99,7 @@ class ParsedBaseMetaValue : public ParsedInternalValue {
10099 type_ = static_cast <DataType>(static_cast <uint8_t >(internal_value_slice[0 ]));
101100 offset += kTypeLength ;
102101 user_value_ = Slice (internal_value_slice.data () + offset,
103- internal_value_slice.size () - kBaseMetaValueSuffixLength - offset);
102+ internal_value_slice.size () - kBaseMetaValueSuffixLength - offset);
104103 offset += user_value_.size ();
105104 version_ = DecodeFixed64 (internal_value_slice.data () + offset);
106105 offset += sizeof (uint64_t );
@@ -110,14 +109,17 @@ class ParsedBaseMetaValue : public ParsedInternalValue {
110109 offset += sizeof (ctime_);
111110 uint64_t etime = DecodeFixed64 (internal_value_slice.data () + offset);
112111
112+ // 修复时间戳解析问题:只有当时间戳没有毫秒标志时才乘以 1000
113+ // 毫秒时间戳的最高位是 1,秒时间戳的最高位是 0
113114 ctime_ = (ctime & ~(1ULL << 63 ));
114- // if ctime_!= ctime, means ctime_ storaged in seconds
115- if (ctime_ == ctime) {
115+ if (( ctime & ( 1ULL << 63 )) == 0 ) {
116+ // 秒时间戳,转换为毫秒
116117 ctime_ *= 1000 ;
117118 }
119+
118120 etime_ = (etime & ~(1ULL << 63 ));
119- // if etime_!= etime, means etime_ storaged in seconds
120- if (etime == etime_) {
121+ if (( etime & ( 1ULL << 63 )) == 0 ) {
122+ // 秒时间戳,转换为毫秒
121123 etime_ *= 1000 ;
122124 }
123125 }
0 commit comments