Class IndexedMapPersisted<Value extends Storable>
- All Implemented Interfaces:
AsyncStorage<Value>
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.
-
Field Summary
Fields inherited from class com.codingchili.core.storage.IndexedMap
context, db, FIELD_ID
-
Constructor Summary
ConstructorDescriptionIndexedMapPersisted(io.vertx.core.Promise<AsyncStorage<Value>> promise, StorageContext<Value> context)
Creates a possibly shared instance of the persisted IndexedMap. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addIndexesForAttribute(com.googlecode.cqengine.attribute.Attribute<Value,String> attribute)
static void
reindex()
Disk indexes are not discovered by CQEngine at startup.Methods inherited from class com.codingchili.core.storage.IndexedMap
addIndex, clear, context, get, getAttribute, getDatabase, put, putIfAbsent, query, remove, setMapper, size, update, values
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.codingchili.core.storage.AsyncStorage
contains, query
-
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 classIndexedMap<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.
-