Class IndexedMapPersisted<Value extends Storable>

java.lang.Object
com.codingchili.core.storage.IndexedMap<Value>
com.codingchili.core.storage.IndexedMapPersisted<Value>
All Implemented Interfaces:
AsyncStorage<Value>

public class IndexedMapPersisted<Value extends Storable> extends IndexedMap<Value>
Adds disk persistence to IndexedMap.

Overrides some methods where the underlying implementation differs between on heap and on disk indexes.

The update method for disk persistence cannot be trusted. It only replaces an existing version by using the objects serialized form as its composite PK.

  • Constructor Details

    • IndexedMapPersisted

      public IndexedMapPersisted(io.vertx.core.Promise<AsyncStorage<Value>> promise, StorageContext<Value> context)
      Creates a possibly shared instance of the persisted IndexedMap. It is recommended to not call this directly and instead use the storage loader.
      Parameters:
      promise - completed when the storage is ready.
      context - the storage context to set up file locations etc.
  • Method Details

    • addIndexesForAttribute

      public void addIndexesForAttribute(com.googlecode.cqengine.attribute.Attribute<Value,​String> attribute)
      Specified by:
      addIndexesForAttribute in class IndexedMap<Value extends Storable>
      Parameters:
      attribute - the attribute to add an index for based on implementation.
    • reindex

      public static void reindex()
      Disk indexes are not discovered by CQEngine at startup. This means that CQEngine will not update existing indexes unless AsyncStorage#addIndex is called before any items are added.

      To work around this there are two options,

      a) Always add all indexes before inserting ANY items. b) Call this method before loading the IndexedMapPersisted plugin. Then items can be added before adding an index. Because when the index is added later it will be rebuilt. In the window between adding the object and adding the index the object will not be visible in the affected indexes.

      If this method is called after an instance of IndexedMapPersisted has been loaded through the storage loader an exception is thrown.