~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/logging_stats/stats_schema.cc

  • Committer: Monty Taylor
  • Date: 2010-08-12 16:38:48 UTC
  • mto: (1711.1.11 build)
  • mto: This revision was merged to the branch mainline in revision 1713.
  • Revision ID: mordred@inaugust.com-20100812163848-s7o3uu537e9bnuqo
Fix timegm issue on solaris.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
 *
104
104
 */
105
105
 
106
 
#include "config.h"
 
106
#include <config.h>
107
107
 
108
108
#include "stats_schema.h"
109
109
 
121
121
  add_field("VARIABLE_VALUE", 1024);
122
122
}
123
123
 
124
 
SessionStatementsTool::Generator::Generator(Field **arg, LoggingStats *in_logging_stats) :
 
124
SessionStatementsTool::Generator::Generator(Field **arg, LoggingStats *logging_stats) :
125
125
  plugin::TableFunction::Generator(arg)
126
126
{
127
127
  count= 0;
128
128
 
129
129
  /* Set user_commands */
130
 
  Scoreboard *current_scoreboard= in_logging_stats->getCurrentScoreboard();
 
130
  Scoreboard *current_scoreboard= logging_stats->getCurrentScoreboard();
131
131
 
132
132
  uint32_t bucket_number= current_scoreboard->getBucketNumber(&getSession());
133
133
 
134
 
  std::vector<ScoreboardSlot* > *scoreboard_vector=
 
134
  vector<ScoreboardSlot* > *scoreboard_vector=
135
135
     current_scoreboard->getVectorOfScoreboardVectors()->at(bucket_number);
136
136
 
137
 
  std::vector<ScoreboardSlot *>::iterator scoreboard_vector_it= scoreboard_vector->begin();
138
 
  std::vector<ScoreboardSlot *>::iterator scoreboard_vector_end= scoreboard_vector->end();
 
137
  vector<ScoreboardSlot *>::iterator scoreboard_vector_it= scoreboard_vector->begin();
 
138
  vector<ScoreboardSlot *>::iterator scoreboard_vector_end= scoreboard_vector->end();
139
139
 
140
140
  ScoreboardSlot *scoreboard_slot= NULL;
141
 
  for (std::vector<ScoreboardSlot *>::iterator it= scoreboard_vector->begin();
 
141
  for (vector<ScoreboardSlot *>::iterator it= scoreboard_vector->begin();
142
142
       it != scoreboard_vector->end(); ++it)
143
143
  {
144
144
    scoreboard_slot= *it;
187
187
  add_field("VARIABLE_VALUE", 1024);
188
188
}
189
189
 
190
 
GlobalStatementsTool::Generator::Generator(Field **arg, LoggingStats *in_logging_stats) :
 
190
GlobalStatementsTool::Generator::Generator(Field **arg, LoggingStats *logging_stats) :
191
191
  plugin::TableFunction::Generator(arg)
192
192
{
193
193
  count= 0;
194
194
  /* add the current scoreboard and the saved global statements */
195
195
  global_stats_to_display= new GlobalStats();
196
 
  CumulativeStats *cumulativeStats= in_logging_stats->getCumulativeStats();
197
 
  cumulativeStats->sumCurrentScoreboard(in_logging_stats->getCurrentScoreboard(), 
 
196
  CumulativeStats *cumulativeStats= logging_stats->getCumulativeStats();
 
197
  cumulativeStats->sumCurrentScoreboard(logging_stats->getCurrentScoreboard(), 
198
198
                                        NULL, global_stats_to_display->getUserCommands());
199
 
  global_stats_to_display->merge(in_logging_stats->getCumulativeStats()->getGlobalStats()); 
 
199
  global_stats_to_display->merge(logging_stats->getCumulativeStats()->getGlobalStats()); 
200
200
}
201
201
 
202
202
GlobalStatementsTool::Generator::~Generator()
260
260
 
261
261
void CurrentCommandsTool::Generator::setVectorIteratorsAndLock(uint32_t bucket_number)
262
262
{
263
 
  std::vector<ScoreboardSlot* > *scoreboard_vector= 
 
263
  vector<ScoreboardSlot* > *scoreboard_vector= 
264
264
    current_scoreboard->getVectorOfScoreboardVectors()->at(bucket_number); 
265
265
 
266
266
  current_lock= current_scoreboard->getVectorOfScoreboardLocks()->at(bucket_number);
454
454
 
455
455
  return false;
456
456
}
457
 
 
458
 
ScoreboardStatsTool::ScoreboardStatsTool(LoggingStats *logging_stats) :
459
 
  plugin::TableFunction("DATA_DICTIONARY", "SCOREBOARD_STATISTICS")
460
 
{
461
 
  outer_logging_stats= logging_stats;
462
 
 
463
 
  add_field("SCOREBOARD_SIZE", TableFunction::NUMBER);
464
 
  add_field("NUMBER_OF_RANGE_LOCKS", TableFunction::NUMBER);
465
 
  add_field("MAX_USERS_LOGGED", TableFunction::NUMBER);
466
 
  add_field("MEMORY_USAGE_BYTES", TableFunction::NUMBER);
467
 
}
468
 
 
469
 
ScoreboardStatsTool::Generator::Generator(Field **arg, LoggingStats *logging_stats) :
470
 
  plugin::TableFunction::Generator(arg)
471
 
{
472
 
  inner_logging_stats= logging_stats;
473
 
  is_last_record= false; 
474
 
}
475
 
 
476
 
bool ScoreboardStatsTool::Generator::populate()
477
 
{
478
 
  if (is_last_record)
479
 
  {
480
 
    return false;
481
 
  }
482
 
 
483
 
  Scoreboard *scoreboard= inner_logging_stats->getCurrentScoreboard();
484
 
  CumulativeStats *cumulativeStats= inner_logging_stats->getCumulativeStats();
485
 
 
486
 
  push(static_cast<uint64_t>(scoreboard->getNumberPerBucket() * scoreboard->getNumberBuckets()));
487
 
  push(static_cast<uint64_t>(scoreboard->getNumberBuckets()));
488
 
  push(static_cast<uint64_t>(cumulativeStats->getCumulativeStatsByUserMax()));
489
 
  push(cumulativeStats->getCumulativeSizeBytes() + scoreboard->getScoreboardSizeBytes()); 
490
 
  
491
 
  is_last_record= true;
492
 
 
493
 
  return true;
494
 
}