16 package com.mapd.tests;
18 import org.apache.thrift.TException;
19 import org.apache.thrift.protocol.TBinaryProtocol;
20 import org.apache.thrift.protocol.TProtocol;
21 import org.apache.thrift.transport.TSocket;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.HashSet;
26 import java.util.List;
28 import ai.heavy.thrift.server.*;
29 import ai.heavy.thrift.server.Heavy;
36 return client.get_server_status(
sessionId);
39 public List<TServerStatus>
get_status() throws TDBException, TException {
44 return client.get_hardware_info(
sessionId);
47 public List<TNodeMemoryInfo>
get_memory(String memory_level)
48 throws TDBException, TException {
49 return client.get_memory(
sessionId, memory_level);
53 return client.get_table_details(
sessionId, table_name);
57 String tableName, String databaseName)
throws Exception {
58 return client.get_table_details_for_database(
sessionId, tableName, databaseName);
65 public TQueryResult
runSql(String sql)
throws Exception {
66 return client.sql_execute(
sessionId, sql,
true, null, -1, -1);
69 public List<TColumnType>
sqlValidate(String sql)
throws Exception {
70 return client.sql_validate(
sessionId, sql);
74 return client.create_dashboard(
79 int dashboard_id, java.lang.String
name, java.lang.String new_owner)
91 TDashboard dashboard = client.get_dashboard(
sessionId, id);
103 public void import_table(String table_name, String file_name, TCopyParams copy_params)
105 client.import_table(
sessionId, table_name, file_name, copy_params);
110 TCopyParams copy_params,
111 java.util.List<TColumnType> row_desc,
112 TCreateParams create_params)
throws Exception {
113 client.import_geo_table(
114 sessionId, table_name, file_name, copy_params, row_desc, create_params);
127 return client.get_db_object_privs(
sessionId, objectName,
type);
135 List<String> roles = client.get_all_roles_for_user(
sessionId, username);
136 return new HashSet<String>(roles);
140 return client.get_queries_info(
sessionId);
144 String tableName, List<List<String>>
rows, List<String> columnNames)
146 List<TStringRow> load_rows =
new ArrayList<>();
147 for (List<String> row :
rows) {
148 TStringRow tStringRow =
new TStringRow(
new ArrayList<>());
149 for (String value : row) {
150 tStringRow.cols.add(
new TStringValue(value,
false));
152 load_rows.add(tStringRow);
154 client.load_table(
sessionId, tableName, load_rows, columnNames);
158 String tableName, List<List<Object>>
rows, List<String> columnNames)
160 List<TRow> load_rows =
new ArrayList<>();
161 for (List<Object> row :
rows) {
162 TRow tRow =
new TRow(
new ArrayList<>());
163 for (Object value : row) {
168 client.load_table_binary(
sessionId, tableName, load_rows, columnNames);
172 TDatumVal tDatumVal =
new TDatumVal();
173 if (value instanceof Long) {
174 tDatumVal.int_val = ((Long) value);
175 }
else if (value instanceof
Double) {
176 tDatumVal.real_val = ((Double) value);
177 }
else if (value instanceof String) {
178 tDatumVal.str_val = ((String) value);
179 }
else if (value instanceof List) {
180 tDatumVal.arr_val =
new ArrayList<>();
181 for (Object arrayValue : ((List<Object>) value)) {
185 throw new RuntimeException(
"Unexpected value type. Value: " + value);
187 return new TDatum(tDatumVal,
false);
191 String tableName, List<List<Object>> columns, List<String> columnNames)
194 client.load_table_binary_columnar(
sessionId, tableName, load_columns, columnNames);
198 List<TColumn> load_columns =
new ArrayList<>();
199 for (List<Object> column : columns) {
206 TColumn tColumn =
new TColumn();
207 tColumn.data =
new TColumnData(
208 new ArrayList<>(),
new ArrayList<>(),
new ArrayList<>(),
new ArrayList<>());
209 tColumn.nulls =
new ArrayList<>();
210 for (Object value : column) {
211 if (value instanceof Long) {
212 tColumn.data.int_col.add((Long) value);
213 }
else if (value instanceof
Double) {
214 tColumn.data.real_col.add((Double) value);
215 }
else if (value instanceof String) {
216 tColumn.data.str_col.add((String) value);
217 }
else if (value instanceof List) {
220 throw new RuntimeException(
"Unexpected value type. Value: " + value);
222 tColumn.nulls.add(
false);
228 String host,
int port, String db, String user, String password)
230 TSocket transport =
new TSocket(host, port);
232 TProtocol protocol =
new TBinaryProtocol(transport);
233 Heavy.Client
client =
new Heavy.Client(protocol);
236 session.sessionId = client.connect(user, password, db);
List< TQueryInfo > get_queries_info()
TColumn convertToTColumn(List< Object > column)
List< TDashboard > get_dashboards()
List< String > get_roles()
TClusterHardwareInfo get_hardware_info()
void load_table(String tableName, List< List< String >> rows, List< String > columnNames)
TDatum convertToTDatum(Object value)
int create_dashboard(String name)
static HeavyDBTestClient getClient(String host, int port, String db, String user, String password)
void import_table(String table_name, String file_name, TCopyParams copy_params)
Collection< String > get_all_roles_for_user(String username)
TTableDetails get_table_details(String table_name)
void replace_dashboard(int dashboard_id, java.lang.String name, java.lang.String new_owner)
void import_geo_table(String table_name, String file_name, TCopyParams copy_params, java.util.List< TColumnType > row_desc, TCreateParams create_params)
List< TColumnType > sqlValidate(String sql)
List< TDBObject > get_db_object_privs(String objectName, TDBObjectType type)
void load_table_binary_columnar(String tableName, List< List< Object >> columns, List< String > columnNames)
List< TNodeMemoryInfo > get_memory(String memory_level)
List< TTableMeta > get_tables_meta()
void load_table_binary(String tableName, List< List< Object >> rows, List< String > columnNames)
void delete_dashboard(int id)
List< TServerStatus > get_status()
TQueryResult runSql(String sql)
TServerStatus get_server_status()
List< TColumn > convertToTColumns(List< List< Object >> columns)
List< String > get_users()
TTableDetails get_table_details_for_database(String tableName, String databaseName)
TDashboard get_dashboard(int id)