K
- T
- public class CassandraClient<K,T extends PersistentBase> extends Object
CassandraStore.initialize(Class, Class, Properties)
.
CassandraClient deals with Cassandra data model definition, mutation,
and general/specific mappings.org.apache.gora.cassandra.store.CassandraStore#initialize(Class, Class, Properties)}
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_HECTOR_CONSIS_LEVEL
Hector client default column family consistency level.
|
static org.slf4j.Logger |
LOG
The logging implementation
|
Constructor and Description |
---|
CassandraClient() |
Modifier and Type | Method and Description |
---|---|
void |
addColumn(K key,
String fieldName,
Object value)
Insert a field in a column.
|
void |
addGenericArray(K key,
String fieldName,
org.apache.avro.generic.GenericArray<?> array) |
void |
addStatefulHashMap(K key,
String fieldName,
Map<CharSequence,Object> map) |
void |
addSubColumn(K key,
String fieldName,
ByteBuffer columnName,
Object value)
Insert a member in a super column.
|
void |
addSubColumn(K key,
String fieldName,
Integer columnName,
Object value)
Adds an subColumn inside the cassandraMapping file when an Integer is serialized
|
void |
addSubColumn(K key,
String fieldName,
String columnName,
Object value)
Adds an subColumn inside the cassandraMapping file when a String is serialized
|
void |
checkKeyspace()
Check if keyspace already exists.
|
void |
deleteByKey(K key)
Deletes an entry based on its key.
|
void |
deleteColumn(K key,
String familyName,
ByteBuffer columnName)
Delete a row within the keyspace.
|
void |
deleteGenericArray(K key,
String fieldName) |
void |
deleteStatefulHashMap(K key,
String fieldName) |
void |
deleteSubColumn(K key,
String fieldName)
Deletes all subcolumns from a super column.
|
void |
deleteSubColumn(K key,
String fieldName,
ByteBuffer columnName)
Delete a member in a super column.
|
void |
deleteSubColumn(K key,
String fieldName,
String columnName)
Deletes a subColumn
|
void |
dropKeyspace()
Drop keyspace.
|
List<me.prettyprint.hector.api.beans.Row<K,ByteBuffer,ByteBuffer>> |
execute(CassandraQuery<K,T> cassandraQuery,
String family)
Select a family column in the keyspace.
|
List<me.prettyprint.hector.api.beans.SuperRow<K,String,ByteBuffer,ByteBuffer>> |
executeSuper(CassandraQuery<K,T> cassandraQuery,
String family) |
CassandraMapping |
getCassandraMapping()
Retrieves the cassandraMapping which holds whatever was mapped
from the gora-cassandra-mapping.xml
|
Map<String,List<String>> |
getFamilyMap(Query<K,T> query)
Select the families that contain at least one column mapped to a query field.
|
String |
getKeyspaceName()
Obtain Schema/Keyspace name
|
Map<String,String> |
getReverseMap(Query<K,T> query)
Select the field names according to the column names, which format
if fully qualified: "family:column"
|
void |
initialize(Class<K> keyClass,
Class<T> persistentClass)
Method to maintain backward compatibility with earlier versions.
|
void |
initialize(Class<K> keyClass,
Class<T> persistentClass,
Properties properties)
Given our key, persistentClass from
CassandraStore.initialize(Class, Class, Properties)
we make best efforts to dictate our data model. |
boolean |
isSuper(String family)
Determines if a column is a superColumn or not.
|
boolean |
keyspaceExists()
Check if keyspace already exists.
|
ByteBuffer |
toByteBuffer(Object value)
Serialize value to ByteBuffer using
GoraSerializerTypeInferer.getSerializer(Object) . |
public static final org.slf4j.Logger LOG
public static final String DEFAULT_HECTOR_CONSIS_LEVEL
public void initialize(Class<K> keyClass, Class<T> persistentClass) throws Exception
Exception
public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws Exception
CassandraStore.initialize(Class, Class, Properties)
we make best efforts to dictate our data model.
We make a quick check within org.apache.gora.cassandra.store.CassandraClient#checkKeyspace(String)
to see if our keyspace has already been invented, this simple check prevents us from
recreating the keyspace if it already exists.
We then simple specify (based on the input keyclass) an appropriate serializer
via {@link org.apache.gora.cassandra.serializers.GoraSerializerTypeInferer} before
defining a mutator from and by which we can mutate this object.keyClass
- the Key by which we wish o assign a record objectpersistentClass
- the generated org.apache.org.gora.persistency.Peristent
bean representing the data.properties
- key value pairs from gora.propertiesException
public boolean keyspaceExists()
public void checkKeyspace()
ConfigurableConsistencyLevel
logic.
It is set by passing a
ConfigurableConsistencyLevel
object right
when the Keyspace
is created.
If we cannot find a consistency level within gora.properites
,
then column family consistency level is set to QUORUM (by default) which permits
consistency to wait for a quorum of replicas to respond regardless of data center.
QUORUM is Hector Client's default setting and we respect that here as well.http://hector-client.github.io/hector/build/html/content/consistency_level.html
public void dropKeyspace()
public void addColumn(K key, String fieldName, Object value)
key
- the row keyfieldName
- the field namevalue
- the field value.public void deleteColumn(K key, String familyName, ByteBuffer columnName)
key
- fieldName
- columnName
- public void deleteByKey(K key)
key
- public void addSubColumn(K key, String fieldName, ByteBuffer columnName, Object value)
key
- the row keyfieldName
- the field namecolumnName
- the column name (the member name, or the index of array)value
- the member valuepublic void addSubColumn(K key, String fieldName, String columnName, Object value)
key
- the row keyfieldName
- the field namecolumnName
- the column name (the member name, or the index of array)value
- the member valuepublic void addSubColumn(K key, String fieldName, Integer columnName, Object value)
key
- the row keyfieldName
- the field namecolumnName
- the column name (the member name, or the index of array)value
- the member valuepublic void deleteSubColumn(K key, String fieldName, ByteBuffer columnName)
key
- the row keyfieldName
- the field namecolumnName
- the column name (the member name, or the index of array)public void deleteSubColumn(K key, String fieldName, String columnName)
key
- fieldName
- columnName
- public void deleteSubColumn(K key, String fieldName)
key
- the row key.fieldName
- the field name.public void addGenericArray(K key, String fieldName, org.apache.avro.generic.GenericArray<?> array)
public void addStatefulHashMap(K key, String fieldName, Map<CharSequence,Object> map)
public ByteBuffer toByteBuffer(Object value)
GoraSerializerTypeInferer.getSerializer(Object)
.value
- the member value Object
.public List<me.prettyprint.hector.api.beans.Row<K,ByteBuffer,ByteBuffer>> execute(CassandraQuery<K,T> cassandraQuery, String family)
cassandraQuery
- a wrapper of the queryfamily
- the family name to be queriedpublic Map<String,List<String>> getFamilyMap(Query<K,T> query)
query
- indicates the columns to selectpublic CassandraMapping getCassandraMapping()
public Map<String,String> getReverseMap(Query<K,T> query)
query
- public boolean isSuper(String family)
family
- public List<me.prettyprint.hector.api.beans.SuperRow<K,String,ByteBuffer,ByteBuffer>> executeSuper(CassandraQuery<K,T> cassandraQuery, String family)
public String getKeyspaceName()
Copyright © 2010-2015 The Apache Software Foundation. All Rights Reserved.