@@ -62,7 +62,6 @@ func (d *MVData) Read(key Key, txn TxnIndex) (Value, TxnVersion, bool) {
62
62
return nil , InvalidTxnVersion , false
63
63
}
64
64
65
- // index order is reversed,
66
65
// find the closing txn that's less than the given txn
67
66
item , ok := seekClosestTxn (tree , txn )
68
67
if ! ok {
@@ -115,8 +114,7 @@ func (d *MVData) Snapshot() (snapshot []KVPair) {
115
114
116
115
func (d * MVData ) SnapshotTo (cb func (pair KVPair ) bool ) {
117
116
d .Scan (func (outer dataItem ) bool {
118
- // index order is reversed, `Min` is the latest
119
- item , ok := outer .Tree .Min ()
117
+ item , ok := outer .Tree .Max ()
120
118
if ! ok {
121
119
return true
122
120
}
@@ -153,16 +151,14 @@ type secondaryDataItem struct {
153
151
}
154
152
155
153
func secondaryLesser (a , b secondaryDataItem ) bool {
156
- // reverse the order
157
- return a .Index > b .Index
154
+ return a .Index < b .Index
158
155
}
159
156
160
157
func (item secondaryDataItem ) Version () TxnVersion {
161
158
return TxnVersion {Index : item .Index , Incarnation : item .Incarnation }
162
159
}
163
160
164
161
// seekClosestTxn returns the closest txn that's less than the given txn.
165
- // NOTE: the tx index order is reversed.
166
162
func seekClosestTxn (tree * BTree [secondaryDataItem ], txn TxnIndex ) (secondaryDataItem , bool ) {
167
- return tree .Seek (secondaryDataItem {Index : txn - 1 })
163
+ return tree .ReverseSeek (secondaryDataItem {Index : txn - 1 })
168
164
}
0 commit comments