org.apache.activemq.kaha.impl.container
Class MapContainerImpl

java.lang.Object
  extended by org.apache.activemq.kaha.impl.container.BaseContainerImpl
      extended by org.apache.activemq.kaha.impl.container.MapContainerImpl
All Implemented Interfaces:
Map, MapContainer

public final class MapContainerImpl
extends BaseContainerImpl
implements MapContainer

Implementation of a MapContainer


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
protected  File directory
           
protected  Index index
           
protected  Marshaller keyMarshaller
           
protected  Marshaller valueMarshaller
           
 
Fields inherited from class org.apache.activemq.kaha.impl.container.BaseContainerImpl
closed, containerId, dataManager, indexList, indexManager, initialized, loaded, persistentIndex, root
 
Constructor Summary
MapContainerImpl(File directory, ContainerId id, IndexItem root, IndexManager indexManager, DataManager dataManager, boolean persistentIndex)
           
 
Method Summary
 void clear()
          empty the container
 boolean containsKey(Object key)
           
 boolean containsValue(Object o)
           
 void delete()
          Clean up all state associated with this container.
 Set entrySet()
           
 Object get(Object key)
          Get the value associated with the key
 StoreEntry getEntry(Object key)
          Get the StoreEntry associated with the key
 StoreEntry getFirst()
          Get the StoreEntry for the first value in the Map
 int getIndexBinSize()
           
 int getIndexKeySize()
           
 int getIndexLoadFactor()
           
 int getIndexMaxBinSize()
           
 IndexMBean getIndexMBean()
           
 int getIndexPageSize()
           
protected  IndexLinkedList getItemList()
           
 Object getKey(StoreEntry item)
          Get the Key object from it's location
 StoreEntry getLast()
          Get the StoreEntry for the last value item of the Map
 StoreEntry getNext(StoreEntry entry)
          Get the next StoreEntry value from the map
 StoreEntry getPrevious(StoreEntry entry)
          Get the previous StoreEntry from the map
 Object getValue(StoreEntry item)
          Get the value from it's location
 void init()
           
 boolean isEmpty()
           
 Set keySet()
           
 void load()
          The container is created or retrieved in an unloaded state.
 StoreEntry place(Object key, Object value)
          Add an entry to the Store Map
 Object put(Object key, Object value)
          Add an entry
 void putAll(Map t)
          Add add entries in the supplied Map
 StoreEntry refresh(StoreEntry entry)
          It's possible that a StoreEntry could be come stale this will return an upto date entry for the StoreEntry position
protected  void remove(IndexItem item)
           
 Object remove(Object key)
          remove an entry associated with the key
 void remove(StoreEntry entry)
          Remove an Entry from ther Map
 boolean removeValue(Object o)
           
 void setIndexBinSize(int indexBinSize)
          Set the index bin size
 void setIndexKeySize(int indexKeySize)
          Add the index key size
 void setIndexLoadFactor(int loadFactor)
           
 void setIndexMaxBinSize(int maxBinSize)
          set the meximum bin size
 void setIndexPageSize(int indexPageSize)
          Set the index page size
 void setKeyMarshaller(Marshaller keyMarshaller)
          For homogenous containers can set a custom marshaller for loading keys The default uses Object serialization
 void setValueMarshaller(Marshaller valueMarshaller)
          For homogenous containers can set a custom marshaller for loading values The default uses Object serialization
 int size()
           
 String toString()
           
 void unload()
          unload indexes from the container
 Collection values()
           
protected  IndexItem write(Object key, Object value)
           
 
Methods inherited from class org.apache.activemq.kaha.impl.container.BaseContainerImpl
checkClosed, close, delete, doClear, expressDataInterest, getContainerId, getDataManager, getId, getIndexManager, getInternalList, getList, isLoaded, isRoot, setList, storeIndex, updateIndexes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.activemq.kaha.MapContainer
getId, isLoaded
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

index

protected Index index

keyMarshaller

protected Marshaller keyMarshaller

valueMarshaller

protected Marshaller valueMarshaller

directory

protected File directory
Constructor Detail

MapContainerImpl

public MapContainerImpl(File directory,
                        ContainerId id,
                        IndexItem root,
                        IndexManager indexManager,
                        DataManager dataManager,
                        boolean persistentIndex)
Method Detail

init

public void init()
Overrides:
init in class BaseContainerImpl

load

public void load()
Description copied from interface: MapContainer
The container is created or retrieved in an unloaded state. load populates the container will all the indexes used etc and should be called before any operations on the container

Specified by:
load in interface MapContainer
Specified by:
load in class BaseContainerImpl

unload

public void unload()
Description copied from interface: MapContainer
unload indexes from the container

Specified by:
unload in interface MapContainer
Specified by:
unload in class BaseContainerImpl

delete

public void delete()
Description copied from interface: MapContainer
Clean up all state associated with this container.

Specified by:
delete in interface MapContainer

setKeyMarshaller

public void setKeyMarshaller(Marshaller keyMarshaller)
Description copied from interface: MapContainer
For homogenous containers can set a custom marshaller for loading keys The default uses Object serialization

Specified by:
setKeyMarshaller in interface MapContainer

setValueMarshaller

public void setValueMarshaller(Marshaller valueMarshaller)
Description copied from interface: MapContainer
For homogenous containers can set a custom marshaller for loading values The default uses Object serialization

Specified by:
setValueMarshaller in interface MapContainer

size

public int size()
Specified by:
size in interface Map
Specified by:
size in interface MapContainer
Specified by:
size in class BaseContainerImpl
Returns:
the number of values in the container

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map
Specified by:
isEmpty in interface MapContainer
Returns:
true if there are no values stored in the container

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map
Specified by:
containsKey in interface MapContainer
Returns:
true if the container contains the key

get

public Object get(Object key)
Description copied from interface: MapContainer
Get the value associated with the key

Specified by:
get in interface Map
Specified by:
get in interface MapContainer
Returns:
the value associated with the key from the store

getEntry

public StoreEntry getEntry(Object key)
Get the StoreEntry associated with the key

Specified by:
getEntry in interface MapContainer
Parameters:
key -
Returns:
the StoreEntry

containsValue

public boolean containsValue(Object o)
Specified by:
containsValue in interface Map
Specified by:
containsValue in interface MapContainer
Returns:
true if the MapContainer contains the value o

putAll

public void putAll(Map t)
Description copied from interface: MapContainer
Add add entries in the supplied Map

Specified by:
putAll in interface Map
Specified by:
putAll in interface MapContainer

keySet

public Set keySet()
Specified by:
keySet in interface Map
Specified by:
keySet in interface MapContainer
Returns:
a Set of all the keys

values

public Collection values()
Specified by:
values in interface Map
Specified by:
values in interface MapContainer
Returns:
a collection of all the values - the values will be lazily pulled out of the store if iterated etc.

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map
Specified by:
entrySet in interface MapContainer
Returns:
a Set of all the Map.Entry instances - the values will be lazily pulled out of the store if iterated etc.

put

public Object put(Object key,
                  Object value)
Description copied from interface: MapContainer
Add an entry

Specified by:
put in interface Map
Specified by:
put in interface MapContainer
Returns:
the old value for the key

remove

public Object remove(Object key)
Description copied from interface: MapContainer
remove an entry associated with the key

Specified by:
remove in interface Map
Specified by:
remove in interface MapContainer
Returns:
the old value assocaited with the key or null

removeValue

public boolean removeValue(Object o)

remove

protected void remove(IndexItem item)
Specified by:
remove in class BaseContainerImpl

clear

public void clear()
Description copied from interface: MapContainer
empty the container

Specified by:
clear in interface Map
Specified by:
clear in interface MapContainer
Overrides:
clear in class BaseContainerImpl

place

public StoreEntry place(Object key,
                        Object value)
Add an entry to the Store Map

Specified by:
place in interface MapContainer
Parameters:
key -
value -
Returns:
the StoreEntry associated with the entry

remove

public void remove(StoreEntry entry)
Remove an Entry from ther Map

Specified by:
remove in interface MapContainer
Parameters:
entry -
Throws:
IOException

getFirst

public StoreEntry getFirst()
Description copied from interface: MapContainer
Get the StoreEntry for the first value in the Map

Specified by:
getFirst in interface MapContainer
Returns:
the first StoreEntry or null if the map is empty

getLast

public StoreEntry getLast()
Description copied from interface: MapContainer
Get the StoreEntry for the last value item of the Map

Specified by:
getLast in interface MapContainer
Returns:
the last StoreEntry or null if the list is empty

getNext

public StoreEntry getNext(StoreEntry entry)
Description copied from interface: MapContainer
Get the next StoreEntry value from the map

Specified by:
getNext in interface MapContainer
Returns:
the next StoreEntry or null

getPrevious

public StoreEntry getPrevious(StoreEntry entry)
Description copied from interface: MapContainer
Get the previous StoreEntry from the map

Specified by:
getPrevious in interface MapContainer
Returns:
the previous store entry or null

refresh

public StoreEntry refresh(StoreEntry entry)
Description copied from interface: MapContainer
It's possible that a StoreEntry could be come stale this will return an upto date entry for the StoreEntry position

Specified by:
refresh in interface MapContainer
Parameters:
entry - old entry
Returns:
a refreshed StoreEntry

getValue

public Object getValue(StoreEntry item)
Get the value from it's location

Specified by:
getValue in interface MapContainer
Specified by:
getValue in class BaseContainerImpl
Parameters:
item -
Returns:
the value associated with the store entry

getKey

public Object getKey(StoreEntry item)
Get the Key object from it's location

Specified by:
getKey in interface MapContainer
Parameters:
item -
Returns:
the Key Object associated with the StoreEntry

getItemList

protected IndexLinkedList getItemList()

write

protected IndexItem write(Object key,
                          Object value)

getIndexBinSize

public int getIndexBinSize()
Specified by:
getIndexBinSize in interface MapContainer
Returns:
index bin size

setIndexBinSize

public void setIndexBinSize(int indexBinSize)
Description copied from interface: MapContainer
Set the index bin size

Specified by:
setIndexBinSize in interface MapContainer

getIndexKeySize

public int getIndexKeySize()
Specified by:
getIndexKeySize in interface MapContainer
Returns:
the index key size

setIndexKeySize

public void setIndexKeySize(int indexKeySize)
Description copied from interface: MapContainer
Add the index key size

Specified by:
setIndexKeySize in interface MapContainer

getIndexPageSize

public int getIndexPageSize()
Specified by:
getIndexPageSize in interface MapContainer
Returns:
the index page size

setIndexPageSize

public void setIndexPageSize(int indexPageSize)
Description copied from interface: MapContainer
Set the index page size

Specified by:
setIndexPageSize in interface MapContainer

getIndexLoadFactor

public int getIndexLoadFactor()
Specified by:
getIndexLoadFactor in interface MapContainer
Returns:
the loadFactor

setIndexLoadFactor

public void setIndexLoadFactor(int loadFactor)
Specified by:
setIndexLoadFactor in interface MapContainer
Parameters:
loadFactor - the loadFactor to set

getIndexMBean

public IndexMBean getIndexMBean()
Specified by:
getIndexMBean in interface MapContainer
Returns:
the Index MBean

getIndexMaxBinSize

public int getIndexMaxBinSize()
Specified by:
getIndexMaxBinSize in interface MapContainer
Returns:
the maximum bin size

setIndexMaxBinSize

public void setIndexMaxBinSize(int maxBinSize)
Description copied from interface: MapContainer
set the meximum bin size

Specified by:
setIndexMaxBinSize in interface MapContainer

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.