~fluidity-core/fluidity/refactor-netcdf

« back to all changes in this revision

Viewing changes to spatialindex-1.5/src/rtree/Statistics.cc

  • Committer: Jon Hill
  • Date: 2013-02-16 09:01:40 UTC
  • mfrom: (3981.7.159 fluidity)
  • Revision ID: jon.hill@imperial.ac.uk-20130216090140-bplzxqzdk1eik4za
Megre from trunk, fixing several conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Spatial Index Library
2
 
//
3
 
// Copyright (C) 2002 Navel Ltd.
4
 
//
5
 
// This library is free software; you can redistribute it and/or
6
 
// modify it under the terms of the GNU Lesser General Public
7
 
// License as published by the Free Software Foundation; either
8
 
// version 2.1 of the License, or (at your option) any later version.
9
 
//
10
 
// This library is distributed in the hope that it will be useful,
11
 
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
// Lesser General Public License for more details.
14
 
//
15
 
// You should have received a copy of the GNU Lesser General Public
16
 
// License along with this library; if not, write to the Free Software
17
 
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
//
19
 
//  Email:
20
 
//    mhadji@gmail.com
21
 
 
22
 
#include "../spatialindex/SpatialIndexImpl.h"
23
 
 
24
 
#include "Statistics.h"
25
 
 
26
 
using namespace SpatialIndex::RTree;
27
 
 
28
 
Statistics::Statistics()
29
 
{
30
 
        reset();
31
 
}
32
 
 
33
 
Statistics::Statistics(const Statistics& s)
34
 
{
35
 
        m_u64Reads  = s.m_u64Reads;
36
 
        m_u64Writes = s.m_u64Writes;
37
 
        m_u64Splits = s.m_u64Splits;
38
 
        m_u64Hits   = s.m_u64Hits;
39
 
        m_u64Misses = s.m_u64Misses;
40
 
        m_u32Nodes  = s.m_u32Nodes;
41
 
        m_u64Adjustments = s.m_u64Adjustments;
42
 
        m_u64QueryResults = s.m_u64QueryResults;
43
 
        m_u64Data = s.m_u64Data;
44
 
        m_u32TreeHeight = s.m_u32TreeHeight;
45
 
        m_nodesInLevel = s.m_nodesInLevel;
46
 
}
47
 
 
48
 
Statistics::~Statistics()
49
 
{
50
 
}
51
 
 
52
 
Statistics& Statistics::operator=(const Statistics& s)
53
 
{
54
 
        if (this != &s)
55
 
        {
56
 
                m_u64Reads  = s.m_u64Reads;
57
 
                m_u64Writes = s.m_u64Writes;
58
 
                m_u64Splits = s.m_u64Splits;
59
 
                m_u64Hits   = s.m_u64Hits;
60
 
                m_u64Misses = s.m_u64Misses;
61
 
                m_u32Nodes  = s.m_u32Nodes;
62
 
                m_u64Adjustments = s.m_u64Adjustments;
63
 
                m_u64QueryResults = s.m_u64QueryResults;
64
 
                m_u64Data = s.m_u64Data;
65
 
                m_u32TreeHeight = s.m_u32TreeHeight;
66
 
                m_nodesInLevel = s.m_nodesInLevel;
67
 
        }
68
 
 
69
 
        return *this;
70
 
}
71
 
 
72
 
uint64_t Statistics::getReads() const
73
 
{
74
 
        return m_u64Reads;
75
 
}
76
 
 
77
 
uint64_t Statistics::getWrites() const
78
 
{
79
 
        return m_u64Writes;
80
 
}
81
 
 
82
 
uint32_t Statistics::getNumberOfNodes() const
83
 
{
84
 
        return m_u32Nodes;
85
 
}
86
 
 
87
 
uint64_t Statistics::getNumberOfData() const
88
 
{
89
 
        return m_u64Data;
90
 
}
91
 
 
92
 
uint64_t Statistics::getSplits() const
93
 
{
94
 
        return m_u64Splits;
95
 
}
96
 
 
97
 
uint64_t Statistics::getHits() const
98
 
{
99
 
        return m_u64Hits;
100
 
}
101
 
 
102
 
uint64_t Statistics::getMisses() const
103
 
{
104
 
        return m_u64Misses;
105
 
}
106
 
 
107
 
uint64_t Statistics::getAdjustments() const
108
 
{
109
 
        return m_u64Adjustments;
110
 
}
111
 
 
112
 
uint64_t Statistics::getQueryResults() const
113
 
{
114
 
        return m_u64QueryResults;
115
 
}
116
 
 
117
 
uint32_t Statistics::getTreeHeight() const
118
 
{
119
 
        return m_u32TreeHeight;
120
 
}
121
 
 
122
 
uint32_t Statistics::getNumberOfNodesInLevel(uint32_t l) const
123
 
{
124
 
        uint32_t u32Nodes;
125
 
        try
126
 
        {
127
 
                u32Nodes = m_nodesInLevel.at(l);
128
 
        }
129
 
        catch (...)
130
 
        {
131
 
                throw Tools::IndexOutOfBoundsException(l);
132
 
        }
133
 
 
134
 
        return u32Nodes;
135
 
}
136
 
 
137
 
void Statistics::reset()
138
 
{
139
 
        m_u64Reads  = 0;
140
 
        m_u64Writes = 0;
141
 
        m_u64Splits = 0;
142
 
        m_u64Hits   = 0;
143
 
        m_u64Misses = 0;
144
 
        m_u32Nodes  = 0;
145
 
        m_u64Adjustments = 0;
146
 
        m_u64QueryResults = 0;
147
 
        m_u64Data = 0;
148
 
        m_u32TreeHeight = 0;
149
 
        m_nodesInLevel.clear();
150
 
}
151
 
 
152
 
std::ostream& SpatialIndex::RTree::operator<<(std::ostream& os, const Statistics& s)
153
 
{
154
 
        os      << "Reads: " << s.m_u64Reads << std::endl
155
 
                << "Writes: " << s.m_u64Writes << std::endl
156
 
                << "Hits: " << s.m_u64Hits << std::endl
157
 
                << "Misses: " << s.m_u64Misses << std::endl
158
 
                << "Tree height: " << s.m_u32TreeHeight << std::endl
159
 
                << "Number of data: " << s.m_u64Data << std::endl
160
 
                << "Number of nodes: " << s.m_u32Nodes << std::endl;
161
 
 
162
 
        for (uint32_t u32Level = 0; u32Level < s.m_u32TreeHeight; ++u32Level)
163
 
        {
164
 
                os << "Level " << u32Level << " pages: " << s.m_nodesInLevel[u32Level] << std::endl;
165
 
        }
166
 
 
167
 
        os      << "Splits: " << s.m_u64Splits << std::endl
168
 
                << "Adjustments: " << s.m_u64Adjustments << std::endl
169
 
                << "Query results: " << s.m_u64QueryResults << std::endl;
170
 
 
171
 
        return os;
172
 
}