Search in sources :

Example 31 with InterpreterCompletion

use of org.apache.zeppelin.interpreter.thrift.InterpreterCompletion in project zeppelin by apache.

the class JupyterKernelInterpreter method completion.

@Override
public List<InterpreterCompletion> completion(String buf, int cursor, InterpreterContext interpreterContext) {
    LOGGER.debug("Call completion for: {}, cursor: {}", buf, cursor);
    List<InterpreterCompletion> completions = new ArrayList<>();
    CompletionResponse response = jupyterKernelClient.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);
        }
        LOGGER.debug("Candidate completion: {}", match);
        completions.add(new InterpreterCompletion(match, match, ""));
    }
    return completions;
}
Also used : CompletionResponse(org.apache.zeppelin.interpreter.jupyter.proto.CompletionResponse) InterpreterCompletion(org.apache.zeppelin.interpreter.thrift.InterpreterCompletion) ArrayList(java.util.ArrayList)

Example 32 with InterpreterCompletion

use of org.apache.zeppelin.interpreter.thrift.InterpreterCompletion in project SSM by Intel-bigdata.

the class Paragraph method getInterpreterCompletion.

public List<InterpreterCompletion> getInterpreterCompletion() {
    List<InterpreterCompletion> completion = new LinkedList();
    for (InterpreterSetting intp : interpreterSettingManager.getInterpreterSettings(note.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));
            }
        } else {
            completion.add(new InterpreterCompletion(intp.getName(), intp.getName()));
        }
    }
    return completion;
}
Also used : InterpreterCompletion(org.apache.zeppelin.interpreter.thrift.InterpreterCompletion)

Aggregations

InterpreterCompletion (org.apache.zeppelin.interpreter.thrift.InterpreterCompletion)32 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)8 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)8 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)6 IOException (java.io.IOException)5 InterpreterException (org.apache.zeppelin.interpreter.InterpreterException)5 LinkedList (java.util.LinkedList)4 List (java.util.List)4 Properties (java.util.Properties)4 Gson (com.google.gson.Gson)2 Map (java.util.Map)2 InterpreterGroup (org.apache.zeppelin.interpreter.InterpreterGroup)2 InterpreterOutput (org.apache.zeppelin.interpreter.InterpreterOutput)2 InterpreterResultMessage (org.apache.zeppelin.interpreter.InterpreterResultMessage)2 Notebook (org.apache.zeppelin.notebook.Notebook)2 Paragraph (org.apache.zeppelin.notebook.Paragraph)2 URISyntaxException (java.net.URISyntaxException)1 UnknownHostException (java.net.UnknownHostException)1 Connection (java.sql.Connection)1