-
Notifications
You must be signed in to change notification settings - Fork 224
/
KernelLike.scala
113 lines (94 loc) · 3.18 KB
/
KernelLike.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package org.apache.toree.kernel.api
import java.io.{InputStream, PrintStream}
import java.net.URI
import com.typesafe.config.Config
import org.apache.spark.api.java.JavaSparkContext
import org.apache.spark.{SparkContext, SparkConf}
import org.apache.spark.sql.SparkSession
/**
* Interface for the kernel API. This does not include exposed variables.
*/
trait KernelLike {
/**
* Executes a block of code represented as a string and returns the result.
*
* @param code The code as an option to execute
*
* @return A tuple containing the result (true/false) and the output as a
* string
*/
def eval(code: Option[String]): (Boolean, String)
/**
* Returns a collection of methods that can be used to generate objects
* related to the kernel.
*
* @return The collection of factory methods
*/
def factory: FactoryMethodsLike
/**
* Returns a collection of methods that can be used to stream data from the
* kernel to the client.
*
* @return The collection of stream methods
*/
def stream: StreamMethodsLike
/**
* Returns a collection of methods that can be used to display data from the
* kernel to the client.
*
* @return The collection of display methods
*/
def display: DisplayMethodsLike
/**
* Returns a print stream to be used for communication back to clients
* via standard out.
*
* @return The print stream instance or an error if the stream info is
* not found
*/
def out: PrintStream
/**
* Returns a print stream to be used for communication back to clients
* via standard error.
*
* @return The print stream instance or an error if the stream info is
* not found
*/
def err: PrintStream
/**
* Returns an input stream to be used to receive information from the client.
*
* @return The input stream instance or an error if the stream info is
* not found
*/
def in: InputStream
/**
* Represents data to be shared using the kernel as the middleman.
*
* @note Using Java structure to enable other languages to have easy access!
*/
val data: java.util.Map[String, Any]
def interpreter(name: String): Option[org.apache.toree.interpreter.Interpreter]
def config: Config
def addJars(uris: URI*)
def sparkContext: SparkContext
def sparkConf: SparkConf
def javaSparkContext: JavaSparkContext
def sparkSession: SparkSession
}