...
Code Block | ||
---|---|---|
| ||
class SimpleSparkHandler extends AbstractSparkHttpServiceHandler {
@Path("/query")
@GET
def query(request: HttpServiceRequest, responder: HttpServiceResponder) {
val sqlContext = SQLContext.getOrCreate(getSparkContext)
val df = sqlContext.sql(Charsets.UTF_8.decode(request.getContent).toString);
val builder = new StringBuilder
df.collect().foreach(row => {
builder.append(...)
})
responder.sendString(builder.toString)
}
}
|
...