deps/rocksdb/table/table_test.cc
// BlockBasedTableIterator should invalidate itself and return
// OutOfBound()=true after Next(), if it finds current index key is no smaller
// than upper bound, unless it is pointing to the last data block.
BlockBasedTableIterator should invalidate itself and return
OutOfBound()=true after Next(), if it finds current index key is no smaller
than upper bound, unless it is pointing to the last data block.
BlockBasedTableIterator should invalidate itself and return OutOfBound () = true after Next () if it finds current index key is no smaller than upper bound unless it is pointing to the last data block .
TEST_P(BlockBasedTableTest, OutOfBoundOnNext) {
  TableConstructor c(BytewiseComparator(), true );
  c.Add("bar", "v");
  c.Add("foo", "v");
  std::vector<std::string> keys;
  stl_wrappers::KVMap kvmap;
  Options options;
  BlockBasedTableOptions table_opt(GetBlockBasedTableOptions());
  table_opt.flush_block_policy_factory =
      std::make_shared<FlushBlockEveryKeyPolicyFactory>();
  options.table_factory.reset(NewBlockBasedTableFactory(table_opt));
  const ImmutableCFOptions ioptions(options);
  const MutableCFOptions moptions(options);
  c.Finish(options, ioptions, moptions, table_opt,
           GetPlainInternalComparator(BytewiseComparator()), &keys, &kvmap);
  auto* reader = c.GetTableReader();
  ReadOptions read_opt;
  std::string ub1 = "bar_after";
  Slice ub_slice1(ub1);
  read_opt.iterate_upper_bound = &ub_slice1;
  std::unique_ptr<InternalIterator> iter;
  iter.reset(new KeyConvertingIterator(reader->NewIterator(
      read_opt, nullptr, nullptr,
      false, TableReaderCaller::kUncategorized)));
  iter->Seek("bar");
  ASSERT_TRUE(iter->Valid());
  ASSERT_EQ("bar", iter->key());
  iter->Next();
  ASSERT_FALSE(iter->Valid());
  ASSERT_TRUE(iter->IsOutOfBound());
  std::string ub2 = "foo_after";
  Slice ub_slice2(ub2);
  read_opt.iterate_upper_bound = &ub_slice2;
  iter.reset(new KeyConvertingIterator(reader->NewIterator(
      read_opt, nullptr, nullptr,
      false, TableReaderCaller::kUncategorized)));
  iter->Seek("foo");
  ASSERT_TRUE(iter->Valid());
  ASSERT_EQ("foo", iter->key());
  iter->Next();
  ASSERT_FALSE(iter->Valid());
  ASSERT_FALSE(iter->IsOutOfBound());
}
TEST_P ( BlockBasedTableTest , OutOfBoundOnNext ) { TableConstructor c ( BytewiseComparator ( ) , true ) ; c . Add ( " " , " " ) ; c . Add ( " " , " " ) ; std :: vector < std :: string > keys ; stl_wrappers :: KVMap kvmap ; Options options ; BlockBasedTableOptions table_opt ( GetBlockBasedTableOptions ( ) ) ; table_opt . flush_block_policy_factory = std :: make_shared < FlushBlockEveryKeyPolicyFactory > ( ) ; options . table_factory . reset ( NewBlockBasedTableFactory ( table_opt ) ) ; const ImmutableCFOptions ioptions ( options ) ; const MutableCFOptions moptions ( options ) ; c . Finish ( options , ioptions , moptions , table_opt , GetPlainInternalComparator ( BytewiseComparator ( ) ) , & keys , & kvmap ) ; auto * reader = c . GetTableReader ( ) ; ReadOptions read_opt ; std :: string ub1 = " " ; Slice ub_slice1 ( ub1 ) ; read_opt . iterate_upper_bound = & ub_slice1 ; std :: unique_ptr < InternalIterator > iter ; iter . reset ( new KeyConvertingIterator ( reader -> NewIterator ( read_opt , nullptr , nullptr , false , TableReaderCaller :: kUncategorized ) ) ) ; iter -> Seek ( " " ) ; ASSERT_TRUE ( iter -> Valid ( ) ) ; ASSERT_EQ ( " " , iter -> key ( ) ) ; iter -> Next ( ) ; ASSERT_FALSE ( iter -> Valid ( ) ) ; ASSERT_TRUE ( iter -> IsOutOfBound ( ) ) ; std :: string ub2 = " " ; Slice ub_slice2 ( ub2 ) ; read_opt . iterate_upper_bound = & ub_slice2 ; iter . reset ( new KeyConvertingIterator ( reader -> NewIterator ( read_opt , nullptr , nullptr , false , TableReaderCaller :: kUncategorized ) ) ) ; iter -> Seek ( " " ) ; ASSERT_TRUE ( iter -> Valid ( ) ) ; ASSERT_EQ ( " " , iter -> key ( ) ) ; iter -> Next ( ) ; ASSERT_FALSE ( iter -> Valid ( ) ) ; ASSERT_FALSE ( iter -> IsOutOfBound ( ) ) ; }
BlockBasedTableIterator should invalidate itself and return
OutOfBound()=true after Next(), if it finds current index key is no smaller
than upper bound, unless it is pointing to the last data block.
BlockBasedTableIterator should invalidate itself and return OutOfBound () = true after Next () if it finds current index key is no smaller than upper bound unless it is pointing to the last data block .
/*convert_to_internal_key*/ /*prefix_extractor=*/ /*arena=*/ /*skip_filters=*/ /*prefix_extractor=*/ /*arena=*/ /*skip_filters=*/