/* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. This program 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; version 2 of the License. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include #include #include int _verbose = 1; int _help = 0; int _batch = 128; int _records = 1000; int _loops = 100; int _loops_per_query = 100; int _depth = 4; unsigned int _seed = 0; static const char * _options = ""; static const char * _db = "TEST_DB"; extern const char *load_default_groups[]; static struct my_option my_long_options[] = { NDB_STD_OPTS("hugoJoin"), { "database", 'd', "Database", (uchar**) &_db, (uchar**) &_db, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "options", 'o', "comma separated list of options", (uchar**) &_options, (uchar**) &_options, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "loops", 'l', "Loops", (uchar**) &_loops, 0, 0, GET_INT, REQUIRED_ARG, _loops, 0, 0, 0, 0, 0}, { "verbose", 'v', "verbosity", (uchar**) &_verbose, 0, 0, GET_INT, REQUIRED_ARG, _verbose, 0, 0, 0, 0, 0}, { "loops_per_query", 'q', "Recreate query each #loops", (uchar**) &_loops_per_query, 0, 0, GET_INT, REQUIRED_ARG, _loops_per_query, 0, 0, 0, 0, 0}, { "batch", 'b', "Batch size (for lookups)", (uchar**) &_batch, 0, 0, GET_INT, REQUIRED_ARG, _batch, 0, 0, 0, 0, 0}, { "records", 'r', "Records (for lookups)", (uchar**) &_records, 0, 0, GET_INT, REQUIRED_ARG, _records, 0, 0, 0, 0, 0}, { "join-depth", 'j', "Join depth", (uchar**) &_depth, 0, 0, GET_INT, REQUIRED_ARG, _depth, 0, 0, 0, 0, 0}, { "seed", NDB_OPT_NOSHORT, "Random seed", (uchar **) &_seed, (uchar **) &_seed, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; static void short_usage_sub(void) { ndb_short_usage_sub(NULL); } static void usage() { char desc[] = "This run random joins on table-list\n"; puts(desc); ndb_usage(short_usage_sub, load_default_groups, my_long_options); } int main(int argc, char** argv){ NDB_INIT(argv[0]); ndb_opt_set_usage_funcs(short_usage_sub, usage); ndb_load_defaults(NULL, load_default_groups, &argc, &argv); int ho_error; if ((ho_error=handle_options(&argc, &argv, my_long_options, ndb_std_get_one_option))) return -1; // Connect to Ndb Ndb_cluster_connection con; if(con.connect(12, 5, 1) != 0) { return NDBT_ProgramExit(NDBT_FAILED); } if (con.wait_until_ready(30,0) < 0) { ndbout << "Cluster nodes not ready in 30 seconds." << endl; return NDBT_ProgramExit(NDBT_FAILED); } Ndb MyNdb( &con, _db); if(MyNdb.init() != 0) { NDB_ERR(MyNdb.getNdbError()); return NDBT_ProgramExit(NDBT_FAILED); } Vector tables; for(int i = 0; i list; BaseString tmp(_options); tmp.split(list, ","); for (unsigned i = 0; i= 2) { q->print(); ndbout << endl; } for (int j = 0; j < _loops_per_query && ((_loops == 0) || (i < _loops)); i++, j++) { int res = 0; HugoQueries hq(* q); if (q->isScanQuery()) { res = hq.runScanQuery(&MyNdb); } else { res = hq.runLookupQuery(&MyNdb, _records/_depth, _batch); } if (res != 0) { return NDBT_ProgramExit(NDBT_FAILED); } if (hq.m_rows_found.size() != 0) { printf("\tfound: [ "); for (unsigned i = 0; i