OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.mapd.logrunner.LogRunner Class Reference
+ Collaboration diagram for com.mapd.logrunner.LogRunner:

Classes

class  myThread
 

Public Member Functions

 LogRunner ()
 

Static Public Member Functions

static void main (String[] args) throws TException
 

Package Functions

void doWork (String[] args) throws TTransportException, TException
 

Static Package Attributes

static final Logger logger = LoggerFactory.getLogger(LogRunner.class)
 

Private Member Functions

Heavy.Client getClient (String hostname, int port) throws TTransportException
 
String getSession (Heavy.Client client) throws TTransportException, TDBException, TException
 
void closeSession (Heavy.Client client, String session) throws TDBException, TException
 
void theRest (Heavy.Client client, String session) throws TException
 

Private Attributes

HashMap< Integer, String > sqlquery
 
HashMap< Integer, String > originalSql
 
HashMap< Integer, String > json
 
boolean gpuMode = false
 
boolean cpuMode = false
 

Detailed Description

Author
michael

Definition at line 62 of file LogRunner.java.

Constructor & Destructor Documentation

com.mapd.logrunner.LogRunner.LogRunner ( )
inline

Definition at line 82 of file LogRunner.java.

References com.mapd.logrunner.LogRunner.json, com.mapd.logrunner.LogRunner.originalSql, and com.mapd.logrunner.LogRunner.sqlquery.

Referenced by com.mapd.logrunner.LogRunner.main().

82  {
83  sqlquery = new HashMap<Integer, String>();
84  originalSql = new HashMap<Integer, String>();
85  json = new HashMap<Integer, String>();
86  }
HashMap< Integer, String > sqlquery
Definition: LogRunner.java:64
HashMap< Integer, String > originalSql
Definition: LogRunner.java:65
HashMap< Integer, String > json
Definition: LogRunner.java:66

+ Here is the caller graph for this function:

Member Function Documentation

void com.mapd.logrunner.LogRunner.closeSession ( Heavy.Client  client,
String  session 
) throws TDBException, TException
inlineprivate

Definition at line 152 of file LogRunner.java.

153  {
154  // Now disconnect
155  logger.info("Trying to disconnect session " + session);
156  client.disconnect(session);
157  }
void com.mapd.logrunner.LogRunner.doWork ( String[]  args) throws TTransportException, TException
inlinepackage

Definition at line 88 of file LogRunner.java.

References run_benchmark_import.args, com.mapd.logrunner.LogRunner.getClient(), com.mapd.logrunner.LogRunner.getSession(), and Integer.

88  {
89  logger.info("In doWork here");
90 
91  int numberThreads = 3;
92  // Runnable[] worker = new Runnable[numberThreads];
93  //
94  // for (int i = 0; i < numberThreads; i++){
95  //
96  Heavy.Client client = getClient(args[0], Integer.valueOf(args[1]));
97  String session = getSession(client);
98  // worker[i] = new myThread(client, session);
99  // }
100 
101  logger.info("got session");
102  try {
103  // ExecutorService executor = Executors.newFixedThreadPool(6);
104  ExecutorService executor = new ThreadPoolExecutor(numberThreads,
105  numberThreads,
106  0L,
107  TimeUnit.MILLISECONDS,
108  new ArrayBlockingQueue<Runnable>(15),
109  new ThreadPoolExecutor.CallerRunsPolicy());
110  while (true) {
111  // BufferedReader in = new BufferedReader(new
112  // FileReader("/data/logfiles/log1"));
113  BufferedReader in = new BufferedReader(new FileReader(args[2]));
114  String str;
115  int current = 0;
116  while ((str = in.readLine()) != null) {
117  Runnable worker = new myThread(str, client, session);
118  // executor.execute(worker);
119  worker.run();
120  }
121  in.close();
122  logger.info("############loop complete");
123  }
124  // executor.shutdown();
125  } catch (IOException e) {
126  logger.error("IOException " + e.getMessage());
127  }
128  }
String getSession(Heavy.Client client)
Definition: LogRunner.java:145
Heavy.Client getClient(String hostname, int port)
Definition: LogRunner.java:130

+ Here is the call graph for this function:

Heavy.Client com.mapd.logrunner.LogRunner.getClient ( String  hostname,
int  port 
) throws TTransportException
inlineprivate

Definition at line 130 of file LogRunner.java.

Referenced by com.mapd.logrunner.LogRunner.doWork().

130  {
131  TTransport transport = null;
132 
133  // transport = new TSocket("localhost", 6274);
134  transport = new THttpClient("http://" + hostname + ":" + port);
135 
136  transport.open();
137 
138  // TProtocol protocol = new TBinaryProtocol(transport);
139  TProtocol protocol = new TJSONProtocol(transport);
140  // TProtocol protocol = new TProtocol(transport);
141 
142  return new Heavy.Client(protocol);
143  }

+ Here is the caller graph for this function:

String com.mapd.logrunner.LogRunner.getSession ( Heavy.Client  client) throws TTransportException, TDBException, TException
inlineprivate

Definition at line 145 of file LogRunner.java.

Referenced by com.mapd.logrunner.LogRunner.doWork().

146  {
147  String session = client.connect("mapd", "HyperInteractive", "mapd");
148  logger.info("Connected session is " + session);
149  return session;
150  }

+ Here is the caller graph for this function:

static void com.mapd.logrunner.LogRunner.main ( String[]  args) throws TException
inlinestatic

Definition at line 70 of file LogRunner.java.

References run_benchmark_import.args, and com.mapd.logrunner.LogRunner.LogRunner().

70  {
71  logger.info("Hello, World");
72 
73  LogRunner x = new LogRunner();
74  try {
75  x.doWork(args);
76  } catch (TTransportException ex) {
77  logger.error(ex.toString());
78  ex.printStackTrace();
79  }
80  }

+ Here is the call graph for this function:

void com.mapd.logrunner.LogRunner.theRest ( Heavy.Client  client,
String  session 
) throws TException
inlineprivate

Definition at line 159 of file LogRunner.java.

References run_benchmark_import.tables, and run_benchmark_import.type.

159  {
160  // lets fetch databases from mapd
161  List<TDBInfo> dbs = client.get_databases(session);
162 
163  for (TDBInfo db : dbs) {
164  logger.info("db is " + db.toString());
165  }
166 
167  // lets fetch tables from mapd
168  List<String> tables = client.get_tables(session);
169 
170  for (String tab : tables) {
171  logger.info("Tables is " + tab);
172  }
173 
174  // lets get the version
175  logger.info("Version " + client.get_version());
176 
177  // get table_details
178  TTableDetails table_details = client.get_table_details(session, "flights");
179  for (TColumnType col : table_details.row_desc) {
180  logger.info("col name :" + col.col_name);
181  logger.info("\tcol encoding :" + col.col_type.encoding);
182  logger.info("\tcol is_array :" + col.col_type.is_array);
183  logger.info("\tcol nullable :" + col.col_type.nullable);
184  logger.info("\tcol type :" + col.col_type.type);
185  }
186 
187  // client.set_execution_mode(session, TExecuteMode.CPU);
188  logger.info(" -- before query -- ");
189 
190  TQueryResult sql_execute = client.sql_execute(session,
191  "Select uniquecarrier,flightnum from flights LIMIT 3;",
192  true,
193  null,
194  -1,
195  -1);
196  // client.send_sql_execute(session, "Select BRAND from ACV ;", true);
197  // logger.info(" -- before query recv -- ");
198  // TQueryResult sql_execute = client.recv_sql_execute();
199 
200  logger.info(" -- after query -- ");
201 
202  logger.info("TQueryResult execution time is " + sql_execute.getExecution_time_ms());
203  logger.info("TQueryResult is " + sql_execute.toString());
204  logger.info("TQueryResult getFieldValue is "
205  + sql_execute.getFieldValue(TQueryResult._Fields.ROW_SET));
206 
207  TRowSet row_set = sql_execute.getRow_set();
208  Object fieldValue = sql_execute.getFieldValue(TQueryResult._Fields.ROW_SET);
209 
210  logger.info("fieldValue " + fieldValue);
211 
212  logger.info("TRowSet is " + row_set.toString());
213 
214  logger.info("Get rows size " + row_set.getRowsSize());
215  logger.info("Get col size " + row_set.getRowsSize());
216 
217  List<TRow> rows = row_set.getRows();
218  int count = 1;
219  for (TRow row : rows) {
220  List<TDatum> cols = row.getCols();
221  if (cols != null) {
222  for (TDatum dat : cols) {
223  logger.info("ROW " + count + " " + dat.getFieldValue(TDatum._Fields.VAL));
224  }
225  count++;
226  }
227  }
228 
229  List<TColumn> columns = row_set.getColumns();
230 
231  logger.info("columns " + columns);
232  count = 1;
233  for (TColumn col : columns) {
234  TColumnData data = col.getData();
235  if (data != null) {
236  logger.info("COL " + count + " " + data.toString());
237  }
238  count++;
239  }
240  }

Member Data Documentation

boolean com.mapd.logrunner.LogRunner.cpuMode = false
private

Definition at line 68 of file LogRunner.java.

Referenced by com.mapd.logrunner.LogRunner.myThread.run().

boolean com.mapd.logrunner.LogRunner.gpuMode = false
private

Definition at line 67 of file LogRunner.java.

Referenced by com.mapd.logrunner.LogRunner.myThread.run().

HashMap<Integer, String> com.mapd.logrunner.LogRunner.json
private

Definition at line 66 of file LogRunner.java.

Referenced by com.mapd.logrunner.LogRunner.LogRunner().

final Logger com.mapd.logrunner.LogRunner.logger = LoggerFactory.getLogger(LogRunner.class)
staticpackage

Definition at line 63 of file LogRunner.java.

HashMap<Integer, String> com.mapd.logrunner.LogRunner.originalSql
private

Definition at line 65 of file LogRunner.java.

Referenced by com.mapd.logrunner.LogRunner.LogRunner().

HashMap<Integer, String> com.mapd.logrunner.LogRunner.sqlquery
private

Definition at line 64 of file LogRunner.java.

Referenced by com.mapd.logrunner.LogRunner.LogRunner().


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