You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/09/15 13:37:09 UTC
[4/6] jena git commit: Clean up.
Clean up.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/52d17aba
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/52d17aba
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/52d17aba
Branch: refs/heads/master
Commit: 52d17aba8a8980ede2056f6b959294b8975fe142
Parents: 763b320
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Sep 15 13:34:33 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Sep 15 13:34:33 2016 +0100
----------------------------------------------------------------------
.../java/org/apache/jena/sparql/SystemARQ.java | 99 ++++++++------------
1 file changed, 38 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/52d17aba/jena-arq/src/main/java/org/apache/jena/sparql/SystemARQ.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/SystemARQ.java b/jena-arq/src/main/java/org/apache/jena/sparql/SystemARQ.java
index 80c0591..108c727 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/SystemARQ.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/SystemARQ.java
@@ -22,10 +22,8 @@ import java.util.ArrayList ;
import java.util.Iterator ;
import java.util.List ;
-import org.apache.jena.atlas.iterator.Iter ;
import org.apache.jena.atlas.lib.Sync ;
import org.apache.jena.graph.Graph ;
-import org.apache.jena.graph.Node ;
import org.apache.jena.graph.compose.Polyadic ;
import org.apache.jena.query.ARQ ;
import org.apache.jena.query.Dataset ;
@@ -74,21 +72,21 @@ public class SystemARQ
*/
public static boolean UseSAX = false ;
- /** Sync a Model if it provides the underlying graph provides sync . Do nothing otherwise. */
- public static void sync(Model model)
- {
+ /**
+ * Sync a Model if it provides the underlying graph provides sync . Do nothing
+ * otherwise.
+ */
+ public static void sync(Model model) {
sync(model.getGraph()) ;
}
-
+
/** Sync if provided. Do nothing if not. */
- public static void sync(Graph graph)
- {
+ public static void sync(Graph graph) {
syncGraph(graph) ;
}
-
- private static void syncGraph(Graph graph)
- {
- // "Temporary" hack. Graph ought to implement sync and casade it down.
+
+ private static void syncGraph(Graph graph) {
+ // "Temporary" hack. Graph ought to implement sync and casade it down.
if ( graph instanceof InfGraph )
syncGraph(((InfGraph)graph).getRawGraph()) ;
else if ( graph instanceof Polyadic ) // MultiUnion
@@ -104,77 +102,56 @@ public class SystemARQ
}
/** Sync a Dataset, if underlying storage provides sync. */
- public static void sync(Dataset dataset)
- {
+ public static void sync(Dataset dataset) {
sync(dataset.asDatasetGraph()) ;
}
-
- /** Sync carefully for compound objects*/
- public static void sync(DatasetGraph dataset)
- {
- // Let implementation declare Sync and decide what to do
- // For light-weight, not truely ACID transaction, implementations.
-// if ( dataset instanceof Transactional )
-// return ;
-
- if ( dataset instanceof Sync )
- {
+
+ /** Sync carefully for compound objects */
+ public static void sync(DatasetGraph dataset) {
+ if ( dataset instanceof Sync ) {
((Sync)dataset).sync() ;
return ;
- }
- else
- {
+ } else {
Graph gDft = dataset.getDefaultGraph() ;
- if ( ! ( gDft instanceof GraphView ) ) {
- // GraphView sync the DatasetGraph leading to possible recursion.
- sync(gDft) ;
- // Go through each graph.
- Iterator<Node> iter = Iter.iterator(dataset.listGraphNodes()) ;
- for ( ; iter.hasNext() ; ) {
- Node n = iter.next();
- Graph g = dataset.getGraph(n) ;
- sync(g) ;
- }
- }
+ // GraphView sync the DatasetGraph leading to possible recursion.
+ syncIfNotView(gDft) ;
+ // Go through each graph.
+ dataset.listGraphNodes().forEachRemaining( gn->syncIfNotView(dataset.getGraph(gn) )) ;
}
}
- /** Sync an object if synchronizable (model, graph, dataset).
- * If force is true, synchronize as much as possible (e.g. file metadata)
- * else make a reasonable attenpt at synchronization but does not gauarantee disk state.
- * Do nothing otherwise.
- */
- public static void syncObject(Object object)
- {
+ private static void syncIfNotView(Graph g) {
+ // GraphView sync calls the DatasetGraph leading to possible recursion.
+ if ( !( g instanceof GraphView) )
+ syncIfNotView(g) ;
+ }
+
+ /** Sync an object if synchronizable (model, graph, dataset). */
+ public static void syncObject(Object object) {
if ( object instanceof Sync )
((Sync)object).sync() ;
}
-
private static List<SystemInfo> versions = new ArrayList<>() ;
public static void registerSubSystem(SystemInfo systemInfo)
{
- ARQMgt.register(systemInfo.getJmxPath()+".system:type=SystemInfo", systemInfo) ;
+ ARQMgt.register(systemInfo.getJmxPath() + ".system:type=SystemInfo", systemInfo) ;
versions.add(systemInfo) ;
}
-
- public static Iterator<SystemInfo> registeredSubsystems()
- {
+
+ public static Iterator<SystemInfo> registeredSubsystems() {
return versions.iterator() ;
}
- public static Symbol allocSymbol(String shortName)
- {
- if ( shortName.startsWith(ARQ.arqSymbolPrefix))
- throw new ARQInternalErrorException("Symbol short name begins with the ARQ namespace prefix: "+shortName) ;
- if ( shortName.startsWith("http:"))
- throw new ARQInternalErrorException("Symbol short name begins with http: "+shortName) ;
+ public static Symbol allocSymbol(String shortName) {
+ if ( shortName.startsWith(ARQ.arqSymbolPrefix) )
+ throw new ARQInternalErrorException("Symbol short name begins with the ARQ namespace prefix: " + shortName) ;
+ if ( shortName.startsWith("http:") )
+ throw new ARQInternalErrorException("Symbol short name begins with http: " + shortName) ;
return SystemARQ.allocSymbol(ARQ.arqParamNS, shortName) ;
}
- public static Symbol allocSymbol(String base, String shortName)
- {
- return Symbol.create(base+shortName) ;
+ public static Symbol allocSymbol(String base, String shortName) {
+ return Symbol.create(base + shortName) ;
}
-
}