00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #pragma once
00031
00032 #include "scoreboard_slot.h"
00033 #include "scoreboard.h"
00034 #include "global_stats.h"
00035
00036 #include <drizzled/atomics.h>
00037
00038 #include <vector>
00039
00040 static const int32_t INVALID_INDEX= -1;
00041
00042 class CumulativeStats
00043 {
00044 public:
00045 CumulativeStats(uint32_t in_cumulative_stats_by_user_max);
00046
00047 ~CumulativeStats();
00048
00049 void logUserStats(ScoreboardSlot* scoreboard_slot, bool reserveSlot);
00050
00051 void logGlobalStats(ScoreboardSlot* scoreboard_slot);
00052
00053 void logGlobalStatusVars(ScoreboardSlot* scoreboard_slot);
00054
00055 std::vector<ScoreboardSlot* > *getCumulativeStatsByUserVector()
00056 {
00057 return cumulative_stats_by_user_vector;
00058 }
00059
00060 GlobalStats *getGlobalStats()
00061 {
00062 return global_stats;
00063 }
00064
00065 StatusVars *getGlobalStatusVars()
00066 {
00067 return global_status_vars;
00068 }
00069
00070 int32_t getCumulativeStatsByUserMax()
00071 {
00072 return cumulative_stats_by_user_max;
00073 }
00074
00075 uint64_t getCumulativeSizeBytes()
00076 {
00077 return cumulative_size_bytes;
00078 }
00079
00080 int32_t getCumulativeStatsLastValidIndex();
00081
00082 bool hasOpenUserSlots()
00083 {
00084 return isOpenUserSlots;
00085 }
00086
00087 void sumCurrentScoreboard(Scoreboard *scoreboard,
00088 StatusVars *current_status_vars,
00089 UserCommands *current_user_commands);
00090
00091 private:
00092 std::vector<ScoreboardSlot* > *cumulative_stats_by_user_vector;
00093 GlobalStats *global_stats;
00094 StatusVars *global_status_vars;
00095 uint64_t cumulative_size_bytes;
00096 int32_t cumulative_stats_by_user_max;
00097 drizzled::atomic<int32_t> last_valid_index;
00098 bool isOpenUserSlots;
00099 };
00100