MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hugoCalculator.cpp
1 /*
2  Copyright (C) 2003-2006 MySQL AB
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program 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 this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 
20 #include <ndb_global.h>
21 
22 #include <NdbOut.hpp>
23 #include <NdbSleep.h>
24 #include <NDBT_Tables.hpp>
25 #include <getarg.h>
26 #include <NDBT.hpp>
27 #include <HugoCalculator.hpp>
28 
29 //extern NdbOut g_info;
30 
31 int main(int argc, const char** argv)
32 {
33  ndb_init();
34  int _row = 0;
35  int _column = 0;
36  int _updates = 0;
37  const char* _tableName = NULL;
38 
39  struct getargs args[] = {
40  { "row", 'r', arg_integer, &_row, "The row number", "row" },
41  { "column", 'c', arg_integer, &_column, "The column id", "column" },
42  { "updates", 'u', arg_integer, &_updates, "# of updates", "updates" }
43  };
44 
45  int num_args = sizeof(args) / sizeof(args[0]);
46  int optind = 0;
47 
48  if(getarg(args, num_args, argc, argv, &optind) || argv[optind] == NULL) {
49  arg_printusage(args, num_args, argv[0], "table name\n");
50  return NDBT_WRONGARGS;
51  }
52  // Check if table name is supplied
53  if (argv[optind] != NULL)
54  _tableName = argv[optind];
55 
56 
57  const NdbDictionary::Table* table = NDBT_Tables::getTable(_tableName);
58  const NdbDictionary::Column * attribute = table->getColumn(_column);
59 
60  g_info << "Table " << _tableName << endl
61  << "Row: " << _row << ", "
62  << "Column(" << attribute->getName() << ")"
63  << "[" << attribute->getType() << "]"
64  << ", Updates: " << _updates
65  << endl;
66 
67  HugoCalculator calc(*table);
68  char buf[8000];
69  g_info << "Value: " << calc.calcValue(_row, _column, _updates, buf)
70  << endl;
71 
72  return 0;
73 }