Skip to content

Commit

Permalink
txn_btree: add some rsearch test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Tu committed Oct 23, 2013
1 parent bfa2176 commit 69e7921
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions txn_btree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

#include "scopedperf.hh"

#if defined(NDB_MASSTREE)
#define HAVE_REVERSE_RANGE_SCANS
#endif

using namespace std;
using namespace util;
uint64_t initial_timestamp;
Expand Down Expand Up @@ -463,9 +467,26 @@ test_long_keys()
ALWAYS_ASSERT_COND_IN_TXN(t, c.ctr == N);
}

#ifdef HAVE_REVERSE_RANGE_SCANS
{
TxnType<Traits> t(txn_flags, arena);
const string lowkey_s = make_long_key(4, 5, 3, 0);
const string highkey_s = make_long_key(4, 5, 3, N);
const varkey lowkey(lowkey_s);
counting_scan_callback<TxnType> c(1);
btr.rsearch_range_call(t, varkey(highkey_s), &lowkey, c);
AssertSuccessfulCommit(t);
if (c.ctr != (N-1))
cerr << "c.ctr: " << c.ctr << ", N: " << N << endl;
ALWAYS_ASSERT_COND_IN_TXN(t, c.ctr == (N-1));
}
#endif

txn_epoch_sync<TxnType>::sync();
txn_epoch_sync<TxnType>::finish();
}

cerr << "test_long_keys passed" << endl;
}

template <template <typename> class TxnType, typename Traits>
Expand Down
15 changes: 15 additions & 0 deletions txn_btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,21 @@ class txn_btree : public base_txn_btree<Transaction, txn_btree_> {
upper ? &u : nullptr, callback, max_bytes_read);
}

template <typename Traits>
inline void
rsearch_range_call(Transaction<Traits> &t,
const varkey &upper,
const varkey *lower,
search_range_callback &callback,
size_type max_bytes_read = string_type::npos)
{
key_type l;
if (lower)
l = to_string_type(*lower);
rsearch_range_call(t, to_string_type(upper),
lower ? &l : nullptr, callback, max_bytes_read);
}

template <typename Traits, typename T>
inline void
search_range(Transaction<Traits> &t,
Expand Down

0 comments on commit 69e7921

Please sign in to comment.