voldemort.store.readonly
Class ReadOnlyUtils

java.lang.Object
  extended by voldemort.store.readonly.ReadOnlyUtils

public class ReadOnlyUtils
extends java.lang.Object


Field Summary
static int POSITION_SIZE
           
 
Constructor Summary
ReadOnlyUtils()
           
 
Method Summary
static boolean checkVersionDirName(java.io.File versionDir)
          Checks if the name of the file follows the version-n format
static int chunk(byte[] key, int numChunks)
           
static java.io.File[] findKthVersionedDir(java.io.File[] versionDirs, int start, int end)
          Returns the directories sorted and indexed between [start, end] where start >= 0 and end < len(files)
static int getChunkId(java.lang.String fileName)
          Returns the chunk id for the file name
static java.io.File getCurrentVersion(java.io.File storeDirectory)
          Retrieve the dir pointed to by 'latest' symbolic-link or the current version dir
static java.io.File getLatestDir(java.io.File parentDir)
          Retrieve the directory pointed by latest symbolic link
static Pair<java.lang.Integer,java.lang.Integer> getPartitionReplicaTuple(java.lang.String fileName)
          Given a file name first checks whether it belongs to storage format v2 and then retieves the tuple of out of it.
static java.io.File[] getVersionDirs(java.io.File rootDir)
          Returns all the version directories present in the root directory specified
static java.io.File[] getVersionDirs(java.io.File rootDir, long minId, long maxId)
          Returns all the version directories present in the root directory specified
static long getVersionId(java.io.File versionDir)
          Extracts the version id from the directory
static boolean isFormatCorrect(java.lang.String fileName, ReadOnlyStorageFormat format)
          Given a file name and read-only storage format, tells whether the file name format is correct
static byte[] readKey(java.nio.ByteBuffer index, int indexByteOffset, byte[] foundKey)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSITION_SIZE

public static final int POSITION_SIZE
See Also:
Constant Field Values
Constructor Detail

ReadOnlyUtils

public ReadOnlyUtils()
Method Detail

chunk

public static int chunk(byte[] key,
                        int numChunks)

readKey

public static byte[] readKey(java.nio.ByteBuffer index,
                             int indexByteOffset,
                             byte[] foundKey)

isFormatCorrect

public static boolean isFormatCorrect(java.lang.String fileName,
                                      ReadOnlyStorageFormat format)
Given a file name and read-only storage format, tells whether the file name format is correct

Parameters:
fileName - The name of the file
format - The RO format
Returns:
true if file format is correct, else false

getPartitionReplicaTuple

public static Pair<java.lang.Integer,java.lang.Integer> getPartitionReplicaTuple(java.lang.String fileName)
Given a file name first checks whether it belongs to storage format v2 and then retieves the tuple of out of it.

Parameters:
fileName - The name of the file
Returns:
Pair of partition id to replica type

getChunkId

public static int getChunkId(java.lang.String fileName)
Returns the chunk id for the file name

Parameters:
fileName - The file name
Returns:
Chunk id

getCurrentVersion

public static java.io.File getCurrentVersion(java.io.File storeDirectory)
Retrieve the dir pointed to by 'latest' symbolic-link or the current version dir

Returns:
Current version directory, else null

getLatestDir

public static java.io.File getLatestDir(java.io.File parentDir)
Retrieve the directory pointed by latest symbolic link

Parameters:
parentDir - The root directory
Returns:
The directory pointed to by the latest symbolic link, else null

checkVersionDirName

public static boolean checkVersionDirName(java.io.File versionDir)
Checks if the name of the file follows the version-n format

Parameters:
versionDir - The directory
Returns:
Returns true if the name is correct, else false

getVersionId

public static long getVersionId(java.io.File versionDir)
Extracts the version id from the directory

Parameters:
versionDir - The directory path
Returns:
Returns the version id of the directory, else -1

getVersionDirs

public static java.io.File[] getVersionDirs(java.io.File rootDir)
Returns all the version directories present in the root directory specified

Parameters:
rootDir - The parent directory
Returns:
An array of version directories

getVersionDirs

public static java.io.File[] getVersionDirs(java.io.File rootDir,
                                            long minId,
                                            long maxId)
Returns all the version directories present in the root directory specified

Parameters:
rootDir - The parent directory
maxId - The
Returns:
An array of version directories

findKthVersionedDir

public static java.io.File[] findKthVersionedDir(java.io.File[] versionDirs,
                                                 int start,
                                                 int end)
Returns the directories sorted and indexed between [start, end] where start >= 0 and end < len(files)

TODO: Can be made better using 'selection algorithm'

Parameters:
versionDirs - The list of files to search in
start - Starting index
end - End index
Returns:
Array of files


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu