OmniSciDB  a987f07e93
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.tests.ReductionConcurrencyTest Class Reference
+ Collaboration diagram for com.mapd.tests.ReductionConcurrencyTest:

Public Member Functions

void testConcurrency () throws Exception
 

Static Public Member Functions

static void main (String[] args) throws Exception
 

Static Package Attributes

static final Logger logger = LoggerFactory.getLogger(ReductionConcurrencyTest.class)
 
static final String[] text_values
 

Private Member Functions

void runTest (String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword, int numRows, int fragmentSize) throws Exception
 

Detailed Description

Definition at line 24 of file ReductionConcurrencyTest.java.

Member Function Documentation

static void com.mapd.tests.ReductionConcurrencyTest.main ( String[]  args) throws Exception
inlinestatic

Definition at line 48 of file ReductionConcurrencyTest.java.

48  {
49  ReductionConcurrencyTest test = new ReductionConcurrencyTest();
50  test.testConcurrency();
51  }
void com.mapd.tests.ReductionConcurrencyTest.runTest ( String  db,
String  dbaUser,
String  dbaPassword,
String  dbUser,
String  dbPassword,
int  numRows,
int  fragmentSize 
) throws Exception
inlineprivate

Definition at line 53 of file ReductionConcurrencyTest.java.

References run, and com.mapd.tests.ReductionConcurrencyTest.text_values.

Referenced by com.mapd.tests.ReductionConcurrencyTest.testConcurrency().

59  {
60  int num_threads = 5;
61  final int runs = 5;
62  Exception exceptions[] = new Exception[num_threads];
63 
64  ArrayList<Thread> threads = new ArrayList<>();
65  for (int i = 0; i < num_threads; i++) {
66  logger.info("Starting " + i);
67  final int threadId = i;
68 
69  Thread t = new Thread(new Runnable() {
70  @Override
71  public void run() {
72  long tid = Thread.currentThread().getId();
73  String logPrefix = "[" + tid + "]";
74  String sql = "";
75 
76  for (int runId = 0; runId < runs; runId++) {
77  final String tableName = dbaUser + "_" + threadId + "_" + runId;
78 
79  try {
80  HeavyDBTestClient user = HeavyDBTestClient.getClient(
81  "localhost", 6274, db, dbUser, dbPassword);
82  user.runSql("DROP TABLE IF EXISTS " + tableName + ";");
83  user.runSql("CREATE TABLE " + tableName
84  + "(x BIGINT, y INTEGER, z SMALLINT, a TINYINT, f FLOAT, d DOUBLE, deci DECIMAL(18,6), str TEXT ENCODING NONE) WITH (FRAGMENT_SIZE = "
85  + fragmentSize + ")");
86 
87  for (int i = 0; i < numRows; i++) {
88  final String integer_val = Integer.toString(i);
89  final String small_val = Integer.toString(i % 128);
90  final String fp_val = Double.toString(i * 1.1);
91  final String deci_val = Double.toString(i + 0.01);
92  final String str_val = "'" + text_values[i % text_values.length] + "'";
93  final String values_string = String.join(" , ",
94  integer_val,
95  integer_val,
96  small_val,
97  small_val,
98  fp_val,
99  fp_val,
100  deci_val,
101  str_val);
102  user.runSql("INSERT INTO " + tableName + " VALUES "
103  + "(" + values_string + ")");
104  }
105 
106  Random rand = new Random(tid);
107 
108  sql = "SELECT * FROM " + tableName + " LIMIT 2;";
109  logger.info(logPrefix + " " + sql);
110  user.runSql(sql);
111 
112  sql = "SELECT x, sum(1) FROM " + tableName + " GROUP BY 1;";
113  logger.info(logPrefix + " " + sql);
114  user.runSql(sql);
115 
116  sql = "SELECT x, y, sum(1) FROM " + tableName + " GROUP BY 1, 2;";
117  logger.info(logPrefix + " " + sql);
118  user.runSql(sql);
119 
120  sql = "SELECT x, y, z, sum(1) FROM " + tableName + " GROUP BY 1, 2, 3;";
121  logger.info(logPrefix + " " + sql);
122  user.runSql(sql);
123 
124  sql = "SELECT x, y, avg(z), sum(1) FROM " + tableName + " GROUP BY 1, 2;";
125  logger.info(logPrefix + " " + sql);
126  user.runSql(sql);
127 
128  sql = "SELECT x, y, max(z), sum(1) FROM " + tableName + " GROUP BY 1, 2;";
129  logger.info(logPrefix + " " + sql);
130  user.runSql(sql);
131 
132  sql = "SELECT x, y, min(z), sum(1) FROM " + tableName + " GROUP BY 1, 2;";
133  logger.info(logPrefix + " " + sql);
134  user.runSql(sql);
135 
136  sql = "SELECT * FROM " + tableName + " WHERE str = '"
137  + text_values[rand.nextInt(text_values.length)] + "';";
138  logger.info(logPrefix + " " + sql);
139  user.runSql(sql);
140 
141  } catch (Exception e) {
142  logger.error(logPrefix + " Caught Exception: " + e.getMessage(), e);
143  exceptions[threadId] = e;
144  }
145  }
146  }
147  });
148  t.start();
149  threads.add(t);
150  }
151 
152  for (Thread t : threads) {
153  t.join();
154  }
155 
156  for (Exception e : exceptions) {
157  if (null != e) {
158  logger.error("Exception: " + e.getMessage(), e);
159  throw e;
160  }
161  }
162  }
static bool run

+ Here is the caller graph for this function:

void com.mapd.tests.ReductionConcurrencyTest.testConcurrency ( ) throws Exception
inline

Definition at line 164 of file ReductionConcurrencyTest.java.

References com.mapd.tests.ReductionConcurrencyTest.runTest().

164  {
165  logger.info("ReductionConcurrencyTest()");
166 
167  HeavyDBTestClient su = HeavyDBTestClient.getClient(
168  "localhost", 6274, "heavyai", "admin", "HyperInteractive");
169  su.runSql("DROP USER IF EXISTS dba;");
170  su.runSql("DROP USER IF EXISTS bob;");
171  su.runSql("CREATE USER dba (password = 'password', is_super = 'true');");
172  su.runSql("CREATE USER bob (password = 'password', is_super = 'false');");
173 
174  su.runSql("GRANT CREATE on DATABASE heavyai TO bob;");
175 
176  su.runSql("DROP DATABASE IF EXISTS db1;");
177  su.runSql("CREATE DATABASE db1;");
178 
179  su.runSql("GRANT CREATE on DATABASE db1 TO bob;");
180  su.runSql("GRANT CREATE VIEW on DATABASE db1 TO bob;");
181  su.runSql("GRANT DROP on DATABASE db1 TO bob;");
182  su.runSql("GRANT DROP VIEW on DATABASE db1 TO bob;");
183 
184  // run the test multiple times to make sure about the test results
185  for (int i = 0; i < 3; ++i) {
186  // test 1. reduction by interpreter
187  runTest("db1", "admin", "HyperInteractive", "admin", "HyperInteractive", 10, 3);
188  // test 2. reduction by codegen
189  runTest("db1", "admin", "HyperInteractive", "admin", "HyperInteractive", 30, 3);
190  }
191 
192  su.runSql("DROP DATABASE db1;");
193  su.runSql("DROP USER bob;");
194  su.runSql("DROP USER dba;");
195 
196  logger.info("ReductionConcurrencyTest() done");
197  }
void runTest(String db, String dbaUser, String dbaPassword, String dbUser, String dbPassword, int numRows, int fragmentSize)

+ Here is the call graph for this function:

Member Data Documentation

final Logger com.mapd.tests.ReductionConcurrencyTest.logger = LoggerFactory.getLogger(ReductionConcurrencyTest.class)
staticpackage

Definition at line 25 of file ReductionConcurrencyTest.java.

final String [] com.mapd.tests.ReductionConcurrencyTest.text_values
staticpackage
Initial value:
= {"foo",
"bar",
"hello",
"world",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p"}

Definition at line 27 of file ReductionConcurrencyTest.java.

Referenced by com.mapd.tests.ReductionConcurrencyTest.runTest().


The documentation for this class was generated from the following file: