1 22 package org.enhydra.dods.statistics; 23 24 import java.util.Date ; 25 26 35 public class TableStatistics implements Statistics { 36 37 40 protected int insertNum = 0; 41 42 45 protected int updateNum = 0; 46 47 50 protected int deleteNum = 0; 51 52 55 protected int lazyLoadingNum = 0; 56 57 60 protected Date startTime; 61 62 65 protected Date stopTime; 66 67 72 protected int queryNum = 0; 73 74 79 protected int queryByOIdNum = 0; 80 81 86 protected int averageQueryTime = 0; 87 88 93 protected int averageQueryByOIdTime = 0; 94 95 98 public TableStatistics() { 99 this.clears(); 100 } 101 102 107 public int getStatisticsType() { 108 return TABLE_STATISTICS; 109 } 110 111 116 public int getInsertNum() { 117 return insertNum; 118 } 119 120 126 public void setInsertNum(int newInsertNum) { 127 this.insertNum = newInsertNum; 128 } 129 130 133 public void incrementInsertNum() { 134 insertNum++; 135 } 136 137 142 public int getUpdateNum() { 143 return updateNum; 144 } 145 146 152 public void setUpdateNum(int newUpdateNum) { 153 this.updateNum = newUpdateNum; 154 } 155 156 159 public void incrementUpdateNum() { 160 updateNum++; 161 } 162 163 168 public int getDeleteNum() { 169 return deleteNum; 170 } 171 172 178 public void setDeleteNum(int newDeleteNum) { 179 this.deleteNum = newDeleteNum; 180 } 181 182 185 public void incrementDeleteNum() { 186 deleteNum++; 187 } 188 189 195 public int getDMLNum() { 196 return insertNum + updateNum + deleteNum; 197 } 198 199 204 public int getLazyLoadingNum() { 205 return lazyLoadingNum; 206 } 207 208 214 public void setLazyLoadingNum(int newLazyLoadingNum) { 215 this.lazyLoadingNum = newLazyLoadingNum; 216 } 217 218 221 public void incrementLazyLoadingNum() { 222 lazyLoadingNum++; 223 } 224 225 230 public Date getStartTime() { 231 return startTime; 232 } 233 234 239 public void setStartTime(Date startTime) { 240 this.startTime = startTime; 241 } 242 243 248 public Date getStopTime() { 249 return stopTime; 250 } 251 252 257 public void setStopTime(Date stopTime) { 258 this.stopTime = stopTime; 259 } 260 261 264 public void stopTime() { 265 stopTime = new Date (); 266 } 267 268 275 public int getQueryNum() { 276 return queryNum; 277 } 278 279 287 public void setQueryNum(int newQueryNum) { 288 this.queryNum = newQueryNum; 289 } 290 291 296 public void incrementQueryNum() { 297 queryNum++; 298 } 299 300 307 public int getQueryByOIdNum() { 308 return queryByOIdNum; 309 } 310 311 319 public void setQueryByOIdNum(int newQueryByOIdNum) { 320 this.queryByOIdNum = newQueryByOIdNum; 321 } 322 323 328 public void incrementQueryByOIdNum() { 329 queryByOIdNum++; 330 } 331 332 339 public int getQueryAverageTime() { 340 return averageQueryTime; 341 } 342 343 350 public void updateQueryAverageTime(int newTime) { 351 long sum = 0; 352 353 if (queryNum > 0) { 354 sum = (queryNum - 1) * averageQueryTime + newTime; 355 sum = sum / queryNum; 356 averageQueryTime = (new Long (sum)).intValue(); 357 } 358 } 359 360 367 public int getQueryByOIdAverageTime() { 368 return averageQueryByOIdTime; 369 } 370 371 380 public void updateQueryByOIdAverageTime(int newTime, int no) { 381 if (no > 0) { 382 long sum = 0; 383 384 if (queryByOIdNum > 0) { 385 sum = (queryByOIdNum) * averageQueryByOIdTime + newTime; 386 queryByOIdNum += no; 387 sum = sum / queryByOIdNum; 388 averageQueryByOIdTime = (new Long (sum)).intValue(); 389 } else { 390 sum = newTime; 391 queryByOIdNum += no; 392 sum = sum / queryByOIdNum; 393 averageQueryByOIdTime = (new Long (sum)).intValue(); 394 } 395 } 396 } 397 398 401 public void clears() { 402 insertNum = 0; 403 updateNum = 0; 404 deleteNum = 0; 405 lazyLoadingNum = 0; 406 startTime = new Date (); 407 stopTime = new Date (); 408 queryNum = 0; 409 queryByOIdNum = 0; 410 averageQueryTime = 0; 411 averageQueryByOIdTime = 0; 412 } 413 414 417 public void clear() { 418 this.clears(); 419 } 420 421 433 public CacheStatistics getCacheStatistics(int type) { 434 return null; 435 } 436 } 437 | Popular Tags |