You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.9 KiB

  1. /*
  2. Copyright (c) 2015, Facebook, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
  13. /* MyRocks header files */
  14. #include "../ha_rocksdb.h"
  15. #include "../rdb_datadic.h"
  16. void putKeys(myrocks::Rdb_tbl_prop_coll *coll, int num, bool is_delete,
  17. uint64_t expected_deleted) {
  18. std::string str("aaaaaaaaaaaaaa");
  19. rocksdb::Slice sl(str.data(), str.size());
  20. for (int i = 0; i < num; i++) {
  21. coll->AddUserKey(
  22. sl, sl, is_delete ? rocksdb::kEntryDelete : rocksdb::kEntryPut, 0, 100);
  23. }
  24. DBUG_ASSERT(coll->GetMaxDeletedRows() == expected_deleted);
  25. }
  26. int main(int argc, char **argv) {
  27. // test the circular buffer for delete flags
  28. myrocks::Rdb_compact_params params;
  29. params.m_file_size = 333;
  30. params.m_deletes = 333; // irrelevant
  31. params.m_window = 10;
  32. myrocks::Rdb_tbl_prop_coll coll(nullptr, params, 0,
  33. RDB_DEFAULT_TBL_STATS_SAMPLE_PCT);
  34. putKeys(&coll, 2, true, 2); // [xx]
  35. putKeys(&coll, 3, false, 2); // [xxo]
  36. putKeys(&coll, 1, true, 3); // [xxox]
  37. putKeys(&coll, 6, false, 3); // [xxoxoooooo]
  38. putKeys(&coll, 3, true, 4); // xxo[xooooooxxx]
  39. putKeys(&coll, 1, false, 4); // xxox[ooooooxxxo]
  40. putKeys(&coll, 100, false, 4); // ....[oooooooooo]
  41. putKeys(&coll, 100, true, 10); // ....[xxxxxxxxxx]
  42. putKeys(&coll, 100, true, 10); // ....[oooooooooo]
  43. return 0;
  44. }