org.apache.activemq.store.kahadb.disk.index
Class ListIndex<Key,Value>

java.lang.Object
  extended by org.apache.activemq.store.kahadb.disk.index.ListIndex<Key,Value>
All Implemented Interfaces:
Index<Key,Value>
Direct Known Subclasses:
PListImpl

public class ListIndex<Key,Value>
extends Object
implements Index<Key,Value>


Field Summary
protected  long headPageId
           
protected  AtomicBoolean loaded
           
static long NOT_SET
           
protected  PageFile pageFile
           
protected  long tailPageId
           
 
Constructor Summary
ListIndex()
           
ListIndex(PageFile pageFile, long headPageId)
           
ListIndex(PageFile pageFile, Page page)
           
 
Method Summary
 Value add(Transaction tx, Key key, Value value)
           
 Value addFirst(Transaction tx, Key key, Value value)
           
 void clear(Transaction tx)
          clear the index
 boolean containsKey(Transaction tx, Key key)
           
 ListNode<Key,Value> createNode(Transaction tx)
           
 Value get(Transaction tx, Key key)
           
 Map.Entry<Key,Value> getFirst(Transaction tx)
           
protected  ListNode<Key,Value> getHead(Transaction tx)
           
 long getHeadPageId()
           
 Marshaller<Key> getKeyMarshaller()
           
 Map.Entry<Key,Value> getLast(Transaction tx)
           
 PageFile getPageFile()
           
protected  ListNode<Key,Value> getTail(Transaction tx)
           
 long getTailPageId()
           
 Marshaller<Value> getValueMarshaller()
           
 boolean isEmpty(Transaction tx)
           
 boolean isTransient()
           
 Iterator<Map.Entry<Key,Value>> iterator(Transaction tx)
           
 Iterator<Map.Entry<Key,Value>> iterator(Transaction tx, long initialPosition)
           
 Iterator<ListNode<Key,Value>> listNodeIterator(Transaction tx)
           
 void load(Transaction tx)
          load indexes
 void onRemove()
           
 Value put(Transaction tx, Key key, Value value)
          Update the value of the item with the given key in the list if ot exists, otherwise it appends the value to the end of the list.
 Value remove(Transaction tx, Key key)
          remove the index key
 void setHeadPageId(long headPageId)
           
 void setKeyMarshaller(Marshaller<Key> keyMarshaller)
          Set the marshaller for key objects
 void setPageFile(PageFile pageFile)
           
 void setTailPageId(long tailPageId)
           
 void setValueMarshaller(Marshaller<Value> valueMarshaller)
          Set the marshaller for key objects
 long size()
           
 void storeNode(Transaction tx, ListNode<Key,Value> node, boolean overflow)
           
 void unload(Transaction tx)
          unload indexes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_SET

public static final long NOT_SET
See Also:
Constant Field Values

pageFile

protected PageFile pageFile

headPageId

protected long headPageId

tailPageId

protected long tailPageId

loaded

protected AtomicBoolean loaded
Constructor Detail

ListIndex

public ListIndex()

ListIndex

public ListIndex(PageFile pageFile,
                 long headPageId)

ListIndex

public ListIndex(PageFile pageFile,
                 Page page)
Method Detail

load

public void load(Transaction tx)
          throws IOException
Description copied from interface: Index
load indexes

Specified by:
load in interface Index<Key,Value>
Throws:
IOException

unload

public void unload(Transaction tx)
Description copied from interface: Index
unload indexes

Specified by:
unload in interface Index<Key,Value>

getHead

protected ListNode<Key,Value> getHead(Transaction tx)
                               throws IOException
Throws:
IOException

getTail

protected ListNode<Key,Value> getTail(Transaction tx)
                               throws IOException
Throws:
IOException

containsKey

public boolean containsKey(Transaction tx,
                           Key key)
                    throws IOException
Specified by:
containsKey in interface Index<Key,Value>
Returns:
true if it contains the key
Throws:
IOException

get

public Value get(Transaction tx,
                 Key key)
          throws IOException
Specified by:
get in interface Index<Key,Value>
Returns:
the entry
Throws:
IOException

put

public Value put(Transaction tx,
                 Key key,
                 Value value)
          throws IOException
Update the value of the item with the given key in the list if ot exists, otherwise it appends the value to the end of the list.

Specified by:
put in interface Index<Key,Value>
Returns:
the old value contained in the list if one exists or null.
Throws:
IOException

add

public Value add(Transaction tx,
                 Key key,
                 Value value)
          throws IOException
Throws:
IOException

addFirst

public Value addFirst(Transaction tx,
                      Key key,
                      Value value)
               throws IOException
Throws:
IOException

remove

public Value remove(Transaction tx,
                    Key key)
             throws IOException
Description copied from interface: Index
remove the index key

Specified by:
remove in interface Index<Key,Value>
Returns:
StoreEntry removed
Throws:
IOException

onRemove

public void onRemove()

isTransient

public boolean isTransient()
Specified by:
isTransient in interface Index<Key,Value>
Returns:
true if the index is transient

clear

public void clear(Transaction tx)
           throws IOException
Description copied from interface: Index
clear the index

Specified by:
clear in interface Index<Key,Value>
Throws:
IOException

listNodeIterator

public Iterator<ListNode<Key,Value>> listNodeIterator(Transaction tx)
                                               throws IOException
Throws:
IOException

isEmpty

public boolean isEmpty(Transaction tx)
                throws IOException
Throws:
IOException

iterator

public Iterator<Map.Entry<Key,Value>> iterator(Transaction tx)
                                        throws IOException
Specified by:
iterator in interface Index<Key,Value>
Returns:
Throws:
IOException

iterator

public Iterator<Map.Entry<Key,Value>> iterator(Transaction tx,
                                               long initialPosition)
                                        throws IOException
Throws:
IOException

getFirst

public Map.Entry<Key,Value> getFirst(Transaction tx)
                              throws IOException
Throws:
IOException

getLast

public Map.Entry<Key,Value> getLast(Transaction tx)
                             throws IOException
Throws:
IOException

createNode

public ListNode<Key,Value> createNode(Transaction tx)
                               throws IOException
Throws:
IOException

storeNode

public void storeNode(Transaction tx,
                      ListNode<Key,Value> node,
                      boolean overflow)
               throws IOException
Throws:
IOException

getPageFile

public PageFile getPageFile()

setPageFile

public void setPageFile(PageFile pageFile)

getHeadPageId

public long getHeadPageId()

setHeadPageId

public void setHeadPageId(long headPageId)

getKeyMarshaller

public Marshaller<Key> getKeyMarshaller()

setKeyMarshaller

public void setKeyMarshaller(Marshaller<Key> keyMarshaller)
Description copied from interface: Index
Set the marshaller for key objects

Specified by:
setKeyMarshaller in interface Index<Key,Value>

getValueMarshaller

public Marshaller<Value> getValueMarshaller()

setValueMarshaller

public void setValueMarshaller(Marshaller<Value> valueMarshaller)
Description copied from interface: Index
Set the marshaller for key objects

Specified by:
setValueMarshaller in interface Index<Key,Value>

setTailPageId

public void setTailPageId(long tailPageId)

getTailPageId

public long getTailPageId()

size

public long size()


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