[GitHub] jena pull request: Deprecating and removing some iterators from je...

2015-06-24 Thread ajs6f
GitHub user ajs6f opened a pull request:

https://github.com/apache/jena/pull/80

Deprecating and removing some iterators from jena-core

https://issues.apache.org/jira/browse/JENA-966

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/ajs6f/jena DeprecateSomeIterators

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/80.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 #80


commit b58fe263c97da3c51f66872e8e99b07b2d49fcf7
Author: ajs6f 
Date:   2015-06-24T18:04:30Z

Deprecating and removing some iterators from jena-core




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-966: Eliminating some unnecessary iterator...

2015-06-24 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/79#issuecomment-114963573
  
Closed in favor of #80 .


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-966: Eliminating some unnecessary iterator...

2015-06-24 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/79#issuecomment-114963486
  
Closed in favor of #80 .


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-966: Eliminating some unnecessary iterator...

2015-06-24 Thread ajs6f
Github user ajs6f closed the pull request at:

https://github.com/apache/jena/pull/79


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/82#discussion_r33451617
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java
 ---
@@ -0,0 +1,98 @@
+/**
+ * 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.jena.fuseki.mgt;
+
+import org.apache.jena.atlas.json.JsonBuilder;
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.server.FusekiServer;
+import org.apache.jena.fuseki.servlets.ServletOps;
+import org.apache.jena.web.HttpSC;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import static org.apache.jena.riot.WebContent.charsetUTF8;
+import static org.apache.jena.riot.WebContent.contentTypeTextPlain;
+
+/**
+ * A JSON API to list all the backups in the backup directory
+ * Created by Yang Yuanzhe on 6/26/15.
+ */
+public class ActionBackupList extends HttpServlet {
+
+@Override
+protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
{
+doCommon(req, resp);
+}
+
+@Override
+protected void doPost(HttpServletRequest req, HttpServletResponse 
resp) {
+doCommon(req, resp);
+}
+
+@Override
+protected void doHead(HttpServletRequest req, HttpServletResponse 
resp) {
+doCommon(req, resp);
+}
+
+protected void doCommon(HttpServletRequest request, 
HttpServletResponse response) {
+JsonBuilder builder = new JsonBuilder() ;
+builder.startObject("top") ;
+builder.key("backups") ;
+builder.startArray() ;
+
+ArrayList fileNames = new ArrayList<>();
+if (Files.isDirectory(FusekiServer.dirBackups)) {
+try (DirectoryStream stream = 
Files.newDirectoryStream(FusekiServer.dirBackups)) {
+for (Path path : stream) {
+fileNames.add(path.getFileName().toString());
+}
+} catch (IOException ex) {
+Fuseki.serverLog.warn("backup file list :: IOException :: 
"+ex.getMessage());
+}
+}
+
+Collections.sort(fileNames);
+for (String str : fileNames) {
+builder.value(str);
+}
--- End diff --

Given Java 8, this is a little briefer as  
`fileNames.forEach(builder::value)`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116597497
  
`POST` is one way to enable a "force up-to-date`, but it should also be 
possible to supply an ETag, which is a little more to the exact need. Perhaps 
Fuseki has helpers for this?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116603288
  
Okay-- do you think it's worth a separate ticket and PR for some helpers 
for ETags, so that future new Fuseki HTTP functions could offer them at low 
cost?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116612135
  
I meant something as simple as a method that accepts an identifier and 
response and adds the correctly-formatted tag.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/82#issuecomment-116628538
  
Okay, sorry to cloud the waters.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-979: add a fuseki admin service to list al...

2015-06-29 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/82#discussion_r33457733
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionBackupList.java
 ---
@@ -0,0 +1,98 @@
+/**
+ * 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.jena.fuseki.mgt;
+
+import org.apache.jena.atlas.json.JsonBuilder;
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.server.FusekiServer;
+import org.apache.jena.fuseki.servlets.ServletOps;
+import org.apache.jena.web.HttpSC;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import static org.apache.jena.riot.WebContent.charsetUTF8;
+import static org.apache.jena.riot.WebContent.contentTypeTextPlain;
+
+/**
+ * A JSON API to list all the backups in the backup directory
+ * Created by Yang Yuanzhe on 6/26/15.
+ */
+public class ActionBackupList extends HttpServlet {
+
+@Override
+protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
{
+doCommon(req, resp);
+}
+
+@Override
+protected void doPost(HttpServletRequest req, HttpServletResponse 
resp) {
+doCommon(req, resp);
+}
+
+@Override
+protected void doHead(HttpServletRequest req, HttpServletResponse 
resp) {
+doCommon(req, resp);
+}
+
+protected void doCommon(HttpServletRequest request, 
HttpServletResponse response) {
+JsonBuilder builder = new JsonBuilder() ;
+builder.startObject("top") ;
+builder.key("backups") ;
+builder.startArray() ;
+
+ArrayList fileNames = new ArrayList<>();
+if (Files.isDirectory(FusekiServer.dirBackups)) {
+try (DirectoryStream stream = 
Files.newDirectoryStream(FusekiServer.dirBackups)) {
+for (Path path : stream) {
+fileNames.add(path.getFileName().toString());
+}
+} catch (IOException ex) {
+Fuseki.serverLog.warn("backup file list :: IOException :: 
"+ex.getMessage());
+}
+}
+
+Collections.sort(fileNames);
+for (String str : fileNames) {
+builder.value(str);
+}
--- End diff --

No, I believe we are now officially at Java 8 for the main line of 
development.  We use Java 8-only idioms elsewhere. In any case, it's nothing to 
worry about. I just have a vicious yen for brevity. :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Removing out-of-date comment and empty @Overrid...

2015-06-29 Thread ajs6f
GitHub user ajs6f opened a pull request:

https://github.com/apache/jena/pull/83

Removing out-of-date comment and empty @Overrides from Dataset

A comment in `Dataset` indicated that it did not implement `Transactional` 
when in fact it now does. I removed that comment and the now-unnecessary 
overriden methods.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/ajs6f/jena CommentFix

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/83.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 #83


commit 08e97db53dc56e2bed496bcb01587ca9f53f81a7
Author: ajs6f 
Date:   2015-06-29T13:57:00Z

Removing out-of-date comment and empty @Overrides from Dataset




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Deprecating and removing some iterators from je...

2015-07-15 Thread ajs6f
Github user ajs6f closed the pull request at:

https://github.com/apache/jena/pull/80


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Bump versions of Hadoop, Guava for Elephas

2015-07-21 Thread ajs6f
GitHub user ajs6f opened a pull request:

https://github.com/apache/jena/pull/87

Bump versions of Hadoop, Guava for Elephas

https://issues.apache.org/jira/browse/JENA-994

Possibly off-target or too late for this ticket, but bumping Hadoop to 
latest release enables bringing Guava to latest release as well, a nice bonus.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/ajs6f/jena ElephasBump

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/87.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 #87


commit dbb11f4c4127749bd297af11b19ba6ff3c2297e0
Author: ajs6f 
Date:   2015-07-21T13:59:55Z

Bump versions of Hadoop, Guava for Elephas




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Bump versions of Hadoop, Guava for Elephas

2015-07-21 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/87#issuecomment-123350955
  
Have users asked for upgrades in the past?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Bump versions of Hadoop, Guava for Elephas

2015-07-21 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/87#issuecomment-123352349
  
The version of Hadoop in use is controlled by a Maven profile. Perhaps we 
could offer a "reliable" default profile and a "latest release" profile for 
those looking to explore?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Bump versions of Hadoop, Guava for Elephas

2015-07-21 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/87#issuecomment-123365451
  
Okay, I'll back off on Hadoop and just offer a simple bump for Guava up to 
the last version that is compatible with the current Hadoop.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Bump versions of Hadoop, Guava for Elephas

2015-07-21 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/87#issuecomment-123373621
  
I brought this back to just a bump for Guava (to an old, but less old, 
version) and JUnit.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Bump versions of JUnit, Guava for Elephas

2015-07-21 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/87#issuecomment-123455323
  
I know nothing of the story behind the chosen JUnit version, but I can tell 
you that the current version of Guava used in the main codebase (18.0) will not 
work with the version of Hadoop in use in Elephas now. (That's actually how I 
ended up trying to bump Hadoop.) This (16.0.1) is the latest version I could 
find that would. Guava 18.0 _will_ work with a later version of Hadoop, but I 
don't know how much later-- I only tried with 2.7.1. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

2015-07-22 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/89#discussion_r35211148
  
--- Diff: 
jena-arq/src-examples/arq/examples/constructquads/ExampleConstructQuads.java ---
@@ -0,0 +1,141 @@
+/*
+ * 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 arq.examples.constructquads;
+
+import java.util.Iterator;
+
+import org.apache.jena.graph.Triple;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
+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.Syntax;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.sparql.core.Quad;
+import org.apache.jena.util.PrintUtil;
+
+public class ExampleConstructQuads {
+   public static void main(String[] args) {
+
+   // create testing data :
+   // 1) default graph data
+   Model model = ModelFactory.createDefaultModel();
+   Resource s = model.createResource("http://eg.com/s";);
+   Property p = model.createProperty("http://eg.com/p";);
+   Resource o = model.createResource("http://eg.com/o";);
+   model.add(s, p, o);
+   Dataset dataset = DatasetFactory.create(model);
+   // 2) named graph data
+   Model model1 = ModelFactory.createDefaultModel();
+   Resource s1 = model.createResource("http://eg.com/s1";);
+   Property p1 = model.createProperty("http://eg.com/p1";);
+   Resource o1 = model.createResource("http://eg.com/o1";);
+   model1.add(s1, p1, o1);
+   dataset.addNamedModel("<http://eg.com/g1>", model1);
+
--- End diff --

This might read a little better by just adding quads directly to a 
DatasetGraph, but I suppose it's a matter of taste.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

2015-07-22 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/89#discussion_r35211501
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java ---
@@ -242,6 +257,49 @@ public Model execConstruct(Model model)
 Template template = query.getConstructTemplate() ;
 return TemplateLib.calcTriples(template.getTriples(), 
queryIterator);
 }
+
+@Override
+public Iterator execConstructQuads()
+{
+checkNotClosed() ;
+if ( ! query.isConstructType() )
+throw new QueryExecException("Attempt to get a CONSTRUCT model 
from a "+labelForQuery(query)+" query") ;
+// This causes there to be no PROJECT around the pattern.
+// That in turn, exposes the initial bindings.  
+if ( ! Syntax.syntaxARQ.equals( query.getSyntax() ) )
+   throw new QueryExecException("Attempt to CONSTRUCT quads from a 
"+labelForQuery(query)+" query, which is not ARQ Syntax") ;
+   
+query.setQueryResultStar(true) ;
+
+startQueryIterator() ;
+
+Template template = query.getConstructTemplate() ;
+return TemplateLib.calcQuads(template.getQuads(), queryIterator);
+}
+
+@Override
+public Dataset execConstructDataset(){
+   
+   DatasetGraph graph = DatasetGraphFactory.createMem();
+   
+checkNotClosed() ;
+try
+{
+Iterator it = execConstructQuads();
+
+while (it.hasNext())
+{
+Quad q = it.next();
+graph.add(q);
--- End diff --

Given Java 8 this iterator loop could be just 
`execConstructQuads().forEachRemaining(graph::add);`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

2015-07-22 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/89#discussion_r35211560
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/lang/arq/ARQParserBase.java ---
@@ -67,4 +79,25 @@ protected void jsonValueString(String image, long 
currLine, long currCol)
 protected void jsonValueNull(long currLine, long currCol)  
  { handler.valueNull(currLine, currCol) ; }
 
 protected void jsonValueVar(String image, long currLine, long currCol) 
  { throw new NotImplemented("yet") ; }
+protected ElementGroup createQueryPattern(Template t){
+ElementGroup elg = new ElementGroup();
+List quads = t.getQuads();
+HashMap graphs = new HashMap();
--- End diff --

Just `new HashMap<>` is okay after Java 7.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Bump versions of JUnit, Guava for Elephas

2015-07-22 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/87#issuecomment-123745671
  
Is that something that can be automated as a system test (test-driving the 
demo app in a simple cluster)?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Richer Javadocs for Iter and ExtendedIterator

2015-07-29 Thread ajs6f
GitHub user ajs6f opened a pull request:

https://github.com/apache/jena/pull/90

Richer Javadocs for Iter and ExtendedIterator



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/ajs6f/jena DocsForIterAndExtendedIterator

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/90.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 #90


commit 7730fb47020655369152da065b6c744484b3f15c
Author: ajs6f 
Date:   2015-07-29T14:44:27Z

Richer Javadocs for Iter and ExtendedIterator




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Richer Javadocs for Iter and ExtendedIterator

2015-07-29 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/90#discussion_r35807971
  
--- Diff: jena-base/src/main/java/org/apache/jena/atlas/iterator/Iter.java 
---
@@ -29,6 +29,14 @@
 import org.apache.jena.atlas.lib.Closeable ;
 import org.apache.jena.atlas.lib.Sink ;
 
+/**
+ * Iter provides utilities for working with {@link Iterator}s.
+ *
+ * Iter should never be used as a return type or parameter type in the 
public contract of a class. It is only to be used
+ * inside implementation code and is instantiated only to allow 
method-chaining as part of a calculation.
--- End diff --

Yes, that's why the note is useful. If `Iter` actually imposed that in the 
code there would be no need for documentation.

Is there in fact any difference between `Iter` and `ExtendedIterator`? They 
are both subtypes of `java.util.Iterator` that provide convenient methods, with 
the functionality of `Iter` entirely overlapping that of `ExtendedIterator`. 
I've tried repeatedly to discover this information, and my experience shows 
that it is quite possible to confuse them. You were quite explicit in 
explaining to me in connection with JENA-966 that they are not to be used in 
the same circumstances, and all I'm trying to do here is determine what those 
circumstances actually are and record them.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Richer Javadocs for Iter and ExtendedIterator

2015-07-30 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/90#discussion_r35869523
  
--- Diff: jena-base/src/main/java/org/apache/jena/atlas/iterator/Iter.java 
---
@@ -29,6 +29,14 @@
 import org.apache.jena.atlas.lib.Closeable ;
 import org.apache.jena.atlas.lib.Sink ;
 
+/**
+ * Iter provides utilities for working with {@link Iterator}s.
+ *
+ * Iter should never be used as a return type or parameter type in the 
public contract of a class. It is only to be used
+ * inside implementation code and is instantiated only to allow 
method-chaining as part of a calculation.
--- End diff --

What I meant by "difference" was context of use. In other words, what I 
have been trying to get at with this conversation, as I have written, is the 
answer to "When should one use `Iter`, and when should one use 
`ExtendedIterator`?" I tried to use `Iter` inside an `ExtendedIterator` during 
JENA-966 and you explained that this was wrong, and I am trying to get Javadocs 
into these classes so that other people don't have the same confusion. 

I still have no idea when to use either. If the difference is purely 
historical, then there is no inherent need for both, and perhaps I should open 
a ticket for a slow, careful, un-disruptive migration towards a single type for 
these purposes?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Merge confidencesun/master (Merged from JENA-49...

2015-07-30 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/89#discussion_r35870389
  
--- Diff: 
jena-arq/src-examples/arq/examples/constructquads/ExampleConstructQuads.java ---
@@ -0,0 +1,141 @@
+/*
+ * 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 arq.examples.constructquads;
+
+import java.util.Iterator;
+
+import org.apache.jena.graph.Triple;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
+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.Syntax;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.sparql.core.Quad;
+import org.apache.jena.util.PrintUtil;
+
+public class ExampleConstructQuads {
+   public static void main(String[] args) {
+
+   // create testing data :
+   // 1) default graph data
+   Model model = ModelFactory.createDefaultModel();
+   Resource s = model.createResource("http://eg.com/s";);
+   Property p = model.createProperty("http://eg.com/p";);
+   Resource o = model.createResource("http://eg.com/o";);
+   model.add(s, p, o);
+   Dataset dataset = DatasetFactory.create(model);
+   // 2) named graph data
+   Model model1 = ModelFactory.createDefaultModel();
+   Resource s1 = model.createResource("http://eg.com/s1";);
+   Property p1 = model.createProperty("http://eg.com/p1";);
+   Resource o1 = model.createResource("http://eg.com/o1";);
+   model1.add(s1, p1, o1);
+   dataset.addNamedModel("<http://eg.com/g1>", model1);
+
+
+   // construct named graph
+   System.out.println("construct named graph:");
+   String queryString = "CONSTRUCT { GRAPH ?g {<http://eg.com/s1> 
<http://eg.com/p1> ?o} } WHERE{ GRAPH ?g {<http://eg.com/s1> <http://eg.com/p1> 
?o} }";
+   Query query = QueryFactory.create(queryString, 
Syntax.syntaxARQ);
+   QueryExecution qexec = QueryExecutionFactory.create(query, 
dataset);
--- End diff --

You may have them turned off. Check Preferences > Java > Compiler > 
Errors/Warnings. There is a serried host of settings there and amongst them, 
under Code Style, you will find `Resource not managed via try-with-resource 
(1.7 or higher)`. It's worth turning on. In any event, even without the 
warning, `try-with-resource` is the right thing to do.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Richer Javadocs for Iter and ExtendedIterator

2015-07-30 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/90#discussion_r35871940
  
--- Diff: jena-base/src/main/java/org/apache/jena/atlas/iterator/Iter.java 
---
@@ -29,6 +29,14 @@
 import org.apache.jena.atlas.lib.Closeable ;
 import org.apache.jena.atlas.lib.Sink ;
 
+/**
+ * Iter provides utilities for working with {@link Iterator}s.
+ *
+ * Iter should never be used as a return type or parameter type in the 
public contract of a class. It is only to be used
+ * inside implementation code and is instantiated only to allow 
method-chaining as part of a calculation.
--- End diff --

This is exactly what I needed. Sorry to have bugged you so much about it, 
but I really think this deserves to be written down. I will correct this PR to 
advise just what you just did.

I am a little surprised that Jena's policy is that once a type is exposed, 
it can never be changed. That seems extraordinarily restrictive. But that's a 
completely different question.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: Richer Javadocs for Iter and ExtendedIterator

2015-08-10 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/90#issuecomment-129442497
  
Since commit 
https://github.com/apache/jena/commit/fd5a94ae61bcd32d2a82cebb6d088d0d81f1da39 
contains literally none of the usage advice that was the only purpose of this 
PR and merely reformats the extant comments, this PR should probably be marked 
"rejected", not "closed with".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-10-14 Thread ajs6f
GitHub user ajs6f opened a pull request:

https://github.com/apache/jena/pull/94

JENA-624 

JENA-624: new in-memory dataset implementation using persistent data 
structures

There are a lot of commits in this: I can squash them if desired, just let 
me know.

I will be happy to make any changes, large or small, no matter how 
numerous, right here in this actual branch and PR so that if/when it gets 
merged, the history and my authorship is preserved. Thanks!

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/ajs6f/jena jena-624-dexx

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/94.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 #94


commit de97040bac309e7a5098d418d19633910a25a97c
Author: ajs6f 
Date:   2015-07-20T00:58:45Z

First sketch

commit 605591afc5ea0adf48f720344098a956033effe7
Author: ajs6f 
Date:   2015-07-20T17:12:17Z

Firs simple tests

commit 0ba4b65b2dd8bb57cda03f9082b81265f4e4d35a
Author: ajs6f 
Date:   2015-07-21T15:58:19Z

Added test for "copy-on-addGraph", improved other tests

commit e2085dde79e323a46814b16045740a6d8dfed8c6
Author: ajs6f 
Date:   2015-07-21T16:43:45Z

Improved TestDatasetGraphWithRecord tests

commit a4d4a925276445abe4191a581d2f721b7c897610
Author: ajs6f 
Date:   2015-07-21T17:02:00Z

Improved TestDatasetGraphWithRecord::testClear

commit 5b07640f37abb76b83eb9c1ac8f009151f89fe18
Author: ajs6f 
Date:   2015-07-21T18:58:17Z

Full use of AbstractDatasetGraphTests

commit 41925bdabf0fcf4b1d8e681c12634db39f853731
Author: ajs6f 
Date:   2015-07-21T20:01:16Z

Stronger type-safety regime

commit f99cd5eb5bfe3febca3b70f84e28fe4ec5e85343
Author: ajs6f 
Date:   2015-07-21T20:23:21Z

Linking tests into ARQ tests

commit 446f2a632862e9fc0d5fdeaa39c66907834b6c3b
Author: ajs6f 
Date:   2015-07-21T20:38:27Z

Using DatasetGraphBase to require MRSW lock semantics

commit 44e0f8808755c2f3ebded0ee5e62e295ff1e2b7b
Author: ajs6f 
Date:   2015-07-21T20:42:49Z

Small emendation to Javadoc

commit f3e9159197dcd94c7069fadc6b6e3d54a25e7749
Author: ajs6f 
Date:   2015-07-22T14:31:04Z

Adding license headers

commit 4c22c4403117dafa412f840b8a269d52d38b9aa8
Author: ajs6f 
Date:   2015-07-22T15:05:02Z

Better equals() for QuadOperation subclasses

commit af1ff8ba15bda146d9cffcfd136c617acada2438
Author: ajs6f 
Date:   2015-07-23T13:13:38Z

Using GraphFactory method instead of GraphMem constructor

commit 2bb20f46be516e66712e637bac69d6be4cdab49e
Author: ajs6f 
Date:   2015-07-27T19:06:11Z

QuadOperation no longer extends Quad

commit 7a34b5cc39a2d08f1e301394ca08d3e191997913
Author: ajs6f 
Date:   2015-08-10T15:07:01Z

Improve comments for usage, separate locking for DatasetGraph from locking 
for operation record

commit 606de4de5e3c9fae5cd2e5708fe11d329f973592
Author: ajs6f 
Date:   2015-09-20T13:29:14Z

First draft

commit acfbd2211ef510e4bb68fac29c680a63e4df5bc7
Author: ajs6f 
Date:   2015-09-20T15:07:59Z

Moving base persistent map types to jena-base, better isolation of impl

commit 5552b557793b307b31613fb92d3c9cb85cb974ec
Author: ajs6f 
Date:   2015-09-20T18:32:07Z

First tests

commit 52d08f64ad6f80af56458b57c9c6bb3c41485a5f
Author: ajs6f 
Date:   2015-09-20T19:40:31Z

Slight improvements to basic persistent datatypes

commit fb3935ab7c5a98e4cf5c5507de421df1beeb0bcf
Author: ajs6f 
Date:   2015-09-21T00:00:02Z

Minor refactoring

commit b721c1f3018bdc6ea48a80724a286f270ed9a93c
Author: ajs6f 
Date:   2015-09-21T00:05:44Z

Minor refactoring

commit 58d19f7acb25486755a931b57245d690f2acb807
Author: ajs6f 
Date:   2015-09-21T13:12:18Z

Factoring out unnecessary QuadPattern type

commit b1f2d675b7b1d34d9e4bf084111f8730cbff4609
Author: ajs6f 
Date:   2015-09-21T14:49:28Z

Better tests for IndexForms

commit 06303bb4fd9ac8acaf0fd5710a1f78df00efd0f2
Author: ajs6f 
Date:   2015-09-21T16:28:00Z

Full IndexForm test converage

commit 6fd6d86ec5a6b82466455dc77e7336be6d287a2b
Author: ajs6f 
Date:   2015-09-21T17:56:42Z

Tests for HexIndex and linking tests into Jena test execution framework

commit 985eae9e1ea201c1ef360971253321dd51fc29ce
Author: ajs6f 
Date:   2015-09-21T19:02:05Z

Tests for DatasetGraphInMemory

commit a32db0b67eeff3eef1a0f32207f6fc09c9398ec2
Author: ajs6f 
Date:   2015-09-21T19:15:59Z

Stronger tests for DatasetGraphInMemory, correct semantics for default graph

commit b7d4f69683a2f496a79347c8d5a91ca79f59e290
Author: ajs6f 
Date:   2015-09-21T19:28:42Z

Minor refactoring

commit 05a807d4d9c63a9c46076636f736c9c5d7dcea4a
Author: ajs6f 
Date:   2015-09-21T19:55:38Z

Factoring out new Index type

commit 63ccc0301d508df5ce4bd1073122b270512b4e04
Author: ajs6f 
Date:   2015-09-21T20:03:46Z

Extending Index from Tra

[GitHub] jena pull request: JENA-624

2015-10-14 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-148155899
  
Okay, @afs, I've squashed everything into two commits. They are basically 
orthogonal, although there is a tiny leak from the first into the second (in 
`DatasetGraphWithRecord`), because I found a clearer way of typing mutations 
later in the summer. The first is the dataset-with-operation-record that I did 
earlier, that provides a real abort function to any wrapped MRSW dataset. The 
second is the persistent-data-structure-based MR+SW dataset impl. Let me know 
if you would prefer these to be broken out into two separate PRs-- that's no 
problem, I just didn't want to fire multiple PRs at once without clearing it. I 
can easily remedy the small leak and build two PRs.

You are right in that other than that, there aren't really natural 
boundaries inside each commit. That's a little unfortunate, because I know it 
will make review more of a pain in the neck, but at least I can promise that of 
the extant code into which this is being flung, nothing is touched outside of 
adding dependencies to POM files. This is all new stuff and shouldn't bother 
anything else.

Now back to ISWC!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320206
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheEntry.java
 ---
@@ -0,0 +1,57 @@
+/**
+ * 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.jena.fuseki.cache;
+
+
+import org.apache.jena.sparql.resultset.SPARQLResult;
+
+public class CacheEntry {
--- End diff --

What is the purpose of the initialization machinery in this class? It 
doesn't check to see that any of the fields are initialized... 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320210
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheStore.java
 ---
@@ -0,0 +1,150 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.servlets.ActionLib;
+import org.apache.jena.fuseki.servlets.HttpAction;
+import org.slf4j.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class CacheStore {
+
+
+/** flag to check if data store was initialized */
+public static boolean initialized = false ;
+
+private static Logger log = Fuseki.cacheLog ;
+
+/** execution timeout for any method */
+private int defaultExecutionTimeout = 500 ;
+
+/** thread pool size for this data store */
+protected int defaultThreadPoolSize = 500 ;
+
+/** client for interacting with  Cache store **/
+private final CacheClient client = new GuavaCacheClient();
+
+private static CacheStore instance;
+
+public static CacheStore getInstance(){
+
+if(instance==null){
+instance = new CacheStore();
+return instance;
+}
+return instance;
+}
+
+/** For testing - reset the places which initialize once */
+public synchronized static void reset() {
+initialized = false ;
+CacheStore.initialized = false ;
+}
+
+public synchronized static void init(){
+if ( initialized )
+return ;
+initialized = true ;
+
+}
+
+/**
+ * Get cache data from cache store.
+ * @param key Cache store key
+ */
+public Object doGet(String key) throws CacheStoreException{
+try{
+Object data = client.get(key);
+if(data == null)
+return null;
+else
+return data;
--- End diff --

Why check for `null` and then return it? Why not just `return 
client.get(key)`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320279
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheClient.java
 ---
@@ -0,0 +1,30 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+public abstract class CacheClient {
--- End diff --

Why isn't this class generic for type-safety, e.g. `CacheClient` with `V 
get(String key)`? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320283
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheClient.java
 ---
@@ -0,0 +1,30 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+public abstract class CacheClient {
--- End diff --

Isn't this better as an interface instead of an `abstract` class? There is 
no state in it, which is the purpose of an `abstract` class.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320566
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheStore.java
 ---
@@ -0,0 +1,150 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.servlets.ActionLib;
+import org.apache.jena.fuseki.servlets.HttpAction;
+import org.slf4j.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class CacheStore {
--- End diff --

Why is this machinery being created independently of 
`org.apache.jena.atlas.lib.Cache`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320602
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheStore.java
 ---
@@ -0,0 +1,150 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.servlets.ActionLib;
+import org.apache.jena.fuseki.servlets.HttpAction;
+import org.slf4j.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class CacheStore {
+
+
+/** flag to check if data store was initialized */
+public static boolean initialized = false ;
+
+private static Logger log = Fuseki.cacheLog ;
+
+/** execution timeout for any method */
+private int defaultExecutionTimeout = 500 ;
+
+/** thread pool size for this data store */
+protected int defaultThreadPoolSize = 500 ;
+
+/** client for interacting with  Cache store **/
+private final CacheClient client = new GuavaCacheClient();
+
+private static CacheStore instance;
+
+public static CacheStore getInstance(){
+
+if(instance==null){
--- End diff --

Just  `if (instance == null)  instance = new CacheStore(); return 
instance;` would work. No need for two `return` statements. Or even, less 
clearly, just `return instance == null ? instance = new CacheStore(): 
instance;`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320616
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheStore.java
 ---
@@ -0,0 +1,150 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.servlets.ActionLib;
+import org.apache.jena.fuseki.servlets.HttpAction;
+import org.slf4j.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class CacheStore {
+
+
+/** flag to check if data store was initialized */
+public static boolean initialized = false ;
+
+private static Logger log = Fuseki.cacheLog ;
+
+/** execution timeout for any method */
+private int defaultExecutionTimeout = 500 ;
+
+/** thread pool size for this data store */
+protected int defaultThreadPoolSize = 500 ;
+
+/** client for interacting with  Cache store **/
+private final CacheClient client = new GuavaCacheClient();
+
+private static CacheStore instance;
+
+public static CacheStore getInstance(){
+
+if(instance==null){
+instance = new CacheStore();
+return instance;
+}
+return instance;
+}
+
+/** For testing - reset the places which initialize once */
+public synchronized static void reset() {
+initialized = false ;
+CacheStore.initialized = false ;
+}
+
+public synchronized static void init(){
--- End diff --

This method doesn't seem to actually initialize anything...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320640
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheStore.java
 ---
@@ -0,0 +1,150 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.servlets.ActionLib;
+import org.apache.jena.fuseki.servlets.HttpAction;
+import org.slf4j.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class CacheStore {
+
+
+/** flag to check if data store was initialized */
+public static boolean initialized = false ;
+
+private static Logger log = Fuseki.cacheLog ;
+
+/** execution timeout for any method */
+private int defaultExecutionTimeout = 500 ;
+
+/** thread pool size for this data store */
+protected int defaultThreadPoolSize = 500 ;
+
+/** client for interacting with  Cache store **/
+private final CacheClient client = new GuavaCacheClient();
+
+private static CacheStore instance;
+
+public static CacheStore getInstance(){
+
+if(instance==null){
+instance = new CacheStore();
+return instance;
+}
+return instance;
+}
+
+/** For testing - reset the places which initialize once */
--- End diff --

The fact that this is just for testing isn't great. Maybe this doesn't need 
to be a singleton? That has other effects that can be suboptimal-- e.g. it can 
create problems with OSGi compatibility.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320655
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheClient.java
 ---
@@ -0,0 +1,30 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+
+public abstract class CacheClient {
+
+public abstract Object get(String key) throws InterruptedException, 
ExecutionException, TimeoutException ;
--- End diff --

You end up constantly checking for `null` on return values of this method. 
Maybe it might be better to just return `Optional` (or better, `Optional` as 
noted above)?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/95#issuecomment-149012148
  
This may be me being thick, but I don't see how a mutating query 
invalidates any part of the cache? 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320697
  
--- Diff: jena-arq/src/main/java/org/apache/jena/riot/system/InitRIOT.java 
---
@@ -31,7 +31,7 @@ public void start() {
 
 @Override
 public void stop() {}
-
--- End diff --

Needless whitespace change.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320704
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/resultset/CSVOutput.java ---
@@ -102,6 +102,62 @@ public void format(OutputStream out, ResultSet 
resultSet)
 }
 }
 
+@Override
+public void format(OutputStream out, ResultSet resultSet, 
StringBuilder cacheBuilder)
+{
+try {
+Writer w = FileUtils.asUTF8(out) ;
+NodeToLabelMap bnodes = new NodeToLabelMap() ;
+w = new BufferedWriter(w) ;
--- End diff --

Why not use `try-with-resource` here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320708
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/resultset/CSVOutput.java ---
@@ -102,6 +102,62 @@ public void format(OutputStream out, ResultSet 
resultSet)
 }
 }
 
+@Override
+public void format(OutputStream out, ResultSet resultSet, 
StringBuilder cacheBuilder)
+{
+try {
+Writer w = FileUtils.asUTF8(out) ;
+NodeToLabelMap bnodes = new NodeToLabelMap() ;
+w = new BufferedWriter(w) ;
+
+String sep = null ;
+List varNames = resultSet.getResultVars() ;
+List vars = new ArrayList<>(varNames.size()) ;
+
+// Convert to Vars and output the header line.
+for( String v : varNames )
+{
+if ( sep != null ){
--- End diff --

How is `sep` not going to be `null` at this line?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320718
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/resultset/CSVOutput.java ---
@@ -102,6 +102,62 @@ public void format(OutputStream out, ResultSet 
resultSet)
 }
 }
 
+@Override
+public void format(OutputStream out, ResultSet resultSet, 
StringBuilder cacheBuilder)
+{
+try {
+Writer w = FileUtils.asUTF8(out) ;
+NodeToLabelMap bnodes = new NodeToLabelMap() ;
+w = new BufferedWriter(w) ;
+
+String sep = null ;
+List varNames = resultSet.getResultVars() ;
+List vars = new ArrayList<>(varNames.size()) ;
+
+// Convert to Vars and output the header line.
+for( String v : varNames )
+{
+if ( sep != null ){
+w.write(sep) ;
+cacheBuilder.append(sep);
+}
+else
+sep = "," ;
+w.write(csvSafe(v)) ;
+cacheBuilder.append(csvSafe(v));
+vars.add(Var.alloc(v)) ;
+}
+w.write(NL) ;
+cacheBuilder.append(NL);
+
+// Data output
+for ( ; resultSet.hasNext() ; )
+{
+sep = null ;
+Binding b = resultSet.nextBinding() ;
+
+for( Var v : vars )
+{
+if ( sep != null ){
--- End diff --

Again, how is `sep` not going to be `null` at this line?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320957
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/resultset/CSVOutput.java ---
@@ -102,6 +102,62 @@ public void format(OutputStream out, ResultSet 
resultSet)
 }
 }
 
+@Override
+public void format(OutputStream out, ResultSet resultSet, 
StringBuilder cacheBuilder)
+{
+try {
+Writer w = FileUtils.asUTF8(out) ;
+NodeToLabelMap bnodes = new NodeToLabelMap() ;
+w = new BufferedWriter(w) ;
+
+String sep = null ;
+List varNames = resultSet.getResultVars() ;
+List vars = new ArrayList<>(varNames.size()) ;
+
+// Convert to Vars and output the header line.
+for( String v : varNames )
+{
+if ( sep != null ){
+w.write(sep) ;
+cacheBuilder.append(sep);
+}
+else
+sep = "," ;
+w.write(csvSafe(v)) ;
+cacheBuilder.append(csvSafe(v));
+vars.add(Var.alloc(v)) ;
+}
+w.write(NL) ;
+cacheBuilder.append(NL);
+
+// Data output
+for ( ; resultSet.hasNext() ; )
--- End diff --

These two loops could be managed a bit more tightly between 
`resultSet::forEachRemaining` and `vars.stream()::map`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42320974
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/resultset/CSVOutput.java ---
@@ -114,7 +170,19 @@ else if ( n.isBlank() )
 str = csvSafe(str) ;
 w.write(str) ;
 }
+private void output(Writer w, Node n, NodeToLabelMap bnodes, 
StringBuilder cacheBuilder) throws IOException
+{
+//String str = FmtUtils.stringForNode(n) ;
--- End diff --

Why not use `FmtUtils::stringForNode` here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42321146
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/resultset/TSVOutput.java ---
@@ -97,6 +97,63 @@ public void format(OutputStream out, ResultSet resultSet)
 w.flush() ;
 }
 
+@Override
+public void format(OutputStream out, ResultSet resultSet, 
StringBuilder cacheBuilder)
--- End diff --

See comments above on `CSVOutput`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42325590
  
--- Diff: jena-arq/src/main/java/org/apache/jena/sparql/system/InitARQ.java 
---
@@ -23,7 +23,7 @@
 
 /** ARQ initialization. Used by {@code JenaSystem} */
 public class InitARQ implements JenaSubsystemLifecycle {
-
+
--- End diff --

Needless whitespace change.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42325746
  
--- Diff: 
jena-core/src/main/java/org/apache/jena/system/JenaSubsystemLifecycle.java ---
@@ -18,15 +18,15 @@
 
 package org.apache.jena.system;
 
--- End diff --

These are all needless whitespace changes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42325752
  
--- Diff: jena-fuseki2/jena-fuseki-core/pom.xml ---
@@ -108,6 +108,12 @@
 
 
 
+  com.google.guava
--- End diff --

Guava types should be coming from Jena's shaded Guava artifact, not 
directly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42325779
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheAction.java
 ---
@@ -0,0 +1,45 @@
+/**
+ * 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.jena.fuseki.cache;
+
+public class CacheAction {
+
+public CacheAction.Type type;
--- End diff --

Possibly better to make this `final`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42325781
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheAction.java
 ---
@@ -0,0 +1,45 @@
+/**
+ * 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.jena.fuseki.cache;
+
+public class CacheAction {
+
+public CacheAction.Type type;
+
+private String key;
--- End diff --

Possibly better to make this `final`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42329075
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/GuavaCacheClient.java
 ---
@@ -0,0 +1,73 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+public class GuavaCacheClient extends CacheClient{
--- End diff --

There already exists a Guava-backed client in the form of `CacheGuava`. If 
you used the standard Jena `Cache` type instead of a new caching contract you 
could just use that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-18 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/95#issuecomment-149066287
  
I'm a little confused by the fact that for a feature that seems to require 
purchase only in an HTTP API (in Fuseki itself) this code seems to tangle all 
the way down into very low-level serialization code and basic types. It seems 
to me to be possible to do this reusing the extant caching machinery and doing 
new work only in Fuseki. Perhaps you can explain a little about why you chose 
to develop new caching machinery and why you integrated it in ARQ's 
serialization machinery. Perhaps I am misunderstanding the intent here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-19 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/95#issuecomment-149213529
  
There has been some discussion of ETags on the mailing list recently:

http://jena.markmail.org/search/%22Fuskei+and+ETags%22

and there is also this older issue:

https://issues.apache.org/jira/browse/JENA-388

Actually, I think 626 and 388 may be duplicates...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-19 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42413334
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheEntry.java
 ---
@@ -0,0 +1,57 @@
+/**
+ * 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.jena.fuseki.cache;
+
+
+import org.apache.jena.sparql.resultset.SPARQLResult;
+
+public class CacheEntry {
--- End diff --

My inclination would actually be to make this type as immutable as 
possible. If I am right in understanding that `result` must always be set, then 
make `result` `final`, have the constructor set it, and be done with it. If 
`cacheBuilder` may or may not be set, leave it mutable, and provide a mutator 
and a flag to show whether it has been set.Of course, this all deserves 
reconsideration in light of the advice @afs has given about architectural 
issues. You may want to have this type contain very different state or even 
wrap a computation instead of values.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-19 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42413412
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheStore.java
 ---
@@ -0,0 +1,150 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.servlets.ActionLib;
+import org.apache.jena.fuseki.servlets.HttpAction;
+import org.slf4j.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class CacheStore {
+
+
+/** flag to check if data store was initialized */
+public static boolean initialized = false ;
+
+private static Logger log = Fuseki.cacheLog ;
+
+/** execution timeout for any method */
+private int defaultExecutionTimeout = 500 ;
+
+/** thread pool size for this data store */
+protected int defaultThreadPoolSize = 500 ;
+
+/** client for interacting with  Cache store **/
+private final CacheClient client = new GuavaCacheClient();
+
+private static CacheStore instance;
+
+public static CacheStore getInstance(){
+
+if(instance==null){
+instance = new CacheStore();
+return instance;
+}
+return instance;
+}
+
+/** For testing - reset the places which initialize once */
+public synchronized static void reset() {
+initialized = false ;
+CacheStore.initialized = false ;
+}
+
+public synchronized static void init(){
+if ( initialized )
+return ;
+initialized = true ;
+
+}
+
+/**
+ * Get cache data from cache store.
+ * @param key Cache store key
+ */
+public Object doGet(String key) throws CacheStoreException{
+try{
+Object data = client.get(key);
+if(data == null)
+return null;
+else
+return data;
--- End diff --

I think tht of the two, you definitely want to use `java.util.Optional`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-19 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42413572
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheStore.java
 ---
@@ -0,0 +1,150 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.servlets.ActionLib;
+import org.apache.jena.fuseki.servlets.HttpAction;
+import org.slf4j.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class CacheStore {
--- End diff --

Ah, cool. I made other remarks like this elsewhere, so I guess those should 
be ignored. I think `Cache` has actually been around for quite some time, but 
it was maybe tucked into `jena-core` and not as visible?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-19 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42413696
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheStore.java
 ---
@@ -0,0 +1,150 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.servlets.ActionLib;
+import org.apache.jena.fuseki.servlets.HttpAction;
+import org.slf4j.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class CacheStore {
+
+
+/** flag to check if data store was initialized */
+public static boolean initialized = false ;
+
+private static Logger log = Fuseki.cacheLog ;
+
+/** execution timeout for any method */
+private int defaultExecutionTimeout = 500 ;
+
+/** thread pool size for this data store */
+protected int defaultThreadPoolSize = 500 ;
+
+/** client for interacting with  Cache store **/
+private final CacheClient client = new GuavaCacheClient();
+
+private static CacheStore instance;
+
+public static CacheStore getInstance(){
+
+if(instance==null){
--- End diff --

Yeah, the value of an assignment expression is the value that was assigned. 
Sometimes that can be a really opaque idiom, but here the context makes clear 
what's going on. Of course, depending on the architectural plan going forward, 
you may not be needing a singleton of this type anyway.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-626 SPARQL Query Caching

2015-10-19 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/95#discussion_r42413989
  
--- Diff: 
jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cache/CacheStore.java
 ---
@@ -0,0 +1,150 @@
+/**
+ * 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.jena.fuseki.cache;
+
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.servlets.ActionLib;
+import org.apache.jena.fuseki.servlets.HttpAction;
+import org.slf4j.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class CacheStore {
+
+
+/** flag to check if data store was initialized */
+public static boolean initialized = false ;
+
+private static Logger log = Fuseki.cacheLog ;
+
+/** execution timeout for any method */
+private int defaultExecutionTimeout = 500 ;
+
+/** thread pool size for this data store */
+protected int defaultThreadPoolSize = 500 ;
+
+/** client for interacting with  Cache store **/
+private final CacheClient client = new GuavaCacheClient();
+
+private static CacheStore instance;
+
+public static CacheStore getInstance(){
+
+if(instance==null){
+instance = new CacheStore();
+return instance;
+}
+return instance;
+}
+
+/** For testing - reset the places which initialize once */
--- End diff --

Singletons can be tricky, sometimes, because OSGi doesn't offer a single 
unified classpath to a multi-module application or library. It's not always an 
issue, but unless you have a really good reason to have a singleton (and I 
would argue here that you do not-- you are trying to build a single cache 
per-Fuseki-instance, not per-JVM, and as @afs pointed out, that is probably not 
the right approach in the end _anyway_) it's better to keep it simple.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-10-21 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-149916761
  
Thanks for the feedback, @afs! I'll take it point-by-point:

- Performance Status: The suspicion to which I was referring is that it's 
because using the Streams API generates more objects and those objects have 
more state than using iterators. It should be noted that I have not been able 
to verify this. I could, by rewriting the PR to avoid the Streams API, but it 
would require a good bit of work to do that and I think it would be _much_ 
harder to read. I think the majority of the performance decline is because of 
the changes in design, not incidental stuff like this.

- DatasetFactory: I just hadn't touched that yet to avoid touching anything 
outside of my code until we are happy with the basic machinery. I will happily 
put that in as per your proposal in that message. See a forthcoming commit. 
{grin}

- Assembler: I'm still reading through the assembler subsystem and making 
sure I understand it before extending it. I should be able to supply something 
soon.

- Documentation: Yes, I haven't done anything here. I assume you are 
talking about documentation in the website, right? Not Javadocs?

- Persistent datastructures: Cool, I'll break these out and give them some 
tests.

- Dependency management: Okay, I'll square that away. I didn't realize that 
$module/DEPENDENCIES even existed. What does that support?

- (Not) Mocking in tests: I think that should be doable in most cases. I 
usually prefer mocking because it makes everything very explicit, but if Jena's 
habit is otherwise, I'm happy to follow it.

- Warnings: Hm, didn't see those (except for the casts). I will make sure 
everything is clean. Those casts are really weird, because sometimes I have 
seen compilation fail without them, but they do seem to be unnecessary and the 
types are infer-able. I will check into it more thoroughly.

- Journaling: I think including it could be a good way also to get some 
feedback. Is there some Jena-standard way to mark something as "slightly 
experimental" a la Google's `@Beta` annotation?

- LockMRPlusSW: I will slap some tests on that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-10-26 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-151139579
  
@afs I can't find any of the unnecessary semicolon warnings-- can you give 
me a pointer?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-10-26 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-151155300
  
@afs For "Persistent datastructures: These could go in their own package." 
are you thinking of a subpackage of the one I'm currently using in `jena-arq`: 
`org.apache.jena.sparql.core.mem`, or since these structures are really just 
about arranging `Nodes`, maybe stick 'em in `jena-core`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-10-26 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-151154190
  
Got 'em, thanks. I had forgotten to turn on Eclipse's warnings for "empty 
statements".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-10-26 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-151165442
  
Okay, you mean then to add a 
`jena-base`:`org.apache.jena.atlas.lib.persistent`? Can do.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-10-26 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-151170795
  
Oh, okay, that's different: so you're thinking 
`jena-base`:`org.apache.jena.atlas.lib.persistent` or the like? Cool.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-10-26 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-151194518
  
@afs On the assembler front, did you want me to contribute a totally new 
assembler that works for this new dataset impl, or to alter the current 
`DatasetAssembler` to use this new impl instead of what it now uses?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-10-26 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-151317139
  
Makes sense, @afs. I'll head down that road.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-1062: configurable Lucene analyzer for jen...

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/97#discussion_r44012158
  
--- Diff: 
jena-text/src/main/java/org/apache/jena/query/text/analyzer/ConfigurableAnalyzer.java
 ---
@@ -0,0 +1,93 @@
+/**
+ * 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.jena.query.text.analyzer ;
+
+import java.io.Reader ;
+import java.util.List ;
+
+import org.apache.jena.query.text.TextIndexException;
+import org.apache.lucene.analysis.Analyzer ;
+import org.apache.lucene.analysis.TokenFilter ;
+import org.apache.lucene.analysis.Tokenizer ;
+import org.apache.lucene.analysis.TokenStream ;
+import org.apache.lucene.analysis.core.KeywordTokenizer ;
+import org.apache.lucene.analysis.core.LetterTokenizer;
+import org.apache.lucene.analysis.core.LowerCaseFilter ;
+import org.apache.lucene.analysis.core.WhitespaceTokenizer ;
+import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilter;
+import org.apache.lucene.analysis.standard.StandardFilter;
+import org.apache.lucene.analysis.standard.StandardTokenizer;
+import org.apache.lucene.util.Version ;
+
+
+/** 
+ * Lucene Analyzer implementation that can be configured with different
+ * Tokenizer and (optionally) TokenFilter implementations.
+ */
+
+public class ConfigurableAnalyzer extends Analyzer {
+private Version version;
--- End diff --

Couldn't these files be `final`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-1062: configurable Lucene analyzer for jen...

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/97#discussion_r44013590
  
--- Diff: 
jena-text/src/main/java/org/apache/jena/query/text/assembler/ConfigurableAnalyzerAssembler.java
 ---
@@ -0,0 +1,101 @@
+/**
+ * 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.jena.query.text.assembler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jena.assembler.Assembler;
+import org.apache.jena.assembler.Mode;
+import org.apache.jena.assembler.assemblers.AssemblerBase;
+import org.apache.jena.query.text.TextIndexException;
+import org.apache.jena.query.text.TextIndexLucene;
+import org.apache.jena.query.text.analyzer.ConfigurableAnalyzer;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.Statement ;
+import org.apache.jena.vocabulary.RDF ;
+import org.apache.lucene.analysis.Analyzer;
+
+
+/**
+ * Assembler to create a configurable analyzer.
+ */
+public class ConfigurableAnalyzerAssembler extends AssemblerBase {
+/*
+text:map (
+ [ text:field "text" ; 
+   text:predicate rdfs:label;
+   text:analyzer [
+   a  text:ConfigurableAnalyzer ;
+   text:tokenizer text:LetterTokenizer ;
+   text:filters (text:LowerCaseFilter)
+   ]
+ ]
+.
+*/
+
+
+@Override
+public Analyzer open(Assembler a, Resource root, Mode mode) {
+if (root.hasProperty(TextVocab.pTokenizer)) {
+Resource tokenizerResource = (Resource) 
root.getProperty(TextVocab.pTokenizer).getObject();
--- End diff --

Would `Resource::getPropertyResourceValue` be more readable here? (No cast.)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-1062: configurable Lucene analyzer for jen...

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/97#discussion_r44015443
  
--- Diff: 
jena-text/src/test/java/org/apache/jena/query/text/TestDatasetWithConfigurableAnalyzer.java
 ---
@@ -0,0 +1,63 @@
+/**
+ * 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.jena.query.text;
+
+import java.util.Arrays ;
+import java.util.HashSet ;
+import java.util.Set ;
+
+import org.apache.jena.atlas.lib.StrUtils ;
+import org.junit.Before ;
+import org.junit.Test ;
+
+/**
+ * This class defines a setup configuration for a dataset that uses an 
ASCII folding lowercase keyword analyzer with a Lucene index.
+ */
+public class TestDatasetWithConfigurableAnalyzer extends 
TestDatasetWithLowerCaseKeywordAnalyzer {
+@Override
+@Before
+public void before() {
+init(StrUtils.strjoinNL(
+"text:ConfigurableAnalyzer ;",
+"text:tokenizer text:KeywordTokenizer ;",
+"text:filters (text:ASCIIFoldingFilter text:LowerCaseFilter)"
+));
+}
+
+@Test
+public void testConfigurableAnalyzerIsCaseAndAccentInsensitive() {
+final String testName = 
"testConfigurableAnalyzerIsCaseAndAccentInsensitive";
+final String turtle = StrUtils.strjoinNL(
+TURTLE_PROLOG,
+"<" + RESOURCE_BASE + testName + ">",
+"  rdfs:label 'Feeling a déjà vu'",
+"."
+);
+String queryString = StrUtils.strjoinNL(
+QUERY_PROLOG,
+"SELECT ?s",
+"WHERE {",
+"?s text:query ( rdfs:label '\"feeling ä déja\"*' 10 
) .",
+"}"
+);
+Set expectedURIs = new HashSet<>() ;
--- End diff --

Our shaded Guava offers various `Sets::newHashSet` functions for this kind 
of use, which read a pinch better.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-1062: configurable Lucene analyzer for jen...

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/97#discussion_r44015231
  
--- Diff: 
jena-text/src/main/java/org/apache/jena/query/text/assembler/ConfigurableAnalyzerAssembler.java
 ---
@@ -0,0 +1,101 @@
+/**
+ * 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.jena.query.text.assembler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jena.assembler.Assembler;
+import org.apache.jena.assembler.Mode;
+import org.apache.jena.assembler.assemblers.AssemblerBase;
+import org.apache.jena.query.text.TextIndexException;
+import org.apache.jena.query.text.TextIndexLucene;
+import org.apache.jena.query.text.analyzer.ConfigurableAnalyzer;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.Statement ;
+import org.apache.jena.vocabulary.RDF ;
+import org.apache.lucene.analysis.Analyzer;
+
+
+/**
+ * Assembler to create a configurable analyzer.
+ */
+public class ConfigurableAnalyzerAssembler extends AssemblerBase {
+/*
+text:map (
+ [ text:field "text" ; 
+   text:predicate rdfs:label;
+   text:analyzer [
+   a  text:ConfigurableAnalyzer ;
+   text:tokenizer text:LetterTokenizer ;
+   text:filters (text:LowerCaseFilter)
+   ]
+ ]
+.
+*/
+
+
+@Override
+public Analyzer open(Assembler a, Resource root, Mode mode) {
+if (root.hasProperty(TextVocab.pTokenizer)) {
+Resource tokenizerResource = (Resource) 
root.getProperty(TextVocab.pTokenizer).getObject();
+String tokenizer = tokenizerResource.getLocalName();
+List filters;
+if (root.hasProperty(TextVocab.pFilters)) {
+Resource filtersResource = (Resource) 
root.getProperty(TextVocab.pFilters).getObject();
+filters = toFilterList(filtersResource);
+} else {
+filters = new ArrayList<>();
+}
+return new ConfigurableAnalyzer(TextIndexLucene.VER, 
tokenizer, filters);
+} else {
+throw new TextIndexException("text:tokenizer setting is 
required by ConfigurableAnalyzer");
+}
+}
+
+private List toFilterList(Resource list) {
+List result = new ArrayList<>();
+Resource current = list;
+while (current != null && ! current.equals(RDF.nil)){
+Statement stmt = current.getProperty(RDF.first);
+if (stmt == null) {
+throw new TextIndexException("filter list not well 
formed");
+}
+RDFNode node = stmt.getObject();
+if (! node.isResource()) {
+throw new TextIndexException("filter is not a resource : " 
+ node);
+}
+
+Resource res = (Resource)node;
--- End diff --

Isn't `Node::asResource` a little better here and below?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-1062: configurable Lucene analyzer for jen...

2015-11-05 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/97#issuecomment-154093794
  
@osma I am a nitpicker of the worst kind! {grin}

If you would like me to make a PR against `jena-text` looking for this kind 
of thing (using Guava or Java 8 idioms to shorten things up) I'm happy to do 
that sometime in the next week or three. I'm a born "code janitor".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44025566
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
 ---
@@ -0,0 +1,67 @@
+package org.apache.jena.sparql.core.assembler;
+
+import static org.apache.jena.assembler.JA.MemoryDataset;
+import static org.apache.jena.assembler.JA.data;
+import static org.apache.jena.query.DatasetFactory.createTxnMem;
+import static org.apache.jena.riot.RDFDataMgr.loadModel;
+import static org.apache.jena.riot.RDFDataMgr.read;
+import static 
org.apache.jena.sparql.core.assembler.AssemblerUtils.setContext;
+import static 
org.apache.jena.sparql.core.assembler.DatasetAssemblerVocab.*;
+import static org.apache.jena.sparql.util.FmtUtils.stringForRDFNode;
+import static org.apache.jena.sparql.util.graph.GraphUtils.*;
+
+import java.util.function.Predicate;
+
+import org.apache.jena.assembler.Assembler;
+import org.apache.jena.assembler.Mode;
+import org.apache.jena.assembler.assemblers.AssemblerBase;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+
+/**
+ * An {@link Assembler} that creates in-memory {@link Dataset}s.
+ *
+ */
+public class InMemDatasetAssembler extends AssemblerBase {
+
+   @Override
+   public Dataset open(final Assembler assembler, final Resource root, 
final Mode mode) {
+   checkType(root, MemoryDataset);
+   final Dataset dataset = createTxnMem();
+   setContext(root, dataset.getContext());
+   // Default graph can be defined with ja:graph or ja:defaultGraph
+   final Resource defaultGraphDef = 
root.hasProperty(pDefaultGraph) ? getResourceValue(root,
+   pDefaultGraph) : root.hasProperty(pGraph) ? 
getResourceValue(root, pGraph) : null;
+   if (defaultGraphDef != null) 
dataset.setDefaultModel(retrieve(defaultGraphDef, assembler, mode));
+   // or with ja:data
+   final Predicate isResource = n -> {
+   if (n.isResource()) return true;
+   throw new DatasetAssemblerException(root, "Not a 
resource: " + stringForRDFNode(n));
+   };
+   multiValue(root, data).parallelStream().filter(isResource)
+   .forEach(defaultGraphNode -> read(dataset, 
defaultGraphNode.asResource().getURI()));
+
--- End diff --

`defaultGraphNode` could be a file, could be a network resource: how about 
`defaultGraphdocument`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44025441
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
 ---
@@ -0,0 +1,67 @@
+package org.apache.jena.sparql.core.assembler;
+
+import static org.apache.jena.assembler.JA.MemoryDataset;
+import static org.apache.jena.assembler.JA.data;
+import static org.apache.jena.query.DatasetFactory.createTxnMem;
+import static org.apache.jena.riot.RDFDataMgr.loadModel;
+import static org.apache.jena.riot.RDFDataMgr.read;
+import static 
org.apache.jena.sparql.core.assembler.AssemblerUtils.setContext;
+import static 
org.apache.jena.sparql.core.assembler.DatasetAssemblerVocab.*;
+import static org.apache.jena.sparql.util.FmtUtils.stringForRDFNode;
+import static org.apache.jena.sparql.util.graph.GraphUtils.*;
+
+import java.util.function.Predicate;
+
+import org.apache.jena.assembler.Assembler;
+import org.apache.jena.assembler.Mode;
+import org.apache.jena.assembler.assemblers.AssemblerBase;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+
+/**
+ * An {@link Assembler} that creates in-memory {@link Dataset}s.
+ *
+ */
+public class InMemDatasetAssembler extends AssemblerBase {
+
+   @Override
+   public Dataset open(final Assembler assembler, final Resource root, 
final Mode mode) {
+   checkType(root, MemoryDataset);
+   final Dataset dataset = createTxnMem();
+   setContext(root, dataset.getContext());
+   // Default graph can be defined with ja:graph or ja:defaultGraph
+   final Resource defaultGraphDef = 
root.hasProperty(pDefaultGraph) ? getResourceValue(root,
+   pDefaultGraph) : root.hasProperty(pGraph) ? 
getResourceValue(root, pGraph) : null;
+   if (defaultGraphDef != null) 
dataset.setDefaultModel(retrieve(defaultGraphDef, assembler, mode));
+   // or with ja:data
+   final Predicate isResource = n -> {
+   if (n.isResource()) return true;
+   throw new DatasetAssemblerException(root, "Not a 
resource: " + stringForRDFNode(n));
+   };
+   multiValue(root, data).parallelStream().filter(isResource)
+   .forEach(defaultGraphNode -> read(dataset, 
defaultGraphNode.asResource().getURI()));
+
--- End diff --

The hope from using `parallelStream` was indeed to queue on the lock, but 
get _reading_ going in parallel. IOW, reading could require network access or 
filesystem access that could very well be parallelized. But I take your point 
about the order of error messages. That could be really terribly confusing. 
I'll pull out the parallelization.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44025646
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
 ---
@@ -0,0 +1,67 @@
+package org.apache.jena.sparql.core.assembler;
+
+import static org.apache.jena.assembler.JA.MemoryDataset;
+import static org.apache.jena.assembler.JA.data;
+import static org.apache.jena.query.DatasetFactory.createTxnMem;
+import static org.apache.jena.riot.RDFDataMgr.loadModel;
+import static org.apache.jena.riot.RDFDataMgr.read;
+import static 
org.apache.jena.sparql.core.assembler.AssemblerUtils.setContext;
+import static 
org.apache.jena.sparql.core.assembler.DatasetAssemblerVocab.*;
+import static org.apache.jena.sparql.util.FmtUtils.stringForRDFNode;
+import static org.apache.jena.sparql.util.graph.GraphUtils.*;
+
+import java.util.function.Predicate;
+
+import org.apache.jena.assembler.Assembler;
+import org.apache.jena.assembler.Mode;
+import org.apache.jena.assembler.assemblers.AssemblerBase;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+
+/**
+ * An {@link Assembler} that creates in-memory {@link Dataset}s.
+ *
+ */
+public class InMemDatasetAssembler extends AssemblerBase {
+
+   @Override
+   public Dataset open(final Assembler assembler, final Resource root, 
final Mode mode) {
+   checkType(root, MemoryDataset);
+   final Dataset dataset = createTxnMem();
--- End diff --

Yes, that's a bad oversight. I'll fix that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44025972
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
 ---
@@ -0,0 +1,67 @@
+package org.apache.jena.sparql.core.assembler;
+
+import static org.apache.jena.assembler.JA.MemoryDataset;
+import static org.apache.jena.assembler.JA.data;
+import static org.apache.jena.query.DatasetFactory.createTxnMem;
+import static org.apache.jena.riot.RDFDataMgr.loadModel;
+import static org.apache.jena.riot.RDFDataMgr.read;
+import static 
org.apache.jena.sparql.core.assembler.AssemblerUtils.setContext;
+import static 
org.apache.jena.sparql.core.assembler.DatasetAssemblerVocab.*;
+import static org.apache.jena.sparql.util.FmtUtils.stringForRDFNode;
+import static org.apache.jena.sparql.util.graph.GraphUtils.*;
+
+import java.util.function.Predicate;
+
+import org.apache.jena.assembler.Assembler;
+import org.apache.jena.assembler.Mode;
+import org.apache.jena.assembler.assemblers.AssemblerBase;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+
+/**
+ * An {@link Assembler} that creates in-memory {@link Dataset}s.
+ *
+ */
+public class InMemDatasetAssembler extends AssemblerBase {
+
+   @Override
+   public Dataset open(final Assembler assembler, final Resource root, 
final Mode mode) {
+   checkType(root, MemoryDataset);
+   final Dataset dataset = createTxnMem();
+   setContext(root, dataset.getContext());
+   // Default graph can be defined with ja:graph or ja:defaultGraph
+   final Resource defaultGraphDef = 
root.hasProperty(pDefaultGraph) ? getResourceValue(root,
+   pDefaultGraph) : root.hasProperty(pGraph) ? 
getResourceValue(root, pGraph) : null;
+   if (defaultGraphDef != null) 
dataset.setDefaultModel(retrieve(defaultGraphDef, assembler, mode));
+   // or with ja:data
+   final Predicate isResource = n -> {
+   if (n.isResource()) return true;
+   throw new DatasetAssemblerException(root, "Not a 
resource: " + stringForRDFNode(n));
+   };
+   multiValue(root, data).parallelStream().filter(isResource)
+   .forEach(defaultGraphNode -> read(dataset, 
defaultGraphNode.asResource().getURI()));
+
+   // Assemble or load named graphs
+   multiValue(root, 
pNamedGraph).parallelStream().filter(isResource).forEach(namedGraphNode -> {
+   final Resource namedGraphResource = 
namedGraphNode.asResource();
--- End diff --

Yeah, I wondered about that, but the semantics of what I've got here are 
actually different. If you look at `isResource`, it throws an exception when 
the thing is a literal (which would make no sense in an assembler 
construction). That's what the other assemblers seem to do. I'm happy to just 
ignore any "weird" constructions like that, but I thought I'd better do what 
the others did and throw an exception. I'll happily simplify this to ignore 
instead.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44027198
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
 ---
@@ -0,0 +1,67 @@
+package org.apache.jena.sparql.core.assembler;
+
+import static org.apache.jena.assembler.JA.MemoryDataset;
+import static org.apache.jena.assembler.JA.data;
+import static org.apache.jena.query.DatasetFactory.createTxnMem;
+import static org.apache.jena.riot.RDFDataMgr.loadModel;
+import static org.apache.jena.riot.RDFDataMgr.read;
+import static 
org.apache.jena.sparql.core.assembler.AssemblerUtils.setContext;
+import static 
org.apache.jena.sparql.core.assembler.DatasetAssemblerVocab.*;
+import static org.apache.jena.sparql.util.FmtUtils.stringForRDFNode;
+import static org.apache.jena.sparql.util.graph.GraphUtils.*;
+
+import java.util.function.Predicate;
+
+import org.apache.jena.assembler.Assembler;
+import org.apache.jena.assembler.Mode;
+import org.apache.jena.assembler.assemblers.AssemblerBase;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+
+/**
+ * An {@link Assembler} that creates in-memory {@link Dataset}s.
+ *
+ */
+public class InMemDatasetAssembler extends AssemblerBase {
+
+   @Override
+   public Dataset open(final Assembler assembler, final Resource root, 
final Mode mode) {
+   checkType(root, MemoryDataset);
+   final Dataset dataset = createTxnMem();
+   setContext(root, dataset.getContext());
+   // Default graph can be defined with ja:graph or ja:defaultGraph
+   final Resource defaultGraphDef = 
root.hasProperty(pDefaultGraph) ? getResourceValue(root,
+   pDefaultGraph) : root.hasProperty(pGraph) ? 
getResourceValue(root, pGraph) : null;
--- End diff --

I'm happy to make them do whatever we think is going to be most useful but 
I'm not yet understanding why we would want them to be different here when in 
[DatasetAssembler](https://github.com/apache/jena/blob/master/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java#L58)
 they really do seem to be the same?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-1062: configurable Lucene analyzer for jen...

2015-11-05 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/97#issuecomment-154099939
  
Sure, there's nothing wrong with what's there. All I meant is that 
`newHashSet` seems as clear as `new HashSet<>()` and allows elements, so is 
shorter.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44028911
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
 ---
@@ -0,0 +1,67 @@
+package org.apache.jena.sparql.core.assembler;
+
+import static org.apache.jena.assembler.JA.MemoryDataset;
+import static org.apache.jena.assembler.JA.data;
+import static org.apache.jena.query.DatasetFactory.createTxnMem;
+import static org.apache.jena.riot.RDFDataMgr.loadModel;
+import static org.apache.jena.riot.RDFDataMgr.read;
+import static 
org.apache.jena.sparql.core.assembler.AssemblerUtils.setContext;
+import static 
org.apache.jena.sparql.core.assembler.DatasetAssemblerVocab.*;
+import static org.apache.jena.sparql.util.FmtUtils.stringForRDFNode;
+import static org.apache.jena.sparql.util.graph.GraphUtils.*;
+
+import java.util.function.Predicate;
+
+import org.apache.jena.assembler.Assembler;
+import org.apache.jena.assembler.Mode;
+import org.apache.jena.assembler.assemblers.AssemblerBase;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+
+/**
+ * An {@link Assembler} that creates in-memory {@link Dataset}s.
+ *
+ */
+public class InMemDatasetAssembler extends AssemblerBase {
+
+   @Override
+   public Dataset open(final Assembler assembler, final Resource root, 
final Mode mode) {
+   checkType(root, MemoryDataset);
+   final Dataset dataset = createTxnMem();
+   setContext(root, dataset.getContext());
+   // Default graph can be defined with ja:graph or ja:defaultGraph
+   final Resource defaultGraphDef = 
root.hasProperty(pDefaultGraph) ? getResourceValue(root,
+   pDefaultGraph) : root.hasProperty(pGraph) ? 
getResourceValue(root, pGraph) : null;
--- End diff --

With all respect, that really doesn't seem to be what is happening in 
DatasetAssembler. A value from either predicate is taken and used at 
[this](https://github.com/apache/jena/blob/master/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/DatasetAssembler.java#L64)
 line to build from a model description. A value on `ja:graph` will be used 
there, not to load from a file. 

Is "load-from-a-file" the correct meaning for `ja:graph`? If so, what was 
the point of introducing `ja:data`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44029048
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
 ---
@@ -0,0 +1,67 @@
+package org.apache.jena.sparql.core.assembler;
+
+import static org.apache.jena.assembler.JA.MemoryDataset;
+import static org.apache.jena.assembler.JA.data;
+import static org.apache.jena.query.DatasetFactory.createTxnMem;
+import static org.apache.jena.riot.RDFDataMgr.loadModel;
+import static org.apache.jena.riot.RDFDataMgr.read;
+import static 
org.apache.jena.sparql.core.assembler.AssemblerUtils.setContext;
+import static 
org.apache.jena.sparql.core.assembler.DatasetAssemblerVocab.*;
+import static org.apache.jena.sparql.util.FmtUtils.stringForRDFNode;
+import static org.apache.jena.sparql.util.graph.GraphUtils.*;
+
+import java.util.function.Predicate;
+
+import org.apache.jena.assembler.Assembler;
+import org.apache.jena.assembler.Mode;
+import org.apache.jena.assembler.assemblers.AssemblerBase;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+
+/**
+ * An {@link Assembler} that creates in-memory {@link Dataset}s.
+ *
+ */
+public class InMemDatasetAssembler extends AssemblerBase {
+
+   @Override
+   public Dataset open(final Assembler assembler, final Resource root, 
final Mode mode) {
+   checkType(root, MemoryDataset);
+   final Dataset dataset = createTxnMem();
+   setContext(root, dataset.getContext());
+   // Default graph can be defined with ja:graph or ja:defaultGraph
+   final Resource defaultGraphDef = 
root.hasProperty(pDefaultGraph) ? getResourceValue(root,
+   pDefaultGraph) : root.hasProperty(pGraph) ? 
getResourceValue(root, pGraph) : null;
--- End diff --

I will add some `if-then` statements to unpack the code a bit.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-05 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44030781
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/InMemDatasetAssembler.java
 ---
@@ -0,0 +1,67 @@
+package org.apache.jena.sparql.core.assembler;
+
+import static org.apache.jena.assembler.JA.MemoryDataset;
+import static org.apache.jena.assembler.JA.data;
+import static org.apache.jena.query.DatasetFactory.createTxnMem;
+import static org.apache.jena.riot.RDFDataMgr.loadModel;
+import static org.apache.jena.riot.RDFDataMgr.read;
+import static 
org.apache.jena.sparql.core.assembler.AssemblerUtils.setContext;
+import static 
org.apache.jena.sparql.core.assembler.DatasetAssemblerVocab.*;
+import static org.apache.jena.sparql.util.FmtUtils.stringForRDFNode;
+import static org.apache.jena.sparql.util.graph.GraphUtils.*;
+
+import java.util.function.Predicate;
+
+import org.apache.jena.assembler.Assembler;
+import org.apache.jena.assembler.Mode;
+import org.apache.jena.assembler.assemblers.AssemblerBase;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+
+/**
+ * An {@link Assembler} that creates in-memory {@link Dataset}s.
+ *
+ */
+public class InMemDatasetAssembler extends AssemblerBase {
+
+   @Override
+   public Dataset open(final Assembler assembler, final Resource root, 
final Mode mode) {
+   checkType(root, MemoryDataset);
+   final Dataset dataset = createTxnMem();
+   setContext(root, dataset.getContext());
+   // Default graph can be defined with ja:graph or ja:defaultGraph
+   final Resource defaultGraphDef = 
root.hasProperty(pDefaultGraph) ? getResourceValue(root,
+   pDefaultGraph) : root.hasProperty(pGraph) ? 
getResourceValue(root, pGraph) : null;
--- End diff --

Okay, I thought it would be cool, but I certainly admit that it's gotten 
confusing already, and no users have even gotten involved yet! {grin}

I will strip out this jazz entirely and take it back to the plain case. To 
do that, I will use only one predicate, `ja:data`, with the meaning of "load 
tuples from this URI".


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-05 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-154127004
  
Weird. I don't know what that means, but it certainly doesn't seem right. 
Several of the intermediate commits in that last also came well after 19 July 
(which is what it says on my page!).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44409220
  
--- Diff: jena-arq/src/main/java/org/apache/jena/query/DatasetFactory.java 
---
@@ -16,253 +16,226 @@
  * limitations under the License.
  */
 
-package org.apache.jena.query ;
-
-import java.util.List ;
-
-import org.apache.jena.assembler.Assembler ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.Resource ;
-import org.apache.jena.sparql.ARQException ;
-import org.apache.jena.sparql.core.DatasetGraph ;
-import org.apache.jena.sparql.core.DatasetGraphFactory ;
-import org.apache.jena.sparql.core.DatasetImpl ;
-import org.apache.jena.sparql.core.assembler.DatasetAssembler ;
-import org.apache.jena.sparql.util.DatasetUtils ;
-import org.apache.jena.sparql.util.graph.GraphUtils ;
-import org.apache.jena.util.FileManager ;
-
-/** Make Datasets and DataSources in various ways */
-
+package org.apache.jena.query;
+
+import java.util.List;
+
+import org.apache.jena.assembler.Assembler;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.sparql.ARQException;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphFactory;
+import org.apache.jena.sparql.core.DatasetImpl;
+import org.apache.jena.sparql.core.assembler.DatasetAssembler;
+import org.apache.jena.sparql.util.DatasetUtils;
+import org.apache.jena.sparql.util.graph.GraphUtils;
+import org.apache.jena.util.FileManager;
+
+/**
+ * Makes {@link Dataset}s in various ways.
+ *
+ */
 public class DatasetFactory {
-/** Create an in-memory, modifiable Dataset */
-public static Dataset createMem() {
-return create(DatasetGraphFactory.createMem()) ;
-}
-
-/**
- * Create an in-memory, modifiable Dataset. New graphs must be 
explicitly
- * added using .addGraph.
- */
-public static Dataset createMemFixed() {
-return create(DatasetGraphFactory.createMemFixed()) ;
-}
-
-/**
- * Create a dataset with the given model as the default graph
- * 
- * @param model
- *The model for the default graph
- * @return Dataset
- */
-public static Dataset create(Model model) {
-return new DatasetImpl(model) ;
-}
-
-/**
- * Create a dataset: clone the dataset structure of named graohs, and 
share
- * the graphs themselves.
- * 
- * @param dataset
- *Dataset to clone structure from.
- * @return Dataset
- */
-public static Dataset create(Dataset dataset) {
-return new DatasetImpl(dataset) ;
-}
-
-/**
- * Wrap a datasetgraph to make a mutable dataset
- * 
- * @param dataset
- *DatasetGraph
- * @return Dataset
- */
-public static Dataset create(DatasetGraph dataset) {
-return DatasetImpl.wrap(dataset) ;
-}
-
-/**
- * Create a dataset based on a list of URIs : these are merged into the
- * default graph of the dataset.
- * 
- * @param uriList
- *URIs merged to form the default dataset
- * @return Dataset
- */
-
-public static Dataset create(List uriList) {
-return create(uriList, null, null) ;
-}
-
-/**
- * Create a dataset with a default graph and no named graphs
- * 
- * @param uri
- *URIs merged to form the default dataset
- * @return Dataset
- */
-
-public static Dataset create(String uri) {
-return create(uri, null, null) ;
-}
-
-/**
- * Create a dataset based on a list of URIs : these are merged into the
- * default graph of the dataset.
- * 
- * @param uriList
- *URIs merged to form the default dataset
- * @param fileManager
- * @return Dataset
- */
-
-/**
- * Create a named graph container of graphs based on a list of URIs.
- * 
- * @param namedSourceList
- * @return Dataset
- */
-
-public static Dataset createNamed(List namedSourceList) {
-return create((List)null, namedSourceList, null) ;
-}
-
-/**
- * Create a dataset based on two list of URIs. The first lists is used 
to
- * create the background (unnamed graph) by merging, the second is 
used to
- * create the collection of named graphs.
- * 
- * (Jena calls graphs "M

[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44410022
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/mem/DatasetGraphInMemory.java
 ---
@@ -0,0 +1,310 @@
+/*
+ * 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.jena.sparql.core.mem;
+
+import static java.lang.ThreadLocal.withInitial;
+import static org.apache.jena.graph.Node.ANY;
+import static org.apache.jena.query.ReadWrite.READ;
+import static org.apache.jena.query.ReadWrite.WRITE;
+import static org.apache.jena.sparql.core.Quad.isUnionGraph;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.query.ReadWrite;
+import org.apache.jena.shared.Lock;
+import org.apache.jena.shared.LockMRPlusSW;
+import org.apache.jena.sparql.JenaTransactionException;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphTriplesQuads;
+import org.apache.jena.sparql.core.DatasetPrefixStorage;
+import org.apache.jena.sparql.core.Quad;
+import org.apache.jena.sparql.core.Transactional;
+
+/**
+ * A {@link DatasetGraph} backed by an {@link QuadTable}. By default, this 
is a {@link HexTable} designed for high-speed
+ * in-memory operation.
+ *
+ */
+public class DatasetGraphInMemory extends DatasetGraphTriplesQuads 
implements Transactional {
+
+   private final DatasetPrefixStorage prefixes = new 
DatasetPrefixStorageInMemory();
+
+   private final Lock writeLock = new LockMRPlusSW();
+
+   private Lock writeLock() {
+   return writeLock;
+   }
+
+   private final ReentrantReadWriteLock commitLock = new 
ReentrantReadWriteLock(true);
+
+   /**
+* Commits must be atomic, and because a thread that is committing 
alters the various indexes one after another, we
+* lock out {@link #begin(ReadWrite)} while {@link #commit()} is 
executing.
+*/
+   private ReentrantReadWriteLock commitLock() {
+   return commitLock;
+   }
+
+   private final ThreadLocal isInTransaction = withInitial(() -> 
false);
+
+   @Override
+   public boolean isInTransaction() {
+   return isInTransaction.get();
+   }
+
+   protected void isInTransaction(final boolean b) {
+   isInTransaction.set(b);
+   }
+
+   private final ThreadLocal transactionType = withInitial(() 
-> null);
+
+   /**
+* @return the type of transaction in progress
+*/
+   public ReadWrite transactionType() {
+   return transactionType.get();
+   }
+
+   protected void transactionType(final ReadWrite readWrite) {
+   transactionType.set(readWrite);
+   }
+
+   private final QuadTable quadsIndex;
+
+   private QuadTable quadsIndex() {
+   return quadsIndex;
+   }
+
+   private final TripleTable defaultGraph;
+
+   private TripleTable defaultGraph() {
+   return defaultGraph;
+   }
+
+   @Override
+   public Lock getLock() {
+   return writeLock();
+   }
+
+   /**
+* Default constructor.
+*/
+   public DatasetGraphInMemory() {
+   this(new HexTable(), new TriTable());
+   }
+
+   /**
+* @param i a table in which to store quads
+* @param t a table in which to store triples
+*/
+   public DatasetGraphInMemory(final QuadTable i, final TripleTable t) {
+   this.quadsIndex = i;
+   this.defaultGraph = t;
+   }
+
+   @Override
+   public void begin(final ReadWrite readW

[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44410004
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/mem/DatasetGraphInMemory.java
 ---
@@ -0,0 +1,310 @@
+/*
+ * 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.jena.sparql.core.mem;
+
+import static java.lang.ThreadLocal.withInitial;
+import static org.apache.jena.graph.Node.ANY;
+import static org.apache.jena.query.ReadWrite.READ;
+import static org.apache.jena.query.ReadWrite.WRITE;
+import static org.apache.jena.sparql.core.Quad.isUnionGraph;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.query.ReadWrite;
+import org.apache.jena.shared.Lock;
+import org.apache.jena.shared.LockMRPlusSW;
+import org.apache.jena.sparql.JenaTransactionException;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphTriplesQuads;
+import org.apache.jena.sparql.core.DatasetPrefixStorage;
+import org.apache.jena.sparql.core.Quad;
+import org.apache.jena.sparql.core.Transactional;
+
+/**
+ * A {@link DatasetGraph} backed by an {@link QuadTable}. By default, this 
is a {@link HexTable} designed for high-speed
+ * in-memory operation.
+ *
+ */
+public class DatasetGraphInMemory extends DatasetGraphTriplesQuads 
implements Transactional {
+
+   private final DatasetPrefixStorage prefixes = new 
DatasetPrefixStorageInMemory();
+
+   private final Lock writeLock = new LockMRPlusSW();
+
+   private Lock writeLock() {
+   return writeLock;
+   }
+
+   private final ReentrantReadWriteLock commitLock = new 
ReentrantReadWriteLock(true);
+
+   /**
+* Commits must be atomic, and because a thread that is committing 
alters the various indexes one after another, we
+* lock out {@link #begin(ReadWrite)} while {@link #commit()} is 
executing.
+*/
+   private ReentrantReadWriteLock commitLock() {
+   return commitLock;
+   }
+
+   private final ThreadLocal isInTransaction = withInitial(() -> 
false);
+
+   @Override
+   public boolean isInTransaction() {
+   return isInTransaction.get();
+   }
+
+   protected void isInTransaction(final boolean b) {
+   isInTransaction.set(b);
+   }
+
+   private final ThreadLocal transactionType = withInitial(() 
-> null);
+
+   /**
+* @return the type of transaction in progress
+*/
+   public ReadWrite transactionType() {
+   return transactionType.get();
+   }
+
+   protected void transactionType(final ReadWrite readWrite) {
+   transactionType.set(readWrite);
+   }
+
+   private final QuadTable quadsIndex;
+
+   private QuadTable quadsIndex() {
+   return quadsIndex;
+   }
+
+   private final TripleTable defaultGraph;
+
+   private TripleTable defaultGraph() {
+   return defaultGraph;
+   }
+
+   @Override
+   public Lock getLock() {
+   return writeLock();
+   }
+
+   /**
+* Default constructor.
+*/
+   public DatasetGraphInMemory() {
+   this(new HexTable(), new TriTable());
+   }
+
+   /**
+* @param i a table in which to store quads
+* @param t a table in which to store triples
+*/
+   public DatasetGraphInMemory(final QuadTable i, final TripleTable t) {
+   this.quadsIndex = i;
+   this.defaultGraph = t;
+   }
+
+   @Override
+   public void begin(final ReadWrite readW

[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44410251
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/mem/QuadTable.java ---
@@ -0,0 +1,59 @@
+/*
+ * 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.jena.sparql.core.mem;
+
+import static org.apache.jena.graph.Node.ANY;
+
+import java.util.stream.Stream;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.core.Quad;
+
+/**
+ * A simplex or multiplex table of {@link Quad}s. Implementations may wish 
to override {@link #listGraphNodes()} with a
+ * more efficient implementation.
+ *
+ */
+public interface QuadTable extends TupleTable {
+
+   /**
+* Search the table using a pattern of slots. {@link Node#ANY} or 
null will work as a wildcard.
+*
+* @param g the graph node of the pattern
+* @param s the subject node of the pattern
+* @param p the predicate node of the pattern
+* @param o the object node of the pattern
+* @return an {@link Stream} of matched quads
+*/
+   Stream find(Node g, Node s, Node p, Node o);
+
+   /**
+* Discover the graphs named in the table
+*
+* @return an {@link Stream} of graph names used in this table
+*/
+   default Stream listGraphNodes() {
+   return find(ANY, ANY, ANY, ANY).map(Quad::getGraph).distinct();
+   }
--- End diff --

See my comment on `DatasetGraphInMemory` as to union graph functionality. 
It applies here too. This is an interface which has no reason or right to 
assume anything about adjacency.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44410452
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/mem/QuadTable.java ---
@@ -0,0 +1,59 @@
+/*
+ * 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.jena.sparql.core.mem;
+
+import static org.apache.jena.graph.Node.ANY;
+
+import java.util.stream.Stream;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.core.Quad;
+
+/**
+ * A simplex or multiplex table of {@link Quad}s. Implementations may wish 
to override {@link #listGraphNodes()} with a
+ * more efficient implementation.
+ *
+ */
+public interface QuadTable extends TupleTable {
+
+   /**
+* Search the table using a pattern of slots. {@link Node#ANY} or 
null will work as a wildcard.
+*
+* @param g the graph node of the pattern
+* @param s the subject node of the pattern
+* @param p the predicate node of the pattern
+* @param o the object node of the pattern
+* @return an {@link Stream} of matched quads
+*/
+   Stream find(Node g, Node s, Node p, Node o);
+
+   /**
+* Discover the graphs named in the table
+*
+* @return an {@link Stream} of graph names used in this table
+*/
+   default Stream listGraphNodes() {
+   return find(ANY, ANY, ANY, ANY).map(Quad::getGraph).distinct();
+   }
--- End diff --

As to starting with G, that's why this is a `default` method. Look at 
`HexTable` and you will see that very advantage being taken. But this is a 
`default` method and must not rely on facts about an implementation.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44409436
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/mem/DatasetGraphInMemory.java
 ---
@@ -0,0 +1,310 @@
+/*
+ * 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.jena.sparql.core.mem;
+
+import static java.lang.ThreadLocal.withInitial;
+import static org.apache.jena.graph.Node.ANY;
+import static org.apache.jena.query.ReadWrite.READ;
+import static org.apache.jena.query.ReadWrite.WRITE;
+import static org.apache.jena.sparql.core.Quad.isUnionGraph;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.query.ReadWrite;
+import org.apache.jena.shared.Lock;
+import org.apache.jena.shared.LockMRPlusSW;
+import org.apache.jena.sparql.JenaTransactionException;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphTriplesQuads;
+import org.apache.jena.sparql.core.DatasetPrefixStorage;
+import org.apache.jena.sparql.core.Quad;
+import org.apache.jena.sparql.core.Transactional;
+
+/**
+ * A {@link DatasetGraph} backed by an {@link QuadTable}. By default, this 
is a {@link HexTable} designed for high-speed
+ * in-memory operation.
+ *
+ */
+public class DatasetGraphInMemory extends DatasetGraphTriplesQuads 
implements Transactional {
+
+   private final DatasetPrefixStorage prefixes = new 
DatasetPrefixStorageInMemory();
+
+   private final Lock writeLock = new LockMRPlusSW();
+
+   private Lock writeLock() {
+   return writeLock;
+   }
+
+   private final ReentrantReadWriteLock commitLock = new 
ReentrantReadWriteLock(true);
+
+   /**
+* Commits must be atomic, and because a thread that is committing 
alters the various indexes one after another, we
+* lock out {@link #begin(ReadWrite)} while {@link #commit()} is 
executing.
+*/
+   private ReentrantReadWriteLock commitLock() {
+   return commitLock;
+   }
+
+   private final ThreadLocal isInTransaction = withInitial(() -> 
false);
+
+   @Override
+   public boolean isInTransaction() {
+   return isInTransaction.get();
+   }
+
+   protected void isInTransaction(final boolean b) {
+   isInTransaction.set(b);
+   }
+
+   private final ThreadLocal transactionType = withInitial(() 
-> null);
+
+   /**
+* @return the type of transaction in progress
+*/
+   public ReadWrite transactionType() {
+   return transactionType.get();
+   }
+
+   protected void transactionType(final ReadWrite readWrite) {
+   transactionType.set(readWrite);
+   }
+
+   private final QuadTable quadsIndex;
+
+   private QuadTable quadsIndex() {
+   return quadsIndex;
+   }
+
+   private final TripleTable defaultGraph;
+
+   private TripleTable defaultGraph() {
+   return defaultGraph;
+   }
+
+   @Override
+   public Lock getLock() {
+   return writeLock();
+   }
+
+   /**
+* Default constructor.
+*/
+   public DatasetGraphInMemory() {
+   this(new HexTable(), new TriTable());
+   }
+
+   /**
+* @param i a table in which to store quads
+* @param t a table in which to store triples
+*/
+   public DatasetGraphInMemory(final QuadTable i, final TripleTable t) {
+   this.quadsIndex = i;
+   this.defaultGraph = t;
+   }
+
+   @Override
+   public void begin(final ReadWrite readW

[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44411038
  
--- Diff: jena-arq/src/main/java/org/apache/jena/query/DatasetFactory.java 
---
@@ -16,253 +16,226 @@
  * limitations under the License.
  */
 
-package org.apache.jena.query ;
-
--- End diff --

See your comment 
[here](https://mail-archives.apache.org/mod_mbox/jena-dev/201510.mbox/%3C5610F36D.8090602%40apache.org%3E)
 about "other clearing up of DatasetFactory ...", although I'm not sure why Git 
created the diff in this confusing way.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44411395
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/mem/DatasetGraphInMemory.java
 ---
@@ -0,0 +1,310 @@
+/*
+ * 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.jena.sparql.core.mem;
+
+import static java.lang.ThreadLocal.withInitial;
+import static org.apache.jena.graph.Node.ANY;
+import static org.apache.jena.query.ReadWrite.READ;
+import static org.apache.jena.query.ReadWrite.WRITE;
+import static org.apache.jena.sparql.core.Quad.isUnionGraph;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.query.ReadWrite;
+import org.apache.jena.shared.Lock;
+import org.apache.jena.shared.LockMRPlusSW;
+import org.apache.jena.sparql.JenaTransactionException;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphTriplesQuads;
+import org.apache.jena.sparql.core.DatasetPrefixStorage;
+import org.apache.jena.sparql.core.Quad;
+import org.apache.jena.sparql.core.Transactional;
+
+/**
+ * A {@link DatasetGraph} backed by an {@link QuadTable}. By default, this 
is a {@link HexTable} designed for high-speed
+ * in-memory operation.
+ *
+ */
+public class DatasetGraphInMemory extends DatasetGraphTriplesQuads 
implements Transactional {
+
+   private final DatasetPrefixStorage prefixes = new 
DatasetPrefixStorageInMemory();
+
+   private final Lock writeLock = new LockMRPlusSW();
+
+   private Lock writeLock() {
+   return writeLock;
+   }
+
+   private final ReentrantReadWriteLock commitLock = new 
ReentrantReadWriteLock(true);
+
+   /**
+* Commits must be atomic, and because a thread that is committing 
alters the various indexes one after another, we
+* lock out {@link #begin(ReadWrite)} while {@link #commit()} is 
executing.
+*/
+   private ReentrantReadWriteLock commitLock() {
+   return commitLock;
+   }
+
+   private final ThreadLocal isInTransaction = withInitial(() -> 
false);
+
+   @Override
+   public boolean isInTransaction() {
+   return isInTransaction.get();
+   }
+
+   protected void isInTransaction(final boolean b) {
+   isInTransaction.set(b);
+   }
+
+   private final ThreadLocal transactionType = withInitial(() 
-> null);
+
+   /**
+* @return the type of transaction in progress
+*/
+   public ReadWrite transactionType() {
+   return transactionType.get();
+   }
+
+   protected void transactionType(final ReadWrite readWrite) {
+   transactionType.set(readWrite);
+   }
+
+   private final QuadTable quadsIndex;
+
+   private QuadTable quadsIndex() {
+   return quadsIndex;
+   }
+
+   private final TripleTable defaultGraph;
+
+   private TripleTable defaultGraph() {
+   return defaultGraph;
+   }
+
+   @Override
+   public Lock getLock() {
+   return writeLock();
+   }
+
+   /**
+* Default constructor.
+*/
+   public DatasetGraphInMemory() {
+   this(new HexTable(), new TriTable());
+   }
+
+   /**
+* @param i a table in which to store quads
+* @param t a table in which to store triples
+*/
+   public DatasetGraphInMemory(final QuadTable i, final TripleTable t) {
+   this.quadsIndex = i;
+   this.defaultGraph = t;
+   }
+
+   @Override
+   public void begin(final ReadWrite readW

[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44412440
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/mem/QuadTable.java ---
@@ -0,0 +1,59 @@
+/*
+ * 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.jena.sparql.core.mem;
+
+import static org.apache.jena.graph.Node.ANY;
+
+import java.util.stream.Stream;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.core.Quad;
+
+/**
+ * A simplex or multiplex table of {@link Quad}s. Implementations may wish 
to override {@link #listGraphNodes()} with a
+ * more efficient implementation.
+ *
+ */
+public interface QuadTable extends TupleTable {
+
+   /**
+* Search the table using a pattern of slots. {@link Node#ANY} or 
null will work as a wildcard.
+*
+* @param g the graph node of the pattern
+* @param s the subject node of the pattern
+* @param p the predicate node of the pattern
+* @param o the object node of the pattern
+* @return an {@link Stream} of matched quads
+*/
+   Stream find(Node g, Node s, Node p, Node o);
+
+   /**
+* Discover the graphs named in the table
+*
+* @return an {@link Stream} of graph names used in this table
+*/
+   default Stream listGraphNodes() {
+   return find(ANY, ANY, ANY, ANY).map(Quad::getGraph).distinct();
+   }
--- End diff --

Cool. I agree that the "forked impl" is a bit odd, but I did it for what I 
think are real gains in concision and clarity _within_ those types. The 
important point is that `QuadTableForm` is an `enum` and it's the six values 
_within_ `QuadTableForm` that actually impl `QuadTable`. Then `HexTable` binds 
up all those forms into a structure that acts as _one_ `QuadTable` by selecting 
the most efficient form(s) for any given operation. I'll add some comments to 
explain that relationship more fully and clearly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44414632
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/mem/DatasetGraphInMemory.java
 ---
@@ -0,0 +1,310 @@
+/*
+ * 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.jena.sparql.core.mem;
+
+import static java.lang.ThreadLocal.withInitial;
+import static org.apache.jena.graph.Node.ANY;
+import static org.apache.jena.query.ReadWrite.READ;
+import static org.apache.jena.query.ReadWrite.WRITE;
+import static org.apache.jena.sparql.core.Quad.isUnionGraph;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.query.ReadWrite;
+import org.apache.jena.shared.Lock;
+import org.apache.jena.shared.LockMRPlusSW;
+import org.apache.jena.sparql.JenaTransactionException;
+import org.apache.jena.sparql.core.DatasetGraph;
+import org.apache.jena.sparql.core.DatasetGraphTriplesQuads;
+import org.apache.jena.sparql.core.DatasetPrefixStorage;
+import org.apache.jena.sparql.core.Quad;
+import org.apache.jena.sparql.core.Transactional;
+
+/**
+ * A {@link DatasetGraph} backed by an {@link QuadTable}. By default, this 
is a {@link HexTable} designed for high-speed
+ * in-memory operation.
+ *
+ */
+public class DatasetGraphInMemory extends DatasetGraphTriplesQuads 
implements Transactional {
+
+   private final DatasetPrefixStorage prefixes = new 
DatasetPrefixStorageInMemory();
+
+   private final Lock writeLock = new LockMRPlusSW();
+
+   private Lock writeLock() {
+   return writeLock;
+   }
+
+   private final ReentrantReadWriteLock commitLock = new 
ReentrantReadWriteLock(true);
+
+   /**
+* Commits must be atomic, and because a thread that is committing 
alters the various indexes one after another, we
+* lock out {@link #begin(ReadWrite)} while {@link #commit()} is 
executing.
+*/
+   private ReentrantReadWriteLock commitLock() {
+   return commitLock;
+   }
+
+   private final ThreadLocal isInTransaction = withInitial(() -> 
false);
+
+   @Override
+   public boolean isInTransaction() {
+   return isInTransaction.get();
+   }
+
+   protected void isInTransaction(final boolean b) {
+   isInTransaction.set(b);
+   }
+
+   private final ThreadLocal transactionType = withInitial(() 
-> null);
+
+   /**
+* @return the type of transaction in progress
+*/
+   public ReadWrite transactionType() {
+   return transactionType.get();
+   }
+
+   protected void transactionType(final ReadWrite readWrite) {
+   transactionType.set(readWrite);
+   }
+
+   private final QuadTable quadsIndex;
+
+   private QuadTable quadsIndex() {
+   return quadsIndex;
+   }
+
+   private final TripleTable defaultGraph;
+
+   private TripleTable defaultGraph() {
+   return defaultGraph;
+   }
+
+   @Override
+   public Lock getLock() {
+   return writeLock();
+   }
+
+   /**
+* Default constructor.
+*/
+   public DatasetGraphInMemory() {
+   this(new HexTable(), new TriTable());
+   }
+
+   /**
+* @param i a table in which to store quads
+* @param t a table in which to store triples
+*/
+   public DatasetGraphInMemory(final QuadTable i, final TripleTable t) {
+   this.quadsIndex = i;
+   this.defaultGraph = t;
+   }
+
+   @Override
+   public void begin(final ReadWrite readW

[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-155535885
  
@afs , I've factored a `findInUnionGraph` through the code to provide 
access to implementation efficiencies. Let me know what you think!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on a diff in the pull request:

https://github.com/apache/jena/pull/94#discussion_r44455660
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphFactory.java ---
@@ -53,45 +54,38 @@ private static void copyOver(DatasetGraph dsgDest, 
DatasetGraph dsgSrc)
  * Create a DatasetGraph starting with a single graph.
  * New graphs must be explicitly added.
  */
-public static DatasetGraph create(Graph graph)
+public static DatasetGraph create(final Graph graph)
 {
-DatasetGraph dsg2 = createMemFixed() ;
+final DatasetGraph dsg2 = createMemFixed() ;
 dsg2.setDefaultGraph(graph) ;
 return dsg2 ;
 }
-
+
 /**
  * Create a DatasetGraph which only ever has a single default graph.
  */
-public static DatasetGraph createOneGraph(Graph graph) { return new 
DatasetGraphOne(graph) ; }
+public static DatasetGraph createOneGraph(final Graph graph) { return 
new DatasetGraphOne(graph) ; }
 
 /** Interface for makign graphs when a dataset needs to add a new 
graph.
  *  Return null for no graph created.
- */ 
+ */
 public interface GraphMaker { public Graph create() ; }
 
 /** A graph maker that doesn't make graphs */
-public static GraphMaker graphMakerNull = new GraphMaker() {
-@Override
-public Graph create()
-{
-return null ;
-} } ;
-
-private static GraphMaker memGraphMaker = new GraphMaker()
-{
-@Override
-public Graph create()
-{
-return GraphFactory.createDefaultGraph() ;
-}
-} ;
-
+public static GraphMaker graphMakerNull = () -> null ;
+
+private static GraphMaker memGraphMaker = () -> 
GraphFactory.createDefaultGraph() ;
+
+/**
+ * @return a DatasetGraph which features transactional in-memory 
operation
+ */
+public static DatasetGraph createTxMem() { return new 
DatasetGraphInMemory(); }
+
--- End diff --

Changed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-155581142
  
Ah, that is exciting! I will begin learning the documentation CMS so as to 
offer a good set of pointers and explanations to help people try this out.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-155581224
  
@afs Shall I squash again in preparation?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-10 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-155582592
  
Right, I'll do what I did before and squash to two more-or-less orthogonal 
commits, one for "Introducing a journaling dataset!" and one for "Introducing a 
MR+SW in-mem dataset!". I'll add more useful and full commit comments for each.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-12 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-156126355
  
@afs Squashed 'em pretty flat. The first commit is journaling operation, 
the second is the new in-memory design.

I will wait to hear from you, otherwise moving on the docs and trying to 
understand the ARQ test framework in `/testing`. I think I'm going to have to 
come to the list on that, because while I think I can correctly read much of 
the RDF that is setting up tests, I can't figure out for the life of me how it 
gets executed or how to hook in a section so that my new designs are used.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JENA-624

2015-11-12 Thread ajs6f
Github user ajs6f commented on the pull request:

https://github.com/apache/jena/pull/94#issuecomment-156133626
  
Ah, cool. Well, I've thrown every abstract `DatasetGraph` test I could find 
in the source at this stuff (and you showed me some about which I didn't know) 
and added a bunch of my own to test out qualities specific to these impls, so I 
think we're doing pretty good there.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


<    1   2   3   4   5   6   7   8   9   10   >