com.bigdata.mdi
Class LocalPartitionMetadata

java.lang.Object
  extended by com.bigdata.mdi.LocalPartitionMetadata
All Implemented Interfaces:
IPartitionMetadata, ISeparatorKeys, Externalizable, Serializable

public class LocalPartitionMetadata
extends Object
implements IPartitionMetadata, Externalizable

An immutable object providing metadata about a local index partition, including the partition identifier, the left and right separator keys defining the half-open key range of the index partition, and optionally defining the IResourceMetadata[] required to materialize a view of that index partition.

Version:
$Id: LocalPartitionMetadata.java 4582 2011-05-31 19:12:53Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form

Field Summary
protected static int MAX_HISTORY_LENGTH
          Deprecated.  
 
Constructor Summary
LocalPartitionMetadata()
          De-serialization constructor.
LocalPartitionMetadata(int partitionId, int sourcePartitionId, byte[] leftSeparatorKey, byte[] rightSeparatorKey, IResourceMetadata[] resources, IndexPartitionCause cause)
           
 
Method Summary
 boolean equals(Object o)
           
 IndexPartitionCause getIndexPartitionCause()
          The reason why an index partition was created together with some metadata about when it was created.
 byte[] getLeftSeparatorKey()
          The separator key that defines the left edge of that index partition (always defined) - this is the first key that can enter the index partition.
 int getPartitionId()
          The unique partition identifier.
 IResourceMetadata[] getResources()
          Description of the resources required to materialize a view of the index partition (optional, but required for a BTree).
 byte[] getRightSeparatorKey()
          The separator key that defines the right edge of that index partition or null iff the index partition does not have a right sibling (a null has the semantics of having no upper bound).
 int getSourcePartitionId()
          Deprecated. MoveTask manages without this field (it was required by the previous MOVE implementation).
 int hashCode()
          Return IPartitionMetadata.getPartitionId()
 void readExternal(ObjectInput in)
           
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_HISTORY_LENGTH

protected static final transient int MAX_HISTORY_LENGTH
Deprecated. 
The maximum length of the history string (4kb).

Note: The history is written each time the IndexMetadata is written and is read each time it is read so this can be the main driver of the size of the IndexMetadata record.

See Also:
Constant Field Values
Constructor Detail

LocalPartitionMetadata

public LocalPartitionMetadata()
De-serialization constructor.


LocalPartitionMetadata

public LocalPartitionMetadata(int partitionId,
                              int sourcePartitionId,
                              byte[] leftSeparatorKey,
                              byte[] rightSeparatorKey,
                              IResourceMetadata[] resources,
                              IndexPartitionCause cause)
Parameters:
partitionId - The unique partition identifier assigned by the MetadataIndex.
sourcePartitionId - -1 unless this index partition is the target for a move, in which case this is the partition identifier of the source index partition.
leftSeparatorKey - The first key that can enter this index partition. The left separator key for the first index partition is always new byte[]{}. The left separator key MAY NOT be null.
rightSeparatorKey - The first key that is excluded from this index partition or null iff there is no upper bound.
resources - A description of each Journal or IndexSegment resource(s) required to compose a view of the index partition (optional).

The entries in the array reflect the creation time of the resources. The earliest resource is listed first. The most recently created resource is listed last.

Note: This is required if the LocalPartitionMetadata record will be saved on the IndexMetadata of a BTree. It is NOT recommended when it will be saved on the IndexMetadata of an IndexSegment. When the IndexMetadata is sent to a remote DataService this field MUST be null and the remote DataService will fill it in on arrival.

cause - The underlying cause for the creation of the index partition.
Method Detail

getPartitionId

public final int getPartitionId()
Description copied from interface: IPartitionMetadata
The unique partition identifier.

Specified by:
getPartitionId in interface IPartitionMetadata

getSourcePartitionId

public final int getSourcePartitionId()
Deprecated. MoveTask manages without this field (it was required by the previous MOVE implementation).

-1 unless this index partition is the target for a move, in which case this is the partition identifier of the source index partition and the move operation has not been completed. This property is used to prevent the target data service from de-defining the index partition using a split, join or move operation while the MOVE operation is proceeding. The property is cleared to -1 (which is an invalid index partition identifier) once the move has been completed successfully.


getLeftSeparatorKey

public final byte[] getLeftSeparatorKey()
Description copied from interface: ISeparatorKeys
The separator key that defines the left edge of that index partition (always defined) - this is the first key that can enter the index partition. The left-most separator key for a scale-out index is always an empty byte[] since that is the smallest key that may be defined.

Specified by:
getLeftSeparatorKey in interface ISeparatorKeys

getRightSeparatorKey

public final byte[] getRightSeparatorKey()
Description copied from interface: ISeparatorKeys
The separator key that defines the right edge of that index partition or null iff the index partition does not have a right sibling (a null has the semantics of having no upper bound).

Specified by:
getRightSeparatorKey in interface ISeparatorKeys

getResources

public final IResourceMetadata[] getResources()
Description of the resources required to materialize a view of the index partition (optional, but required for a BTree).

The entries in the array reflect the creation time of the resources. The earliest resource is listed first. The most recently created resource is listed last. The order of the resources corresponds to the order in which a fused view of the index partition will be read. Reads begin with the most "recent" data for the index partition and stop as soon as there is a "hit" on one of the resources (including a hit on a deleted index entry).

When present, the #of sources in the index partition view includes: the mutable BTree, any BTrees on historical journal(s) still incorporated into the view, and any IndexSegments incorporated into the view.

Note: the IResourceMetadata[] is only available when the LocalPartitionMetadata is attached to the IndexMetadata of a BTree and is NOT defined when the LocalPartitionMetadata is attached to an IndexSegment. The reason is that the index partition view is always described by the BTree and that view evolves as journals overflow. On the other hand, IndexSegments are used as resources in index partition views but exist in a one to many relationship to those views.


getIndexPartitionCause

public final IndexPartitionCause getIndexPartitionCause()
The reason why an index partition was created together with some metadata about when it was created.


hashCode

public final int hashCode()
Description copied from interface: IPartitionMetadata
Return IPartitionMetadata.getPartitionId()

Specified by:
hashCode in interface IPartitionMetadata
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException


Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.