Cumulus4j API
(1.1.0)

org.cumulus4j.store.datastoreversion.command
Class RecreateIndex

java.lang.Object
  extended by org.cumulus4j.store.datastoreversion.AbstractDatastoreVersionCommand
      extended by org.cumulus4j.store.datastoreversion.command.RecreateIndex
All Implemented Interfaces:
DatastoreVersionCommand

public class RecreateIndex
extends AbstractDatastoreVersionCommand

Delete all IndexEntrys from the datastore and then iterate all DataEntrys and re-index them.

TODO This class currently does not yet ensure that different keys are used. Thus, very likely the entire index uses only one single key. This should be improved in a future version.

Author:
Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de

Nested Class Summary
protected static class RecreateIndex.DataEntryWithClassName
           
 
Field Summary
protected static String PROPERTY_CREATE_FROM_DATA_ENTRY_ID
           
protected static String PROPERTY_DELETE_COMPLETE
           
protected static String PROPERTY_DELETE_FROM_INDEX_ENTRY_ID
           
 
Constructor Summary
RecreateIndex()
           
 
Method Summary
 void apply(CommandApplyParam commandApplyParam)
          Perform the upgrade or do whatever this command has to do.
protected  void createIndex()
           
protected  void createIndexForRange(long fromDataEntryIDIncl, Long toDataEntryIDExcl)
           
protected  void deleteIndex()
           
protected  void deleteIndexForRange(long fromIndexEntryIDIncl, Long toIndexEntryIDExcl)
           
 int getCommandVersion()
          Get the version of this command.
protected  List<RecreateIndex.DataEntryWithClassName> getDataEntries(long fromDataEntryIDIncl, Long toDataEntryIDExcl)
           
protected  List<IndexEntry> getIndexEntries(Class<? extends IndexEntry> indexEntryClass, long fromIndexEntryIDIncl, Long toIndexEntryIDExcl)
           
protected  List<IndexEntry> getIndexEntries(long fromIndexEntryIDIncl, Long toIndexEntryIDExcl)
           
protected  Set<Class<? extends IndexEntry>> getIndexEntryClasses()
           
protected  long getMaxDataEntryID()
           
protected  Long getMaxIndexEntryID()
           
protected  long getMinDataEntryID()
           
protected  Long getMinIndexEntryID()
           
protected  Long getMinMaxDataEntryID(String minMax)
           
protected  Long getMinMaxIndexEntryID(Class<? extends IndexEntry> indexEntryClass, String minMax)
           
protected  Long getMinMaxIndexEntryID(String minMax, Comparator<Long> comparator)
           
 boolean isFinal()
          Is this command final, i.e.
 boolean isKeyStoreDependent()
          Is this command dependent on the key-store? If yes, it is applied separately for every key-store, i.e.
 
Methods inherited from class org.cumulus4j.store.datastoreversion.AbstractDatastoreVersionCommand
getCommandID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_DELETE_COMPLETE

protected static final String PROPERTY_DELETE_COMPLETE
See Also:
Constant Field Values

PROPERTY_DELETE_FROM_INDEX_ENTRY_ID

protected static final String PROPERTY_DELETE_FROM_INDEX_ENTRY_ID
See Also:
Constant Field Values

PROPERTY_CREATE_FROM_DATA_ENTRY_ID

protected static final String PROPERTY_CREATE_FROM_DATA_ENTRY_ID
See Also:
Constant Field Values
Constructor Detail

RecreateIndex

public RecreateIndex()
Method Detail

getCommandVersion

public int getCommandVersion()
Description copied from interface: DatastoreVersionCommand
Get the version of this command.

This version must be incremented, if this command is modified!

Note, that a final command cannot be modified!!! You can only modify a final command if this command was newly introduced in the current SNAPSHOT. Never modify a command after it was released!!!

Returns:
the version of this command.

isFinal

public boolean isFinal()
Description copied from interface: DatastoreVersionCommand
Is this command final, i.e. applied only once, or should this command be applied again, when the commandVersion was incremented?

Specified by:
isFinal in interface DatastoreVersionCommand
Overrides:
isFinal in class AbstractDatastoreVersionCommand
Returns:
true, if this command is final; false otherwise.

isKeyStoreDependent

public boolean isKeyStoreDependent()
Description copied from interface: DatastoreVersionCommand
Is this command dependent on the key-store? If yes, it is applied separately for every key-store, i.e. with different keyStoreRefIDs. If no, it is applied only once globally.

Specified by:
isKeyStoreDependent in interface DatastoreVersionCommand
Overrides:
isKeyStoreDependent in class AbstractDatastoreVersionCommand
Returns:
true, if this command should be applied once per key-store (and per underlying PersistenceManager [there might be two if data and index is stored separately]); false otherwise.

apply

public void apply(CommandApplyParam commandApplyParam)
Description copied from interface: DatastoreVersionCommand
Perform the upgrade or do whatever this command has to do.

Parameters:
commandApplyParam - various arguments bundled for better compatibility with future extensions. Never null.

deleteIndex

protected void deleteIndex()

deleteIndexForRange

protected void deleteIndexForRange(long fromIndexEntryIDIncl,
                                   Long toIndexEntryIDExcl)

getIndexEntries

protected List<IndexEntry> getIndexEntries(long fromIndexEntryIDIncl,
                                           Long toIndexEntryIDExcl)

getIndexEntries

protected List<IndexEntry> getIndexEntries(Class<? extends IndexEntry> indexEntryClass,
                                           long fromIndexEntryIDIncl,
                                           Long toIndexEntryIDExcl)

createIndex

protected void createIndex()

createIndexForRange

protected void createIndexForRange(long fromDataEntryIDIncl,
                                   Long toDataEntryIDExcl)

getDataEntries

protected List<RecreateIndex.DataEntryWithClassName> getDataEntries(long fromDataEntryIDIncl,
                                                                    Long toDataEntryIDExcl)

getMinDataEntryID

protected long getMinDataEntryID()

getMaxDataEntryID

protected long getMaxDataEntryID()

getMinMaxDataEntryID

protected Long getMinMaxDataEntryID(String minMax)

getMinIndexEntryID

protected Long getMinIndexEntryID()

getMaxIndexEntryID

protected Long getMaxIndexEntryID()

getMinMaxIndexEntryID

protected Long getMinMaxIndexEntryID(String minMax,
                                     Comparator<Long> comparator)

getMinMaxIndexEntryID

protected Long getMinMaxIndexEntryID(Class<? extends IndexEntry> indexEntryClass,
                                     String minMax)

getIndexEntryClasses

protected Set<Class<? extends IndexEntry>> getIndexEntryClasses()

Cumulus4j API
(1.1.0)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.