[ 
https://issues.apache.org/jira/browse/RYA-466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16374853#comment-16374853
 ] 

ASF GitHub Bot commented on RYA-466:
------------------------------------

Github user ejwhite922 commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/275#discussion_r170336740
  
    --- Diff: 
extras/rya.streams/client/src/main/java/org/apache/rya/streams/client/command/StreamResultsCommand.java
 ---
    @@ -167,17 +182,38 @@ public void run() {
                 throw new ExecutionException("Could not parse the SPARQL for 
the query: " + sparql, e);
             }
     
    -        // Iterate through the results and print them to the console until 
the program or the stream ends.
    -        try (final QueryResultStream<?> stream = 
getQueryResultStream.fromStart(queryId)) {
    -            while(!finished.get()) {
    -                for(final Object result : stream.poll(1000)) {
    -                    System.out.println(result);
    +        // Iterate through the results and print them to the configured 
output mechanism.
    +        try (final QueryResultStream<?> resultsStream = 
getQueryResultStream.fromStart(queryId)) {
    +            final TupleExpr tupleExpr = new 
SPARQLParser().parseQuery(sparql, null).getTupleExpr();
    +            if(params.outputPath != null) {
    +                final Path file = Paths.get(params.outputPath);
    +                try(OutputStream out = Files.newOutputStream(file)) {
    +                    if(isStatementResults) {
    +                        final QueryResultStream<VisibilityStatement> 
stmtStream = (QueryResultStream<VisibilityStatement>) resultsStream;
    +                        QueryResultsOutputUtil.toNtriplesFile(out, 
stmtStream, finished);
    +                    } else {
    +                        final QueryResultStream<VisibilityBindingSet> 
bsStream = (QueryResultStream<VisibilityBindingSet>) resultsStream;
    +                        QueryResultsOutputUtil.toBindingSetJSONFile(out, 
tupleExpr, bsStream, finished);
    +                    }
                     }
    +            } else {
    +                streamToSystemOut(resultsStream, finished);
                 }
             } catch (final Exception e) {
                 System.err.println("Error while reading the results from the 
stream.");
                 e.printStackTrace();
                 System.exit(1);
             }
         }
    +
    +    private void streamToSystemOut(final QueryResultStream<?> stream, 
final AtomicBoolean shutdownSignal) throws Exception {
    --- End diff --
    
    make static


> Rya Streams Client - Stream results to file.
> --------------------------------------------
>
>                 Key: RYA-466
>                 URL: https://issues.apache.org/jira/browse/RYA-466
>             Project: Rya
>          Issue Type: Improvement
>            Reporter: Kevin Chilton
>            Assignee: Kevin Chilton
>            Priority: Major
>
> The Rya Streams Client's stream results command needs to be updated to allow 
> a user to stream Statement results to an NTriples file and Binding Sets to 
> the standard JSON representation.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to