summaryrefslogtreecommitdiffstats log msg author committer range
path: root/rasodmg/stattiling.hh
blob: 3577c835424afb0eb102f0860a125e9b110ae6c5 (plain)
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216  /* * This file is part of rasdaman community. * * Rasdaman community is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Rasdaman community is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with rasdaman community. If not, see . * * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / rasdaman GmbH. * * For more information please see * or contact Peter Baumann via . / /** * INCLUDE: stattiling.hh * * MODULE: rasodmg * CLASS: r_Stat_Tiling r_Access * * COMMENTS: * None */ #ifndef _R_STATTILING_HH_ #define _R_STATTILING_HH_ // Include statements class r_Access; class r_Stat_Tiling; //@ManMemo: Module: {\bf rasodmg} /*@Doc: This class represents an access pattern to a certain object. {\tt r_Stat_Tiling} receives a list of this objects so that an appropriate tiling can be defined. */ /** * \ingroup Rasodmgs */ class r_Access { public: /// Class constructor r_Access(const r_Minterval& pattern, r_ULong accesses = 1); /** It takes as parameter the interval and the number of times that interval was accessed. */ /// Gets the current interval (access pattern) const r_Minterval& get_pattern() const; /// Sets the current interval (access pattern) void set_pattern(const r_Minterval& pattern); /// Gets the number of times the pattern was accessed r_ULong get_times() const; /// Sets the number of times the pattern was accessed void set_times(r_ULong accesses); /// Checks if a certain access pattern is "close enough" of other /// throws exception if the domains do not match bool is_near(const r_Access& other, r_ULong border_threshold) const throw (r_Error); /// Merge this access pattern with another void merge_with(const r_Access& other); /// Print object status void print_status(std::ostream& os) const; /// Operator equal bool operator==(const r_Access& other) const; /// Operator different bool operator!=(const r_Access& other) const; private: /// The user can't use the default constructor r_Access(); /// The actual stored pattern r_Minterval interval; /// The number of times it was accessed r_ULong times; }; //@ManMemo: Module: {\bf rasodmg} /** Prints the status of a Access object to a stream */ extern std::ostream& operator<<(std::ostream& os, const r_Access& access); //@ManMemo: Module: {\bf rasodmg} /*@Doc: This class implements the "statistic tiling" algorithm. Three parameters are passed in the constructor of the class, the border threshold for considering two access patterns to be the same, the interesting threshold which specifies the percentage of accesses that must take place so that an areas is considered of interest when performing tiling and also the tilesize. A call to {\tt update_stat_information} should be made prior to performing tiling so that the static information about the accesses to the object can be updated and the tiling operation prepared. */ /** * \ingroup Rasodmgs */ class r_Stat_Tiling : public r_Dimension_Tiling { // ******************* PUBLIC SECTION ******************* public: // constants /// Default threshold for two borders being considered the same const static r_Area DEF_BORDER_THR; /// Default threshold for considering an area interesting when tiling const static r_Double DEF_INTERESTING_THR; /// read everything from an encoded string /// e.g. "2;[0:9,0:9],3;[100:109,0:9],2;2;0.3;100" r_Stat_Tiling(const char* encoded) throw (r_Error); /// Class constructor r_Stat_Tiling(r_Dimension dim, const std::vector& stat_info, r_Bytes ts = RMInit::clientTileSize, r_Area border_threshold = DEF_BORDER_THR, r_Double interesting_threshold = DEF_INTERESTING_THR) throw (r_Error); /** This is the "Statistic Tiling" class constructor. It takes as parameters the threshold for, when performing filtering, considering two borders the same, and also, the threshold at which an area is considered interesting and should be taken in account when performing tiling. Finally, the tilesize is considered as a parameter. stat_info inputs the statistic information into the class and calculates the new interest areas that will be used to perform tiling on the object. An exception is thrown when the statistical data does not fit the dimension. */ virtual ~r_Stat_Tiling(); /// Gets the statistical information virtual const std::vector& get_interesting_areas() const; /// Gets the threshold at which to intervals are considered the same r_Area get_border_threshold() const; /** This method gets the number of points (pixels/cells) at which two intervals are considered to be the same, in the access patterns. */ /// Gets the threshold at which an area is considered to be interesting r_Double get_interesting_threshold() const; /** This method gets the threshold at which an area is considered to be interesting. All the areas that are accessed above the specified threshold, will be considered interest areas when performing tiling. */ virtual void print_status(std::ostream& os) const; virtual std::vector* compute_tiles(const r_Minterval& obj_domain, r_Bytes cell_size) const throw (r_Error); virtual r_Tiling* clone() const; virtual r_Tiling_Scheme get_tiling_scheme() const; static const char* description; protected: // methods /// Filters and access pattern table (list) /// throws exception if dimensions of access patterns are not the same void filter(std::vector& patterns) const throw (r_Error); /// Merges a list of access patterns r_Access merge(const std::vector& patterns) const; /// The "interesting area" threshold r_Double interesting_thr; /// The "same border" threshold r_Area border_thr; /// Current interest areas std::vector iareas; /// Statistical data std::vector stat_info; }; #endif