Merge pull request #611 from afs/rdf-options
JENA-1761: General option setting for RDFParser and RDFWriter
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/AssemblerUtils.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/AssemblerUtils.java
index 715e67b..6c46af9 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/AssemblerUtils.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/assembler/AssemblerUtils.java
@@ -158,6 +158,11 @@
return context;
}
+ /** @deprecated Use {@link #mergeContext(Resource, Context)} */
+ public static void setContext(Resource r, Context context) {
+ mergeContext(r, context);
+ }
+
/** Look for and merge in context declarations.
* e.g.
* <pre>
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/expr/aggregate/AggMode.java b/jena-arq/src/main/java/org/apache/jena/sparql/expr/aggregate/AggMode.java
old mode 100755
new mode 100644
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/expr/aggregate/AggModeDistinct.java b/jena-arq/src/main/java/org/apache/jena/sparql/expr/aggregate/AggModeDistinct.java
old mode 100755
new mode 100644
diff --git a/jena-db/jena-dboe-base/src/main/java/org/apache/jena/dboe/base/file/BufferChannelMem.java b/jena-db/jena-dboe-base/src/main/java/org/apache/jena/dboe/base/file/BufferChannelMem.java
index 4924ae1..6306488 100644
--- a/jena-db/jena-dboe-base/src/main/java/org/apache/jena/dboe/base/file/BufferChannelMem.java
+++ b/jena-db/jena-dboe-base/src/main/java/org/apache/jena/dboe/base/file/BufferChannelMem.java
@@ -26,7 +26,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-// XXX Merge/replace with SegmentedByteBuffer which has more predicable performance.
+// XXX Merge/replace with SegmentedMemBuffer which has more predicable performance.
public class BufferChannelMem implements BufferChannel {
private static Logger log = LoggerFactory.getLogger(BufferChannelMem.class);
// The "file pointer" is the position of this buffer.
diff --git a/jena-db/jena-dboe-storage/pom.xml b/jena-db/jena-dboe-storage/pom.xml
index b6361e8..42d04c1 100644
--- a/jena-db/jena-dboe-storage/pom.xml
+++ b/jena-db/jena-dboe-storage/pom.xml
@@ -34,6 +34,10 @@
<description>Triplestore database storage</description>
+ <properties>
+ <automatic.module.name>org.apache.jena.dboe.storage</automatic.module.name>
+ </properties>
+
<dependencies>
<dependency>
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/apache/jena/dboe/transaction/txn/TransactionCoordinator.java b/jena-db/jena-dboe-transaction/src/main/java/org/apache/jena/dboe/transaction/txn/TransactionCoordinator.java
index daa81d4..42d2697 100644
--- a/jena-db/jena-dboe-transaction/src/main/java/org/apache/jena/dboe/transaction/txn/TransactionCoordinator.java
+++ b/jena-db/jena-dboe-transaction/src/main/java/org/apache/jena/dboe/transaction/txn/TransactionCoordinator.java
@@ -48,7 +48,7 @@
* <p>
* This is a general engine although tested and most used for multiple-reader
* and single-writer (MR+SW). {@link TransactionalComponentLifecycle} provides the
- * per-threadstyle.
+ * per-thread style.
* <p>
* Contrast to MRSW: multiple-reader or single-writer.
* <h3>Block writers</h3>
diff --git a/jena-db/jena-dboe-transaction/src/main/java/org/apache/jena/dboe/transaction/txn/TransactionalComponent.java b/jena-db/jena-dboe-transaction/src/main/java/org/apache/jena/dboe/transaction/txn/TransactionalComponent.java
index e468d7a..4eb8954 100644
--- a/jena-db/jena-dboe-transaction/src/main/java/org/apache/jena/dboe/transaction/txn/TransactionalComponent.java
+++ b/jena-db/jena-dboe-transaction/src/main/java/org/apache/jena/dboe/transaction/txn/TransactionalComponent.java
@@ -126,20 +126,24 @@
*/
public ByteBuffer commitPrepare(Transaction transaction);
- /** Commit a transaction (make durable).
- * Other components not have been commited yet and recovery may occur still.
- * Permanent state should not be finalised until {@link #commitEnd}.
+ /**
+ * Commit a transaction (make durable). The transaction will commit and not abort.
+ * Other components may not have committed yet and recovery may occur
+ * still causing replay of the commit step.
*/
public void commit(Transaction transaction);
- /** Signal all commits on all components are done (the component can clearup now) */
+ /**
+ * Signal all commits on all components are done and replay from the journal will not happen.
+ * The component can clear up now.
+ */
public void commitEnd(Transaction transaction);
/** Abort a transaction (undo the effect of a transaction) */
public void abort(Transaction transaction);
- /** Finalization - the coordinator will not mention the transaction again
- * although recovery after a crash may do so.
+ /**
+ * Finalization - the coordinator will not mention the transaction again.
*/
public void complete(Transaction transaction);
@@ -172,5 +176,4 @@
* This operation is not guaranteed to be called.
*/
public void shutdown();
-
}
diff --git a/jena-elephas/jena-elephas-common/pom.xml b/jena-elephas/jena-elephas-common/pom.xml
index 31cab96..ff44f2e 100644
--- a/jena-elephas/jena-elephas-common/pom.xml
+++ b/jena-elephas/jena-elephas-common/pom.xml
@@ -26,6 +26,10 @@
<name>Apache Jena - Elephas - Common API</name>
<description>Common code for RDF on Hadoop such as writable types for RDF primitives</description>
+ <properties>
+ <automatic.module.name>org.apache.jena.elephas.common</automatic.module.name>
+ </properties>
+
<!-- Note that versions are managed by parent POMs -->
<dependencies>
<!-- Hadoop Dependencies -->
@@ -73,4 +77,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/jena-elephas/jena-elephas-io/pom.xml b/jena-elephas/jena-elephas-io/pom.xml
index 48cf93f..374ba98 100644
--- a/jena-elephas/jena-elephas-io/pom.xml
+++ b/jena-elephas/jena-elephas-io/pom.xml
@@ -27,6 +27,10 @@
<name>Apache Jena - Elephas - I/O</name>
<description>RDF Input/Output formats library for Hadoop</description>
+ <properties>
+ <automatic.module.name>org.apache.jena.elephas.io</automatic.module.name>
+ </properties>
+
<!-- Note that versions are managed by parent POMs -->
<dependencies>
<!-- Internal Project Dependencies -->
diff --git a/jena-elephas/jena-elephas-mapreduce/pom.xml b/jena-elephas/jena-elephas-mapreduce/pom.xml
index e1353a9..5305f02 100644
--- a/jena-elephas/jena-elephas-mapreduce/pom.xml
+++ b/jena-elephas/jena-elephas-mapreduce/pom.xml
@@ -26,6 +26,10 @@
<name>Apache Jena - Elephas - Map/Reduce</name>
<description>Contains some basic Map/Reduce implementations for working with RDF on Hadoop</description>
+ <properties>
+ <automatic.module.name>org.apache.jena.elephas.mapreduce</automatic.module.name>
+ </properties>
+
<dependencies>
<!-- Internal Project Dependencies -->
<dependency>
@@ -103,4 +107,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/jena-elephas/jena-elephas-stats/pom.xml b/jena-elephas/jena-elephas-stats/pom.xml
index d34cd9c..b48eb11 100644
--- a/jena-elephas/jena-elephas-stats/pom.xml
+++ b/jena-elephas/jena-elephas-stats/pom.xml
@@ -26,6 +26,10 @@
<name>Apache Jena - Elephas - Statistics Demo App</name>
<description>A demo application that can be run on Hadoop to produce a statistical analysis on arbitrary RDF inputs</description>
+ <properties>
+ <automatic.module.name>org.apache.jena.elephas.stats</automatic.module.name>
+ </properties>
+
<dependencies>
<!-- Internal Project Dependencies -->
<dependency>
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
index f1af448..7dd269c 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiConfig.java
@@ -80,14 +80,14 @@
private static void initStandardSetup() {
stdRead = new HashMap<>();
- stdRead.put("query", Operation.Query);
stdRead.put("sparql", Operation.Query);
+ stdRead.put("query", Operation.Query);
stdRead.put("data", Operation.GSP_R);
stdRead.put("get", Operation.GSP_R);
stdWrite = new HashMap<>();
- stdWrite.put("query", Operation.Query);
stdWrite.put("sparql", Operation.Query);
+ stdWrite.put("query", Operation.Query);
stdWrite.put("update", Operation.Update);
stdWrite.put("upload", Operation.Upload);
stdWrite.put("data", Operation.GSP_RW);
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/ActionStats.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/ActionStats.java
index f3f8151..60beb5c 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/ActionStats.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/ActionStats.java
@@ -118,7 +118,7 @@
builder.startObject();
operationCounters(builder, endpoint);
- builder.key(ServerConst.operation).value(operName.getName());
+ builder.key(ServerConst.operation).value(operName.getJsonName());
builder.key(ServerConst.description).value(operName.getDescription());
builder.finishObject();
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/JsonDescription.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/JsonDescription.java
index b76cb76..e3b7e12 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/JsonDescription.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/JsonDescription.java
@@ -59,7 +59,7 @@
private static void describe(JsonBuilder builder, Operation operation, List<Endpoint> endpoints) {
builder.startObject();
- builder.key(ServerConst.srvType).value(operation.getName());
+ builder.key(ServerConst.srvType).value(operation.getJsonName());
builder.key(ServerConst.srvDescription).value(operation.getDescription());
builder.key(ServerConst.srvEndpoints);
builder.startArray();
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Operation.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Operation.java
index 45c7dfc..76f0b8e 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Operation.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Operation.java
@@ -19,6 +19,7 @@
package org.apache.jena.fuseki.server;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import java.util.Objects;
@@ -38,19 +39,19 @@
public class Operation {
private static String NS = FusekiVocab.NS;
-
+
/** Create/intern. Maps short name to operation. */
static private Map<Node, Operation> mgr = new HashMap<>();
static public Operation get(Node node) { return mgr.get(node); }
-
+
/** @deprecated Use {@link #alloc(Node, String, String)}. */
@Deprecated
static public Operation register(String shortName, String description) {
String x = IRILib.encodeUriPath(shortName);
return alloc("http://migration/"+x, shortName, description);
}
-
+
/**
* Create an Operation - this operation interns operations so there is only
* one object for each operation. It is an extensible enum.
@@ -64,7 +65,7 @@
Node node = NodeFactory.createURI(iriStr);
return alloc(node, shortName, description);
}
-
+
/**
* Create an Operation - this operation interns operations so there is only
* object for each operation. It is an extensible enum.
@@ -72,10 +73,13 @@
static public Operation alloc(Node op, String shortName, String description) {
return mgr.computeIfAbsent(op, (x)->create(x, shortName, description));
}
-
+
/** Create; not registered */
static private Operation create(Node id, String shortName, String description) {
- return new Operation(id, shortName, description);
+ // Currently, (3.13.0) the JS name is the short display name in lower
+ // case. Just in case it diverges in the future, leave provision for
+ // a different setting.
+ return new Operation(id, shortName, shortName.toLowerCase(Locale.ROOT), description);
}
public static final Operation Query = alloc(FusekiVocab.opQuery.asNode(), "query", "SPARQL Query");
@@ -95,22 +99,39 @@
// -- Object
private final Node id;
private final String name;
+ // Name used in JSON in the "server" description and "stats" details.
+ // This name is know to the JS code (e.g. dataset.js).
+ private final String jsName;
+
private final String description;
-
- private Operation(Node fullName, String name, String description) {
+
+ private Operation(Node fullName, String name, String jsName, String description) {
this.id = fullName;
this.name = name;
+ // Currently, this
+ this.jsName = jsName;
this.description = description;
}
public Node getId() {
return id;
}
-
+
+ /** Return the display name for this operation. */
public String getName() {
return name;
}
+ /**
+ * Name used in JSON in the "server" description and "stats" details.
+ * Highlighted by JENA-1766.
+ * This name is know to the JS code.
+ */
+ public String getJsonName() {
+ return jsName;
+ }
+
+ /** Return the description for this operation. */
public String getDescription() {
return description;
}
@@ -122,7 +143,7 @@
// Could be this == obj
// because we intern'ed the object
-
+
@Override
public boolean equals(Object obj) {
if ( this == obj )
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionProcessor.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionProcessor.java
index d650fdd..81c502d 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionProcessor.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionProcessor.java
@@ -41,6 +41,8 @@
}
}
+ // Override to support the operation.
+ // A common override is "executeLifecycle(action);"
public default void execHead(HttpAction action) { execAny(METHOD_HEAD, action); }
public default void execGet(HttpAction action) { execAny(METHOD_GET, action); }
public default void execPost(HttpAction action) { execAny(METHOD_POST, action); }
diff --git a/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/js/app/models/dataset.js b/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/js/app/models/dataset.js
index 4fc192f..55a677d 100644
--- a/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/js/app/models/dataset.js
+++ b/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/js/app/models/dataset.js
@@ -102,8 +102,14 @@
/** Return the first endpoint of the first service that has the given type */
endpointOfType: function( serviceType ) {
- var service = this.serviceOfType( serviceType );
- return service && _.first( service["srv.endpoints"] );
+ var service = this.serviceOfType( serviceType );
+ if ( ! service )
+ return null;
+ var x = service["srv.endpoints"];
+ x = x.filter(function(v){return v!==''});
+ var ep = _.first(x);
+ return ep;
+ /* return service && _.first( service["srv.endpoints"] );*/
},
/* Return URL for a service of a given type or null, if no such service */
@@ -119,30 +125,22 @@
/** Return the sparql query URL for this dataset, if it has one, or null */
queryURL: function() {
- return this.endpointURL( "Query" ) ;
- },
-
- /** Return the sparql query URL for this dataset, if it has one, or null */
- quadsURL: function() {
- return this.endpointURL( "Quads" ) ;
+ return this.endpointURL( "query" ) ;
},
/** Return the sparql update URL for this dataset, if it has one, or null */
updateURL: function() {
- return this.endpointURL( "Update" ) ;
+ return this.endpointURL( "update" ) ;
},
/** Return the GSP write URL for this dataset, if it has one, or null */
graphStoreProtocolURL: function() {
- if ( this.endpointURL( "GSP" ) )
- // Old name
- return this.endpointURL( "GSP" ) ;
- return this.endpointURL( "GSP_RW" ) ;
+ return this.endpointURL( "gsp-rw" ) ;
},
/** Return the GSP read URL for this dataset, if it has one, or null */
graphStoreProtocolReadURL: function() {
- return this.endpointURL( "GSP_R" ) ;
+ return this.endpointURL( "gsp-r" ) ;
},
/** Return the upload URL for this dataset, if it has one, or null */
diff --git a/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/js/app/templates/dataset-info.tpl b/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/js/app/templates/dataset-info.tpl
index c2c6891..2362f2b 100644
--- a/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/js/app/templates/dataset-info.tpl
+++ b/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/js/app/templates/dataset-info.tpl
@@ -33,8 +33,9 @@
</dl>
<% } %>
-
+<!--
<h2>Ongoing operations</h2>
<p><em>TBD. Will list any long-lasting operations that are ongoing or recently completed,
e.g. backups.</em></p>
+-->
diff --git a/jena-jdbc/jena-jdbc-core/pom.xml b/jena-jdbc/jena-jdbc-core/pom.xml
index 19e4be1..b64fc50 100644
--- a/jena-jdbc/jena-jdbc-core/pom.xml
+++ b/jena-jdbc/jena-jdbc-core/pom.xml
@@ -30,6 +30,7 @@
<properties>
<plugin.license.headerPath>${project.parent.basedir}</plugin.license.headerPath>
+ <automatic.module.name>org.apache.jena.jdbc.core</automatic.module.name>
</properties>
<dependencies>
@@ -111,4 +112,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/jena-jdbc/jena-jdbc-driver-bundle/pom.xml b/jena-jdbc/jena-jdbc-driver-bundle/pom.xml
index 09f15c7..29ace6a 100644
--- a/jena-jdbc/jena-jdbc-driver-bundle/pom.xml
+++ b/jena-jdbc/jena-jdbc-driver-bundle/pom.xml
@@ -30,6 +30,7 @@
<properties>
<plugin.license.headerPath>${project.parent.basedir}</plugin.license.headerPath>
+ <automatic.module.name>org.apache.jena.jdbc.driver.bundle</automatic.module.name>
<!-- Note that we actually skip tests in this module because this module
simply bundles up the other modules BUT it contains a JUnit suite primarily
as a convenience for being able to perform code coverage analysis easily
diff --git a/jena-jdbc/jena-jdbc-driver-mem/pom.xml b/jena-jdbc/jena-jdbc-driver-mem/pom.xml
index 84b28b6..ce2de6a 100644
--- a/jena-jdbc/jena-jdbc-driver-mem/pom.xml
+++ b/jena-jdbc/jena-jdbc-driver-mem/pom.xml
@@ -30,6 +30,7 @@
<properties>
<plugin.license.headerPath>${project.parent.basedir}</plugin.license.headerPath>
+ <automatic.module.name>org.apache.jena.jdbc.driver.mem</automatic.module.name>
</properties>
<dependencies>
@@ -91,4 +92,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/jena-jdbc/jena-jdbc-driver-remote/pom.xml b/jena-jdbc/jena-jdbc-driver-remote/pom.xml
index e18fa58..4bb1b39 100644
--- a/jena-jdbc/jena-jdbc-driver-remote/pom.xml
+++ b/jena-jdbc/jena-jdbc-driver-remote/pom.xml
@@ -30,6 +30,7 @@
<properties>
<plugin.license.headerPath>${project.parent.basedir}</plugin.license.headerPath>
+ <automatic.module.name>org.apache.jena.jdbc.driver.remote</automatic.module.name>
</properties>
<dependencies>
diff --git a/jena-jdbc/jena-jdbc-driver-tdb/pom.xml b/jena-jdbc/jena-jdbc-driver-tdb/pom.xml
index 42a3f36..76bc7f9 100644
--- a/jena-jdbc/jena-jdbc-driver-tdb/pom.xml
+++ b/jena-jdbc/jena-jdbc-driver-tdb/pom.xml
@@ -30,6 +30,7 @@
<properties>
<plugin.license.headerPath>${project.parent.basedir}</plugin.license.headerPath>
+ <automatic.module.name>org.apache.jena.jdbc.driver.tdb</automatic.module.name>
</properties>
<dependencies>
@@ -116,4 +117,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
diff --git a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/DebugTdbConnection.java b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/DebugTdbConnection.java
index 493f3be..62373a6 100644
--- a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/DebugTdbConnection.java
+++ b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/DebugTdbConnection.java
@@ -37,7 +37,7 @@
* @throws SQLException
*/
public DebugTdbConnection() throws SQLException {
- this(DatasetFactory.createMem());
+ this(DatasetFactory.create());
}
/**
diff --git a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestTdbDiskConnection.java b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestTdbDiskConnection.java
index c41f304..124c58d 100644
--- a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestTdbDiskConnection.java
+++ b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestTdbDiskConnection.java
@@ -25,12 +25,11 @@
import org.apache.jena.jdbc.connections.AbstractJenaConnectionTests;
import org.apache.jena.jdbc.connections.DatasetConnection;
import org.apache.jena.jdbc.connections.JenaConnection;
-import org.apache.jena.jdbc.tdb.connections.TDBConnection;
import org.apache.jena.jdbc.utils.TestUtils;
import org.apache.jena.query.Dataset ;
-import org.apache.jena.tdb.StoreConnection ;
import org.apache.jena.tdb.TDBFactory ;
import org.apache.jena.tdb.base.file.Location ;
+import org.apache.jena.tdb.sys.TDBInternal;
import org.junit.After;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
@@ -54,7 +53,7 @@
*/
@After
public void cleanupTest() {
- StoreConnection.expel(Location.create(tempDir.getRoot().getAbsolutePath()), true);
+ TDBInternal.expel(Location.create(tempDir.getRoot().getAbsolutePath()), true);
}
@Override
diff --git a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestTdbMemConnection.java b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestTdbMemConnection.java
index 4302011..b3ab7f5 100644
--- a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestTdbMemConnection.java
+++ b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestTdbMemConnection.java
@@ -28,9 +28,9 @@
import org.apache.jena.jdbc.tdb.connections.TDBConnection;
import org.apache.jena.jdbc.utils.TestUtils;
import org.apache.jena.query.Dataset ;
-import org.apache.jena.tdb.StoreConnection ;
import org.apache.jena.tdb.TDBFactory ;
import org.apache.jena.tdb.base.file.Location ;
+import org.apache.jena.tdb.sys.TDBInternal;
import org.junit.After;
/**
@@ -45,7 +45,7 @@
*/
@After
public void cleanupTest() {
- StoreConnection.expel(Location.mem(), true);
+ TDBInternal.expel(Location.mem(), true);
}
@Override
diff --git a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/metadata/TestTdbConnectionMetadata.java b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/metadata/TestTdbConnectionMetadata.java
index 0e2712b..1a65d61 100644
--- a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/metadata/TestTdbConnectionMetadata.java
+++ b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/metadata/TestTdbConnectionMetadata.java
@@ -28,9 +28,9 @@
import org.apache.jena.jdbc.connections.JenaConnection;
import org.apache.jena.jdbc.metadata.results.AbstractDatabaseMetadataTests;
import org.apache.jena.jdbc.tdb.connections.TDBConnection;
-import org.apache.jena.tdb.StoreConnection ;
import org.apache.jena.tdb.TDBFactory ;
import org.apache.jena.tdb.base.file.Location ;
+import org.apache.jena.tdb.sys.TDBInternal;
import org.junit.After;
/**
@@ -43,7 +43,7 @@
*/
@After
public void cleanupTest() {
- StoreConnection.expel(Location.mem(), true);
+ TDBInternal.expel(Location.mem(), true);
}
@Override
diff --git a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/TestTdbDiskResultSets.java b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/TestTdbDiskResultSets.java
index f38533a..0daae35 100644
--- a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/TestTdbDiskResultSets.java
+++ b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/TestTdbDiskResultSets.java
@@ -54,6 +54,7 @@
Dataset ds = createDataset(tempDir.getRoot().getAbsolutePath());
try (DebugTdbConnection connection = new DebugTdbConnection(ds)) {
Statement stmt = connection.createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY);
+ @SuppressWarnings("resource")
ResultSet rset = stmt.executeQuery("ASK { }");
assertNotNull(rset);
assertFalse(rset.isClosed());
@@ -85,6 +86,7 @@
Dataset ds = createDataset(tempDir.getRoot().getAbsolutePath());
try (DebugTdbConnection connection = new DebugTdbConnection(ds)) {
Statement stmt = connection.createStatement(TYPE_FORWARD_ONLY, CONCUR_READ_ONLY);
+ @SuppressWarnings("resource")
ResultSet rset = stmt.executeQuery("ASK { FILTER(false) }");
assertNotNull(rset);
assertFalse(rset.isClosed());
diff --git a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/TestTdbMemResultSets.java b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/TestTdbMemResultSets.java
index adfb003..2097dfa 100644
--- a/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/TestTdbMemResultSets.java
+++ b/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/TestTdbMemResultSets.java
@@ -20,9 +20,9 @@
import org.apache.jena.jdbc.utils.TestUtils;
import org.apache.jena.query.Dataset ;
-import org.apache.jena.tdb.StoreConnection ;
import org.apache.jena.tdb.TDBFactory ;
import org.apache.jena.tdb.base.file.Location ;
+import org.apache.jena.tdb.sys.TDBInternal;
import org.junit.After;
/**
@@ -41,7 +41,7 @@
if (currDataset != null) {
currDataset.close();
}
- StoreConnection.expel(Location.mem(), true);
+ TDBInternal.expel(Location.mem(), true);
}
@Override
diff --git a/jena-shacl/pom.xml b/jena-shacl/pom.xml
index d4d6c83..401209a 100644
--- a/jena-shacl/pom.xml
+++ b/jena-shacl/pom.xml
@@ -35,7 +35,7 @@
<properties>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ssZ</maven.build.timestamp.format>
<build.time.xsd>${maven.build.timestamp}</build.time.xsd>
- <automatic.module.name>org.apache.jena.tdb</automatic.module.name>
+ <automatic.module.name>org.apache.jena.shacl</automatic.module.name>
</properties>
<dependencies>
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java b/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
index 34e418e..9a82295 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/StoreConnection.java
@@ -34,6 +34,7 @@
import org.apache.jena.tdb.store.DatasetGraphTDB ;
import org.apache.jena.tdb.sys.ProcessUtils;
import org.apache.jena.tdb.sys.SystemTDB ;
+import org.apache.jena.tdb.sys.TDBInternal;
import org.apache.jena.tdb.sys.TDBMaker;
import org.apache.jena.tdb.transaction.* ;
@@ -179,7 +180,10 @@
return make(Location.create(location));
}
- /** Stop managing all locations. Use with great care. */
+ /**
+ * Stop managing all locations. Use with great care.
+ * Use via {@link TDBInternal#expel} wherever possible.
+ */
public static synchronized void reset() {
// Copy to avoid potential CME.
Set<Location> x = new HashSet<>(cache.keySet()) ;
@@ -190,16 +194,24 @@
TDBMaker.resetCache();
}
- /** Stop managing a location. There should be no transactions running. */
+ /**
+ * Stop managing a location. There should be no transactions running.
+ * Use via {@link TDBInternal#expel} wherever possible.
+ */
public static synchronized void release(Location location) {
expel(location, false);
}
- /** Stop managing a location. Use with great care (testing only). */
+ /**
+ * Stop managing a location. Use with great care (testing only).
+ * Use via {@link TDBInternal#expel} wherever possible.
+ */
public static synchronized void expel(Location location, boolean force) {
+ // Evict from TBDMaker cache otherwise that wil retain a reference to this StoreConnection.
StoreConnection sConn = cache.get(location) ;
if (sConn == null)
return ;
+ TDBInternal.releaseDSG(location);
if (!force && sConn.transactionManager.activeTransactions())
throw new TDBTransactionException("Can't expel: Active transactions for location: " + location) ;
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/TDBFactory.java b/jena-tdb/src/main/java/org/apache/jena/tdb/TDBFactory.java
index 4c91032..2d25629 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/TDBFactory.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/TDBFactory.java
@@ -77,14 +77,18 @@
/** Release from the JVM. All caching is lost. */
public static void release(Dataset dataset) {
- _release(location(dataset)) ;
+ release(dataset.asDatasetGraph());
}
/** Release from the JVM. All caching is lost. */
public static void release(DatasetGraph dataset) {
- _release(location(dataset)) ;
+ _release(dataset) ;
}
+ private static void _release(DatasetGraph dataset) {
+ TDBInternal.expel(dataset);
+ }
+
private static DatasetGraph _createDatasetGraph(Location location) {
return TDBMaker.createDatasetGraphTransaction(location) ;
}
@@ -93,12 +97,6 @@
return TDBMaker.createDatasetGraphTransaction() ;
}
- private static void _release(Location location) {
- if ( location == null )
- return ;
- TDBMaker.releaseLocation(location) ;
- }
-
/** Test whether a dataset is backed by TDB.
* @deprecated Use {@link #isTDB1(Dataset)}
*/
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBInternal.java b/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBInternal.java
index 00316d7..c710168 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBInternal.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBInternal.java
@@ -36,8 +36,10 @@
import org.apache.jena.tdb.transaction.DatasetGraphTransaction ;
import org.apache.jena.tdb.transaction.TransactionManager ;
-/** A collection of helpers to abstract away from internal details of TDB.
+/**
+ * A collection of helpers to abstract away from internal details of TDB.
* Use with care.
+ * These are not general purpose operations.
*/
public class TDBInternal
{
@@ -148,18 +150,50 @@
return ((DatasetGraphTransaction)dsg).getStoreConnection() ;
throw new TDBException("Not a suitable TDB-backed DatasetGraph: " + Lib.classShortName(dsg.getClass())) ;
}
-
- /** Stop managing a DatasetGraph. Use with great care. */
+
+ /**
+ * Stop managing a TDB1 {@link DatasetGraph}.
+ * This function does nothing if it is not a TDB1 database.
+ * Use with great care.
+ * Don't call while transactions are active.
+ */
public static synchronized void expel(DatasetGraph dsg) {
DatasetGraphTDB dsgtdb = Txn.calculate(dsg, ()->getDatasetGraphTDB(dsg));
if ( dsgtdb == null )
return;
- Location loc = dsgtdb.getLocation();
- TDBMaker.releaseLocation(loc);
- StoreConnection.expel(dsgtdb.getLocation(), false);
+ expel(dsgtdb.getLocation());
+ }
+
+ /**
+ * Stop managing a TDB1 database at {@link Location}.
+ * Use with great care.
+ * Assumes no transactions are active.
+ */
+ public static synchronized void expel(Location location) {
+ expel(location, false);
+ }
+
+ /**
+ * Stop managing a TDB1 database at {@link Location}.
+ * Use with very great care.
+ * Using "force" will orphan any active transactions.
+ */
+ public static synchronized void expel(Location location, boolean force) {
+ releaseDSG(location);
+ StoreConnection.expel(location, force);
// No longer valid.
}
-
+
+ /**
+ * Stop managing the {@link DatasetGraphTransaction} for the location.
+ * This operation does not release the {@link StoreConnection}.
+ * Use with great care.
+ * Don't call while transactions are active.
+ */
+ public static synchronized void releaseDSG(Location location) {
+ TDBMaker.uncache(location);
+ }
+
/** Look at a directory and see if it is a new area */
public static boolean isNewDatabaseArea(Location location) {
StoreConnection sConn = StoreConnection.getExisting(location) ;
@@ -188,7 +222,7 @@
return true ;
} ;
- public static void reset() {
+ public synchronized static void reset() {
StoreConnection.reset();
TDBMaker.resetCache();
}
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBMaker.java b/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBMaker.java
index 935837a..826bca5 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBMaker.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/sys/TDBMaker.java
@@ -67,16 +67,27 @@
private static final Map<Location, DatasetGraphTransaction> cache = CACHING ? new ConcurrentHashMap<>() : null ;
/**
- * Release a {@code Location}.
+ * Release a {@code Location} and also release its {@link StoreConnection}.
* Do not use a {@code Dataset} at this location without
* remaking it via {@link TDBFactory}.
+ * This operation is primarily for tests.
*/
- public static void releaseLocation(Location location) {
- if ( CACHING && ! location.isMemUnique() )
- cache.remove(location);
+ static void releaseLocation(Location location) {
+ uncache(location);
StoreConnection.release(location) ;
}
+ /**
+ * Release a {@code Location}.
+ * This operation does not release the {@link StoreConnection}.
+ * Use {@link #releaseLocation(Location)} where possible.
+ * This operation is for internal use.
+ */
+ static void uncache(Location location) {
+ if ( CACHING && ! location.isMemUnique() )
+ cache.remove(location);
+ }
+
/**
* Reset the making and caching of datasets.
* Applications should not use this operation.
diff --git a/jena-tdb/src/test/java/org/apache/jena/tdb/TestTDBFactory.java b/jena-tdb/src/test/java/org/apache/jena/tdb/TestTDBFactory.java
index aff6fe5..37fefda 100644
--- a/jena-tdb/src/test/java/org/apache/jena/tdb/TestTDBFactory.java
+++ b/jena-tdb/src/test/java/org/apache/jena/tdb/TestTDBFactory.java
@@ -113,7 +113,7 @@
TDBFactory.createDataset(DIR) ;
b = TDBFactory.inUseLocation(DIR) ;
assertTrue("Expected true after creation attempted", b) ;
- StoreConnection.expel(Location.create(DIR), true);
+ TDBInternal.expel(Location.create(DIR), true);
}
@Test public void testTDBFresh03() {
@@ -122,7 +122,7 @@
TDBFactory.createDataset(DIR) ;
b = TDBFactory.inUseLocation(DIR) ;
assertTrue("Expected true after creation attempted", b) ;
- StoreConnection.expel(Location.create(DIR), true);
+ TDBInternal.expel(Location.create(DIR), true);
b = TDBFactory.inUseLocation(DIR) ;
assertTrue("Expected true even after StoreConenction reset", b) ;
}
diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java
index 92059d1..e2bbb25 100644
--- a/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/TextIndexLucene.java
@@ -740,8 +740,8 @@
// or
// ?s text:query ( "some query string" ... )
// so we just need the qs and process additional args below
- // we add the text:defaultField
- textFields.add(docDef.getPrimaryField());
+ // the qs may be a mutli-field query or just a simple query
+ qString = qs + " ";
log.trace("query$ processed EMPTY LIST of properties: {}; Lucene queryString: {}; textFields: {}", props, qString, textFields) ;
} else {
// otherwise there are one or more properties to search over
@@ -759,6 +759,14 @@
for (String textField : textFields) {
qString += composeQField(qs, textField, lang, usingSearchFor, searchForTags);
}
+
+ // we need to check whether there was a lang arg either on the query string
+ // or explicitly as an input arg and add it to the qString; otherwise, Lucene
+ // won't be able to properly process the query
+ if (textFields.isEmpty() && lang != null) {
+ qString += composeQField(qs, docDef.getPrimaryField(), lang, usingSearchFor, searchForTags);
+ }
+
log.trace("query$ PROCESSED LIST of properties: {} with resulting qString: {} ", props, qString) ;
// add a clause for the lang if not usingSearchFor and there is a defined langFIeld in the config
@@ -785,6 +793,15 @@
ScoreDoc[] sDocs = indexSearcher.search(query, limit).scoreDocs ;
+ // if there were no explicit textFields supplied then Lucene used
+ // the default field if defined otherwise Lucene simply interpreted the qs
+ // as presented - perhaps with multiple fields indexed on a separate system.
+ // In order to handle the results we need to supply the default field to
+ // complete the processing in TextQueryPF
+ if (textFields.isEmpty()) {
+ textFields.add(docDef.getPrimaryField());
+ }
+
if (highlight != null) {
return highlightResults(sDocs, indexSearcher, query, textFields, highlight, usingSearchFor, lang);
} else {
diff --git a/jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java b/jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java
index 8d514c4..c416439 100644
--- a/jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java
+++ b/jena-text/src/main/java/org/apache/jena/query/text/TextQueryPF.java
@@ -236,6 +236,12 @@
return qIter ;
}
+ private static void addIf(BindingMap bmap, Var var, Node node) {
+ if (var != null && node != null) {
+ bmap.add(var, node);
+ }
+ }
+
private QueryIterator resultsToQueryIterator(Binding binding, Node subj, Node score, Node literal, Node graph, Node prop, Collection<TextHit> results, ExecutionContext execCxt) {
log.trace("resultsToQueryIterator CALLED with results: {}", results) ;
Var sVar = Var.isVar(subj) ? Var.alloc(subj) : null ;
@@ -248,16 +254,11 @@
if (score == null && literal == null)
return sVar != null ? BindingFactory.binding(binding, sVar, hit.getNode()) : BindingFactory.binding(binding);
BindingMap bmap = BindingFactory.create(binding);
- if (sVar != null)
- bmap.add(sVar, hit.getNode());
- if (scoreVar != null)
- bmap.add(scoreVar, NodeFactoryExtra.floatToNode(hit.getScore()));
- if (literalVar != null)
- bmap.add(literalVar, hit.getLiteral());
- if (graphVar != null && hit.getGraph() != null)
- bmap.add(graphVar, hit.getGraph());
- if (propVar != null && hit.getProp() != null)
- bmap.add(propVar, hit.getProp());
+ addIf(bmap, sVar, hit.getNode());
+ addIf(bmap, scoreVar, NodeFactoryExtra.floatToNode(hit.getScore()));
+ addIf(bmap, literalVar, hit.getLiteral());
+ addIf(bmap, graphVar, hit.getGraph());
+ addIf(bmap, propVar, hit.getProp());
log.trace("resultsToQueryIterator RETURNING bmap: {}", bmap) ;
return bmap;
} ;