当前位置: 首页>>代码示例>>Java>>正文


Java InterpreterUtils类代码示例

本文整理汇总了Java中org.apache.zeppelin.interpreter.InterpreterUtils的典型用法代码示例。如果您正苦于以下问题:Java InterpreterUtils类的具体用法?Java InterpreterUtils怎么用?Java InterpreterUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InterpreterUtils类属于org.apache.zeppelin.interpreter包,在下文中一共展示了InterpreterUtils类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interpret

import org.apache.zeppelin.interpreter.InterpreterUtils; //导入依赖的package包/类
@Override
public InterpreterResult interpret(String st, InterpreterContext interpreterContext) {
  String html;
  try {
    html = md.process(st);
  } catch (IOException | java.lang.RuntimeException e) {
    return new InterpreterResult(Code.ERROR, InterpreterUtils.getMostRelevantMessage(e));
  }
  return new InterpreterResult(Code.SUCCESS, "%html " + html);
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:11,代码来源:Markdown.java

示例2: interpret

import org.apache.zeppelin.interpreter.InterpreterUtils; //导入依赖的package包/类
@Override
public InterpreterResult interpret(String st, InterpreterContext context) {
  if (StringUtils.isEmpty(st)) {
    return new InterpreterResult(InterpreterResult.Code.SUCCESS, "");
  }

  try {
    return interpret(st, context.getParagraphId(), this.displayAppInfo, true);
  } catch (LivyException e) {
    LOGGER.error("Fail to interpret:" + st, e);
    return new InterpreterResult(InterpreterResult.Code.ERROR,
        InterpreterUtils.getMostRelevantMessage(e));
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:15,代码来源:BaseLivyInterpreter.java

示例3: interpret

import org.apache.zeppelin.interpreter.InterpreterUtils; //导入依赖的package包/类
@Override
public InterpreterResult interpret(String markdownText, InterpreterContext interpreterContext) {
  String html;

  try {
    html = parser.render(markdownText);
  } catch (RuntimeException e) {
    LOGGER.error("Exception in MarkdownInterpreter while interpret ", e);
    return new InterpreterResult(Code.ERROR, InterpreterUtils.getMostRelevantMessage(e));
  }

  return new InterpreterResult(Code.SUCCESS, "%html " + html);
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:14,代码来源:Markdown.java

示例4: interpretInput

import org.apache.zeppelin.interpreter.InterpreterUtils; //导入依赖的package包/类
public InterpreterResult interpretInput(String[] lines) {
  SparkEnv.set(env);

  // add print("") to make sure not finishing with comment
  // see https://github.com/NFLabs/zeppelin/issues/151
  String[] linesToRun = new String[lines.length + 1];
  for (int i = 0; i < lines.length; i++) {
    linesToRun[i] = lines[i];
  }
  linesToRun[lines.length] = "print(\"\")";

  Console.setOut((java.io.PrintStream) binder.get("out"));
  out.reset();
  Code r = null;
  String incomplete = "";

  for (int l = 0; l < linesToRun.length; l++) {
    String s = linesToRun[l];
    // check if next line starts with "." (but not ".." or "./") it is treated as an invocation
    if (l + 1 < linesToRun.length) {
      String nextLine = linesToRun[l + 1].trim();
      if (nextLine.startsWith(".") && !nextLine.startsWith("..") && !nextLine.startsWith("./")) {
        incomplete += s + "\n";
        continue;
      }
    }

    scala.tools.nsc.interpreter.Results.Result res = null;
    try {
      res = intp.interpret(incomplete + s);
    } catch (Exception e) {
      sc.clearJobGroup();
      logger.info("Interpreter exception", e);
      return new InterpreterResult(Code.ERROR, InterpreterUtils.getMostRelevantMessage(e));
    }

    r = getResultCode(res);

    if (r == Code.ERROR) {
      sc.clearJobGroup();
      return new InterpreterResult(r, out.toString());
    } else if (r == Code.INCOMPLETE) {
      incomplete += s + "\n";
    } else {
      incomplete = "";
    }
  }

  if (r == Code.INCOMPLETE) {
    return new InterpreterResult(r, "Incomplete expression");
  } else {
    return new InterpreterResult(r, out.toString());
  }
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:55,代码来源:SparkInterpreter.java

示例5: interpret

import org.apache.zeppelin.interpreter.InterpreterUtils; //导入依赖的package包/类
public InterpreterResult interpret(String[] lines, InterpreterContext context) {
  final IMain imain = flinkIloop.intp();
  
  String[] linesToRun = new String[lines.length + 1];
  for (int i = 0; i < lines.length; i++) {
    linesToRun[i] = lines[i];
  }
  linesToRun[lines.length] = "print(\"\")";

  System.setOut(new PrintStream(out));
  out.reset();
  Code r = null;

  String incomplete = "";
  for (int l = 0; l < linesToRun.length; l++) {
    final String s = linesToRun[l];
    // check if next line starts with "." (but not ".." or "./") it is treated as an invocation
    if (l + 1 < linesToRun.length) {
      String nextLine = linesToRun[l + 1].trim();
      if (nextLine.startsWith(".") && !nextLine.startsWith("..") && !nextLine.startsWith("./")) {
        incomplete += s + "\n";
        continue;
      }
    }

    final String currentCommand = incomplete;

    scala.tools.nsc.interpreter.Results.Result res = null;
    try {
      res = Console.withOut(
        System.out,
        new AbstractFunction0<Results.Result>() {
          @Override
          public Results.Result apply() {
            return imain.interpret(currentCommand + s);
          }
        });
    } catch (Exception e) {
      logger.info("Interpreter exception", e);
      return new InterpreterResult(Code.ERROR, InterpreterUtils.getMostRelevantMessage(e));
    }

    r = getResultCode(res);

    if (r == Code.ERROR) {
      return new InterpreterResult(r, out.toString());
    } else if (r == Code.INCOMPLETE) {
      incomplete += s + "\n";
    } else {
      incomplete = "";
    }
  }

  if (r == Code.INCOMPLETE) {
    return new InterpreterResult(r, "Incomplete expression");
  } else {
    return new InterpreterResult(r, out.toString());
  }
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:60,代码来源:FlinkInterpreter.java

示例6: interpret

import org.apache.zeppelin.interpreter.InterpreterUtils; //导入依赖的package包/类
public InterpreterResult interpret(String[] lines, InterpreterContext context) {
  final IMain imain = flinkIloop.intp();
  
  String[] linesToRun = new String[lines.length + 1];
  for (int i = 0; i < lines.length; i++) {
    linesToRun[i] = lines[i];
  }
  linesToRun[lines.length] = "print(\"\")";

  System.setOut(new PrintStream(out));
  out.reset();
  Code r = null;

  String incomplete = "";
  boolean inComment = false;

  for (int l = 0; l < linesToRun.length; l++) {
    final String s = linesToRun[l];
    // check if next line starts with "." (but not ".." or "./") it is treated as an invocation
    if (l + 1 < linesToRun.length) {
      String nextLine = linesToRun[l + 1].trim();
      boolean continuation = false;
      if (nextLine.isEmpty()
              || nextLine.startsWith("//")         // skip empty line or comment
              || nextLine.startsWith("}")
              || nextLine.startsWith("object")) { // include "} object" for Scala companion object
        continuation = true;
      } else if (!inComment && nextLine.startsWith("/*")) {
        inComment = true;
        continuation = true;
      } else if (inComment && nextLine.lastIndexOf("*/") >= 0) {
        inComment = false;
        continuation = true;
      } else if (nextLine.length() > 1
              && nextLine.charAt(0) == '.'
              && nextLine.charAt(1) != '.'     // ".."
              && nextLine.charAt(1) != '/') {  // "./"
        continuation = true;
      } else if (inComment) {
        continuation = true;
      }
      if (continuation) {
        incomplete += s + "\n";
        continue;
      }
    }

    final String currentCommand = incomplete;

    scala.tools.nsc.interpreter.Results.Result res = null;
    try {
      res = Console.withOut(
        System.out,
        new AbstractFunction0<Results.Result>() {
          @Override
          public Results.Result apply() {
            return imain.interpret(currentCommand + s);
          }
        });
    } catch (Exception e) {
      logger.info("Interpreter exception", e);
      return new InterpreterResult(Code.ERROR, InterpreterUtils.getMostRelevantMessage(e));
    }

    r = getResultCode(res);

    if (r == Code.ERROR) {
      return new InterpreterResult(r, out.toString());
    } else if (r == Code.INCOMPLETE) {
      incomplete += s + "\n";
    } else {
      incomplete = "";
    }
  }

  if (r == Code.INCOMPLETE) {
    return new InterpreterResult(r, "Incomplete expression");
  } else {
    return new InterpreterResult(r, out.toString());
  }
}
 
开发者ID:apache,项目名称:zeppelin,代码行数:82,代码来源:FlinkInterpreter.java


注:本文中的org.apache.zeppelin.interpreter.InterpreterUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。