]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/db/in_memory_stats_history.cc
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under both the GPLv2 (found in the
3 // COPYING file in the root directory) and Apache 2.0 License
4 // (found in the LICENSE.Apache file in the root directory).
5 // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style license that can be
7 // found in the LICENSE file. See the AUTHORS file for names of contributors.
9 #include "db/db_impl.h"
10 #include "db/in_memory_stats_history.h"
14 InMemoryStatsHistoryIterator::~InMemoryStatsHistoryIterator() {}
16 bool InMemoryStatsHistoryIterator::Valid() const { return valid_
; }
18 Status
InMemoryStatsHistoryIterator::status() const { return status_
; }
20 void InMemoryStatsHistoryIterator::Next() {
21 // increment start_time by 1 to avoid infinite loop
22 AdvanceIteratorByTime(GetStatsTime() + 1, end_time_
);
25 uint64_t InMemoryStatsHistoryIterator::GetStatsTime() const { return time_
; }
27 const std::map
<std::string
, uint64_t>&
28 InMemoryStatsHistoryIterator::GetStatsMap() const {
32 // advance the iterator to the next time between [start_time, end_time)
33 // if success, update time_ and stats_map_ with new_time and stats_map
34 void InMemoryStatsHistoryIterator::AdvanceIteratorByTime(uint64_t start_time
,
36 // try to find next entry in stats_history_ map
37 if (db_impl_
!= nullptr) {
39 db_impl_
->FindStatsByTime(start_time
, end_time
, &time_
, &stats_map_
);
45 } // namespace rocksdb