Updated Branches: refs/heads/develop 3db71241d -> 9a7dbd295
performance improvements, but disabled query cache for now as it has heavy influence on importing Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/9a7dbd29 Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/9a7dbd29 Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/9a7dbd29 Branch: refs/heads/develop Commit: 9a7dbd29506685df51b4dc63639e6b8d37ac1a17 Parents: 3db7124 Author: Sebastian Schaffert <[email protected]> Authored: Fri Dec 20 22:28:20 2013 +0100 Committer: Sebastian Schaffert <[email protected]> Committed: Fri Dec 20 22:28:20 2013 +0100 ---------------------------------------------------------------------- .../kiwi/caching/sail/KiWiCachingSail.java | 71 +++++--- .../caching/sail/KiWiCachingSailConnection.java | 169 +++++++++++++------ .../marmotta/kiwi/caching/KiWiCacheManager.java | 21 +-- .../kiwi/model/rdf/KiWiUriResource.java | 12 +- .../kiwi/persistence/KiWiConnection.java | 10 +- .../backend/kiwi/KiWiStoreProvider.java | 4 +- 6 files changed, 189 insertions(+), 98 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/marmotta/blob/9a7dbd29/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSail.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSail.java b/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSail.java index 3870e78..fbc7289 100644 --- a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSail.java +++ b/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSail.java @@ -21,9 +21,12 @@ import org.apache.marmotta.kiwi.caching.config.KiWiQueryCacheConfiguration; import org.apache.marmotta.kiwi.caching.transaction.GeronimoTransactionManagerLookup; import org.apache.marmotta.kiwi.sail.KiWiStore; import org.infinispan.Cache; +import org.infinispan.configuration.cache.CacheMode; import org.infinispan.configuration.cache.Configuration; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.VersioningScheme; +import org.infinispan.context.Flag; +import org.infinispan.distribution.ch.SyncConsistentHashFactory; import org.infinispan.manager.EmbeddedCacheManager; import org.infinispan.transaction.TransactionMode; import org.infinispan.util.concurrent.IsolationLevel; @@ -91,27 +94,55 @@ public class KiWiCachingSail extends NotifyingSailWrapper { */ private Cache getQueryCache() { if(!cacheManager.cacheExists(QUERY_CACHE)) { - Configuration tripleConfiguration = new ConfigurationBuilder().read(cacheManager.getDefaultCacheConfiguration()) - .storeAsBinary() - .transaction() - .transactionMode(TransactionMode.TRANSACTIONAL) - .transactionManagerLookup(new GeronimoTransactionManagerLookup()) - .cacheStopTimeout(1, TimeUnit.SECONDS) - .locking() - .isolationLevel(IsolationLevel.READ_COMMITTED) - .concurrencyLevel(5) - .versioning() - .enabled(true) - .scheme(VersioningScheme.SIMPLE) - .eviction() - . maxEntries(configuration.getMaxCacheSize()) - .expiration() - .lifespan(60, TimeUnit.MINUTES) - .maxIdle(30, TimeUnit.MINUTES) - .build(); - cacheManager.defineConfiguration(QUERY_CACHE, tripleConfiguration); + if(parent.getPersistence().getConfiguration().isClustered()) { + Configuration tripleConfiguration = new ConfigurationBuilder() + .clustering() + .cacheMode(CacheMode.DIST_SYNC) + .sync() + .replTimeout(60, TimeUnit.SECONDS) + .hash() + .numOwners(2) + .numSegments(40) + .consistentHashFactory(new SyncConsistentHashFactory()) + .transaction() + .transactionMode(TransactionMode.TRANSACTIONAL) + .transactionManagerLookup(new GeronimoTransactionManagerLookup()) + .cacheStopTimeout(1, TimeUnit.SECONDS) + .locking() + .isolationLevel(IsolationLevel.READ_COMMITTED) + .concurrencyLevel(5) + .versioning() + .enabled(true) + .scheme(VersioningScheme.SIMPLE) + .eviction() + .maxEntries(configuration.getMaxCacheSize()) + .expiration() + .lifespan(60, TimeUnit.MINUTES) + .maxIdle(30, TimeUnit.MINUTES) + .build(); + cacheManager.defineConfiguration(QUERY_CACHE, tripleConfiguration); + } else { + Configuration tripleConfiguration = new ConfigurationBuilder().read(cacheManager.getDefaultCacheConfiguration()) + .transaction() + .transactionMode(TransactionMode.TRANSACTIONAL) + .transactionManagerLookup(new GeronimoTransactionManagerLookup()) + .cacheStopTimeout(1, TimeUnit.SECONDS) + .locking() + .isolationLevel(IsolationLevel.READ_COMMITTED) + .concurrencyLevel(5) + .versioning() + .enabled(true) + .scheme(VersioningScheme.SIMPLE) + .eviction() + .maxEntries(configuration.getMaxCacheSize()) + .expiration() + .lifespan(60, TimeUnit.MINUTES) + .maxIdle(30, TimeUnit.MINUTES) + .build(); + cacheManager.defineConfiguration(QUERY_CACHE, tripleConfiguration); + } } - return cacheManager.getCache(QUERY_CACHE); + return cacheManager.getCache(QUERY_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/9a7dbd29/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSailConnection.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSailConnection.java b/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSailConnection.java index d0153dd..d1dc908 100644 --- a/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSailConnection.java +++ b/libraries/kiwi/kiwi-caching/src/main/java/org/apache/marmotta/kiwi/caching/sail/KiWiCachingSailConnection.java @@ -17,7 +17,7 @@ package org.apache.marmotta.kiwi.caching.sail; -import com.google.common.collect.ImmutableList; +import com.google.common.base.Function; import com.google.common.collect.Lists; import info.aduna.iteration.CloseableIteration; import info.aduna.iteration.Iteration; @@ -27,6 +27,8 @@ import org.apache.marmotta.commons.sesame.tripletable.IntArray; import org.apache.marmotta.kiwi.caching.iteration.BufferingIteration; import org.apache.marmotta.kiwi.caching.iteration.CachingIteration; import org.apache.marmotta.kiwi.model.rdf.KiWiTriple; +import org.apache.marmotta.kiwi.persistence.KiWiConnection; +import org.apache.marmotta.kiwi.sail.KiWiSailConnection; import org.infinispan.Cache; import org.openrdf.model.Resource; import org.openrdf.model.Statement; @@ -34,14 +36,17 @@ import org.openrdf.model.URI; import org.openrdf.model.Value; import org.openrdf.model.impl.URIImpl; import org.openrdf.sail.NotifyingSailConnection; +import org.openrdf.sail.SailConnection; import org.openrdf.sail.SailConnectionListener; import org.openrdf.sail.SailException; import org.openrdf.sail.helpers.NotifyingSailConnectionWrapper; +import org.openrdf.sail.helpers.SailConnectionWrapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.transaction.*; import java.nio.IntBuffer; +import java.sql.SQLException; import java.util.*; /** @@ -60,7 +65,7 @@ public class KiWiCachingSailConnection extends NotifyingSailConnectionWrapper im private static Logger log = LoggerFactory.getLogger(KiWiCachingSailConnection.class); - private Cache<IntArray,List<Statement>> queryCache; + private Cache<Long,long[]> queryCache; // a dummy default context to work around the double meaning of the null value private final static URI defaultContext = new URIImpl("http://marmotta.apache.org/contexts/default"); @@ -73,11 +78,14 @@ public class KiWiCachingSailConnection extends NotifyingSailConnectionWrapper im private static long connectionIdCounter = 0; - public KiWiCachingSailConnection(NotifyingSailConnection wrappedCon, Cache<IntArray, List<Statement>> queryCache, int limit) { + private KiWiConnection kiWiConnection; + + public KiWiCachingSailConnection(NotifyingSailConnection wrappedCon, Cache<Long, long[]> queryCache, int limit) { super(wrappedCon); this.queryCache = queryCache; this.limit = limit; + this.kiWiConnection = getKiWiConnection(wrappedCon); this.addConnectionListener(this); @@ -276,9 +284,20 @@ public class KiWiCachingSailConnection extends NotifyingSailConnectionWrapper im IntArray key = createCacheKey(subject,property,object,context,inferred); try { - if(queryCache.get(key) != null) return queryCache.get(key); - else + long[] ids = queryCache.get(key.longHashCode()); + if(ids == null) { return null; + } else { + ArrayList<Statement> statements = new ArrayList<>(ids.length); + for(long id : ids) { + try { + statements.add(kiWiConnection.loadTripleById(id)); + } catch (SQLException e) { + log.warn("could not load triple from database: {}",id); + } + } + return statements; + } } finally { if(implicitTx) { closeTransaction(); @@ -297,7 +316,7 @@ public class KiWiCachingSailConnection extends NotifyingSailConnectionWrapper im * @param inferred if true, inferred triples are included in the result; if false not * @param result the result of the triple query to cache */ - private void cacheTriples(Resource subject, URI property, Value object, Resource context, boolean inferred, List<Statement> result) { + private void cacheTriples(final Resource subject, final URI property, final Value object, final Resource context, boolean inferred, List<Statement> result) { boolean implicitTx = tx == null; resumeTransaction(); @@ -305,7 +324,14 @@ public class KiWiCachingSailConnection extends NotifyingSailConnectionWrapper im try { // cache the query result IntArray key = createCacheKey(subject,property,object,context,inferred); - queryCache.put(key, result); + long[] data = new long[result.size()]; + for(int i=0; i<result.size(); i++) { + Statement stmt = result.get(i); + if(stmt instanceof KiWiTriple) { + data[i] = ((KiWiTriple) stmt).getId(); + } + } + queryCache.put(key.longHashCode(), data); // cache the nodes of the triples and the triples themselves Set<Value> nodes = new HashSet<Value>(); @@ -313,25 +339,31 @@ public class KiWiCachingSailConnection extends NotifyingSailConnectionWrapper im if(stmt instanceof KiWiTriple) { KiWiTriple triple = (KiWiTriple)stmt; Collections.addAll(nodes, new Value[]{triple.getSubject(), triple.getObject(), triple.getPredicate(), triple.getContext()}); - queryCache.put(createCacheKey(triple.getSubject(), triple.getPredicate(), triple.getObject(), triple.getContext(), triple.isInferred()), ImmutableList.of(stmt)); + queryCache.put(createCacheKey(triple.getSubject(), triple.getPredicate(), triple.getObject(), triple.getContext(), triple.isInferred()).longHashCode(), new long[] {triple.getId()}); } } // special optimisation: when only the subject (and optionally context) is given, we also fill the caches for // all property values if(subject != null && property == null && object == null) { - HashMap<URI,List<Statement>> properties = new HashMap<>(); + HashMap<URI,ArrayList<Long>> properties = new HashMap<>(); for(Statement triple : result) { - List<Statement> values = properties.get(triple.getPredicate()); + ArrayList<Long> values = properties.get(triple.getPredicate()); if(values == null) { - values = new LinkedList<>(); + values = new ArrayList<>(); properties.put(triple.getPredicate(),values); } - values.add(triple); + if(triple instanceof KiWiTriple) { + values.add(((KiWiTriple) triple).getId()); + } } - for(Map.Entry<URI,List<Statement>> entry : properties.entrySet()) { + for(Map.Entry<URI,ArrayList<Long>> entry : properties.entrySet()) { IntArray key2 = createCacheKey(subject,entry.getKey(),null,context,inferred); - queryCache.put(key2, entry.getValue()); + long[] dvalues = new long[entry.getValue().size()]; + for(int i=0; i<entry.getValue().size(); i++) { + dvalues[i] = entry.getValue().get(i); + } + queryCache.put(key2.longHashCode(), dvalues); } } @@ -360,51 +392,51 @@ public class KiWiCachingSailConnection extends NotifyingSailConnectionWrapper im * */ private void tripleUpdated(Resource subject, URI predicate, Value object, Iterable<Resource> contexts) { - queryCache.remove(createCacheKey(null,null,null,null,false)); - queryCache.remove(createCacheKey(null,null,null,null,true)); + queryCache.remove(createCacheKey(null, null, null, null, false).longHashCode()); + queryCache.remove(createCacheKey(null,null,null,null,true).longHashCode()); - queryCache.remove(createCacheKey(null,null,null,defaultContext,false)); - queryCache.remove(createCacheKey(null,null,null,defaultContext,true)); + queryCache.remove(createCacheKey(null,null,null,defaultContext,false).longHashCode()); + queryCache.remove(createCacheKey(null,null,null,defaultContext,true).longHashCode()); // remove all possible combinations of this triple as they may appear in the cache - queryCache.remove(createCacheKey(subject,null,null,null,false)); - queryCache.remove(createCacheKey(subject,null,null,null,true)); - queryCache.remove(createCacheKey(null,predicate,null,null,false)); - queryCache.remove(createCacheKey(null,predicate,null,null,true)); - queryCache.remove(createCacheKey(null,null,object,null,false)); - queryCache.remove(createCacheKey(null,null,object,null,true)); + queryCache.remove(createCacheKey(subject,null,null,null,false).longHashCode()); + queryCache.remove(createCacheKey(subject,null,null,null,true).longHashCode()); + queryCache.remove(createCacheKey(null,predicate,null,null,false).longHashCode()); + queryCache.remove(createCacheKey(null,predicate,null,null,true).longHashCode()); + queryCache.remove(createCacheKey(null,null,object,null,false).longHashCode()); + queryCache.remove(createCacheKey(null,null,object,null,true).longHashCode()); - queryCache.remove(createCacheKey(subject,predicate,null,null,false)); - queryCache.remove(createCacheKey(subject,predicate,null,null,true)); - queryCache.remove(createCacheKey(subject,null,object,null,false)); - queryCache.remove(createCacheKey(subject,null,object,null,true)); - queryCache.remove(createCacheKey(null,predicate,object,null,false)); - queryCache.remove(createCacheKey(null,predicate,object,null,true)); + queryCache.remove(createCacheKey(subject,predicate,null,null,false).longHashCode()); + queryCache.remove(createCacheKey(subject,predicate,null,null,true).longHashCode()); + queryCache.remove(createCacheKey(subject,null,object,null,false).longHashCode()); + queryCache.remove(createCacheKey(subject,null,object,null,true).longHashCode()); + queryCache.remove(createCacheKey(null,predicate,object,null,false).longHashCode()); + queryCache.remove(createCacheKey(null,predicate,object,null,true).longHashCode()); - queryCache.remove(createCacheKey(subject,predicate,object,null,false)); - queryCache.remove(createCacheKey(subject,predicate,object,null,true)); + queryCache.remove(createCacheKey(subject,predicate,object,null,false).longHashCode()); + queryCache.remove(createCacheKey(subject,predicate,object,null,true).longHashCode()); for(Resource context : contexts) { - queryCache.remove(createCacheKey(null,null,null,context,false)); - queryCache.remove(createCacheKey(null,null,null,context,true)); - queryCache.remove(createCacheKey(subject,null,null,context,false)); - queryCache.remove(createCacheKey(subject,null,null,context,true)); - queryCache.remove(createCacheKey(null,predicate,null,context,false)); - queryCache.remove(createCacheKey(null,predicate,null,context,true)); - queryCache.remove(createCacheKey(null,null,object,context,false)); - queryCache.remove(createCacheKey(null,null,object,context,true)); - - queryCache.remove(createCacheKey(subject,predicate,null,context,false)); - queryCache.remove(createCacheKey(subject,predicate,null,context,true)); - queryCache.remove(createCacheKey(subject,null,object,context,false)); - queryCache.remove(createCacheKey(subject,null,object,context,true)); - queryCache.remove(createCacheKey(null,predicate,object,context,false)); - queryCache.remove(createCacheKey(null,predicate,object,context,true)); - - queryCache.remove(createCacheKey(subject,predicate,object,context,false)); - queryCache.remove(createCacheKey(subject,predicate,object,context,true)); + queryCache.remove(createCacheKey(null,null,null,context,false).longHashCode()); + queryCache.remove(createCacheKey(null,null,null,context,true).longHashCode()); + queryCache.remove(createCacheKey(subject,null,null,context,false).longHashCode()); + queryCache.remove(createCacheKey(subject,null,null,context,true).longHashCode()); + queryCache.remove(createCacheKey(null,predicate,null,context,false).longHashCode()); + queryCache.remove(createCacheKey(null,predicate,null,context,true).longHashCode()); + queryCache.remove(createCacheKey(null,null,object,context,false).longHashCode()); + queryCache.remove(createCacheKey(null,null,object,context,true).longHashCode()); + + queryCache.remove(createCacheKey(subject,predicate,null,context,false).longHashCode()); + queryCache.remove(createCacheKey(subject,predicate,null,context,true).longHashCode()); + queryCache.remove(createCacheKey(subject,null,object,context,false).longHashCode()); + queryCache.remove(createCacheKey(subject,null,object,context,true).longHashCode()); + queryCache.remove(createCacheKey(null,predicate,object,context,false).longHashCode()); + queryCache.remove(createCacheKey(null,predicate,object,context,true).longHashCode()); + + queryCache.remove(createCacheKey(subject,predicate,object,context,false).longHashCode()); + queryCache.remove(createCacheKey(subject,predicate,object,context,true).longHashCode()); } } @@ -431,4 +463,41 @@ public class KiWiCachingSailConnection extends NotifyingSailConnectionWrapper im } + /** + * Get the root sail in the wrapped sail stack + * @param sail + * @return + */ + private KiWiConnection getKiWiConnection(SailConnection sail) { + if(sail instanceof KiWiSailConnection) { + return ((KiWiSailConnection) sail).getDatabaseConnection(); + } else if(sail instanceof SailConnectionWrapper) { + return getKiWiConnection(((SailConnectionWrapper) sail).getWrappedConnection()); + } else { + throw new IllegalArgumentException("root sail connection is not a KiWiSailConnection or could not be found"); + } + } + + private class IDTripleLoader implements Function<Long,Statement> { + @Override + public Statement apply(Long input) { + try { + return kiWiConnection.loadTripleById(input); + } catch (SQLException e) { + log.error("could not load triple with ID {}", input); + throw new RuntimeException(e); + } + } + } + + private class IDTripleExtractor implements Function<Statement,Long> { + @Override + public Long apply(Statement input) { + if(input instanceof KiWiTriple) { + return ((KiWiTriple) input).getId(); + } else { + return -1L; + } + } + } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/9a7dbd29/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/KiWiCacheManager.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/KiWiCacheManager.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/KiWiCacheManager.java index f089ce1..0b250de 100644 --- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/KiWiCacheManager.java +++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/KiWiCacheManager.java @@ -24,6 +24,7 @@ import org.infinispan.configuration.cache.Configuration; import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.global.GlobalConfiguration; import org.infinispan.configuration.global.GlobalConfigurationBuilder; +import org.infinispan.context.Flag; import org.infinispan.distribution.ch.SyncConsistentHashFactory; import org.infinispan.eviction.EvictionStrategy; import org.infinispan.lifecycle.ComponentStatus; @@ -171,7 +172,7 @@ public class KiWiCacheManager { cacheManager.defineConfiguration(NODE_CACHE, nodeConfiguration); } - return cacheManager.getCache(NODE_CACHE); + return cacheManager.getCache(NODE_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } /** @@ -191,7 +192,7 @@ public class KiWiCacheManager { .build(); cacheManager.defineConfiguration(TRIPLE_CACHE, tripleConfiguration); } - return cacheManager.getCache(TRIPLE_CACHE); + return cacheManager.getCache(TRIPLE_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } @@ -209,7 +210,7 @@ public class KiWiCacheManager { .build(); cacheManager.defineConfiguration(URI_CACHE, uriConfiguration); } - return cacheManager.getCache(URI_CACHE); + return cacheManager.getCache(URI_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } @@ -227,7 +228,7 @@ public class KiWiCacheManager { .build(); cacheManager.defineConfiguration(BNODE_CACHE, bnodeConfiguration); } - return cacheManager.getCache(BNODE_CACHE); + return cacheManager.getCache(BNODE_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } /** @@ -245,7 +246,7 @@ public class KiWiCacheManager { .build(); cacheManager.defineConfiguration(LITERAL_CACHE, literalConfiguration); } - return cacheManager.getCache(LITERAL_CACHE); + return cacheManager.getCache(LITERAL_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } @@ -263,7 +264,7 @@ public class KiWiCacheManager { .build(); cacheManager.defineConfiguration(NAMESPACE_URI_CACHE, nsuriConfiguration); } - return cacheManager.getCache(NAMESPACE_URI_CACHE); + return cacheManager.getCache(NAMESPACE_URI_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } /** @@ -280,7 +281,7 @@ public class KiWiCacheManager { .build(); cacheManager.defineConfiguration(NAMESPACE_PREFIX_CACHE, nsprefixConfiguration); } - return cacheManager.getCache(NAMESPACE_PREFIX_CACHE); + return cacheManager.getCache(NAMESPACE_PREFIX_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } @@ -299,7 +300,7 @@ public class KiWiCacheManager { .build(); cacheManager.defineConfiguration(LOADER_CACHE, loaderConfiguration); } - return cacheManager.getCache(LOADER_CACHE); + return cacheManager.getCache(LOADER_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } @@ -330,7 +331,7 @@ public class KiWiCacheManager { cacheManager.defineConfiguration(REGISTRY_CACHE, registryConfiguration); } } - return cacheManager.getCache(REGISTRY_CACHE); + return cacheManager.getCache(REGISTRY_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } /** @@ -344,7 +345,7 @@ public class KiWiCacheManager { if(!cacheManager.cacheExists(name)) { cacheManager.defineConfiguration(name, new ConfigurationBuilder().read(defaultConfiguration).build()); } - return cacheManager.getCache(name); + return cacheManager.getCache(name).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/9a7dbd29/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiUriResource.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiUriResource.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiUriResource.java index 5ced319..74bdfd3 100644 --- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiUriResource.java +++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiUriResource.java @@ -31,12 +31,6 @@ public class KiWiUriResource extends KiWiResource implements URI { private static final long serialVersionUID = -6399293877969640084L; - /** - * The MemURI's hash code, 0 if not yet initialized. - */ - private int hashCode = 0; - - private String uri; @@ -139,11 +133,7 @@ public class KiWiUriResource extends KiWiResource implements URI { @Override public int hashCode() { - if (hashCode == 0) { - hashCode = toString().hashCode(); - } - - return hashCode; + return toString().hashCode(); } http://git-wip-us.apache.org/repos/asf/marmotta/blob/9a7dbd29/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java index 6d932fb..2022c46 100644 --- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java +++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java @@ -1770,20 +1770,20 @@ public class KiWiConnection { private void cacheNode(KiWiNode node) { if(node.getId() >= 0) { - nodeCache.putAsync(node.getId(), node); + nodeCache.putForExternalRead(node.getId(), node); } if(node instanceof KiWiUriResource) { - uriCache.putAsync(node.stringValue(), (KiWiUriResource) node); + uriCache.putForExternalRead(node.stringValue(), (KiWiUriResource) node); } else if(node instanceof KiWiAnonResource) { - bnodeCache.putAsync(node.stringValue(), (KiWiAnonResource) node); + bnodeCache.putForExternalRead(node.stringValue(), (KiWiAnonResource) node); } else if(node instanceof KiWiLiteral) { - literalCache.putAsync(LiteralCommons.createCacheKey((Literal) node), (KiWiLiteral) node); + literalCache.putForExternalRead(LiteralCommons.createCacheKey((Literal) node), (KiWiLiteral) node); } } private void cacheTriple(KiWiTriple triple) { if(triple.getId() >= 0) { - tripleCache.putAsync(triple.getId(),triple); + tripleCache.putForExternalRead(triple.getId(),triple); } } http://git-wip-us.apache.org/repos/asf/marmotta/blob/9a7dbd29/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java ---------------------------------------------------------------------- diff --git a/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java b/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java index 4b19fee..72b3f05 100644 --- a/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java +++ b/platform/backends/marmotta-backend-kiwi/src/main/java/org/apache/marmotta/platform/backend/kiwi/KiWiStoreProvider.java @@ -18,8 +18,6 @@ package org.apache.marmotta.platform.backend.kiwi; import com.google.common.collect.ImmutableList; -import org.apache.marmotta.kiwi.caching.config.KiWiQueryCacheConfiguration; -import org.apache.marmotta.kiwi.caching.sail.KiWiCachingSail; import org.apache.marmotta.kiwi.config.KiWiConfiguration; import org.apache.marmotta.kiwi.exception.DriverNotFoundException; import org.apache.marmotta.kiwi.persistence.KiWiDialect; @@ -138,6 +136,7 @@ public class KiWiStoreProvider implements StoreProvider { NotifyingSail base = new KiWiStore(configuration, cacheManager); + /* if(configurationService.getBooleanConfiguration(CACHING_QUERY_ENABLED,true)) { log.info(" - enabling query caching support"); KiWiQueryCacheConfiguration qcfg = new KiWiQueryCacheConfiguration(); @@ -145,6 +144,7 @@ public class KiWiStoreProvider implements StoreProvider { qcfg.setMaxEntrySize(configurationService.getIntConfiguration(CACHING_QUERY_LIMIT, 150)); base = new KiWiCachingSail(base, qcfg); } + */ if("native".equalsIgnoreCase(configurationService.getStringConfiguration(SPARQL_STRATEGY))) {
