Example #1
0
 /** Try and stop the current kdb query. */
 public void cancelExecution() {
   try {
     kdbClient.interruptQuery();
   } catch (Exception e) {
     logger.log(Level.WARNING, "Interrupt failed", e);
   }
 }
Example #2
0
 /** Pass a string to kdb for evaluation. */
 public void evaluate(SimpleEvaluationObject obj, String code) {
   try {
     kdbProcess.getErrorHandler().reset(obj);
     kdbProcess.getOutputHandler().reset(obj);
     Object result = kdbClient.execute(code);
     obj.finished(convert(result));
   } catch (Exception e) {
     obj.error(e);
   }
   kdbProcess.getErrorHandler().reset(null);
   kdbProcess.getOutputHandler().reset(null);
 }
Example #3
0
 /** So long, farewell. */
 public void exit() {
   try {
     kdbClient.close();
   } catch (IOException e) {
     //
   }
   kdbProcess.interrupt();
   try {
     kdbProcess.join(5000);
   } catch (InterruptedException e) {
     //
   }
 }
Example #4
0
  /** Autocomplete a kdb expression. */
  public List<String> autocomplete(String code, int caretPosition) {
    if (code.isEmpty()) return null;

    // Go back build the longest name string we can.
    int s = caretPosition - 1;
    while ((s >= 0) && isQName(code.charAt(s))) {
      --s;
    }

    try {
      return Arrays.asList(
          (String[]) kdbClient.execute(".bk.ac[\"" + code.substring(s + 1, caretPosition) + "\"]"));
    } catch (Exception ex) {
      return null;
    }
  }