Class KVStorage

java.lang.Object
com.graphhopper.search.KVStorage

public class KVStorage extends Object
This class stores key-value pairs in an append-only manner.
Author:
Peter Karich
  • Constructor Details

    • KVStorage

      public KVStorage(Directory dir, boolean edge)
      Specify a larger cacheSize to reduce disk usage. Note that this increases the memory usage of this object.
  • Method Details

    • create

      public KVStorage create(long initBytes)
    • loadExisting

      public boolean loadExisting()
    • add

      public long add(List<KVStorage.KeyValue> entries)
      This method writes the specified entryMap (key-value pairs) into the storage. Please note that null keys or null values are rejected. The Class of a value can be only: byte[], String, int, long, float or double (or more precisely, their wrapper equivalent). For all other types an exception is thrown. The first call of add assigns a Class to every key in the Map and future calls of add will throw an exception if this Class differs.
      Returns:
      entryPointer with which you can later fetch the entryMap via the get or getAll method
    • getAll

      public List<KVStorage.KeyValue> getAll(long entryPointer)
    • getMap

      public Map<String,Object> getMap(long entryPointer)
      Please note that this method ignores potentially different tags for forward and backward direction. To avoid this use getAll(long) instead.
    • get

      public Object get(long entryPointer, String key, boolean reverse)
    • flush

      public void flush()
    • clear

      public void clear()
    • close

      public void close()
    • isClosed

      public boolean isClosed()
    • getCapacity

      public long getCapacity()
    • cutString

      public static String cutString(String value)
      This method limits the specified String value to the length currently accepted for values in the KVStorage.