diff --git a/db/db_iter.cc b/db/db_iter.cc index a06bde51ba..a8eb727e29 100644 --- a/db/db_iter.cc +++ b/db/db_iter.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. -#include #include "db/db_iter.h" +#include #include "db/filename.h" #include "db/dbformat.h" @@ -61,9 +61,12 @@ class DBIter: public Iterator { sequence_(s), direction_(kForward), valid_(false), - current_entry_is_merged_(false) { + current_entry_is_merged_(false), + statistics_(options.statistics) { + RecordTick(statistics_, NO_ITERATORS, 1); } virtual ~DBIter() { + RecordTick(statistics_, NO_ITERATORS, -1); delete iter_; } virtual bool Valid() const { return valid_; } @@ -124,6 +127,7 @@ class DBIter: public Iterator { Direction direction_; bool valid_; bool current_entry_is_merged_; + std::shared_ptr statistics_; // No copying allowed DBIter(const DBIter&); diff --git a/include/leveldb/statistics.h b/include/leveldb/statistics.h index fe4878f237..b4ba11f594 100644 --- a/include/leveldb/statistics.h +++ b/include/leveldb/statistics.h @@ -47,7 +47,8 @@ enum Tickers { // write throttle because of too many files in L0 STALL_L0_NUM_FILES_MICROS = 15, RATE_LIMIT_DELAY_MILLIS = 16, - TICKER_ENUM_MAX = 17 + NO_ITERATORS = 17, // number of iterators currently open + TICKER_ENUM_MAX = 18 };