com.splout.db.common
Class PartitionMap

java.lang.Object
  extended by com.splout.db.common.PartitionMap
All Implemented Interfaces:
java.io.Serializable

public class PartitionMap
extends java.lang.Object
implements java.io.Serializable

A Splout's partition map definition - The generic type is the type of the Key. For example, if a tablespace is partitioned by an Integer then T = Integer.

A partition map is composed by several PartitionEntry. The partition map implements the logic of finding a partition number given a key of type in findPartition(String).

See Also:
Serialized Form

Field Summary
static int NO_PARTITION
           
static org.codehaus.jackson.type.TypeReference<PartitionMap> PARTITION_MAP_REF
           
 
Constructor Summary
PartitionMap()
           
PartitionMap(java.util.List<PartitionEntry> partitionMap)
           
 
Method Summary
static java.util.List<PartitionEntry> adjustEmptyPartitions(java.util.List<PartitionEntry> entries)
          Method that can be used to adjust PartitionEntries that may contain partitions that will become empty.
 int findPartition(java.lang.String keyObj)
          Given a key, return the partition that it belongs to, or NO_PARTITION if none matches.
 java.util.List<java.lang.Integer> findPartitions(java.lang.String minKey, java.lang.String maxKey)
          Given a min and a max key, return all the partitions that impact this range.
 java.util.List<PartitionEntry> getPartitionEntries()
           
static PartitionMap oneShardOpenedMap()
          Use this method for creating a PartitionMap that has only one shard (0) and whose range is -Infinity, +Infinity
 void setPartitionEntries(java.util.List<PartitionEntry> partitionEntries)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PARTITION_MAP_REF

public static final org.codehaus.jackson.type.TypeReference<PartitionMap> PARTITION_MAP_REF

NO_PARTITION

public static int NO_PARTITION
Constructor Detail

PartitionMap

public PartitionMap()

PartitionMap

public PartitionMap(java.util.List<PartitionEntry> partitionMap)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

oneShardOpenedMap

public static PartitionMap oneShardOpenedMap()
Use this method for creating a PartitionMap that has only one shard (0) and whose range is -Infinity, +Infinity


adjustEmptyPartitions

public static java.util.List<PartitionEntry> adjustEmptyPartitions(java.util.List<PartitionEntry> entries)
Method that can be used to adjust PartitionEntries that may contain partitions that will become empty. This may happen if a key spans more than one partition. In that case, because we cannot divide further, we have to create less partitions than desired. So this method may return less partitions than what it receives.


findPartitions

public java.util.List<java.lang.Integer> findPartitions(java.lang.String minKey,
                                                        java.lang.String maxKey)
Given a min and a max key, return all the partitions that impact this range. The semantics of the search are such that all partitions P will be returned such that P.max > minKey and P.min <= maxKey

Note that (null, null) is a valid input to this method and will be interpreted as the whole key range, regardless of the key type (that's why we use null for representing opened ranges).


findPartition

public int findPartition(java.lang.String keyObj)
Given a key, return the partition that it belongs to, or NO_PARTITION if none matches. Mathematically, partitions match [min, max).


setPartitionEntries

public void setPartitionEntries(java.util.List<PartitionEntry> partitionEntries)

getPartitionEntries

public java.util.List<PartitionEntry> getPartitionEntries()


Copyright © 2012-2013 Datasalt Systems S.L.. All Rights Reserved.