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

java.lang.Object
  extended by org.netbeans.mdr.persistence.btreeimpl.btreeindex.Btree
      extended by org.netbeans.mdr.persistence.btreeimpl.btreeindex.SinglevaluedBtree
All Implemented Interfaces:
Index, SinglevaluedIndex, StorageClient, Streamable

public class SinglevaluedBtree
extends Btree
implements SinglevaluedIndex

Btree implementation of SinglevaluedIndex

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
SinglevaluedBtree()
          No-argument constructor for reconstructing via read().
SinglevaluedBtree(java.lang.String name, Storage.EntryType keyType, Storage.EntryType dataType, BtreePageSource pageSource)
           
 
Method Summary
 java.lang.Object get(java.lang.Object key)
          Return a single object associated with the specified key.
 java.lang.Object getIfExists(java.lang.Object key)
          Return a single object associated with the specified key.
 java.lang.Object getObject(java.lang.Object key, SinglevaluedIndex repos)
          Like get, but if the index contains keys, this returns the object corresponding to the key
 java.lang.Object getObjectIfExists(java.lang.Object key, SinglevaluedIndex repos)
          Like getIfExists, but if the index contains keys, this returns the object corresponding to the key
protected  void init()
           
 boolean put(java.lang.Object key, java.lang.Object data)
          Add a new entry to the index.
 java.util.Collection queryByKeyPrefix(java.lang.Object prefix, SinglevaluedIndex primaryIndex)
          Returns BtreeEntryImpl key-value pairs, where the key contains the queried prefix.
 void replace(java.lang.Object key, java.lang.Object data)
          Replace an index entry.
 java.util.Collection values()
          Return a collection view of this btree's values.
 
Methods inherited from class org.netbeans.mdr.persistence.btreeimpl.btreeindex.Btree
add, beginRead, beginWrite, btreePut, consistencyCheck, dumpTree, endRead, endWrite, getKeyType, getName, getValueType, keySet, pageFactory, read, remove, 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
add, getKeyType, getName, getValueType, keySet, remove
 

Constructor Detail

SinglevaluedBtree

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

SinglevaluedBtree

public SinglevaluedBtree()
No-argument constructor for reconstructing via read(). Only used with Btree's whose pageSource is a BtreeMDRSource.

Method Detail

init

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

getIfExists

public java.lang.Object getIfExists(java.lang.Object key)
                             throws StorageException
Return a single object associated with the specified key.

Specified by:
getIfExists in interface SinglevaluedIndex
Parameters:
key - key for lookup
Returns:
the data stored in the index for that key, or null if not found
Throws:
StorageException - If there was a problem reading pages

getObjectIfExists

public java.lang.Object getObjectIfExists(java.lang.Object key,
                                          SinglevaluedIndex repos)
                                   throws StorageException
Like getIfExists, but if the index contains keys, this returns the object corresponding to the key

Specified by:
getObjectIfExists in interface SinglevaluedIndex
Parameters:
key -
Returns:
Throws:
StorageException

get

public java.lang.Object get(java.lang.Object key)
                     throws StorageException
Return a single object associated with the specified key.

Specified by:
get in interface SinglevaluedIndex
Parameters:
key - key for lookup
Returns:
the data stored in the index for that key
Throws:
StorageException - If no matching item was found, or there was a problem reading pages

getObject

public java.lang.Object getObject(java.lang.Object key,
                                  SinglevaluedIndex repos)
                           throws StorageException
Like get, but if the index contains keys, this returns the object corresponding to the key

Specified by:
getObject in interface SinglevaluedIndex
Parameters:
key -
Returns:
Throws:
StorageException

put

public boolean put(java.lang.Object key,
                   java.lang.Object data)
            throws StorageException
Add a new entry to the index.

Specified by:
put in interface SinglevaluedIndex
Parameters:
key - key to insert
data - data associated with key
Returns:
true if an existing entry was replaced
Throws:
StorageException - If a problem was encountered accessing storage

replace

public void replace(java.lang.Object key,
                    java.lang.Object data)
             throws StorageException
Replace an index entry.

Specified by:
replace in interface SinglevaluedIndex
Parameters:
key - key whose entry is to be replaced
data - new data to be associated with key
Throws:
StorageBadRequestException - If key or data are incorrect type, or if no entry exists matching key.
StorageException - If a problem was encountered accessing storage

values

public java.util.Collection values()
                            throws StorageException
Return a collection view of this btree's values.

Specified by:
values in interface SinglevaluedIndex
Returns:
A collection
Throws:
StorageException

queryByKeyPrefix

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

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


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