com.bigdata.mdi
Class PartitionLocator

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

public class PartitionLocator
extends Object
implements IPartitionMetadata, Externalizable

An immutable object that may be used to locate an index partition. Instances of this class are stored as the values in the MetadataIndex.

Note: The ISeparatorKeys.getLeftSeparatorKey() is always equal to the key under which the PartitionLocator is stored in the metadata index. Likewise, the ISeparatorKeys.getRightSeparatorKey() is always equal to the key under which the successor of the index entry is stored (or null iff there is no successor). However, the left and right separator keys are stored explicitly in the values of the metadata index because it greatly simplifies client operations. While the left separator key is directly obtainable from the key under which the locator was stored, the right separator key is much more difficult to obtain in the various contexts within which the ClientIndexView requires that information.

Version:
$Id: PartitionLocator.java 2265 2009-10-26 12:51:06Z thompsonbry $
Author:
Bryan Thompson
See Also:
Serialized Form
TODO:
write a custom serializer for the MetadataIndex that factors out the left separator key and which uses prefix compression to only write the delta for the right separator key over the left separator key? this would require de-serialization of the partition locator and then re-serialization in a record format which does not include the left separator key, but the aggregate space savings could be quite large. Further space savings could be realized if we simply factored out both keys in the index but delivered the keys to the client when a single partition locator was requested. When a key-range of locators is requested, the space savings again make it worth while to factor out the left/right keys.

Constructor Summary
PartitionLocator()
          De-serialization constructor.
PartitionLocator(int partitionId, UUID logicalDataServiceUUID, byte[] leftSeparatorKey, byte[] rightSeparatorKey)
           
 
Method Summary
 boolean equals(Object o)
           
 UUID getDataServiceUUID()
          The UUID of the (logical) data service on which the index partition resides.
 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.
 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 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
 

Constructor Detail

PartitionLocator

public PartitionLocator()
De-serialization constructor.


PartitionLocator

public PartitionLocator(int partitionId,
                        UUID logicalDataServiceUUID,
                        byte[] leftSeparatorKey,
                        byte[] rightSeparatorKey)
Parameters:
partitionId - The unique partition identifier assigned by the MetadataIndex.
logicalDataServiceUUID - The ordered array of data service identifiers on which data for this partition will be written and from which data for this partition may be read.
leftSeparatorKey - 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.
rightSeparatorKey - 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).
Method Detail

getPartitionId

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

Specified by:
getPartitionId in interface IPartitionMetadata

getDataServiceUUID

public UUID getDataServiceUUID()
The UUID of the (logical) data service on which the index partition resides.


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

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-2009 SYSTAP, LLC. All Rights Reserved.