org.netbeans.mdr.persistence.btreeimpl.btreeindex
Class MultivaluedBtree

java.lang.Object
  extended by org.netbeans.mdr.persistence.btreeimpl.btreeindex.Btree
      extended by org.netbeans.mdr.persistence.btreeimpl.btreeindex.MultivaluedBtree
All Implemented Interfaces:
Index, MultivaluedIndex, StorageClient, Streamable
Direct Known Subclasses:
MultivaluedOrderedBtree

public class MultivaluedBtree
extends Btree
implements MultivaluedIndex

Btree implementation of MultivaluedIndex interface.

Version:
1.0
Author:
Dana Bergen

Field Summary
 
Fields inherited from class org.netbeans.mdr.persistence.btreeimpl.btreeindex.Btree
dataInfo, dataLength, dataType, hasBigKeys, keyInfo, keyType, name, pageIdLength, pageSize, pageSource, rootPageId, storage, uniqueKeys, uniqueValues
 
Constructor Summary
MultivaluedBtree()
           
MultivaluedBtree(java.lang.String name, Storage.EntryType keyType, Storage.EntryType dataType, boolean uniqueValues, BtreePageSource pageSource)
           
 
Method Summary
 void add(java.lang.Object key, java.lang.Object data)
          Add a new entry to the index.
 java.util.Collection getItems(java.lang.Object key)
          Returns a collection view of the values associated in the index with specified key.
 java.util.Collection getObjects(java.lang.Object key, SinglevaluedIndex repos)
          Like getItems, but if the values in the index are a key type, returns the objects associated with the keys.
protected  void init()
           
 boolean isUnique()
          If true, the collection of values is constrained to hold no more than one of any value.
 java.util.Collection queryByKeyPrefix(java.lang.Object prefix, SinglevaluedIndex primaryIndex)
          Returns list of BtreeEntryImpl key-value pairs, where key contains the queried prefix.
 boolean remove(java.lang.Object key)
          Remove all entries associated with the specified key.
 boolean remove(java.lang.Object key, java.lang.Object value)
          Removes the first occurrence of the specified element in the list of values associated with the specified key.
protected  void updateKeyModCount(java.lang.Object key)
          Checks if an instance of BtreeListByKey related to key is in cache, if so, increases list's modification counter.
 
Methods inherited from class org.netbeans.mdr.persistence.btreeimpl.btreeindex.Btree
beginRead, beginWrite, btreePut, consistencyCheck, dumpTree, endRead, endWrite, getKeyType, getName, getValueType, keySet, pageFactory, read, setStorage, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.netbeans.mdr.persistence.Index
getKeyType, getName, getValueType, keySet
 

Constructor Detail

MultivaluedBtree

public MultivaluedBtree(java.lang.String name,
                        Storage.EntryType keyType,
                        Storage.EntryType dataType,
                        boolean uniqueValues,
                        BtreePageSource pageSource)
                 throws StorageException
Throws:
StorageException

MultivaluedBtree

public MultivaluedBtree()
Method Detail

init

protected void init()
             throws StorageException
Overrides:
init in class Btree
Throws:
StorageException

getItems

public java.util.Collection getItems(java.lang.Object key)
                              throws StorageException
Returns a collection view of the values associated in the index with specified key. Returned collection is read only and may not be modified. If there are no values associated with the key empty collection is returned.

Specified by:
getItems in interface MultivaluedIndex
Parameters:
key -
Returns:
Throws:
StorageException

getObjects

public java.util.Collection getObjects(java.lang.Object key,
                                       SinglevaluedIndex repos)
                                throws StorageException
Like getItems, but if the values in the index are a key type, returns the objects associated with the keys.

Specified by:
getObjects in interface MultivaluedIndex
Parameters:
key -
repos - where to look objetcs up
Returns:
Throws:
StorageException

isUnique

public boolean isUnique()
If true, the collection of values is constrained to hold no more than one of any value.

Specified by:
isUnique in interface MultivaluedIndex
Returns:
Throws:
StorageException

remove

public boolean remove(java.lang.Object key,
                      java.lang.Object value)
               throws StorageException
Removes the first occurrence of the specified element in the list of values associated with the specified key.

Specified by:
remove in interface MultivaluedIndex
Parameters:
key -
value -
Returns:
true if this index changed as a result of this call
Throws:
StorageException

add

public void add(java.lang.Object key,
                java.lang.Object data)
         throws StorageException
Description copied from class: Btree
Add a new entry to the index.

Specified by:
add in interface Index
Overrides:
add in class Btree
Parameters:
key - key to insert
data - data associated with key
Throws:
StorageBadRequestException - If key or data are incorrect type, or if the insert would violate the constraints of this index
StorageException - If a problem was encountered accessing storage

remove

public boolean remove(java.lang.Object key)
               throws StorageException
Description copied from class: Btree
Remove all entries associated with the specified key.

Specified by:
remove in interface Index
Overrides:
remove in class Btree
Parameters:
key - key for entry to be removed
Returns:
true if a matching entry was found
Throws:
StorageException - If there was a problem reading or writing pages

queryByKeyPrefix

public java.util.Collection queryByKeyPrefix(java.lang.Object prefix,
                                             SinglevaluedIndex primaryIndex)
                                      throws StorageException
Returns list of BtreeEntryImpl key-value pairs, where key contains the queried prefix.

Specified by:
queryByKeyPrefix in interface MultivaluedIndex
Parameters:
prefix - queried prefix
primaryIndex - primary index
Returns:
Throws:
StorageException

updateKeyModCount

protected void updateKeyModCount(java.lang.Object key)
Checks if an instance of BtreeListByKey related to key is in cache, if so, increases list's modification counter.



Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.