61 final int num_rows = 1000;
62 final int fragment_size = 10;
63 final String tableName =
"test";
64 Exception exceptions[] =
new Exception[num_threads];
66 final CyclicBarrier barrier =
new CyclicBarrier(num_threads,
new Runnable() {
69 HeavyDBTestClient dba = HeavyDBTestClient.getClient(
70 "localhost", 6274, db, dbaUser, dbaPassword);
71 dba.runSql(
"CREATE TABLE " + tableName
72 +
"(x BIGINT, y INTEGER, z SMALLINT, a TINYINT, f FLOAT, d DOUBLE, deci DECIMAL(18,6), str TEXT ENCODING NONE) WITH (FRAGMENT_SIZE = "
73 + fragment_size +
")");
75 for (
int i = 0; i < num_rows; i++) {
76 final String integer_val = Integer.toString(i);
77 final String small_val = Integer.toString(i % 128);
78 final String fp_val = Double.toString(i * 1.1);
79 final String deci_val = Double.toString(i + 0.01);
80 final String str_val =
"'" +
text_values[i % text_values.length] +
"'";
81 final String values_string = String.join(
" , ",
90 dba.runSql(
"INSERT INTO " + tableName +
" VALUES "
91 +
"(" + values_string +
")");
93 }
catch (Exception e) {
94 logger.error(
"[" + Thread.currentThread().getId() +
"]"
95 +
" Caught Exception: " + e.getMessage(),
102 ArrayList<Thread> threads =
new ArrayList<>();
103 for (
int i = 0; i < num_threads; i++) {
104 logger.info(
"Starting " + i);
105 final int threadId = i;
107 Thread t =
new Thread(
new Runnable() {
110 long tid = Thread.currentThread().getId();
111 String logPrefix =
"[" + tid +
"]";
117 HeavyDBTestClient user = HeavyDBTestClient.getClient(
118 "localhost", 6274, db, dbUser, dbPassword);
120 Random rand =
new Random(tid);
123 sql =
"ALTER TABLE " + tableName +
" ADD COLUMN zz TEXT ENCODING DICT(8);";
124 logger.info(logPrefix +
" " + sql);
130 sql =
"SELECT * FROM " + tableName +
" LIMIT 2;";
131 logger.info(logPrefix +
" " + sql);
134 sql =
"DELETE FROM " + tableName +
" WHERE y = " + rand.nextInt(num_rows)
136 logger.info(logPrefix +
" " + sql);
140 sql =
"ALTER TABLE " + tableName +
" DROP COLUMN x;";
141 logger.info(logPrefix +
" " + sql);
145 sql =
"SELECT * FROM " + tableName +
" WHERE str = '"
146 +
text_values[rand.nextInt(text_values.length)] +
"';";
147 logger.info(logPrefix +
" " + sql);
150 sql =
"SELECT COUNT(*) FROM " + tableName +
";";
151 logger.info(logPrefix +
" VALIDATE " + sql);
152 user.sqlValidate(sql);
154 sql =
"TRUNCATE TABLE " + tableName +
";";
155 logger.info(logPrefix +
" " + sql);
158 }
catch (Exception e) {
159 logger.error(logPrefix +
" Caught Exception: " + e.getMessage(), e);
160 exceptions[threadId] = e;
168 for (Thread t : threads) {
172 HeavyDBTestClient dba =
173 HeavyDBTestClient.getClient(
"localhost", 6274, db, dbaUser, dbaPassword);
174 dba.runSql(
"DROP TABLE " + tableName +
";");
176 for (Exception e : exceptions) {
178 logger.error(
"Exception: " + e.getMessage(), e);
static final String[] text_values