ozone core API

org.ozoneDB.core.storage.gammaStore
Class IndexNode

java.lang.Object
  extended byorg.ozoneDB.core.storage.gammaStore.IndexNode
All Implemented Interfaces:
java.io.Serializable, Storable
Direct Known Subclasses:
IndexBranchNode, IndexLeafNode

public abstract class IndexNode
extends java.lang.Object
implements Storable

Index nodes are the nodes that make up the tree used for storing information on where objects can be found (cluster + location). Because memory is limited, it is impossible to have all index nodes in memory under all circumstances. Therefor there are no hard references to other index nodes but only ids are stored.

There is not much logic here, most logic is in IndexManager.

Version:
$Id: IndexNode.java,v 1.4 2004/02/01 20:55:47 leomekenkamp Exp $
Author:
Leo Mekenkamp (mind the anti sp@m)
See Also:
Serialized Form

Field Summary
private  boolean dirty
          indicates a change which requires a write to storage when finalized
private  IndexManager indexManager
          Index manager this instance is in.
private static java.lang.String INDEXNODENAMESUFFIX
          used for StorageFactory instances
private  int invoked
           
protected static java.util.logging.Logger log
           
static long LONGNULL
          alternative null value
static long MAXOBJECTID
           
private  int maxSize
          maximum number of subnodes or object entries
static long MINOBJECTID
           
private static int NAMECONVERTRADIX
          Used to name indexfiles.
private  long nextNodeId
          sibling node in the tree
private  long nodeId
          our id
private  long parentNodeId
          parent in the tree
private  long prevNodeId
          sibling node in the tree
private static java.lang.ThreadLocal readBufHolder
          Read buffer for instantiating new index nodes from storage.
private static long serialVersionUID
           
 
Constructor Summary
protected IndexNode(IndexManager indexManager)
          Constructor for an index node.
 
Method Summary
(package private)  void endInvoke()
           
protected  void finalize()
           
protected  IndexManager getIndexManager()
          Returns the index manager that is 'managing' this tree.
(package private) abstract  long getMaxObjectId()
          Returns the maximum object id that can be found be in this node
(package private)  int getMaxSize()
           
(package private) abstract  long getMinObjectId()
          Returns the minimum object id that can be found be in this node
(package private)  IndexNode getNextNode()
           
(package private)  long getNextNodeId()
           
(package private)  long getNodeId()
           
(package private)  IndexBranchNode getParentNode()
           
(package private)  long getParentNodeId()
           
(package private)  IndexNode getPrevNode()
           
(package private)  long getPrevNodeId()
           
 java.lang.String getStorageName()
          Returnes the filename that this node can be saved to, or to be more precise: the name that can be used by a StorageFactory to create a unique Storable.
(package private)  boolean isDirty()
          Indicates if this node has changed since last call to write().
protected  boolean isFull()
          Returns true if there is no more room for new elements, false otherwise
protected  boolean isFull(int withExtraElements)
          Returns true if there is no more room for new elements after the specified number of elements were added, false otherwise
(package private)  boolean isInvoked()
           
(package private) static java.lang.String nodeIdToStorageName(long nodeId)
          Converts a node id to corresponding (file)name for a node.
(package private) static IndexNode read(IndexManager indexManager, long nodeId)
          Factory method to create a node by reading it from the storage used for index nodes by the specified index manager.
(package private)  float relSize()
          Returns the relative size of this node, on a scale of [0 .. 1]
(package private)  void setDirty()
           
(package private)  void setDirty(boolean dirty)
           
protected  void setIndexManager(IndexManager indexManager)
          Sets the index manager that is 'managing' this tree.
protected  void setMaxSize(int maxSize)
           
(package private)  void setNextNode(IndexNode next)
           
(package private)  void setNextNodeId(long nextNodeId)
           
(package private)  void setParentNode(IndexBranchNode parent)
          Only ment to be called from IndexBranchNode.putChildNode(IndexNode).
(package private)  void setParentNodeId(long parentNodeId)
           
(package private)  void setPrevNode(IndexNode prev)
           
(package private)  void setPrevNodeId(long prevNodeId)
           
protected abstract  int size()
          Returns the number of elements in this node.
(package private)  void startInvoke()
           
(package private) static long storageNameToNodeId(java.lang.String indexFilename)
          Converts an index (file)name to its corresponding node id
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

log

protected static final java.util.logging.Logger log

LONGNULL

public static final long LONGNULL
alternative null value

See Also:
Constant Field Values

MINOBJECTID

public static final long MINOBJECTID
See Also:
Constant Field Values

MAXOBJECTID

public static final long MAXOBJECTID
See Also:
Constant Field Values

INDEXNODENAMESUFFIX

private static final java.lang.String INDEXNODENAMESUFFIX
used for StorageFactory instances

See Also:
Constant Field Values

NAMECONVERTRADIX

private static final int NAMECONVERTRADIX

Used to name indexfiles. We could take any value from 2 to Character.MAX_RADIX (36) here, but we settle for 16 because it looks nice and nerdy. 36 would look less nice because that would inevitably lead to filenames with very nasty words in them, like fuck.idxnode and microsoft.idxnode.

Before you know it, someone sues you for trademark infringement.

Insiders joke: CAFEBABE is not a trademark, is she?

See Also:
Constant Field Values

readBufHolder

private static java.lang.ThreadLocal readBufHolder
Read buffer for instantiating new index nodes from storage.


nodeId

private long nodeId
our id


parentNodeId

private long parentNodeId
parent in the tree


maxSize

private int maxSize
maximum number of subnodes or object entries


dirty

private transient boolean dirty
indicates a change which requires a write to storage when finalized


prevNodeId

private long prevNodeId
sibling node in the tree


nextNodeId

private long nextNodeId
sibling node in the tree


indexManager

private transient IndexManager indexManager
Index manager this instance is in. Set by constructor and/or read() factory method.


invoked

private transient int invoked
Constructor Detail

IndexNode

protected IndexNode(IndexManager indexManager)
Constructor for an index node. Extending classes should place themselves in its index managers cache.

Parameters:
indexManager - manages this instance
Method Detail

getIndexManager

protected IndexManager getIndexManager()
Returns the index manager that is 'managing' this tree.

Returns:
IndexManager manager this instance is in

setIndexManager

protected void setIndexManager(IndexManager indexManager)
Sets the index manager that is 'managing' this tree. Also deletes image from storage if necessary.

Parameters:
indexManager - manager this instance is in

toString

public java.lang.String toString()

isDirty

final boolean isDirty()
Indicates if this node has changed since last call to write().


setDirty

final void setDirty(boolean dirty)

setDirty

final void setDirty()

nodeIdToStorageName

static java.lang.String nodeIdToStorageName(long nodeId)
Converts a node id to corresponding (file)name for a node.


storageNameToNodeId

static long storageNameToNodeId(java.lang.String indexFilename)
Converts an index (file)name to its corresponding node id


getStorageName

public java.lang.String getStorageName()
Returnes the filename that this node can be saved to, or to be more precise: the name that can be used by a StorageFactory to create a unique Storable.

Specified by:
getStorageName in interface Storable

read

static IndexNode read(IndexManager indexManager,
                      long nodeId)
               throws java.io.IOException
Factory method to create a node by reading it from the storage used for index nodes by the specified index manager.

Parameters:
indexManager - index manager that manages this instance
nodeId - id of the node to be read
Throws:
java.io.IOException

size

protected abstract int size()
Returns the number of elements in this node.

Returns:
number of elements in this node

isFull

protected final boolean isFull()
Returns true if there is no more room for new elements, false otherwise

Returns:
true if this node is full, false otherwise

isFull

protected final boolean isFull(int withExtraElements)
Returns true if there is no more room for new elements after the specified number of elements were added, false otherwise

Returns:
true if this node (+ specified extra) is full, false otherwise

relSize

final float relSize()
Returns the relative size of this node, on a scale of [0 .. 1]


setMaxSize

protected final void setMaxSize(int maxSize)
Throws:
java.lang.IllegalStateException - when called for the second time

getMaxSize

final int getMaxSize()

getMinObjectId

abstract long getMinObjectId()
Returns the minimum object id that can be found be in this node


getMaxObjectId

abstract long getMaxObjectId()
Returns the maximum object id that can be found be in this node


getNodeId

final long getNodeId()

getParentNodeId

final long getParentNodeId()

setParentNodeId

final void setParentNodeId(long parentNodeId)

setParentNode

final void setParentNode(IndexBranchNode parent)
Only ment to be called from IndexBranchNode.putChildNode(IndexNode).


getParentNode

final IndexBranchNode getParentNode()

getPrevNodeId

final long getPrevNodeId()

getPrevNode

final IndexNode getPrevNode()

setPrevNodeId

final void setPrevNodeId(long prevNodeId)

setPrevNode

final void setPrevNode(IndexNode prev)

getNextNodeId

final long getNextNodeId()

getNextNode

final IndexNode getNextNode()

setNextNodeId

final void setNextNodeId(long nextNodeId)

setNextNode

final void setNextNode(IndexNode next)

startInvoke

final void startInvoke()

endInvoke

final void endInvoke()

isInvoked

final boolean isInvoked()

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable

ozone core API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.