66 final int fragment_size = 10;
67 Exception exceptions[] =
new Exception[num_threads];
69 final CyclicBarrier barrier =
new CyclicBarrier(num_threads,
new Runnable() {
72 HeavyDBTestClient dba = HeavyDBTestClient.getClient(
73 "localhost", 6274, db, dbaUser, dbaPassword);
75 +
"(pt GEOMETRY(POINT), ls GEOMETRY(LINESTRING), faii INTEGER[2], fadc DECIMAL(5, 2)[2], fatx TEXT[] ENCODING DICT(32), fatx2 TEXT[2] ENCODING DICT(32)) WITH(FRAGMENT_SIZE = "
76 + fragment_size +
")");
79 +
"( trip INT, mpoly MULTIPOLYGON ) WITH(FRAGMENT_SIZE = "
80 + fragment_size +
")");
82 }
catch (Exception e) {
83 logger.error(
"[" + Thread.currentThread().getId() +
"]"
84 +
" Caught Exception: " + e.getMessage(),
91 ArrayList<Thread> threads =
new ArrayList<>();
92 for (
int i = 0; i < num_threads; i++) {
93 logger.info(
"Starting " + i);
94 final int threadId = i;
96 Thread t =
new Thread(
new Runnable() {
99 long tid = Thread.currentThread().getId();
100 String logPrefix =
"[" + tid +
"]";
103 TCopyParams copy_params =
new TCopyParams();
104 copy_params.has_header = TImportHeaderRow.NO_HEADER;
105 copy_params.delimiter =
",";
106 copy_params.null_str =
"\\N";
107 copy_params.quoted =
true;
108 copy_params.quote =
"\"";
109 copy_params.escape =
"\"";
110 copy_params.line_delim =
"\n";
111 copy_params.array_delim =
",";
112 copy_params.array_begin =
"{";
113 copy_params.array_end =
"}";
114 copy_params.threads = 0;
116 TCopyParams geo_copy_params =
new TCopyParams();
117 geo_copy_params.delimiter =
",";
118 geo_copy_params.null_str =
"\\N";
119 geo_copy_params.quoted =
true;
120 geo_copy_params.quote =
"\"";
121 geo_copy_params.escape =
"\"";
122 geo_copy_params.line_delim =
"\n";
123 geo_copy_params.array_delim =
",";
124 geo_copy_params.array_begin =
"{";
125 geo_copy_params.array_end =
"}";
126 geo_copy_params.threads = 0;
127 geo_copy_params.source_type = TSourceType.GEO_FILE;
132 HeavyDBTestClient user = HeavyDBTestClient.getClient(
133 "localhost", 6274, db, dbUser, dbPassword);
135 if (threadId % 2 == 0) {
136 logger.info(logPrefix +
" IMPORT TABLE");
142 sql =
"COPY " + csvTableName +
" FROM '" + csv_file_path
143 +
"' WITH (header = 'false');";
148 sql =
"DELETE FROM " + csvTableName +
" WHERE fatx2 IS NULL;";
151 sql =
"SELECT COUNT(*) FROM " + csvTableName +
";";
156 sql =
"ALTER TABLE " + csvTableName +
" DROP COLUMN faii;";
160 if (threadId % 2 == 1) {
167 logger.info(logPrefix +
" VALIDATE " + sql);
168 final String validateSql = sql;
173 final String alterSql =
"ALTER TABLE " +
geoTableName +
" SET max_rows = 10;";
180 logger.info(logPrefix +
" IMPORT GEO TABLE");
187 new java.util.ArrayList<TColumnType>(),
188 new TCreateParams()),
193 final String selectSql =
"SELECT * FROM " +
geoTableName +
" LIMIT 2;";
199 sql =
"SELECT * FROM " + csvTableName +
";";
200 logger.info(logPrefix +
" VALIDATE " + sql);
201 user.sqlValidate(sql);
203 sql =
"ALTER TABLE " + csvTableName +
" SET max_rollback_epochs = 0;";
206 sql =
"COPY (SELECT * FROM " + csvTableName +
") TO 'test_export.csv';";
209 for (
int i = 0; i < 5; i++) {
210 final String insertSql =
"INSERT INTO " +
geoTableName +
" VALUES (" + i
211 +
", 'MULTIPOLYGON(((0 0, 1 1, 2 2)))');";
218 sql =
"COPY (SELECT * FROM " + csvTableName +
") TO 'test_export.csv';";
221 sql =
"TRUNCATE TABLE " + csvTableName +
";";
224 sql =
"SELECT COUNT(*) FROM " + csvTableName +
";";
225 logger.info(logPrefix +
" VALIDATE " + sql);
226 user.sqlValidate(sql);
233 }
catch (Exception e) {
234 logger.error(logPrefix +
" Caught Exception: " + e.getMessage(), e);
235 exceptions[threadId] = e;
243 for (Thread t : threads) {
247 HeavyDBTestClient dba =
248 HeavyDBTestClient.getClient(
"localhost", 6274, db, dbaUser, dbaPassword);
249 dba.runSql(
"DROP TABLE " + csvTableName +
";");
251 for (Exception e : exceptions) {
253 logger.error(
"Exception: " + e.getMessage(), e);
void getTableDetails(HeavyDBTestClient user, String logPrefix)
void getTablesMetadata(HeavyDBTestClient user, String logPrefix)
void logAndRunSql(String sql, HeavyDBTestClient user, String logPrefix)
static final String geoTableName
void loadTableBinaryColumnar(HeavyDBTestClient user, String logPrefix)
static final String csvTableName
void loadTable(HeavyDBTestClient user, String logPrefix)
void ignoreMissingTable(final VoidFunction function, final String tableName)