org.netbeans.mdr.persistence.btreeimpl.btreestorage
Class BtreeStorage

java.lang.Object
  extended by org.netbeans.mdr.persistence.btreeimpl.btreestorage.BtreeStorage
All Implemented Interfaces:
Storage

public class BtreeStorage
extends java.lang.Object
implements Storage

This class implements Storage using Btree files. Almost all implementation is in BtreeDatabase, which see.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.netbeans.mdr.persistence.Storage
Storage.EntryType
 
Constructor Summary
BtreeStorage(java.lang.String name)
          Create a BtreeStorage object.
 
Method Summary
 void close()
          close the btree repository.
 void commitChanges()
          Save all objects changed since this method was last call.
 void create(boolean replace, ObjectResolver resolver)
          Create btree repository
 MultivaluedIndex createMultivaluedIndex(java.lang.String name, Storage.EntryType keyType, Storage.EntryType valueType, boolean unique)
          Create index that hold a set of values for each key.
 MultivaluedOrderedIndex createMultivaluedOrderedIndex(java.lang.String name, Storage.EntryType keyType, Storage.EntryType valueType, boolean unique)
          Create index that holds sorted set of values for each key.
 SinglevaluedIndex createSinglevaluedIndex(java.lang.String name, Storage.EntryType keyType, Storage.EntryType valueType)
          Create index that holds exactly one value for each key.
 boolean delete()
          delete the btree repository.
 void dropIndex(java.lang.String name)
          Delete index.
 boolean exists()
          determine if the btree currently exists
 Index getIndex(java.lang.String name)
          Retrieve index by name.
 byte[] getMOFIDData(MOFID mofid)
           
 MofidGenerator getMofidGenerator()
          Return the MOFID generator for this repository
 java.util.Map getMofidMap()
          Return the map of MOFID UUIDs we know about
 MultivaluedIndex getMultivaluedIndex(java.lang.String name)
          Retrieve index by name.
 MultivaluedOrderedIndex getMultivaluedOrderedIndex(java.lang.String name)
          Retrieve index by name.
 java.lang.String getName()
          Return our name
 SinglevaluedIndex getPrimaryIndex()
          Return the primary index (the BtreeDatabase)
 long getSerialNumber()
           
 SinglevaluedIndex getSinglevaluedIndex(java.lang.String name)
          Retrieve index by name.
 java.lang.String getStorageId()
          Returns storage id
 java.lang.String numberToStorageId(int number)
          Resolves external storage number coded by an integer.
 void objectStateChanged(java.lang.Object key)
          Notify the Storage that state of the object was changed.
 void objectStateWillChange(java.lang.Object key)
          Notify the Storage that state of the object will be changed.
 void open(boolean createIfNoExist, ObjectResolver resolver)
          Open a btree MDR
 MOFID readMOFID(java.io.InputStream inputStream)
          Reads a MOFID from Storage, must be called in the streamable read context.
 MOFID readMOFIDData(java.io.InputStream in)
           
 java.lang.Object resolveObject(MOFID key)
          Delegates resolving of external mof ids on the object resolver.
 void rollBackChanges()
          Discard all changes since commitChanges() method was last called.
 void shutDown()
          Shutdowns btree databes (i.e.
 int storageIdToNumber(java.lang.String storageId)
          Maps an external storage prefix to integer.
 boolean supportsMultipleStorableIndexes()
          Returns true if the storage supports more than one index with type Entrytype.STREAMABLE
 void writeMOFID(java.io.OutputStream outputStream, MOFID mofId)
          Writes a MOFID into Storage, must be called in the streamable write context.
 void writeMOFIDData(java.io.OutputStream out, MOFID mofid)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BtreeStorage

public BtreeStorage(java.lang.String name)
Create a BtreeStorage object. Note that this does not create or open the Btree repository

Parameters:
name - the name of the btree. This will be the base name for the btree files
Method Detail

getName

public java.lang.String getName()
Return our name

Specified by:
getName in interface Storage

getStorageId

public java.lang.String getStorageId()
Returns storage id

Specified by:
getStorageId in interface Storage

getSerialNumber

public long getSerialNumber()
Specified by:
getSerialNumber in interface Storage

exists

public boolean exists()
determine if the btree currently exists

Specified by:
exists in interface Storage
Returns:
true if it exists

delete

public boolean delete()
               throws StorageException
delete the btree repository.

Specified by:
delete in interface Storage
Returns:
true if, at method end, there is no repository. false if the repository exists but could not be deleted for any reason
Throws:
StorageException

create

public void create(boolean replace,
                   ObjectResolver resolver)
            throws StorageException
Create btree repository

Specified by:
create in interface Storage
Parameters:
replace - whether to replace an existing repository
Throws:
StorageException - on any error creating the repository

open

public void open(boolean createIfNoExist,
                 ObjectResolver resolver)
          throws StorageException
Open a btree MDR

Specified by:
open in interface Storage
Parameters:
createIfNoExist - whether to create the repository if it doesn't exist
Throws:
StorageException - on any error opening or creating the repository

close

public void close()
           throws StorageException
close the btree repository. This does not commit any outstanding changes.

Specified by:
close in interface Storage
Throws:
StorageException

getPrimaryIndex

public SinglevaluedIndex getPrimaryIndex()
                                  throws StorageException
Return the primary index (the BtreeDatabase)

Specified by:
getPrimaryIndex in interface Storage
Throws:
StorageException

createSinglevaluedIndex

public SinglevaluedIndex createSinglevaluedIndex(java.lang.String name,
                                                 Storage.EntryType keyType,
                                                 Storage.EntryType valueType)
                                          throws StorageException
Create index that holds exactly one value for each key.

Specified by:
createSinglevaluedIndex in interface Storage
Parameters:
name - name of the index
keyType - type of keys in the index
valueType - type of values in the index
Returns:
created index
Throws:
StorageException

createMultivaluedOrderedIndex

public MultivaluedOrderedIndex createMultivaluedOrderedIndex(java.lang.String name,
                                                             Storage.EntryType keyType,
                                                             Storage.EntryType valueType,
                                                             boolean unique)
                                                      throws StorageException
Create index that holds sorted set of values for each key.

Specified by:
createMultivaluedOrderedIndex in interface Storage
Parameters:
name - name of the index
keyType - type of keys in the index
valueType - type of values in the index
unique - true if values associated with one key do not contain duplicates
Returns:
created index
Throws:
StorageException

createMultivaluedIndex

public MultivaluedIndex createMultivaluedIndex(java.lang.String name,
                                               Storage.EntryType keyType,
                                               Storage.EntryType valueType,
                                               boolean unique)
                                        throws StorageException
Create index that hold a set of values for each key. Elements in one Multivalued are not sorted. Set does not contain duplicate values.

Specified by:
createMultivaluedIndex in interface Storage
Parameters:
name - name of the index
keyType - type of keys in the index
valueType - type of values in the index
unique - true if values associated with one key do not contain duplicates
Returns:
created index
Throws:
StorageException

getIndex

public Index getIndex(java.lang.String name)
               throws StorageException
Retrieve index by name.

Specified by:
getIndex in interface Storage
Parameters:
name - name of the index
Returns:
index of the specified name
Throws:
StorageException

getSinglevaluedIndex

public SinglevaluedIndex getSinglevaluedIndex(java.lang.String name)
                                       throws StorageException
Retrieve index by name.

Specified by:
getSinglevaluedIndex in interface Storage
Parameters:
name - name of the index
Returns:
index of the specified name and type
Throws:
StorageException

getMultivaluedIndex

public MultivaluedIndex getMultivaluedIndex(java.lang.String name)
                                     throws StorageException
Retrieve index by name.

Specified by:
getMultivaluedIndex in interface Storage
Parameters:
name - name of the index
Returns:
index of the specified name and type
Throws:
StorageException

getMultivaluedOrderedIndex

public MultivaluedOrderedIndex getMultivaluedOrderedIndex(java.lang.String name)
                                                   throws StorageException
Retrieve index by name.

Specified by:
getMultivaluedOrderedIndex in interface Storage
Parameters:
name - name of the index
Returns:
index of the specified name and type
Throws:
StorageException

dropIndex

public void dropIndex(java.lang.String name)
               throws StorageException
Delete index.

Specified by:
dropIndex in interface Storage
Parameters:
name - name of the index
Throws:
StorageException

objectStateWillChange

public void objectStateWillChange(java.lang.Object key)
                           throws StorageException
Notify the Storage that state of the object will be changed.

Specified by:
objectStateWillChange in interface Storage
Parameters:
key - key of object that will be changed
Throws:
StorageException

objectStateChanged

public void objectStateChanged(java.lang.Object key)
                        throws StorageException
Notify the Storage that state of the object was changed.

Specified by:
objectStateChanged in interface Storage
Parameters:
key - key of object that was changed
Throws:
StorageException

commitChanges

public void commitChanges()
                   throws StorageException
Save all objects changed since this method was last call. This operation implements transactions on the storage. It must either whole complete or whole fail.

Specified by:
commitChanges in interface Storage
Throws:
StorageException

rollBackChanges

public void rollBackChanges()
                     throws StorageException
Discard all changes since commitChanges() method was last called. This operation implements transactions on the storage. It must either whole complete or whole fail. Note that, after this method completes, the persistent MDR and any modified objects in memory are inconsistent, so it should be followed shortly by program exit.

Specified by:
rollBackChanges in interface Storage
Throws:
StorageException

shutDown

public void shutDown()
              throws StorageException
Shutdowns btree databes (i.e. flushes cached commited data in transaction cache).

Specified by:
shutDown in interface Storage
Throws:
StorageException

supportsMultipleStorableIndexes

public boolean supportsMultipleStorableIndexes()
Returns true if the storage supports more than one index with type Entrytype.STREAMABLE

Returns:
true if the storage supports more than one index with type Entrytype.STREAMABLE

writeMOFID

public void writeMOFID(java.io.OutputStream outputStream,
                       MOFID mofId)
                throws StorageException
Description copied from interface: Storage
Writes a MOFID into Storage, must be called in the streamable write context.

Specified by:
writeMOFID in interface Storage
Throws:
StorageException

writeMOFIDData

public final void writeMOFIDData(java.io.OutputStream out,
                                 MOFID mofid)
                          throws StorageException
Throws:
StorageException

getMOFIDData

public final byte[] getMOFIDData(MOFID mofid)
                          throws StorageException
Throws:
StorageException

readMOFID

public MOFID readMOFID(java.io.InputStream inputStream)
                throws StorageException
Description copied from interface: Storage
Reads a MOFID from Storage, must be called in the streamable read context.

Specified by:
readMOFID in interface Storage
Returns:
MOFID red object
Throws:
StorageException

readMOFIDData

public final MOFID readMOFIDData(java.io.InputStream in)
                          throws StorageException
Throws:
StorageException

getMofidGenerator

public MofidGenerator getMofidGenerator()
Return the MOFID generator for this repository


getMofidMap

public java.util.Map getMofidMap()
Return the map of MOFID UUIDs we know about


storageIdToNumber

public int storageIdToNumber(java.lang.String storageId)
                      throws StorageException
Maps an external storage prefix to integer.

Throws:
StorageException

numberToStorageId

public java.lang.String numberToStorageId(int number)
                                   throws StorageException
Resolves external storage number coded by an integer.

Throws:
StorageException

resolveObject

public java.lang.Object resolveObject(MOFID key)
                               throws StorageException
Delegates resolving of external mof ids on the object resolver.

Throws:
StorageException


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