voldemort.store.mysql
Class MysqlStorageEngine

java.lang.Object
  extended by voldemort.store.mysql.MysqlStorageEngine
All Implemented Interfaces:
StorageEngine<ByteArray,byte[]>, Store<ByteArray,byte[]>

public class MysqlStorageEngine
extends java.lang.Object
implements StorageEngine<ByteArray,byte[]>

A StorageEngine that uses Mysql for persistence


Constructor Summary
MysqlStorageEngine(java.lang.String name, javax.sql.DataSource datasource)
           
 
Method Summary
 void close()
          Close the store.
 void create()
           
 boolean delete(ByteArray key, Version maxVersion)
          Delete all entries prior to the given version
 void destroy()
           
 ClosableIterator<Pair<ByteArray,Versioned<byte[]>>> entries()
          Get an iterator over pairs of entries in the store.
 void execute(java.lang.String query)
           
 java.util.List<Versioned<byte[]>> get(ByteArray key)
          Get the value associated with the given key
 java.util.Map<ByteArray,java.util.List<Versioned<byte[]>>> getAll(java.lang.Iterable<ByteArray> keys)
          Get the values associated with the given keys and returns them in a Map of keys to a list of versioned values.
 java.lang.Object getCapability(StoreCapabilityType capability)
          Get some capability of the store.
 java.lang.String getName()
           
 java.util.List<Version> getVersions(ByteArray key)
           
 ClosableIterator<ByteArray> keys()
          Get an iterator over keys in the store.
 void put(ByteArray key, Versioned<byte[]> value)
          Associate the value with the key and version in this store
 void truncate()
          Truncate all entries in the store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MysqlStorageEngine

public MysqlStorageEngine(java.lang.String name,
                          javax.sql.DataSource datasource)
Method Detail

destroy

public void destroy()

create

public void create()

execute

public void execute(java.lang.String query)

keys

public ClosableIterator<ByteArray> keys()
Description copied from interface: StorageEngine
Get an iterator over keys in the store. Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Specified by:
keys in interface StorageEngine<ByteArray,byte[]>
Returns:
An iterator over the keys in this StorageEngine.

truncate

public void truncate()
Description copied from interface: StorageEngine
Truncate all entries in the store

Specified by:
truncate in interface StorageEngine<ByteArray,byte[]>

entries

public ClosableIterator<Pair<ByteArray,Versioned<byte[]>>> entries()
Description copied from interface: StorageEngine
Get an iterator over pairs of entries in the store. The key is the first element in the pair and the versioned value is the second element. Note that the iterator need not be threadsafe, and that it must be manually closed after use.

Specified by:
entries in interface StorageEngine<ByteArray,byte[]>
Returns:
An iterator over the entries in this StorageEngine.

close

public void close()
           throws PersistenceFailureException
Description copied from interface: Store
Close the store.

Specified by:
close in interface Store<ByteArray,byte[]>
Throws:
PersistenceFailureException

getCapability

public java.lang.Object getCapability(StoreCapabilityType capability)
Description copied from interface: Store
Get some capability of the store. Examples would be the serializer used, or the routing strategy. This provides a mechanism to verify that the store hierarchy has some set of capabilities without knowing the precise layering.

Specified by:
getCapability in interface Store<ByteArray,byte[]>
Parameters:
capability - The capability type to retrieve
Returns:
The given capaiblity

delete

public boolean delete(ByteArray key,
                      Version maxVersion)
               throws PersistenceFailureException
Description copied from interface: Store
Delete all entries prior to the given version

Specified by:
delete in interface Store<ByteArray,byte[]>
Parameters:
key - The key to delete
maxVersion - The current value of the key
Returns:
True if anything was deleted
Throws:
PersistenceFailureException

getAll

public java.util.Map<ByteArray,java.util.List<Versioned<byte[]>>> getAll(java.lang.Iterable<ByteArray> keys)
                                                                  throws VoldemortException
Description copied from interface: Store
Get the values associated with the given keys and returns them in a Map of keys to a list of versioned values. Note that the returned map will only contain entries for the keys which have a value associated with them.

Specified by:
getAll in interface Store<ByteArray,byte[]>
Parameters:
keys - The keys to check for.
Returns:
A Map of keys to a list of versioned values.
Throws:
VoldemortException

get

public java.util.List<Versioned<byte[]>> get(ByteArray key)
                                      throws PersistenceFailureException
Description copied from interface: Store
Get the value associated with the given key

Specified by:
get in interface Store<ByteArray,byte[]>
Parameters:
key - The key to check for
Returns:
The value associated with the key or an empty list if no values are found.
Throws:
PersistenceFailureException

getName

public java.lang.String getName()
Specified by:
getName in interface Store<ByteArray,byte[]>
Returns:
The name of the store.

put

public void put(ByteArray key,
                Versioned<byte[]> value)
         throws PersistenceFailureException
Description copied from interface: Store
Associate the value with the key and version in this store

Specified by:
put in interface Store<ByteArray,byte[]>
Parameters:
key - The key to use
value - The value to store and its version.
Throws:
PersistenceFailureException

getVersions

public java.util.List<Version> getVersions(ByteArray key)
Specified by:
getVersions in interface Store<ByteArray,byte[]>


Jay Kreps