OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
com.mapd.logrunner.LogRunner.myThread Class Reference
+ Inheritance diagram for com.mapd.logrunner.LogRunner.myThread:
+ Collaboration diagram for com.mapd.logrunner.LogRunner.myThread:

Public Member Functions

void run ()
 

Package Functions

 myThread (String str1, MapD.Client client1, String session1)
 

Private Attributes

String str
 
MapD.Client client
 
String session
 

Detailed Description

Definition at line 241 of file LogRunner.java.

Constructor & Destructor Documentation

com.mapd.logrunner.LogRunner.myThread.myThread ( String  str1,
MapD.Client  client1,
String  session1 
)
inlinepackage

Member Function Documentation

void com.mapd.logrunner.LogRunner.myThread.run ( )
inline

Definition at line 253 of file LogRunner.java.

References com.mapd.logrunner.LogRunner.cpuMode, com.mapd.logrunner.LogRunner.gpuMode, Integer, com.mapd.logrunner.LogRunner.myThread.session, and Experimental.String.

253  {
254  int logStart = str.indexOf(']');
255  if (logStart != -1) {
256  String det = str.substring(logStart + 1).trim();
257  String header = str.substring(0, logStart).trim();
258 
259  String[] headDet = header.split(" .");
260  // logger.info("header "+ header + " count " + headDet.length + " detail " + det
261  // );
262  if (headDet.length != 4 || headDet[0].equals("Log")) {
263  return;
264  }
265  Integer pid = Integer.valueOf(headDet[2]);
266 
267  if (det.contains("sql_execute :")) {
268  logger.info("det " + det);
269  String sl[] = det.split(":query_str:");
270  logger.info("run query " + sl[1]);
271  try {
272  client.sql_execute(session, sl[1], true, null, -1, -1);
273  } catch (TMapDException ex1) {
274  logger.error("Failed to execute " + sl[1] + " exception " + ex1.toString());
275  } catch (TException ex) {
276  logger.error("Failed to execute " + sl[1] + " exception " + ex.toString());
277  }
278  return;
279  }
280 
281  // get_result_row_for_pixel
282  // :5pFFQUCKs17GLHOqI7ykK09U8mX7GnLF:widget_id:3:pixel.x:396:pixel.y:53:column_format:1
283  //:PixelRadius:2:table_col_names::points,dest,conv_4326_900913_x(dest_lon) as
284  // x,conv_4326_900913_y(dest_lat) as y,arrdelay as size
285  if (det.contains("get_result_row_for_pixel :")) {
286  logger.info("det " + det);
287  String ss[] = det.split(":");
288  String sl[] = det.split(":table_col_names:");
289  logger.info("run get_result_for_pixel " + sl[1]);
290  Map<String, List<String>> tcn = new HashMap<String, List<String>>();
291 
292  String tn[] = sl[1].split(":");
293  for (int i = 0; i < tn.length; i++) {
294  String name[] = tn[i].split(",");
295  List<String> col = new ArrayList<String>();
296  for (int j = 1; j < name.length; j++) {
297  col.add(name[j]);
298  }
299  tcn.put(name[0], col);
300  }
301  try {
302  client.get_result_row_for_pixel(session,
303  Integer.parseInt(ss[3]),
304  new TPixel(Integer.parseInt(ss[5]), Integer.parseInt(ss[7])),
305  tcn,
306  Boolean.TRUE,
307  Integer.parseInt(ss[11]),
308  null);
309  } catch (TMapDException ex1) {
310  logger.error("Failed to execute get_result_row_for_pixel exception "
311  + ex1.toString());
312  } catch (TException ex) {
313  logger.error("Failed to execute get_result_row_for_pixel exception "
314  + ex.toString());
315  }
316  return;
317  }
318 
319  if (det.contains("render_vega :")) {
320  logger.info("det " + det);
321  String ss[] = det.split(":");
322  String sl[] = det.split(":vega_json:");
323  json.put(pid, det.substring(det.indexOf("render_vega :") + 13, det.length()));
324  logger.info("JSON = " + sl[1]);
325  logger.info("widget = " + Integer.parseInt(ss[3]));
326  logger.info("compressionLevel = " + Integer.parseInt(ss[5]));
327  logger.info("run render_vega");
328  if (cpuMode) {
329  logger.info("In render: setting gpu mode as we were in CPU mode");
330  gpuMode = true;
331  cpuMode = false;
332  try {
333  client.set_execution_mode(session, TExecuteMode.GPU);
334  } catch (TException ex) {
335  logger.error("Failed to set_execution_mode exception " + ex.toString());
336  }
337  }
338  try {
339  TRenderResult fred = client.render_vega(session,
340  Integer.parseInt(ss[3]),
341  sl[1],
342  Integer.parseInt(ss[5]),
343  null);
344  if (false) {
345  try {
346  FileOutputStream fos;
347 
348  fos = new FileOutputStream("/tmp/png.png");
349 
350  fred.image.position(0);
351  byte[] tgxImageDataByte = new byte[fred.image.limit()];
352  fred.image.get(tgxImageDataByte);
353  fos.write(tgxImageDataByte);
354  fos.close();
355  } catch (FileNotFoundException ex) {
356  logger.error("Failed to create file exception " + ex.toString());
357  } catch (IOException ex) {
358  logger.error("Failed to create file exception " + ex.toString());
359  }
360  }
361 
362  } catch (TException ex) {
363  logger.error("Failed to execute render_vega exception " + ex.toString());
364  }
365  return;
366  }
367 
368  if (det.contains("User mapd sets CPU mode")) {
369  logger.info("Set cpu mode");
370  cpuMode = true;
371  gpuMode = false;
372  try {
373  client.set_execution_mode(session, TExecuteMode.CPU);
374  } catch (TException ex) {
375  logger.error("Failed to set_execution_mode exception " + ex.toString());
376  }
377  return;
378  }
379 
380  if (det.contains("User mapd sets GPU mode")) {
381  logger.info("Set gpu mode");
382  gpuMode = true;
383  cpuMode = false;
384  try {
385  client.set_execution_mode(session, TExecuteMode.GPU);
386  } catch (TException ex) {
387  logger.error(
388  "Failed to execute set_execution_mode exception " + ex.toString());
389  }
390  return;
391  }
392  }
393  }

Member Data Documentation

MapD.Client com.mapd.logrunner.LogRunner.myThread.client
private

Definition at line 243 of file LogRunner.java.

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

String com.mapd.logrunner.LogRunner.myThread.session
private
String com.mapd.logrunner.LogRunner.myThread.str
private

Definition at line 242 of file LogRunner.java.

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


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