zjffdu commented on a change in pull request #3480: [ZEPPELIN-3644] SPARQL-Interpreter support via Apache Jena ARQ URL: https://github.com/apache/zeppelin/pull/3480#discussion_r335782244
########## File path: sparql/src/main/java/org/apache/zeppelin/fuseki/SparqlInterpreter.java ########## @@ -0,0 +1,163 @@ +/* + * 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.zeppelin.sparql; + +import org.apache.commons.lang3.StringUtils; + +import org.apache.http.HttpStatus; + +import org.apache.jena.query.Query; +import org.apache.jena.query.QueryExecution; +import org.apache.jena.query.QueryExecutionFactory; +import org.apache.jena.query.QueryFactory; +import org.apache.jena.query.QueryParseException; +import org.apache.jena.query.ResultSet; +import org.apache.jena.query.ResultSetFormatter; +import org.apache.jena.shared.PrefixMapping; +import org.apache.jena.sparql.engine.http.QueryExceptionHTTP; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.ByteArrayOutputStream; +import java.util.Map; +import java.util.Properties; + +import org.apache.zeppelin.interpreter.Interpreter; +import org.apache.zeppelin.interpreter.InterpreterContext; +import org.apache.zeppelin.interpreter.InterpreterResult; + + +/** + * Interpreter for SPARQL-Query via Apache Jena ARQ. + */ +public class SparqlInterpreter extends Interpreter { + private static final Logger LOGGER = LoggerFactory.getLogger(SparqlInterpreter.class); + + public static final String SPARQL_SERVICE_ENDPOINT = "sparql.endpoint"; + public static final String SPARQL_REPLACE_URIS = "sparql.replaceURIs"; + public static final String SPARQL_REMOVE_DATATYPES = "sparql.removeDatatypes"; + + public SparqlInterpreter(Properties properties) { + super(properties); + } + + @Override + public void open() { + LOGGER.info("Properties: {}", getProperties()); + } + + @Override + public void close() { + } + + @Override + public InterpreterResult interpret(String queryString, InterpreterContext context) { + final String serviceEndpoint = getProperty(SPARQL_SERVICE_ENDPOINT); + final String replaceURIs = getProperty(SPARQL_REPLACE_URIS); + final String removeDatatypes = getProperty(SPARQL_REMOVE_DATATYPES); Review comment: These variables should be initialized in open method ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services