Class ValueStore

  • All Implemented Interfaces:
    ValueFactory

    @InternalUseOnly
    public class ValueStore
    extends SimpleValueFactory
    File-based indexed storage and retrieval of RDF values. ValueStore maps RDF values to integer IDs and vice-versa.
    Author:
    Arjohn Kampman
    • Field Detail

      • VALUE_CACHE_SIZE

        public static final int VALUE_CACHE_SIZE
        The default value cache size.
        See Also:
        Constant Field Values
      • VALUE_ID_CACHE_SIZE

        public static final int VALUE_ID_CACHE_SIZE
        The default value id cache size.
        See Also:
        Constant Field Values
      • NAMESPACE_CACHE_SIZE

        public static final int NAMESPACE_CACHE_SIZE
        The default namespace cache size.
        See Also:
        Constant Field Values
      • NAMESPACE_ID_CACHE_SIZE

        public static final int NAMESPACE_ID_CACHE_SIZE
        The default namespace id cache size.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ValueStore

        public ValueStore​(File dataDir,
                          boolean forceSync,
                          int valueCacheSize,
                          int valueIDCacheSize,
                          int namespaceCacheSize,
                          int namespaceIDCacheSize)
                   throws IOException
        Throws:
        IOException
    • Method Detail

      • getValue

        public NativeValue getValue​(int id)
                             throws IOException
        Gets the value for the specified ID.
        Parameters:
        id - A value ID.
        Returns:
        The value for the ID, or null no such value could be found.
        Throws:
        IOException - If an I/O error occurred.
      • getID

        public int getID​(Value value)
                  throws IOException
        Gets the ID for the specified value.
        Parameters:
        value - A value.
        Returns:
        The ID for the specified value, or NativeValue.UNKNOWN_ID if no such ID could be found.
        Throws:
        IOException - If an I/O error occurred.
      • storeValue

        public int storeValue​(Value value)
                       throws IOException
        Stores the supplied value and returns the ID that has been assigned to it. In case the value was already present, the value will not be stored again and the ID of the existing value is returned.
        Parameters:
        value - The Value to store.
        Returns:
        The ID that has been assigned to the value.
        Throws:
        IOException - If an I/O error occurred.
      • clear

        public void clear()
                   throws IOException
        Removes all values from the ValueStore.
        Throws:
        IOException - If an I/O error occurred.
      • sync

        public void sync()
                  throws IOException
        Synchronizes any changes that are cached in memory to disk.
        Throws:
        IOException - If an I/O error occurred.
      • close

        public void close()
                   throws IOException
        Closes the ValueStore, releasing any file references, etc. Once closed, the ValueStore can no longer be used.
        Throws:
        IOException - If an I/O error occurred.
      • createLiteral

        public NativeLiteral createLiteral​(String value,
                                           IRI datatype)
        Description copied from interface: ValueFactory
        Creates a new literal with the supplied label and datatype.
        Specified by:
        createLiteral in interface ValueFactory
        Overrides:
        createLiteral in class SimpleValueFactory
        Parameters:
        value - The literal's label, must not be null.
        datatype - The literal's datatype. If it is null, the datatype xsd:string will be assigned to this literal.
        Returns:
        A literal for the specified value and type.
      • getNativeURI

        public NativeIRI getNativeURI​(IRI uri)
        Creates a NativeURI that is equal to the supplied URI. This method returns the supplied URI itself if it is already a NativeURI that has been created by this ValueStore, which prevents unnecessary object creations.
        Returns:
        A NativeURI for the specified URI.
      • getNativeBNode

        public NativeBNode getNativeBNode​(BNode bnode)
        Creates a NativeBNode that is equal to the supplied bnode. This method returns the supplied bnode itself if it is already a NativeBNode that has been created by this ValueStore, which prevents unnecessary object creations.
        Returns:
        A NativeBNode for the specified bnode.
      • getNativeLiteral

        public NativeLiteral getNativeLiteral​(Literal l)
        Creates an NativeLiteral that is equal to the supplied literal. This method returns the supplied literal itself if it is already a NativeLiteral that has been created by this ValueStore, which prevents unnecessary object creations.
        Returns:
        A NativeLiteral for the specified literal.