libspatialindex API Reference  (git-trunk)
mvrtree/Statistics.cc
Go to the documentation of this file.
1 /******************************************************************************
2  * Project: libspatialindex - A C++ library for spatial indexing
3  * Author: Marios Hadjieleftheriou, mhadji@gmail.com
4  ******************************************************************************
5  * Copyright (c) 2002, Marios Hadjieleftheriou
6  *
7  * All rights reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included
17  * in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26 ******************************************************************************/
27 
29 
30 #include "Statistics.h"
31 
32 using namespace SpatialIndex::MVRTree;
33 
35 {
36  reset();
37 }
38 
40 {
41  m_u64Reads = s.m_u64Reads;
42  m_u64Writes = s.m_u64Writes;
43  m_u64Splits = s.m_u64Splits;
44  m_u64Hits = s.m_u64Hits;
45  m_u64Misses = s.m_u64Misses;
46  m_u32Nodes = s.m_u32Nodes;
47  m_u32DeadIndexNodes = s.m_u32DeadIndexNodes;
48  m_u32DeadLeafNodes = s.m_u32DeadLeafNodes;
49  m_u64Adjustments = s.m_u64Adjustments;
50  m_u64QueryResults = s.m_u64QueryResults;
51  m_u64Data = s.m_u64Data;
52  m_u64TotalData = s.m_u64TotalData;
53  m_treeHeight = s.m_treeHeight;
54  m_nodesInLevel = s.m_nodesInLevel;
55 }
56 
58 = default;
59 
61 {
62  if (this != &s)
63  {
64  m_u64Reads = s.m_u64Reads;
65  m_u64Writes = s.m_u64Writes;
66  m_u64Splits = s.m_u64Splits;
67  m_u64Hits = s.m_u64Hits;
68  m_u64Misses = s.m_u64Misses;
69  m_u32Nodes = s.m_u32Nodes;
70  m_u32DeadIndexNodes = s.m_u32DeadIndexNodes;
71  m_u32DeadLeafNodes = s.m_u32DeadLeafNodes;
72  m_u64Adjustments = s.m_u64Adjustments;
73  m_u64QueryResults = s.m_u64QueryResults;
74  m_u64Data = s.m_u64Data;
75  m_u64TotalData = s.m_u64TotalData;
76  m_treeHeight = s.m_treeHeight;
77  m_nodesInLevel = s.m_nodesInLevel;
78  }
79 
80  return *this;
81 }
82 
83 uint64_t Statistics::getReads() const
84 {
85  return m_u64Reads;
86 }
87 
88 uint64_t Statistics::getWrites() const
89 {
90  return m_u64Writes;
91 }
92 
94 {
95  return m_u32Nodes;
96 }
97 
99 {
100  return m_u64Data;
101 }
102 
103 uint64_t Statistics::getSplits() const
104 {
105  return m_u64Splits;
106 }
107 
108 uint64_t Statistics::getHits() const
109 {
110  return m_u64Hits;
111 }
112 
113 uint64_t Statistics::getMisses() const
114 {
115  return m_u64Misses;
116 }
117 
119 {
120  return m_u64Adjustments;
121 }
122 
124 {
125  return m_u64QueryResults;
126 }
127 
129 {
130  uint32_t ret = 0;
131 
132  for (size_t cIndex = 0; cIndex < m_treeHeight.size(); ++cIndex)
133  {
134  ret = std::max(ret, m_treeHeight[cIndex]);
135  }
136 
137  return ret;
138 }
139 
140 uint32_t Statistics::getNumberOfNodesInLevel(uint32_t l) const
141 {
142  try
143  {
144  return m_nodesInLevel.at(l);
145  }
146  catch (...)
147  {
149  }
150 }
151 
152 void Statistics::reset()
153 {
154  m_u64Reads = 0;
155  m_u64Writes = 0;
156  m_u64Splits = 0;
157  m_u64Hits = 0;
158  m_u64Misses = 0;
159  m_u32Nodes = 0;
160  m_u32DeadIndexNodes = 0;
161  m_u32DeadLeafNodes = 0;
162  m_u64Adjustments = 0;
163  m_u64QueryResults = 0;
164  m_u64Data = 0;
165  m_u64TotalData = 0;
166  m_treeHeight.clear();
167  m_nodesInLevel.clear();
168 }
169 
170 std::ostream& SpatialIndex::MVRTree::operator<<(std::ostream& os, const Statistics& s)
171 {
172  os << "Reads: " << s.m_u64Reads << std::endl
173  << "Writes: " << s.m_u64Writes << std::endl
174  << "Hits: " << s.m_u64Hits << std::endl
175  << "Misses: " << s.m_u64Misses << std::endl
176  << "Number of live data: " << s.m_u64Data << std::endl
177  << "Total number of data: " << s.m_u64TotalData << std::endl
178  << "Number of nodes: " << s.m_u32Nodes << std::endl
179  << "Number of dead index nodes: " << s.m_u32DeadIndexNodes << std::endl
180  << "Number of dead leaf nodes: " << s.m_u32DeadLeafNodes << std::endl;
181 
182  for (size_t cTree = 0; cTree < s.m_treeHeight.size(); ++cTree)
183  {
184  os << "Tree " << cTree << ", Height " << s.m_treeHeight[cTree] << std::endl;
185  }
186 
187  for (size_t cLevel = 0; cLevel < s.m_nodesInLevel.size(); ++cLevel)
188  {
189  os << "Level " << cLevel << " pages: " << s.m_nodesInLevel[cLevel] << std::endl;
190  }
191 
192  os << "Splits: " << s.m_u64Splits << std::endl
193  << "Adjustments: " << s.m_u64Adjustments << std::endl
194  << "Query results: " << s.m_u64QueryResults << std::endl;
195 
196  return os;
197 }
virtual uint64_t getAdjustments() const
uint32_t getNumberOfNodes() const override
virtual uint32_t getTreeHeight() const
virtual uint64_t getSplits() const
uint64_t getNumberOfData() const override
virtual uint64_t getMisses() const
uint64_t getWrites() const override
Statistics & operator=(const Statistics &)
virtual uint32_t getNumberOfNodesInLevel(uint32_t l) const
virtual uint64_t getQueryResults() const
uint64_t getReads() const override
std::ostream & operator<<(std::ostream &os, const MVRTree &t)
Definition: MVRTree.cc:1325