OmniSciDB  04ee39c94c
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

MapD.Client getClient (String hostname, int port) throws TTransportException
 
String getSession (MapD.Client client) throws TTransportException, TMapDException, TException
 
void closeSession (MapD.Client client, String session) throws TMapDException, TException
 
void theRest (MapD.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

◆ LogRunner()

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

Definition at line 82 of file LogRunner.java.

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

◆ closeSession()

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

Definition at line 151 of file LogRunner.java.

References client, and session.

152  {
153  // Now disconnect
154  logger.info("Trying to disconnect session " + session);
155  client.disconnect(session);
156  }
mapd::shared_ptr< MapDClient > client
TSessionId session

◆ doWork()

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, client, com.mapd.logrunner.LogRunner.getClient(), com.mapd.logrunner.LogRunner.getSession(), Integer, session, and Experimental.String.

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

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  MapD.Client client = getClient(args[0], Integer.valueOf(args[1]));
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 FileReader("/data/logfiles/log1"));
112  BufferedReader in = new BufferedReader(new FileReader(args[2]));
113  String str;
114  int current = 0;
115  while ((str = in.readLine()) != null) {
116  Runnable worker = new myThread(str, client, session);
117  // executor.execute(worker);
118  worker.run();
119  }
120  in.close();
121  logger.info("############loop complete");
122  }
123  // executor.shutdown();
124  } catch (IOException e) {
125  logger.error("IOException " + e.getMessage());
126  }
127  }
MapD.Client getClient(String hostname, int port)
Definition: LogRunner.java:129
mapd::shared_ptr< MapDClient > client
String getSession(MapD.Client client)
Definition: LogRunner.java:144
TSessionId session
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClient()

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

Definition at line 129 of file LogRunner.java.

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

129  {
130  TTransport transport = null;
131 
132  // transport = new TSocket("localhost", 6274);
133  transport = new THttpClient("http://" + hostname + ":" + port);
134 
135  transport.open();
136 
137  // TProtocol protocol = new TBinaryProtocol(transport);
138  TProtocol protocol = new TJSONProtocol(transport);
139  // TProtocol protocol = new TProtocol(transport);
140 
141  return new MapD.Client(protocol);
142  }
+ Here is the caller graph for this function:

◆ getSession()

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

Definition at line 144 of file LogRunner.java.

References client, session, and Experimental.String.

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

145  {
146  String session = client.connect("mapd", "HyperInteractive", "mapd");
147  logger.info("Connected session is " + session);
148  return session;
149  }
mapd::shared_ptr< MapDClient > client
TSessionId session
+ Here is the caller graph for this function:

◆ main()

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, com.mapd.logrunner.LogRunner.doWork(), 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:

◆ theRest()

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

Definition at line 158 of file LogRunner.java.

References client, session, Experimental.String, and run-benchmark-import.tables.

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

Member Data Documentation

◆ cpuMode

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

Definition at line 68 of file LogRunner.java.

◆ gpuMode

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

Definition at line 67 of file LogRunner.java.

◆ json

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

Definition at line 66 of file LogRunner.java.

◆ logger

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

Definition at line 63 of file LogRunner.java.

◆ originalSql

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

Definition at line 65 of file LogRunner.java.

◆ sqlquery

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

Definition at line 64 of file LogRunner.java.


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