54 logger.info(
"In doWork");
56 TTransport transport = null;
58 transport =
new TSocket(
"localhost", 6274);
63 TProtocol protocol =
new TBinaryProtocol(transport);
67 Heavy.Client client =
new Heavy.Client(protocol);
69 String session = null;
71 session = client.connect(
"admin",
"HyperInteractive",
"omnisci");
73 logger.info(
"Connected session is " + session);
76 List<TDBInfo> dbs = client.get_databases(session);
78 for (TDBInfo db : dbs) {
79 logger.info(
"db is " + db.toString());
83 List<String>
tables = client.get_tables(session);
85 for (String tab : tables) {
86 logger.info(
"Tables is " + tab);
90 logger.info(
"Version " + client.get_version());
93 TTableDetails table_details = client.get_table_details(session,
"flights");
94 for (TColumnType col : table_details.row_desc) {
95 logger.info(
"col name :" + col.col_name);
96 logger.info(
"\tcol encoding :" + col.col_type.encoding);
97 logger.info(
"\tcol is_array :" + col.col_type.is_array);
98 logger.info(
"\tcol nullable :" + col.col_type.nullable);
103 logger.info(
" -- before query -- ");
105 TQueryResult sql_execute = client.sql_execute(session,
106 "Select uniquecarrier,flightnum from flights LIMIT 3;",
115 logger.info(
" -- after query -- ");
117 logger.info(
"TQueryResult execution time is " + sql_execute.getExecution_time_ms());
118 logger.info(
"TQueryResult is " + sql_execute.toString());
119 logger.info(
"TQueryResult getFieldValue is "
120 + sql_execute.getFieldValue(TQueryResult._Fields.ROW_SET));
122 TRowSet row_set = sql_execute.getRow_set();
123 Object fieldValue = sql_execute.getFieldValue(TQueryResult._Fields.ROW_SET);
124 logger.info(
"fieldValue " + fieldValue);
126 logger.info(
"TRowSet is " + row_set.toString());
128 logger.info(
"Get rows size " + row_set.getRowsSize());
129 logger.info(
"Get col size " + row_set.getRowsSize());
131 List<TRow>
rows = row_set.getRows();
133 for (TRow row :
rows) {
134 List<TDatum> cols = row.getCols();
136 for (TDatum dat : cols) {
137 logger.info(
"ROW " + count +
" " + dat.getFieldValue(TDatum._Fields.VAL));
143 List<TColumn> columns = row_set.getColumns();
145 logger.info(
"columns " + columns);
147 for (TColumn col : columns) {
148 TColumnData data = col.getData();
150 logger.info(
"COL " + count +
" " + data.toString());
155 int dash = client.create_dashboard(session,
"test1",
"state",
"image",
"metadata");
157 logger.info(
"dash id is " + dash);
160 client.create_dashboard(session,
"test2",
"state2",
"image2",
"metadata2");
162 logger.info(
"dash2 id is " + dash2);
164 client.replace_dashboard(
165 session, dash2,
"test3",
"mapd",
"state3",
"image3",
"metadata3");
167 logger.info(
"replaced");
170 logger.info(
"Trying to disconnect session " + session);
171 client.disconnect(session);
172 }
catch (TDBException ex) {
173 logger.error(ex.getError_msg());
174 ex.printStackTrace();
175 }
catch (TException ex) {
176 logger.error(ex.toString());
177 ex.printStackTrace();
178 }
catch (Exception ex) {
179 logger.error(ex.toString());
180 ex.printStackTrace();
183 logger.info(
"Connection Ended");