com.netflix.astyanax.mapping
Class MappingUtil

java.lang.Object
  extended by com.netflix.astyanax.mapping.MappingUtil

public class MappingUtil
extends Object

Higher level mapping functions. Methods that behave similar to a Map.


Constructor Summary
MappingUtil(Keyspace keyspace)
           
MappingUtil(Keyspace keyspace, AnnotationSet<?,?> annotationSet)
           
MappingUtil(Keyspace keyspace, MappingCache cache)
           
MappingUtil(Keyspace keyspace, MappingCache cache, AnnotationSet<?,?> annotationSet)
           
 
Method Summary
<T,K> T
get(ColumnFamily<K,String> columnFamily, K id, Class<T> itemClass)
          Get the specified item by its key/id
<T,K> List<T>
getAll(ColumnFamily<K,String> columnFamily, Class<T> itemClass)
          Get all rows of the specified item
<T> Mapping<T>
getMapping(Class<T> clazz)
          Return the mapping instance for the given class
<T,K> void
put(ColumnFamily<K,String> columnFamily, T item)
          Add/update the given item
<T,K> void
remove(ColumnFamily<K,String> columnFamily, T item)
          Remove the given item
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MappingUtil

public MappingUtil(Keyspace keyspace)
Parameters:
keyspace - keyspace to use

MappingUtil

public MappingUtil(Keyspace keyspace,
                   AnnotationSet<?,?> annotationSet)
Parameters:
keyspace - keyspace to use
annotationSet - annotation set to use

MappingUtil

public MappingUtil(Keyspace keyspace,
                   MappingCache cache)
Parameters:
keyspace - keyspace to use
cache - cache to use

MappingUtil

public MappingUtil(Keyspace keyspace,
                   MappingCache cache,
                   AnnotationSet<?,?> annotationSet)
Parameters:
keyspace - keyspace to use
cache - cache to use
annotationSet - annotation set to use
Method Detail

remove

public <T,K> void remove(ColumnFamily<K,String> columnFamily,
                         T item)
            throws Exception
Remove the given item

Parameters:
columnFamily - column family of the item
item - the item to remove
Throws:
Exception - errors

put

public <T,K> void put(ColumnFamily<K,String> columnFamily,
                      T item)
         throws Exception
Add/update the given item

Parameters:
columnFamily - column family of the item
item - the item to add/update
Throws:
Exception - errors

get

public <T,K> T get(ColumnFamily<K,String> columnFamily,
                   K id,
                   Class<T> itemClass)
      throws Exception
Get the specified item by its key/id

Parameters:
columnFamily - column family of the item
id - id/key of the item
itemClass - item's class
Returns:
new instance with the item's columns propagated
Throws:
Exception - errors

getAll

public <T,K> List<T> getAll(ColumnFamily<K,String> columnFamily,
                            Class<T> itemClass)
               throws Exception
Get all rows of the specified item

Parameters:
columnFamily - column family of the item
itemClass - item's class
Returns:
new instances with the item's columns propagated
Throws:
Exception - errors

getMapping

public <T> Mapping<T> getMapping(Class<T> clazz)
Return the mapping instance for the given class

Parameters:
clazz - the class
Returns:
mapping instance (new or from cache)


Copyright © 2012. All Rights Reserved.