Search in sources :

Example 1 with FluoLoader

use of org.apache.rya.indexing.pcj.fluo.client.util.FluoLoader in project incubator-rya by apache.

the class LoadTriplesCommand method execute.

@Override
public void execute(final Connector accumulo, final String ryaTablePrefix, final RyaSailRepository rya, final FluoClient fluo, final String[] args) throws ArgumentsException, ExecutionException {
    checkNotNull(accumulo);
    checkNotNull(fluo);
    checkNotNull(args);
    log.trace("Executing the Load Triples 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 load the Triples file because of invalid command line parameters.", e);
    }
    // Iterate over the Statements that are in the input file and write them to Fluo.
    log.trace("Loading RDF Statements from the Triples file '" + params.nTriplesFile + "'.");
    final Path triplesPath = Paths.get(params.nTriplesFile);
    try {
        final RDFParser parser = Rio.createParser(RDFFormat.forFileName(triplesPath.getFileName().toString()));
        final FluoLoader loader = new FluoLoader(fluo, new InsertTriples());
        parser.setRDFHandler(loader);
        parser.parse(Files.newInputStream(triplesPath), triplesPath.toUri().toString());
    } catch (final Exception e) {
        throw new ExecutionException("Could not load the RDF file into the Fluo app.", e);
    }
    log.trace("Finished executing the Load Triples Command.");
}
Also used : Path(java.nio.file.Path) InsertTriples(org.apache.rya.indexing.pcj.fluo.api.InsertTriples) JCommander(com.beust.jcommander.JCommander) FluoLoader(org.apache.rya.indexing.pcj.fluo.client.util.FluoLoader) ParameterException(com.beust.jcommander.ParameterException) RDFParser(org.openrdf.rio.RDFParser) ParameterException(com.beust.jcommander.ParameterException)

Aggregations

JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 Path (java.nio.file.Path)1 InsertTriples (org.apache.rya.indexing.pcj.fluo.api.InsertTriples)1 FluoLoader (org.apache.rya.indexing.pcj.fluo.client.util.FluoLoader)1 RDFParser (org.openrdf.rio.RDFParser)1