[jira] [Commented] (JENA-1544) FROM handling is inconsistent
[ https://issues.apache.org/jira/browse/JENA-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16466350#comment-16466350 ] ASF GitHub Bot commented on JENA-1544: -- GitHub user afs opened a pull request: https://github.com/apache/jena/pull/417 JENA-1544: Consistent FROM/FROM NAMED naming handling You can merge this pull request into a Git repository by running: $ git pull https://github.com/afs/jena dataset-from Alternatively you can review and apply these changes as the patch at: https://github.com/apache/jena/pull/417.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #417 commit 46c28c66faa33b7f69e89f76c15516c753403165 Author: Andy SeaborneDate: 2018-05-07T13:58:03Z JENA-1544: Consistent FROM/FROM NAMED naming handling commit 32ebe84dbae96c63405833d9c0b859ba0893a4ef Author: Andy Seaborne Date: 2018-05-07T19:18:46Z Removed old code > FROM handling is inconsistent > - > > Key: JENA-1544 > URL: https://issues.apache.org/jira/browse/JENA-1544 > Project: Apache Jena > Issue Type: Bug >Affects Versions: Jena 3.7.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Dataset description (FROM and FROM NAMED) handling seems to be missing for > memory datasets. > For persistent ones, the action is to take graph from the dataset itself. > The proposal is to add this for memory datasets. > The ability to load graphs from the web or from files using FROM / FROM NAMED > will be available when a query is executed with no dataset. > Executing a query with no dataset and no dataset description is an error. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[GitHub] jena pull request #417: JENA-1544: Consistent FROM/FROM NAMED naming handlin...
GitHub user afs opened a pull request: https://github.com/apache/jena/pull/417 JENA-1544: Consistent FROM/FROM NAMED naming handling You can merge this pull request into a Git repository by running: $ git pull https://github.com/afs/jena dataset-from Alternatively you can review and apply these changes as the patch at: https://github.com/apache/jena/pull/417.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #417 commit 46c28c66faa33b7f69e89f76c15516c753403165 Author: Andy SeaborneDate: 2018-05-07T13:58:03Z JENA-1544: Consistent FROM/FROM NAMED naming handling commit 32ebe84dbae96c63405833d9c0b859ba0893a4ef Author: Andy Seaborne Date: 2018-05-07T19:18:46Z Removed old code ---
[jira] [Commented] (JENA-1545) Add ParserProfileWrapper; expose checkTriple/checkQuad.
[ https://issues.apache.org/jira/browse/JENA-1545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16466331#comment-16466331 ] ASF GitHub Bot commented on JENA-1545: -- Github user ajs6f commented on a diff in the pull request: https://github.com/apache/jena/pull/416#discussion_r186517509 --- Diff: jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfile.java --- @@ -49,6 +49,12 @@ /** Create a triple */ public Triple createTriple(Node subject, Node predicate, Node object, long line, long col); +/** Check a triple */ --- End diff -- Might be nice to include a Javadoc note declaring what to do for bad tuples. Presumably `throw` something, but is there a specific type to throw that would be best? > Add ParserProfileWrapper; expose checkTriple/checkQuad. > --- > > Key: JENA-1545 > URL: https://issues.apache.org/jira/browse/JENA-1545 > Project: Apache Jena > Issue Type: Improvement > Components: RIOT >Affects Versions: Jena 3.7.0 >Reporter: Andy Seaborne >Priority: Major > > See [https://github.com/apache/jena/pull/299] > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[GitHub] jena pull request #416: JENA-1545: ParserProfileWrapper and public checkTrup...
Github user ajs6f commented on a diff in the pull request: https://github.com/apache/jena/pull/416#discussion_r186517509 --- Diff: jena-arq/src/main/java/org/apache/jena/riot/system/ParserProfile.java --- @@ -49,6 +49,12 @@ /** Create a triple */ public Triple createTriple(Node subject, Node predicate, Node object, long line, long col); +/** Check a triple */ --- End diff -- Might be nice to include a Javadoc note declaring what to do for bad tuples. Presumably `throw` something, but is there a specific type to throw that would be best? ---
[jira] [Commented] (JENA-1545) Add ParserProfileWrapper; expose checkTriple/checkQuad.
[ https://issues.apache.org/jira/browse/JENA-1545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16466330#comment-16466330 ] ASF GitHub Bot commented on JENA-1545: -- GitHub user afs opened a pull request: https://github.com/apache/jena/pull/416 JENA-1545: ParserProfileWrapper and public checkTruple, checkQuad You can merge this pull request into a Git repository by running: $ git pull https://github.com/afs/jena parserprofile-wrapper Alternatively you can review and apply these changes as the patch at: https://github.com/apache/jena/pull/416.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #416 commit 669392c75bf53f25918578f140b07c068c2566e8 Author: Andy SeaborneDate: 2018-05-07T16:45:43Z JENA-1545: ParserProfileWrapper and public checkTruple, checkQuad > Add ParserProfileWrapper; expose checkTriple/checkQuad. > --- > > Key: JENA-1545 > URL: https://issues.apache.org/jira/browse/JENA-1545 > Project: Apache Jena > Issue Type: Improvement > Components: RIOT >Affects Versions: Jena 3.7.0 >Reporter: Andy Seaborne >Priority: Major > > See [https://github.com/apache/jena/pull/299] > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[GitHub] jena pull request #416: JENA-1545: ParserProfileWrapper and public checkTrup...
GitHub user afs opened a pull request: https://github.com/apache/jena/pull/416 JENA-1545: ParserProfileWrapper and public checkTruple, checkQuad You can merge this pull request into a Git repository by running: $ git pull https://github.com/afs/jena parserprofile-wrapper Alternatively you can review and apply these changes as the patch at: https://github.com/apache/jena/pull/416.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #416 commit 669392c75bf53f25918578f140b07c068c2566e8 Author: Andy SeaborneDate: 2018-05-07T16:45:43Z JENA-1545: ParserProfileWrapper and public checkTruple, checkQuad ---
[jira] [Created] (JENA-1545) Add ParserProfileWrapper; expose checkTriple/checkQuad.
Andy Seaborne created JENA-1545: --- Summary: Add ParserProfileWrapper; expose checkTriple/checkQuad. Key: JENA-1545 URL: https://issues.apache.org/jira/browse/JENA-1545 Project: Apache Jena Issue Type: Improvement Components: RIOT Affects Versions: Jena 3.7.0 Reporter: Andy Seaborne See [https://github.com/apache/jena/pull/299] -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (JENA-1544) FROM handling is inconsistent
[ https://issues.apache.org/jira/browse/JENA-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465998#comment-16465998 ] Andy Seaborne commented on JENA-1544: - There is one other case - the data is in the query through `BIND` or `VALUES`. The command line SPARQL execution tool puts in an empty dataset if there is no dataset description and no data, making `VALUES` etc. For programmatic use, I propose that "no data, no dataset description" is treated as an error. The application can provide an empty dataset, and iot probably meant to provide a dataset with data. The command line tool works the way it does for simple examples and quick experiments (see stackoverflow). > FROM handling is inconsistent > - > > Key: JENA-1544 > URL: https://issues.apache.org/jira/browse/JENA-1544 > Project: Apache Jena > Issue Type: Bug >Affects Versions: Jena 3.7.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Dataset description (FROM and FROM NAMED) handling seems to be missing for > memory datasets. > For persistent ones, the action is to take graph from the dataset itself. > The proposal is to add this for memory datasets. > The ability to load graphs from the web or from files using FROM / FROM NAMED > will be available when a query is executed with no dataset. > Executing a query with no dataset and no dataset description is an error. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (JENA-1544) FROM handling is inconsistent
[ https://issues.apache.org/jira/browse/JENA-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465994#comment-16465994 ] Andy Seaborne commented on JENA-1544: - In the SPARQL machinery (in {{QueryEngineBase}}). WIP: [https://github.com/afs/jena/commit/8e705a7f034fd7691729b02821cb5ee5c6e92a21] (though I found it working on the jena-text tests). > FROM handling is inconsistent > - > > Key: JENA-1544 > URL: https://issues.apache.org/jira/browse/JENA-1544 > Project: Apache Jena > Issue Type: Bug >Affects Versions: Jena 3.7.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Dataset description (FROM and FROM NAMED) handling seems to be missing for > memory datasets. > For persistent ones, the action is to take graph from the dataset itself. > The proposal is to add this for memory datasets. > The ability to load graphs from the web or from files using FROM / FROM NAMED > will be available when a query is executed with no dataset. > Executing a query with no dataset and no dataset description is an error. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (JENA-1544) FROM handling is inconsistent
[ https://issues.apache.org/jira/browse/JENA-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465941#comment-16465941 ] A. Soroka commented on JENA-1544: - Is this work that needs to be done in the dataset impls, or in the SPARQL machinery? > FROM handling is inconsistent > - > > Key: JENA-1544 > URL: https://issues.apache.org/jira/browse/JENA-1544 > Project: Apache Jena > Issue Type: Bug >Affects Versions: Jena 3.7.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Dataset description (FROM and FROM NAMED) handling seems to be missing for > memory datasets. > For persistent ones, the action is to take graph from the dataset itself. > The proposal is to add this for memory datasets. > The ability to load graphs from the web or from files using FROM / FROM NAMED > will be available when a query is executed with no dataset. > Executing a query with no dataset and no dataset description is an error. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (JENA-1544) FROM handling is inconsistent
[ https://issues.apache.org/jira/browse/JENA-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Andy Seaborne updated JENA-1544: Issue Type: Bug (was: Improvement) > FROM handling is inconsistent > - > > Key: JENA-1544 > URL: https://issues.apache.org/jira/browse/JENA-1544 > Project: Apache Jena > Issue Type: Bug >Affects Versions: Jena 3.7.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Dataset description (FROM and FROM NAMED) handling seems to be missing for > memory datasets. > For persistent ones, the action is to take graph from the dataset itself. > The proposal is to add this for memory datasets. > The ability to load graphs from the web or from files using FROM / FROM NAMED > will be available when a query is executed with no dataset. > Executing a query with no dataset and no dataset description is an error. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Assigned] (JENA-1544) FROM handling is inconsistent
[ https://issues.apache.org/jira/browse/JENA-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Andy Seaborne reassigned JENA-1544: --- Assignee: Andy Seaborne > FROM handling is inconsistent > - > > Key: JENA-1544 > URL: https://issues.apache.org/jira/browse/JENA-1544 > Project: Apache Jena > Issue Type: Improvement >Affects Versions: Jena 3.7.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Dataset description (FROM and FROM NAMED) handling seems to be missing for > memory datasets. > For persistent ones, the action is to take graph from the dataset itself. > The proposal is to add this for memory datasets. > The ability to load graphs from the web or from files using FROM / FROM NAMED > will be available when a query is executed with no dataset. > Executing a query with no dataset and no dataset description is an error. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (JENA-1544) FROM handling is inconsistent
[ https://issues.apache.org/jira/browse/JENA-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Andy Seaborne updated JENA-1544: Affects Version/s: Jena 3.7.0 > FROM handling is inconsistent > - > > Key: JENA-1544 > URL: https://issues.apache.org/jira/browse/JENA-1544 > Project: Apache Jena > Issue Type: Improvement >Affects Versions: Jena 3.7.0 >Reporter: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Dataset description (FROM and FROM NAMED) handling seems to be missing for > memory datasets. > For persistent ones, the action is to take graph from the dataset itself. > The proposal is to add this for memory datasets. > The ability to load graphs from the web or from files using FROM / FROM NAMED > will be available when a query is executed with no dataset. > Executing a query with no dataset and no dataset description is an error. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (JENA-1544) FROM handling is inconsistent
[ https://issues.apache.org/jira/browse/JENA-1544?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Andy Seaborne updated JENA-1544: Fix Version/s: Jena 3.8.0 > FROM handling is inconsistent > - > > Key: JENA-1544 > URL: https://issues.apache.org/jira/browse/JENA-1544 > Project: Apache Jena > Issue Type: Improvement >Affects Versions: Jena 3.7.0 >Reporter: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Dataset description (FROM and FROM NAMED) handling seems to be missing for > memory datasets. > For persistent ones, the action is to take graph from the dataset itself. > The proposal is to add this for memory datasets. > The ability to load graphs from the web or from files using FROM / FROM NAMED > will be available when a query is executed with no dataset. > Executing a query with no dataset and no dataset description is an error. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (JENA-1544) FROM handling is inconsistent
Andy Seaborne created JENA-1544: --- Summary: FROM handling is inconsistent Key: JENA-1544 URL: https://issues.apache.org/jira/browse/JENA-1544 Project: Apache Jena Issue Type: Improvement Reporter: Andy Seaborne Dataset description (FROM and FROM NAMED) handling seems to be missing for memory datasets. For persistent ones, the action is to take graph from the dataset itself. The proposal is to add this for memory datasets. The ability to load graphs from the web or from files using FROM / FROM NAMED will be available when a query is executed with no dataset. Executing a query with no dataset and no dataset description is an error. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[GitHub] jena pull request #415: JENA-1543: QueryEngineHttp support for JSON queries.
Github user afs commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186391505 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) +{} +return v.getAsArray(); } @Override public Iterator execJsonItems() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +// Non-streaming. +// TODO Integrate with the JSON parser to stream the results. +JsonArray array = execJson().getAsArray(); +List x = new ArrayList<>(array.size()); +array.forEach(elt->{ +if ( ! elt.isObject()) --- End diff -- You did see `If ( ) { }` :-) I amended the commit and forced the push to my repo so the changes as history in master will be the changes all together in a single commit. ---
[jira] [Commented] (JENA-1543) Remote execution of JSON queries
[ https://issues.apache.org/jira/browse/JENA-1543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465787#comment-16465787 ] ASF GitHub Bot commented on JENA-1543: -- Github user afs commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186391505 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) +{} +return v.getAsArray(); } @Override public Iterator execJsonItems() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +// Non-streaming. +// TODO Integrate with the JSON parser to stream the results. +JsonArray array = execJson().getAsArray(); +List x = new ArrayList<>(array.size()); +array.forEach(elt->{ +if ( ! elt.isObject()) --- End diff -- You did see `If ( ) { }` :-) I amended the commit and forced the push to my repo so the changes as history in master will be the changes all together in a single commit. > Remote execution of JSON queries > > > Key: JENA-1543 > URL: https://issues.apache.org/jira/browse/JENA-1543 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ >Affects Versions: Jena 3.8.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Provide remote execution of JSON queries (JENA-632). > {noformat} > String qs= "JSON { 'abc': ?X } WHERE {BIND (now() As ?X)}"; > Query query = QueryFactory.create(qs, Syntax.syntaxARQ); > try ( QueryExecution qExec = > QueryExecutionFactory.sparqlService("http://localhost:3030/ds;, query)) { > QueryExecUtils.executeQuery(qExec); > } > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (JENA-1543) Remote execution of JSON queries
[ https://issues.apache.org/jira/browse/JENA-1543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465770#comment-16465770 ] ASF GitHub Bot commented on JENA-1543: -- Github user ajs6f commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186387602 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) +{} +return v.getAsArray(); } @Override public Iterator execJsonItems() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +// Non-streaming. +// TODO Integrate with the JSON parser to stream the results. +JsonArray array = execJson().getAsArray(); +List x = new ArrayList<>(array.size()); +array.forEach(elt->{ +if ( ! elt.isObject()) --- End diff -- Another way: ``` return array.stream().peek(e -> if (!elt.isObject()) throw etc. ) .map(JsonValue::getAsObject) .iterator(); ``` > Remote execution of JSON queries > > > Key: JENA-1543 > URL: https://issues.apache.org/jira/browse/JENA-1543 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ >Affects Versions: Jena 3.8.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Provide remote execution of JSON queries (JENA-632). > {noformat} > String qs= "JSON { 'abc': ?X } WHERE {BIND (now() As ?X)}"; > Query query = QueryFactory.create(qs, Syntax.syntaxARQ); > try ( QueryExecution qExec = > QueryExecutionFactory.sparqlService("http://localhost:3030/ds;, query)) { > QueryExecUtils.executeQuery(qExec); > } > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (JENA-1543) Remote execution of JSON queries
[ https://issues.apache.org/jira/browse/JENA-1543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465769#comment-16465769 ] ASF GitHub Bot commented on JENA-1543: -- Github user ajs6f commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186386296 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) +throw new QueryExecException("Return from a JSON query isn't an array"); +return v.getAsArray(); } @Override public Iterator execJsonItems() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +// Non-streaming. +// TODO Integrate with the JSON parser to stream the results. +JsonArray array = execJson().getAsArray(); +List x = new ArrayList<>(array.size()); +array.forEach(elt->{ +if ( ! elt.isObject()) +throw new QueryExecException("Item in anarray from a JSON query isn't an object"); --- End diff -- Typo `anarray` => `an array` > Remote execution of JSON queries > > > Key: JENA-1543 > URL: https://issues.apache.org/jira/browse/JENA-1543 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ >Affects Versions: Jena 3.8.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Provide remote execution of JSON queries (JENA-632). > {noformat} > String qs= "JSON { 'abc': ?X } WHERE {BIND (now() As ?X)}"; > Query query = QueryFactory.create(qs, Syntax.syntaxARQ); > try ( QueryExecution qExec = > QueryExecutionFactory.sparqlService("http://localhost:3030/ds;, query)) { > QueryExecUtils.executeQuery(qExec); > } > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[GitHub] jena pull request #415: JENA-1543: QueryEngineHttp support for JSON queries.
Github user ajs6f commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186387602 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) +{} +return v.getAsArray(); } @Override public Iterator execJsonItems() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +// Non-streaming. +// TODO Integrate with the JSON parser to stream the results. +JsonArray array = execJson().getAsArray(); +List x = new ArrayList<>(array.size()); +array.forEach(elt->{ +if ( ! elt.isObject()) --- End diff -- Another way: ``` return array.stream().peek(e -> if (!elt.isObject()) throw etc. ) .map(JsonValue::getAsObject) .iterator(); ``` ---
[jira] [Commented] (JENA-1543) Remote execution of JSON queries
[ https://issues.apache.org/jira/browse/JENA-1543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465739#comment-16465739 ] ASF GitHub Bot commented on JENA-1543: -- Github user kinow commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186383751 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) +{} +return v.getAsArray(); } @Override public Iterator execJsonItems() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +// Non-streaming. +// TODO Integrate with the JSON parser to stream the results. +JsonArray array = execJson().getAsArray(); +List x = new ArrayList<>(array.size()); +array.forEach(elt->{ +if ( ! elt.isObject()) --- End diff -- Oh, now I see the `throew new QueryExecException`, but I could swear I had seen as `if (...) {}` before in GitHub. My bad. > Remote execution of JSON queries > > > Key: JENA-1543 > URL: https://issues.apache.org/jira/browse/JENA-1543 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ >Affects Versions: Jena 3.8.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Provide remote execution of JSON queries (JENA-632). > {noformat} > String qs= "JSON { 'abc': ?X } WHERE {BIND (now() As ?X)}"; > Query query = QueryFactory.create(qs, Syntax.syntaxARQ); > try ( QueryExecution qExec = > QueryExecutionFactory.sparqlService("http://localhost:3030/ds;, query)) { > QueryExecUtils.executeQuery(qExec); > } > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[GitHub] jena pull request #415: JENA-1543: QueryEngineHttp support for JSON queries.
Github user kinow commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186383751 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) +{} +return v.getAsArray(); } @Override public Iterator execJsonItems() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +// Non-streaming. +// TODO Integrate with the JSON parser to stream the results. +JsonArray array = execJson().getAsArray(); +List x = new ArrayList<>(array.size()); +array.forEach(elt->{ +if ( ! elt.isObject()) --- End diff -- Oh, now I see the `throew new QueryExecException`, but I could swear I had seen as `if (...) {}` before in GitHub. My bad. ---
[jira] [Commented] (JENA-1543) Remote execution of JSON queries
[ https://issues.apache.org/jira/browse/JENA-1543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465698#comment-16465698 ] ASF GitHub Bot commented on JENA-1543: -- Github user afs commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186377839 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) +{} +return v.getAsArray(); } @Override public Iterator execJsonItems() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +// Non-streaming. +// TODO Integrate with the JSON parser to stream the results. +JsonArray array = execJson().getAsArray(); +List x = new ArrayList<>(array.size()); +array.forEach(elt->{ +if ( ! elt.isObject()) --- End diff -- They are checking expectations to be defensive against misbehaving remote servers. Otherwise the app will get a less helpful exception on the attempt cast performed by `getAsArray` or `getAsObject`. > Remote execution of JSON queries > > > Key: JENA-1543 > URL: https://issues.apache.org/jira/browse/JENA-1543 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ >Affects Versions: Jena 3.8.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Provide remote execution of JSON queries (JENA-632). > {noformat} > String qs= "JSON { 'abc': ?X } WHERE {BIND (now() As ?X)}"; > Query query = QueryFactory.create(qs, Syntax.syntaxARQ); > try ( QueryExecution qExec = > QueryExecutionFactory.sparqlService("http://localhost:3030/ds;, query)) { > QueryExecUtils.executeQuery(qExec); > } > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[GitHub] jena pull request #415: JENA-1543: QueryEngineHttp support for JSON queries.
Github user afs commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186377839 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) +{} +return v.getAsArray(); } @Override public Iterator execJsonItems() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +// Non-streaming. +// TODO Integrate with the JSON parser to stream the results. +JsonArray array = execJson().getAsArray(); +List x = new ArrayList<>(array.size()); +array.forEach(elt->{ +if ( ! elt.isObject()) --- End diff -- They are checking expectations to be defensive against misbehaving remote servers. Otherwise the app will get a less helpful exception on the attempt cast performed by `getAsArray` or `getAsObject`. ---
[jira] [Commented] (JENA-1543) Remote execution of JSON queries
[ https://issues.apache.org/jira/browse/JENA-1543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465660#comment-16465660 ] ASF GitHub Bot commented on JENA-1543: -- Github user kinow commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186369128 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) --- End diff -- A left-over from development/debugging ? > Remote execution of JSON queries > > > Key: JENA-1543 > URL: https://issues.apache.org/jira/browse/JENA-1543 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ >Affects Versions: Jena 3.8.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Provide remote execution of JSON queries (JENA-632). > {noformat} > String qs= "JSON { 'abc': ?X } WHERE {BIND (now() As ?X)}"; > Query query = QueryFactory.create(qs, Syntax.syntaxARQ); > try ( QueryExecution qExec = > QueryExecutionFactory.sparqlService("http://localhost:3030/ds;, query)) { > QueryExecUtils.executeQuery(qExec); > } > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (JENA-1543) Remote execution of JSON queries
[ https://issues.apache.org/jira/browse/JENA-1543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465662#comment-16465662 ] ASF GitHub Bot commented on JENA-1543: -- Github user kinow commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186369815 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) +{} +return v.getAsArray(); } @Override public Iterator execJsonItems() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +// Non-streaming. +// TODO Integrate with the JSON parser to stream the results. +JsonArray array = execJson().getAsArray(); +List x = new ArrayList<>(array.size()); +array.forEach(elt->{ +if ( ! elt.isObject()) --- End diff -- Are these two `if` necessary? > Remote execution of JSON queries > > > Key: JENA-1543 > URL: https://issues.apache.org/jira/browse/JENA-1543 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ >Affects Versions: Jena 3.8.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Provide remote execution of JSON queries (JENA-632). > {noformat} > String qs= "JSON { 'abc': ?X } WHERE {BIND (now() As ?X)}"; > Query query = QueryFactory.create(qs, Syntax.syntaxARQ); > try ( QueryExecution qExec = > QueryExecutionFactory.sparqlService("http://localhost:3030/ds;, query)) { > QueryExecUtils.executeQuery(qExec); > } > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (JENA-1543) Remote execution of JSON queries
[ https://issues.apache.org/jira/browse/JENA-1543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465661#comment-16465661 ] ASF GitHub Bot commented on JENA-1543: -- Github user kinow commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186369795 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/util/QueryExecUtils.java --- @@ -191,6 +197,11 @@ private static void doSelectQuery(Prologue prologue, QueryExecution qe, ResultsF outputResultSet(results, prologue, outputFormat) ; } +private static void doJsonQuery(Prologue prologue, QueryExecution queryExecution, ResultsFormat outputFormat) { +JsonArray results = queryExecution.execJson();; --- End diff -- Double `;`. Nit-pick, as it's normally harmelss (unless after some "end" statements like `return`, `break`, etc, I think?) > Remote execution of JSON queries > > > Key: JENA-1543 > URL: https://issues.apache.org/jira/browse/JENA-1543 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ >Affects Versions: Jena 3.8.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Provide remote execution of JSON queries (JENA-632). > {noformat} > String qs= "JSON { 'abc': ?X } WHERE {BIND (now() As ?X)}"; > Query query = QueryFactory.create(qs, Syntax.syntaxARQ); > try ( QueryExecution qExec = > QueryExecutionFactory.sparqlService("http://localhost:3030/ds;, query)) { > QueryExecUtils.executeQuery(qExec); > } > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[GitHub] jena pull request #415: JENA-1543: QueryEngineHttp support for JSON queries.
Github user kinow commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186369128 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) --- End diff -- A left-over from development/debugging ? ---
[GitHub] jena pull request #415: JENA-1543: QueryEngineHttp support for JSON queries.
Github user kinow commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186369795 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/util/QueryExecUtils.java --- @@ -191,6 +197,11 @@ private static void doSelectQuery(Prologue prologue, QueryExecution qe, ResultsF outputResultSet(results, prologue, outputFormat) ; } +private static void doJsonQuery(Prologue prologue, QueryExecution queryExecution, ResultsFormat outputFormat) { +JsonArray results = queryExecution.execJson();; --- End diff -- Double `;`. Nit-pick, as it's normally harmelss (unless after some "end" statements like `return`, `break`, etc, I think?) ---
[GitHub] jena pull request #415: JENA-1543: QueryEngineHttp support for JSON queries.
Github user kinow commented on a diff in the pull request: https://github.com/apache/jena/pull/415#discussion_r186369815 --- Diff: jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java --- @@ -538,13 +539,29 @@ else if ( actualContentType.equals(WebContent.contentTypeJSON)) @Override public JsonArray execJson() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +checkNotClosed(); +HttpQuery httpQuery = makeHttpQuery(); +httpQuery.setAccept(WebContent.contentTypeJSON); +InputStream in = httpQuery.exec(); +JsonValue v = JSON.parseAny(in); +if ( ! v.isArray() ) +{} +return v.getAsArray(); } @Override public Iterator execJsonItems() { -throw new NotImplemented("JSON queries not implemented for remote calls") ; +// Non-streaming. +// TODO Integrate with the JSON parser to stream the results. +JsonArray array = execJson().getAsArray(); +List x = new ArrayList<>(array.size()); +array.forEach(elt->{ +if ( ! elt.isObject()) --- End diff -- Are these two `if` necessary? ---
[jira] [Commented] (JENA-1543) Remote execution of JSON queries
[ https://issues.apache.org/jira/browse/JENA-1543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16465654#comment-16465654 ] Andy Seaborne commented on JENA-1543: - and via RDFConnection: {noformat} try ( RDFConnection conn = RDFConnectionFactory.connect("http://localhost:3030/ds;) ) { try ( QueryExecution qExec = conn.query(query) ) { // qexec.execJson + printing QueryExecUtils.executeQuery(qExec); } } {noformat} > Remote execution of JSON queries > > > Key: JENA-1543 > URL: https://issues.apache.org/jira/browse/JENA-1543 > Project: Apache Jena > Issue Type: Improvement > Components: ARQ >Affects Versions: Jena 3.8.0 >Reporter: Andy Seaborne >Assignee: Andy Seaborne >Priority: Major > Fix For: Jena 3.8.0 > > > Provide remote execution of JSON queries (JENA-632). > {noformat} > String qs= "JSON { 'abc': ?X } WHERE {BIND (now() As ?X)}"; > Query query = QueryFactory.create(qs, Syntax.syntaxARQ); > try ( QueryExecution qExec = > QueryExecutionFactory.sparqlService("http://localhost:3030/ds;, query)) { > QueryExecUtils.executeQuery(qExec); > } > {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (JENA-1543) Remote execution of JSON queries
Andy Seaborne created JENA-1543: --- Summary: Remote execution of JSON queries Key: JENA-1543 URL: https://issues.apache.org/jira/browse/JENA-1543 Project: Apache Jena Issue Type: Improvement Components: ARQ Affects Versions: Jena 3.8.0 Reporter: Andy Seaborne Assignee: Andy Seaborne Fix For: Jena 3.8.0 Provide remote execution of JSON queries (JENA-632). {noformat} String qs= "JSON { 'abc': ?X } WHERE {BIND (now() As ?X)}"; Query query = QueryFactory.create(qs, Syntax.syntaxARQ); try ( QueryExecution qExec = QueryExecutionFactory.sparqlService("http://localhost:3030/ds;, query)) { QueryExecUtils.executeQuery(qExec); } {noformat} -- This message was sent by Atlassian JIRA (v7.6.3#76005)