本文整理汇总了Java中org.apache.zeppelin.interpreter.thrift.InterpreterCompletion类的典型用法代码示例。如果您正苦于以下问题:Java InterpreterCompletion类的具体用法?Java InterpreterCompletion怎么用?Java InterpreterCompletion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InterpreterCompletion类属于org.apache.zeppelin.interpreter.thrift包,在下文中一共展示了InterpreterCompletion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testAutoCompletion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Test
public void testAutoCompletion() throws SQLException, IOException {
Properties properties = new Properties();
properties.setProperty("common.max_count", "1000");
properties.setProperty("common.max_retry", "3");
properties.setProperty("default.driver", "org.apache.hive.jdbc.HiveDriver");
properties.setProperty("default.url", getJdbcConnection());
properties.setProperty("default.user", "");
properties.setProperty("default.password", "");
ImpalaInterpreter ImpalaInterpreter = new ImpalaInterpreter(properties);
ImpalaInterpreter.open();
ImpalaInterpreter.interpret("", interpreterContext);
List<InterpreterCompletion> completionList = ImpalaInterpreter.completion("SEL", 0);
InterpreterCompletion correctCompletionKeyword = new InterpreterCompletion("SELECT", "SELECT");
assertEquals(2, completionList.size());
assertEquals(true, completionList.contains(correctCompletionKeyword));
assertEquals(0, ImpalaInterpreter.completion("SEL", 100).size());
}
开发者ID:cas-bigdatalab,项目名称:zeppelin-impala-interpreter,代码行数:23,代码来源:ImpalaInterpreterTest.java
示例2: completion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Override
public List<InterpreterCompletion> completion(String s, int i) {
final List<InterpreterCompletion> suggestions = new ArrayList<>();
if (StringUtils.isEmpty(s)) {
suggestions.addAll(SUGGESTIONS);
}
else {
for (final String cmd : COMMANDS) {
if (cmd.contains(s.toUpperCase())) {
suggestions.add(new InterpreterCompletion(cmd, cmd));
}
}
}
return suggestions;
}
开发者ID:bbonnin,项目名称:zeppelin-arangodb-interpreter,代码行数:19,代码来源:ArangoDbInterpreter.java
示例3: getInterpreterCompletion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
public List<InterpreterCompletion> getInterpreterCompletion() {
List<InterpreterCompletion> completion = new LinkedList();
for (InterpreterSetting intp : interpreterSettingManager.getInterpreterSettings(getId())) {
List<InterpreterInfo> intInfo = intp.getInterpreterInfos();
if (intInfo.size() > 1) {
for (InterpreterInfo info : intInfo) {
String name = intp.getName() + "." + info.getName();
completion.add(new InterpreterCompletion(name, name, CompletionType.setting.name()));
}
} else {
completion.add(new InterpreterCompletion(intp.getName(), intp.getName(),
CompletionType.setting.name()));
}
}
return completion;
}
开发者ID:apache,项目名称:zeppelin,代码行数:17,代码来源:Note.java
示例4: completion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
public List<InterpreterCompletion> completion(String buffer, int cursor) {
String lines[] = buffer.split(System.getProperty("line.separator"));
if (lines.length > 0 && lines[0].startsWith("%") && cursor <= lines[0].trim().length()) {
int idx = lines[0].indexOf(' ');
if (idx < 0 || (idx > 0 && cursor <= idx)) {
return note.getInterpreterCompletion();
}
}
this.interpreter = getBindedInterpreter();
setText(buffer);
cursor = calculateCursorPosition(buffer, cursor);
InterpreterContext interpreterContext = getInterpreterContextWithoutRunner(null);
try {
if (this.interpreter != null) {
return this.interpreter.completion(this.scriptText, cursor, interpreterContext);
} else {
return null;
}
} catch (InterpreterException e) {
throw new RuntimeException("Fail to get completion", e);
}
}
开发者ID:apache,项目名称:zeppelin,代码行数:27,代码来源:Paragraph.java
示例5: completion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Override
public List<InterpreterCompletion> completion(final String buf, final int cursor,
final InterpreterContext interpreterContext)
throws InterpreterException {
if (!isOpened) {
open();
}
RemoteInterpreterProcess interpreterProcess = null;
try {
interpreterProcess = getOrCreateInterpreterProcess();
} catch (IOException e) {
throw new InterpreterException(e);
}
this.lifecycleManager.onInterpreterUse(this.getInterpreterGroup(), sessionId);
return interpreterProcess.callRemoteFunction(
new RemoteInterpreterProcess.RemoteFunction<List<InterpreterCompletion>>() {
@Override
public List<InterpreterCompletion> call(Client client) throws Exception {
return client.completion(sessionId, className, buf, cursor,
convert(interpreterContext));
}
});
}
开发者ID:apache,项目名称:zeppelin,代码行数:24,代码来源:RemoteInterpreter.java
示例6: completion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Override
public List<InterpreterCompletion> completion(String buf, int cursor,
InterpreterContext interpreterContext) throws InterpreterException {
List<InterpreterCompletion> candidates = new ArrayList<>();
String propertyKey = getPropertyKey(buf);
String sqlCompleterKey =
String.format("%s.%s", interpreterContext.getAuthenticationInfo().getUser(), propertyKey);
SqlCompleter sqlCompleter = sqlCompletersMap.get(sqlCompleterKey);
Connection connection = null;
try {
if (interpreterContext != null) {
connection = getConnection(propertyKey, interpreterContext);
}
} catch (ClassNotFoundException | SQLException | IOException e) {
logger.warn("SQLCompleter will created without use connection");
}
sqlCompleter = createOrUpdateSqlCompleter(sqlCompleter, connection, propertyKey, buf, cursor);
sqlCompletersMap.put(sqlCompleterKey, sqlCompleter);
sqlCompleter.complete(buf, cursor, candidates);
return candidates;
}
开发者ID:apache,项目名称:zeppelin,代码行数:25,代码来源:JDBCInterpreter.java
示例7: testAutoCompletion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Test
public void testAutoCompletion() throws SQLException, IOException, InterpreterException {
Properties properties = new Properties();
properties.setProperty("common.max_count", "1000");
properties.setProperty("common.max_retry", "3");
properties.setProperty("default.driver", "org.h2.Driver");
properties.setProperty("default.url", getJdbcConnection());
properties.setProperty("default.user", "");
properties.setProperty("default.password", "");
JDBCInterpreter jdbcInterpreter = new JDBCInterpreter(properties);
jdbcInterpreter.open();
jdbcInterpreter.interpret("", interpreterContext);
List<InterpreterCompletion> completionList = jdbcInterpreter.completion("sel", 3, interpreterContext);
InterpreterCompletion correctCompletionKeyword = new InterpreterCompletion("select", "select", CompletionType.keyword.name());
assertEquals(1, completionList.size());
assertEquals(true, completionList.contains(correctCompletionKeyword));
}
开发者ID:apache,项目名称:zeppelin,代码行数:22,代码来源:JDBCInterpreterTest.java
示例8: expectedCompletions
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
private void expectedCompletions(String buffer, int cursor,
Set<InterpreterCompletion> expected) {
if (StringUtils.isNotEmpty(buffer) && buffer.length() > cursor) {
buffer = buffer.substring(0, cursor);
}
List<InterpreterCompletion> candidates = new ArrayList<>();
completer.complete(buffer, cursor, candidates);
String explain = explain(buffer, cursor, candidates);
logger.info(explain);
Assert.assertEquals("Buffer [" + buffer.replace(" ", ".") + "] and Cursor[" + cursor + "] "
+ explain, expected, newHashSet(candidates));
}
开发者ID:apache,项目名称:zeppelin,代码行数:18,代码来源:SqlCompleterTest.java
示例9: testCompleteName_Empty
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Test
public void testCompleteName_Empty() {
String buffer = "";
int cursor = 0;
List<InterpreterCompletion> candidates = new ArrayList<>();
Map<String, String> aliases = new HashMap<>();
sqlCompleter.completeName(buffer, cursor, candidates, aliases);
assertEquals(9, candidates.size());
assertTrue(candidates.contains(new InterpreterCompletion("prod_dds", "prod_dds", CompletionType.schema.name())));
assertTrue(candidates.contains(new InterpreterCompletion("prod_emart", "prod_emart", CompletionType.schema.name())));
assertTrue(candidates.contains(new InterpreterCompletion("SUM", "SUM", CompletionType.keyword.name())));
assertTrue(candidates.contains(new InterpreterCompletion("SUBSTRING", "SUBSTRING", CompletionType.keyword.name())));
assertTrue(candidates.contains(new InterpreterCompletion("SUBCLASS_ORIGIN", "SUBCLASS_ORIGIN", CompletionType.keyword.name())));
assertTrue(candidates.contains(new InterpreterCompletion("SELECT", "SELECT", CompletionType.keyword.name())));
assertTrue(candidates.contains(new InterpreterCompletion("ORDER", "ORDER", CompletionType.keyword.name())));
assertTrue(candidates.contains(new InterpreterCompletion("LIMIT", "LIMIT", CompletionType.keyword.name())));
assertTrue(candidates.contains(new InterpreterCompletion("FROM", "FROM", CompletionType.keyword.name())));
}
开发者ID:apache,项目名称:zeppelin,代码行数:19,代码来源:SqlCompleterTest.java
示例10: testEdges
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Test
public void testEdges() {
String buffer = " ORDER ";
tester.buffer(buffer).from(3).to(7).expect(newHashSet(new InterpreterCompletion("ORDER", "ORDER", CompletionType.keyword.name()))).test();
tester.buffer(buffer).from(0).to(1).expect(newHashSet(
new InterpreterCompletion("ORDER", "ORDER", CompletionType.keyword.name()),
new InterpreterCompletion("SUBCLASS_ORIGIN", "SUBCLASS_ORIGIN", CompletionType.keyword.name()),
new InterpreterCompletion("SUBSTRING", "SUBSTRING", CompletionType.keyword.name()),
new InterpreterCompletion("prod_emart", "prod_emart", CompletionType.schema.name()),
new InterpreterCompletion("LIMIT", "LIMIT", CompletionType.keyword.name()),
new InterpreterCompletion("SUM", "SUM", CompletionType.keyword.name()),
new InterpreterCompletion("prod_dds", "prod_dds", CompletionType.schema.name()),
new InterpreterCompletion("SELECT", "SELECT", CompletionType.keyword.name()),
new InterpreterCompletion("FROM", "FROM", CompletionType.keyword.name())
)).test();
}
开发者ID:apache,项目名称:zeppelin,代码行数:17,代码来源:SqlCompleterTest.java
示例11: completion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Override
public List<InterpreterCompletion> completion(String buf, int cursor,
InterpreterContext interpreterContext) {
LOGGER.debug("Call completion for: " + buf);
List<InterpreterCompletion> completions = new ArrayList<>();
CompletionResponse response =
ipythonClient.complete(
CompletionRequest.getDefaultInstance().newBuilder().setCode(buf)
.setCursor(cursor).build());
for (int i = 0; i < response.getMatchesCount(); i++) {
String match = response.getMatches(i);
int lastIndexOfDot = match.lastIndexOf(".");
if (lastIndexOfDot != -1) {
match = match.substring(lastIndexOfDot + 1);
}
completions.add(new InterpreterCompletion(match, match, ""));
}
return completions;
}
开发者ID:apache,项目名称:zeppelin,代码行数:20,代码来源:IPythonInterpreter.java
示例12: completion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Override
public List<InterpreterCompletion> completion(String buf, int cursor,
InterpreterContext interpreterContext) {
if (Utils.isScala2_10()) {
ScalaCompleter c = (ScalaCompleter) Utils.invokeMethod(completer, "completer");
Candidates ret = c.complete(buf, cursor);
List<String> candidates = WrapAsJava$.MODULE$.seqAsJavaList(ret.candidates());
List<InterpreterCompletion> completions = new LinkedList<>();
for (String candidate : candidates) {
completions.add(new InterpreterCompletion(candidate, candidate, StringUtils.EMPTY));
}
return completions;
} else {
return new LinkedList<>();
}
}
开发者ID:apache,项目名称:zeppelin,代码行数:20,代码来源:DepInterpreter.java
示例13: testCompletion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Theory
public void testCompletion(ElasticsearchInterpreter interpreter) {
final List<InterpreterCompletion> expectedResultOne = Arrays.asList(new InterpreterCompletion("count", "count", CompletionType.command.name()));
final List<InterpreterCompletion> expectedResultTwo = Arrays.asList(new InterpreterCompletion("help", "help", CompletionType.command.name()));
final List<InterpreterCompletion> resultOne = interpreter.completion("co", 0, null);
final List<InterpreterCompletion> resultTwo = interpreter.completion("he", 0, null);
final List<InterpreterCompletion> resultAll = interpreter.completion("", 0, null);
Assert.assertEquals(expectedResultOne, resultOne);
Assert.assertEquals(expectedResultTwo, resultTwo);
final List<String> allCompletionList = new ArrayList<>();
for (final InterpreterCompletion ic : resultAll) {
allCompletionList.add(ic.getName());
}
Assert.assertEquals(ElasticsearchInterpreter.COMMANDS, allCompletionList);
}
开发者ID:apache,项目名称:zeppelin,代码行数:19,代码来源:ElasticsearchInterpreterTest.java
示例14: completion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Override
public List<InterpreterCompletion> completion(String buf, int cursor,
InterpreterContext interpreterContext) {
String[] words = splitAndRemoveEmpty(splitAndRemoveEmpty(buf, "\n"), " ");
String lastWord = "";
if (words.length > 0) {
lastWord = words[ words.length - 1 ];
}
List<InterpreterCompletion> voices = new LinkedList<>();
for (String command : keywords) {
if (command.startsWith(lastWord)) {
voices.add(new InterpreterCompletion(command, command, CompletionType.command.name()));
}
}
return voices;
}
开发者ID:apache,项目名称:zeppelin,代码行数:18,代码来源:AlluxioInterpreter.java
示例15: completion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
private void completion(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook,
Message fromMessage) throws IOException {
String paragraphId = (String) fromMessage.get("id");
String buffer = (String) fromMessage.get("buf");
int cursor = (int) Double.parseDouble(fromMessage.get("cursor").toString());
Message resp = new Message(OP.COMPLETION_LIST).put("id", paragraphId);
if (paragraphId == null) {
conn.send(serializeMessage(resp));
return;
}
final Note note = notebook.getNote(getOpenNoteId(conn));
List<InterpreterCompletion> candidates = note.completion(paragraphId, buffer, cursor);
resp.put("completions", candidates);
conn.send(serializeMessage(resp));
}
开发者ID:apache,项目名称:zeppelin,代码行数:17,代码来源:NotebookServer.java
示例16: completion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
public void completion(Session conn, HashSet<String> userAndRoles, Notebook notebook,
Message fromMessage) throws IOException {
String paragraphId = (String) fromMessage.get("id");
String buffer = (String) fromMessage.get("buf");
int cursor = (int) Double.parseDouble(fromMessage.get("cursor").toString());
Message resp = new Message(Message.OP.COMPLETION_LIST).put("id", paragraphId);
if (paragraphId == null) {
sendMsg(conn, serializeMessage(resp));
return;
}
final Note note = notebook.getNote(getOpenNoteId(conn));
List<InterpreterCompletion> candidates = note.completion(paragraphId, buffer, cursor);
resp.put("completions", candidates);
sendMsg(conn, serializeMessage(resp));
}
开发者ID:hopshadoop,项目名称:hopsworks,代码行数:17,代码来源:NotebookServerImpl.java
示例17: testAutoCompletionWithNoCompletions
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
/**
* What happens when we have nothing useful to auto-complete?
*/
@Test
public void testAutoCompletionWithNoCompletions() {
// the user's input that needs auto-completed
final String buffer = "NOTHING_AUTOCOMPLETES_THIS_";
// the cursor is at the end of the buffer
int cursor = buffer.length();
// perform auto-completion
List<InterpreterCompletion> completions = interpreter.completion(buffer, cursor);
// expect no completions
assertEquals(0, completions.size());
}
开发者ID:apache,项目名称:metron,代码行数:19,代码来源:StellarInterpreterTest.java
示例18: completion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Override
public List<InterpreterCompletion> completion(final String s, final int i) {
final List<InterpreterCompletion> suggestions = new ArrayList<>();
for (final Command cmd : Command.values()) {
if (cmd.getCommand().toLowerCase().contains(s)) {
suggestions.add(new InterpreterCompletion(cmd.getCommand(), cmd
.getCommand()));
}
}
return suggestions;
}
开发者ID:sanjuthomas,项目名称:zeppelin-marklogic-interpreter,代码行数:13,代码来源:MarkLogicInterpreter.java
示例19: completion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
@Override
public List<InterpreterCompletion> completion(String buf, int cursor,
InterpreterContext interpreterContext) {
List<InterpreterCompletion> candidates = Collections.emptyList();
try {
candidates = callCompletion(new CompletionRequest(buf, getSessionKind(), cursor));
} catch (SessionNotFoundException e) {
LOGGER.warn("Livy session {} is expired. Will return empty list of candidates.",
sessionInfo.id);
} catch (LivyException le) {
logger.error("Failed to call code completions. Will return empty list of candidates", le);
}
return candidates;
}
开发者ID:apache,项目名称:zeppelin,代码行数:15,代码来源:BaseLivyInterpreter.java
示例20: callCompletion
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; //导入依赖的package包/类
private List<InterpreterCompletion> callCompletion(CompletionRequest req) throws LivyException {
List<InterpreterCompletion> candidates = new ArrayList<>();
try {
CompletionResponse resp = CompletionResponse.fromJson(
callRestAPI("/sessions/" + sessionInfo.id + "/completion", "POST", req.toJson()));
for (String candidate : resp.candidates) {
candidates.add(new InterpreterCompletion(candidate, candidate, StringUtils.EMPTY));
}
} catch (APINotFoundException e) {
logger.debug("completion api seems not to be available. (available from livy 0.5)", e);
}
return candidates;
}
开发者ID:apache,项目名称:zeppelin,代码行数:14,代码来源:BaseLivyInterpreter.java
注:本文中的org.apache.zeppelin.interpreter.thrift.InterpreterCompletion类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论