use of org.apache.rya.indexing.pcj.fluo.client.util.ParsedQueryRequest in project incubator-rya by apache.
the class ParsedQueryRequestTest method parseNoVarOrders.
@Test
public void parseNoVarOrders() throws IOException {
final String requestText = "SELECT * \n" + "WHERE { \n" + " ?a <http://talksTo> ?b. \n" + " ?b <http://talksTo> ?c. \n" + "}";
final ParsedQueryRequest expected = new ParsedQueryRequest("SELECT * \n" + "WHERE { \n" + " ?a <http://talksTo> ?b. \n" + " ?b <http://talksTo> ?c. \n" + "}", new HashSet<VariableOrder>());
final ParsedQueryRequest request = ParsedQueryRequest.parse(requestText);
assertEquals(expected, request);
}
use of org.apache.rya.indexing.pcj.fluo.client.util.ParsedQueryRequest in project incubator-rya by apache.
the class NewQueryCommand method execute.
@Override
public void execute(final Connector accumulo, final String ryaTablePrefix, final RyaSailRepository rya, final FluoClient fluo, final String[] args) throws ArgumentsException, ExecutionException, UnsupportedQueryException {
checkNotNull(accumulo);
checkNotNull(fluo);
checkNotNull(args);
log.trace("Executing the New Query Command...");
// Parse the command line arguments.
final Parameters params = new Parameters();
try {
new JCommander(params, args);
} catch (final ParameterException e) {
throw new ArgumentsException("Could not create a new query because of invalid command line parameters.", e);
}
// Load the request from the file into memory.
log.trace("Loading the query found in file '" + params.queryRequestFile + "' into the client app.");
ParsedQueryRequest request = null;
try {
final Path requestFile = Paths.get(params.queryRequestFile);
final String requestText = IOUtils.toString(Files.newInputStream(requestFile));
request = ParsedQueryRequest.parse(requestText);
} catch (final IOException e) {
throw new ExecutionException("Could not load the query request into memory.", e);
}
// Load the query into the Fluo app.
log.trace("SPARQL Query: " + request.getQuery());
log.trace("Var Orders: " + request.getVarOrders());
log.trace("Loading these values into the Fluo app.");
final CreateFluoPcj createPcj = new CreateFluoPcj();
try {
// Create the PCJ in Rya.
final String sparql = request.getQuery();
final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(accumulo, ryaTablePrefix);
final String pcjId = pcjStorage.createPcj(sparql);
// Tell the Fluo PCJ Updater app to maintain the PCJ.
createPcj.withRyaIntegration(pcjId, pcjStorage, fluo, accumulo, ryaTablePrefix);
} catch (MalformedQueryException | PcjException | RyaDAOException e) {
throw new ExecutionException("Could not create and load historic matches into the the Fluo app for the query.", e);
}
log.trace("Finished executing the New Query Command.");
}
use of org.apache.rya.indexing.pcj.fluo.client.util.ParsedQueryRequest in project incubator-rya by apache.
the class ParsedQueryRequestTest method parseHasVarOrders.
@Test
public void parseHasVarOrders() throws IOException {
final String requestText = "#prefix a, b,c\n" + "#prefix b, c, a\n" + "SELECT * \n" + "WHERE { \n" + " ?a <http://talksTo> ?b. \n" + " ?b <http://talksTo> ?c. \n" + "}";
final ParsedQueryRequest expected = new ParsedQueryRequest("SELECT * \n" + "WHERE { \n" + " ?a <http://talksTo> ?b. \n" + " ?b <http://talksTo> ?c. \n" + "}", Sets.newHashSet(new VariableOrder("a", "b", "c"), new VariableOrder("b", "c", "a")));
final ParsedQueryRequest request = ParsedQueryRequest.parse(requestText);
assertEquals(expected, request);
}
Aggregations