Package org.eclipse.rdf4j.sail.nativerdf
Class NativeStore
- java.lang.Object
-
- org.eclipse.rdf4j.sail.helpers.AbstractSail
-
- org.eclipse.rdf4j.sail.helpers.AbstractNotifyingSail
-
- org.eclipse.rdf4j.sail.nativerdf.NativeStore
-
- All Implemented Interfaces:
FederatedServiceResolverClient
,NotifyingSail
,Sail
- Direct Known Subclasses:
LimitedSizeNativeStore
public class NativeStore extends AbstractNotifyingSail implements FederatedServiceResolverClient
A SAIL implementation using B-Tree indexing on disk for storing and querying its data.The NativeStore is designed for datasets between 100,000 and 100 million triples. On most operating systems, if there is sufficient physical memory, the NativeStore will act like the MemoryStore, because the read/write commands will be cached by the OS. This technique allows the NativeStore to operate quite well for millions of triples.
- Author:
- Arjohn Kampman, jeen
-
-
Field Summary
-
Fields inherited from class org.eclipse.rdf4j.sail.helpers.AbstractSail
connectionTimeOut, DEFAULT_CONNECTION_TIMEOUT, DEFAULT_ITERATION_SYNC_THRESHOLD, initializationLock
-
-
Constructor Summary
Constructors Constructor Description NativeStore()
Creates a new NativeStore.NativeStore(File dataDir)
NativeStore(File dataDir, String tripleIndexes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Supplier<CollectionFactory>
getCollectionFactory()
Gets a CollectionFactory that may be optimized for this store and may or may not use disk or other resources.protected NotifyingSailConnection
getConnectionInternal()
Returns a store-specific SailConnection object.EvaluationStrategyFactory
getEvaluationStrategyFactory()
FederatedServiceResolver
getFederatedServiceResolver()
Gets theFederatedServiceResolver
used by this client.boolean
getForceSync()
protected Lock
getTransactionLock(IsolationLevel level)
This call will block whenIsolationLevels.NONE
is provided when there are active transactions with a higher isolation and block when a higher isolation is provided when there are active transactions withIsolationLevels.NONE
isolation.String
getTripleIndexes()
ValueFactory
getValueFactory()
Gets a ValueFactory object that can be used to create IRI-, blank node-, literal- and statement objects.protected void
initializeInternal()
Initializes this NativeStore.boolean
isWritable()
Checks whether this Sail object is writable, i.e.void
setDataDir(File dataDir)
Sets the data directory for the Sail.void
setEvaluationStrategyFactory(EvaluationStrategyFactory factory)
Sets theEvaluationStrategy
to use.void
setFederatedServiceResolver(FederatedServiceResolver resolver)
Overrides theFederatedServiceResolver
used by this instance, but the given resolver is not shutDown when this instance is.void
setForceSync(boolean forceSync)
Specifies whether updates should be synced to disk forcefully, must be called before initialization.void
setNamespaceCacheSize(int namespaceCacheSize)
void
setNamespaceIDCacheSize(int namespaceIDCacheSize)
void
setTripleIndexes(String tripleIndexes)
Sets the triple indexes for the native store, must be called before initialization.void
setValueCacheSize(int valueCacheSize)
void
setValueIDCacheSize(int valueIDCacheSize)
void
shutDown()
Shuts down the Sail, giving it the opportunity to synchronize any stale data.protected void
shutDownInternal()
Do store-specific operations to ensure proper shutdown of the store.-
Methods inherited from class org.eclipse.rdf4j.sail.helpers.AbstractNotifyingSail
addSailChangedListener, getConnection, notifySailChanged, removeSailChangedListener
-
Methods inherited from class org.eclipse.rdf4j.sail.helpers.AbstractSail
addSupportedIsolationLevel, connectionClosed, debugEnabled, getDataDir, getDefaultIsolationLevel, getDefaultQueryEvaluationMode, getIterationCacheSyncThreshold, getSupportedIsolationLevels, init, isInitialized, isTrackResultSize, removeSupportedIsolationLevel, setConnectionTimeOut, setDefaultIsolationLevel, setDefaultQueryEvaluationMode, setIterationCacheSyncThreshold, setSupportedIsolationLevels, setSupportedIsolationLevels, setTrackResultSize, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.sail.Sail
getDataDir, getDefaultIsolationLevel, getSupportedIsolationLevels, init
-
-
-
-
Method Detail
-
setDataDir
public void setDataDir(File dataDir)
Description copied from interface:Sail
Sets the data directory for the Sail. The Sail can use this directory for storage of data, parameters, etc. This directory must be set before the Sail isinitialized
.- Specified by:
setDataDir
in interfaceSail
- Overrides:
setDataDir
in classAbstractSail
-
setTripleIndexes
public void setTripleIndexes(String tripleIndexes)
Sets the triple indexes for the native store, must be called before initialization.- Parameters:
tripleIndexes
- An index strings, e.g. spoc,posc.
-
getTripleIndexes
public String getTripleIndexes()
-
setForceSync
public void setForceSync(boolean forceSync)
Specifies whether updates should be synced to disk forcefully, must be called before initialization. Enabling this feature may prevent corruption in case of events like power loss, but can have a severe impact on write performance. By default, this feature is disabled.
-
getForceSync
public boolean getForceSync()
-
setValueCacheSize
public void setValueCacheSize(int valueCacheSize)
-
setValueIDCacheSize
public void setValueIDCacheSize(int valueIDCacheSize)
-
setNamespaceCacheSize
public void setNamespaceCacheSize(int namespaceCacheSize)
-
setNamespaceIDCacheSize
public void setNamespaceIDCacheSize(int namespaceIDCacheSize)
-
getEvaluationStrategyFactory
public EvaluationStrategyFactory getEvaluationStrategyFactory()
- Returns:
- Returns the
EvaluationStrategy
.
-
setEvaluationStrategyFactory
public void setEvaluationStrategyFactory(EvaluationStrategyFactory factory)
Sets theEvaluationStrategy
to use.
-
getFederatedServiceResolver
public FederatedServiceResolver getFederatedServiceResolver()
Description copied from interface:FederatedServiceResolverClient
Gets theFederatedServiceResolver
used by this client.- Specified by:
getFederatedServiceResolver
in interfaceFederatedServiceResolverClient
- Returns:
- Returns the SERVICE resolver.
-
setFederatedServiceResolver
public void setFederatedServiceResolver(FederatedServiceResolver resolver)
Overrides theFederatedServiceResolver
used by this instance, but the given resolver is not shutDown when this instance is.- Specified by:
setFederatedServiceResolver
in interfaceFederatedServiceResolverClient
- Parameters:
resolver
- The SERVICE resolver to set.
-
initializeInternal
protected void initializeInternal() throws SailException
Initializes this NativeStore.- Overrides:
initializeInternal
in classAbstractSail
- Throws:
SailException
- If this NativeStore could not be initialized using the parameters that have been set.
-
shutDownInternal
protected void shutDownInternal() throws SailException
Description copied from class:AbstractSail
Do store-specific operations to ensure proper shutdown of the store.- Specified by:
shutDownInternal
in classAbstractSail
- Throws:
SailException
-
shutDown
public void shutDown() throws SailException
Description copied from interface:Sail
Shuts down the Sail, giving it the opportunity to synchronize any stale data. Care should be taken that all initialized Sails are being shut down before an application exits to avoid potential loss of data. Once shut down, a Sail can no longer be used until it is re-initialized.- Specified by:
shutDown
in interfaceSail
- Overrides:
shutDown
in classAbstractSail
- Throws:
SailException
- If the Sail object encountered an error or unexpected situation internally.
-
isWritable
public boolean isWritable()
Description copied from interface:Sail
Checks whether this Sail object is writable, i.e. if the data contained in this Sail object can be changed.- Specified by:
isWritable
in interfaceSail
-
getConnectionInternal
protected NotifyingSailConnection getConnectionInternal() throws SailException
Description copied from class:AbstractSail
Returns a store-specific SailConnection object.- Specified by:
getConnectionInternal
in classAbstractNotifyingSail
- Returns:
- A connection to the store.
- Throws:
SailException
-
getValueFactory
public ValueFactory getValueFactory()
Description copied from interface:Sail
Gets a ValueFactory object that can be used to create IRI-, blank node-, literal- and statement objects.- Specified by:
getValueFactory
in interfaceSail
- Returns:
- a ValueFactory object for this Sail object.
-
getTransactionLock
protected Lock getTransactionLock(IsolationLevel level) throws SailException
This call will block whenIsolationLevels.NONE
is provided when there are active transactions with a higher isolation and block when a higher isolation is provided when there are active transactions withIsolationLevels.NONE
isolation. Store is either exclusively inIsolationLevels.NONE
isolation with potentially zero or more transactions, or exclusively in higher isolation mode with potentially zero or more transactions.- Parameters:
level
- indicating desired modeIsolationLevels.NONE
or higher- Returns:
- Lock used to prevent Store from switching isolation modes
- Throws:
SailException
-
getCollectionFactory
public Supplier<CollectionFactory> getCollectionFactory()
Description copied from interface:Sail
Gets a CollectionFactory that may be optimized for this store and may or may not use disk or other resources.- Specified by:
getCollectionFactory
in interfaceSail
- Returns:
- a CollectionFactory
-
-