rasdaman complete source
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 /
33 #ifndef _R_STATTILING_HH_
34 #define _R_STATTILING_HH_
35 
36 // Include statements
37 
38 class r_Access;
39 class r_Stat_Tiling;
40 
41 //@ManMemo: Module: {\bf rasodmg}
42 
43 /*@Doc:
44 
45  This class represents an access pattern to a certain object.
46  {\tt r_Stat_Tiling} receives a list of this objects so that
47  an appropriate tiling can be defined.
48 */
49 
53 class r_Access
54 {
55 public:
56 
58  r_Access(const r_Minterval& pattern, r_ULong accesses = 1);
64  const r_Minterval& get_pattern() const;
66 
68  void set_pattern(const r_Minterval& pattern);
69 
71  r_ULong get_times() const;
72 
74  void set_times(r_ULong accesses);
75 
78  bool is_near(const r_Access& other, r_ULong border_threshold) const throw (r_Error);
79 
81  void merge_with(const r_Access& other);
82 
84  void print_status(std::ostream& os) const;
85 
87  bool operator==(const r_Access& other) const;
88 
90  bool operator!=(const r_Access& other) const;
91 
92 private:
93 
95  r_Access();
96 
98  r_Minterval interval;
99 
101  r_ULong times;
102 };
103 
104 //@ManMemo: Module: {\bf rasodmg}
108 extern std::ostream& operator<<(std::ostream& os, const r_Access& access);
109 
110 
111 //@ManMemo: Module: {\bf rasodmg}
112 
113 /*@Doc:
114  This class implements the "statistic tiling" algorithm.
115 
116  Three parameters are passed in the constructor of the class,
117  the border threshold for considering two access patterns to be the
118  same, the interesting threshold which specifies the percentage of
119  accesses that must take place so that an areas is considered of interest
120  when performing tiling and also the tilesize.
121 
122  A call to {\tt update_stat_information} should be made prior to performing
123  tiling so that the static information about the accesses to the object
124  can be updated and the tiling operation prepared.
125 */
126 
130 class r_Stat_Tiling : public r_Dimension_Tiling
131 {
132  // ******************* PUBLIC SECTION *******************
133 
134 public: // constants
135 
137  const static r_Area DEF_BORDER_THR;
138 
140  const static r_Double DEF_INTERESTING_THR;
141 
144  r_Stat_Tiling(const char* encoded) throw (r_Error);
145 
147  r_Stat_Tiling(r_Dimension dim,
148  const std::vector<r_Access>& stat_info,
149  r_Bytes ts = RMInit::clientTileSize,
150  r_Area border_threshold = DEF_BORDER_THR,
151  r_Double interesting_threshold = DEF_INTERESTING_THR) throw (r_Error);
164  virtual ~r_Stat_Tiling();
165 
167  virtual const std::vector<r_Minterval>& get_interesting_areas() const;
168 
170  r_Area get_border_threshold() const;
176  r_Double get_interesting_threshold() const;
184  virtual void print_status(std::ostream& os) const;
185 
186  virtual std::vector<r_Minterval>* compute_tiles(const r_Minterval& obj_domain, r_Bytes cell_size) const throw (r_Error);
187 
188  virtual r_Tiling* clone() const;
189 
190  virtual r_Tiling_Scheme get_tiling_scheme() const;
191 
192  static const char* description;
193 
194 protected: // methods
195 
198  void filter(std::vector<r_Access>& patterns) const throw (r_Error);
199 
201  r_Access merge(const std::vector<r_Access>& patterns) const;
202 
204  r_Double interesting_thr;
205 
207  r_Area border_thr;
208 
210  std::vector<r_Minterval> iareas;
211 
213  std::vector<r_Access> stat_info;
214 };
215 
216 #endif
static r_Bytes clientTileSize
Definition: rminit.hh:132
bool operator==(const OId::OIdPrimitive one, const OId &two)
template std::ostream & operator<<(const vector< KeyObject > &, std::ostream &)