rasdaman client API  10.6.3
The Array Analytics Engine: Datacubes at Your Fingertips
stattiling.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 */
23 
24 #ifndef _R_STATTILING_HH_
25 #define _R_STATTILING_HH_
26 
27 // Include statements
28 
29 #include "rasodmg/tiling.hh"
30 #include "raslib/minterval.hh"
31 #include "raslib/odmgtypes.hh"
32 #include <iosfwd>
33 
34 class r_Access;
35 class r_Stat_Tiling;
36 
37 //@ManMemo: Module: {\bf rasodmg}
38 
49 class r_Access
50 {
51 public:
53  explicit r_Access(const r_Minterval &pattern, r_ULong accesses = 1);
59  const r_Minterval &get_pattern() const;
61 
63  void set_pattern(const r_Minterval &pattern);
64 
66  r_ULong get_times() const;
67 
69  void set_times(r_ULong accesses);
70 
73  bool is_near(const r_Access &other, r_ULong border_threshold) const;
74 
76  void merge_with(const r_Access &other);
77 
79  void print_status(std::ostream &os) const;
80 
82  bool operator==(const r_Access &other) const;
83 
85  bool operator!=(const r_Access &other) const;
86 
87 private:
89  r_Access() = default;
90 
92  r_Minterval interval;
93 
95  r_ULong times{};
96 };
97 
98 //@ManMemo: Module: {\bf rasodmg}
102 extern std::ostream &operator<<(std::ostream &os, const r_Access &access);
103 
104 //@ManMemo: Module: {\bf rasodmg}
105 
106 /*@Doc:
107  This class implements the "statistic tiling" algorithm.
108 
109  Three parameters are passed in the constructor of the class,
110  the border threshold for considering two access patterns to be the
111  same, the interesting threshold which specifies the percentage of
112  accesses that must take place so that an areas is considered of interest
113  when performing tiling and also the tilesize.
114 
115  A call to \c update_stat_information should be made prior to performing
116  tiling so that the static information about the accesses to the object
117  can be updated and the tiling operation prepared.
118 */
119 
124 {
125  // ******************* PUBLIC SECTION *******************
126 
127 public: // constants
129  const static r_Area DEF_BORDER_THR;
130 
133 
136  explicit r_Stat_Tiling(const char *encoded);
137 
140  const std::vector<r_Access> &stat_info,
142  r_Area border_threshold = DEF_BORDER_THR,
143  r_Double interesting_threshold = DEF_INTERESTING_THR);
156  virtual ~r_Stat_Tiling() = default;
157 
159  virtual const std::vector<r_Minterval> &get_interesting_areas() const;
160 
176  void print_status(std::ostream &os) const override;
177 
178  std::vector<r_Minterval> compute_tiles(const r_Minterval &obj_domain, r_Bytes cell_size) const override;
179 
180  r_Tiling *clone() const override;
181 
182  r_Tiling_Scheme get_tiling_scheme() const override;
183 
184  static const char *description;
185 
186 protected: // methods
189  void filter(std::vector<r_Access> &patterns) const;
190 
192  r_Access merge(const std::vector<r_Access> &patterns) const;
193 
196 
199 
201  std::vector<r_Minterval> iareas;
202 
204  std::vector<r_Access> stat_info;
205 };
206 
207 #endif
r_Access::merge_with
void merge_with(const r_Access &other)
Merge this access pattern with another.
r_Access::operator!=
bool operator!=(const r_Access &other) const
Operator different.
r_Access::set_times
void set_times(r_ULong accesses)
Sets the number of times the pattern was accessed.
r_Dimension_Tiling
Definition: tiling.hh:168
r_Dimension
std::uint32_t r_Dimension
number of dimensions in r_Point and r_Minterval.
Definition: mddtypes.hh:56
r_Stat_Tiling::filter
void filter(std::vector< r_Access > &patterns) const
Filters and access pattern table (list) throws exception if dimensions of access patterns are not the...
r_Stat_Tiling::iareas
std::vector< r_Minterval > iareas
Current interest areas.
Definition: stattiling.hh:201
r_Stat_Tiling::description
static const char * description
Definition: stattiling.hh:184
r_Stat_Tiling::stat_info
std::vector< r_Access > stat_info
Statistical data.
Definition: stattiling.hh:204
r_Stat_Tiling::get_interesting_threshold
r_Double get_interesting_threshold() const
This method gets the number of points (pixels/cells) at which two intervals are considered to be the ...
r_Stat_Tiling::border_thr
r_Area border_thr
The "same border" threshold.
Definition: stattiling.hh:198
tiling.hh
r_Stat_Tiling::get_tiling_scheme
r_Tiling_Scheme get_tiling_scheme() const override
This method is similar to a copy constructor, this is, is returns a copy of the current object.
r_Stat_Tiling::interesting_thr
r_Double interesting_thr
The "interesting area" threshold.
Definition: stattiling.hh:195
r_Stat_Tiling::DEF_INTERESTING_THR
const static r_Double DEF_INTERESTING_THR
Default threshold for considering an area interesting when tiling.
Definition: stattiling.hh:132
r_Tiling_Scheme
r_Tiling_Scheme
Tiling of the object:
Definition: mddtypes.hh:316
r_Stat_Tiling
Definition: stattiling.hh:123
r_ULong
std::uint32_t r_ULong
Definition: odmgtypes.hh:38
minterval.hh
r_Access::set_pattern
void set_pattern(const r_Minterval &pattern)
Sets the current interval (access pattern)
r_Tiling::defaultTileSize
static const r_Bytes defaultTileSize
Definition: tiling.hh:92
r_Tiling
The r_Tiling class is used to specify in which way the tiling is done by the system.
Definition: tiling.hh:52
r_Bytes
size_t r_Bytes
number of bytes in an tile or mdd or type.
Definition: mddtypes.hh:43
r_Access::operator==
bool operator==(const r_Access &other) const
Operator equal.
r_Access
This class represents an access pattern to a certain object.
Definition: stattiling.hh:49
r_Stat_Tiling::DEF_BORDER_THR
const static r_Area DEF_BORDER_THR
Default threshold for two borders being considered the same.
Definition: stattiling.hh:129
r_Stat_Tiling::merge
r_Access merge(const std::vector< r_Access > &patterns) const
Merges a list of access patterns.
r_Stat_Tiling::get_border_threshold
r_Area get_border_threshold() const
Gets the threshold at which to intervals are considered the same.
r_Stat_Tiling::r_Stat_Tiling
r_Stat_Tiling(const char *encoded)
read everything from an encoded string e.g.
r_Stat_Tiling::clone
r_Tiling * clone() const override
This method provides the core funcionality of this class.
odmgtypes.hh
r_Stat_Tiling::print_status
void print_status(std::ostream &os) const override
This method gets the threshold at which an area is considered to be interesting.
r_Access::is_near
bool is_near(const r_Access &other, r_ULong border_threshold) const
Checks if a certain access pattern is "close enough" of other throws exception if the domains do not ...
r_Stat_Tiling::compute_tiles
std::vector< r_Minterval > compute_tiles(const r_Minterval &obj_domain, r_Bytes cell_size) const override
Decompose an object in tiles.
r_Double
double r_Double
Definition: odmgtypes.hh:40
operator<<
std::ostream & operator<<(std::ostream &os, const r_Access &access)
Prints the status of a Access object to a stream.
r_Minterval
The spatial domain of an MDD is represented by an object of class r_Minterval.
Definition: minterval.hh:225
r_Stat_Tiling::get_interesting_areas
virtual const std::vector< r_Minterval > & get_interesting_areas() const
Gets the statistical information.
r_Area
std::uint64_t r_Area
number of cells in an mdd object or tile.
Definition: mddtypes.hh:49
r_Access::get_times
r_ULong get_times() const
Gets the number of times the pattern was accessed.
r_Access::print_status
void print_status(std::ostream &os) const
Print object status.
r_Stat_Tiling::~r_Stat_Tiling
virtual ~r_Stat_Tiling()=default
This is the "Statistic Tiling" class constructor.
r_Access::get_pattern
const r_Minterval & get_pattern() const
It takes as parameter the interval and the number of times that interval was accessed.