public class HectorCassandraClient extends Object
Constructor and Description |
---|
HectorCassandraClient(me.prettyprint.cassandra.service.CassandraHostConfigurator config,
String keyspaceName,
String clusterName,
Integer columnFamilyGcGraceSeconds,
CassandraConsistencyLevel readConsistencyLevel,
CassandraConsistencyLevel writeConsistencyLevel) |
Modifier and Type | Method and Description |
---|---|
void |
addIndexesToColumnFamily(String typeName,
List<String> columnNames,
SpaceDocumentColumnFamilyMapper mapper)
Adds a secondary index to the provided columns in the column family matching the provided
typeName.
|
void |
close()
Closes hector's connection pool.
|
void |
createColumnFamilyIfNecessary(ColumnFamilyMetadata metadata,
boolean shouldPersist)
Creates a column family on the configured keyspace if one does not already exist.
|
void |
createMetadataColumnFamilyColumnFamilyIfNecessary() |
ColumnFamilyMetadata |
fetchColumnFamilyMetadata(String typeName,
SpaceDocumentColumnFamilyMapper mapper)
Tries to read from the internal metadata column family, the
ColumnFamilyMetadata
metadata matching the given type name. |
Map<String,ColumnFamilyMetadata> |
getColumnFamiliesMetadata() |
ColumnFamilyMetadata |
getColumnFamilyMetadata(String typeName)
Reads from cache the
ColumnFamilyMetadata instance matching the provided typeName |
CassandraConsistencyLevel |
getReadConsistencyLevel() |
CassandraConsistencyLevel |
getWriteConsistencyLevel() |
void |
performBatchOperation(List<ColumnFamilyRow> rows)
Writes the given
ColumnFamilyRow 's in a mutate operation to the configured keyspace. |
Map<String,ColumnFamilyMetadata> |
populateColumnFamiliesMetadata(SpaceDocumentColumnFamilyMapper mapper)
Reads all the column families metadata for the internal metadata column family into cache.
|
SpaceDocument |
readDocmentByKey(SpaceDocumentColumnFamilyMapper mapper,
String typeName,
Object keyValue)
Reads the entry matching the typeName and key value from the matching column family.
|
Map<Object,SpaceDocument> |
readDocumentsByKeys(SpaceDocumentColumnFamilyMapper mapper,
String typeName,
Object[] keyValues)
Reads the entries matching the typeName and key values from the matching column family.
|
public HectorCassandraClient(me.prettyprint.cassandra.service.CassandraHostConfigurator config, String keyspaceName, String clusterName, Integer columnFamilyGcGraceSeconds, CassandraConsistencyLevel readConsistencyLevel, CassandraConsistencyLevel writeConsistencyLevel)
HectorCassandraClientConfigurer.create()
public void close()
public void createMetadataColumnFamilyColumnFamilyIfNecessary()
public void performBatchOperation(List<ColumnFamilyRow> rows)
ColumnFamilyRow
's in a mutate operation to the configured keyspace.rows
- The ColumnFamilyRow
's to perform the mutate operation on.
Contract: It is assumed that all the rows in the passed list argument belong to
the same column family. Failure to comply with contract will most likely lead to
some data corruption.public void createColumnFamilyIfNecessary(ColumnFamilyMetadata metadata, boolean shouldPersist)
metadata
- The metadata describing the column family to create.shouldPersist
- Should the ColumnFamilyMetadata
instance be persisted to the
internal metadata column family.public void addIndexesToColumnFamily(String typeName, List<String> columnNames, SpaceDocumentColumnFamilyMapper mapper)
typeName
- The type name describing the matchin column family.columnNames
- the columns to which secondary indexes should be added.public ColumnFamilyMetadata fetchColumnFamilyMetadata(String typeName, SpaceDocumentColumnFamilyMapper mapper)
ColumnFamilyMetadata
metadata matching the given type name. If found, this metadata is stored in cache and can
later be aquired by calling getColumnFamilyMetadata(String)
typeName
- The typeName describing the matching column family.ColumnFamilyMetadata
instance if found, null otherwise.public Map<String,ColumnFamilyMetadata> populateColumnFamiliesMetadata(SpaceDocumentColumnFamilyMapper mapper)
Map
from type name to its matching ColumnFamilyMetadata
.
Of all the currently known column families.public SpaceDocument readDocmentByKey(SpaceDocumentColumnFamilyMapper mapper, String typeName, Object keyValue)
typeName
- The typeName describing the matching column family.keyValue
- The key of the requested entry.public Map<Object,SpaceDocument> readDocumentsByKeys(SpaceDocumentColumnFamilyMapper mapper, String typeName, Object[] keyValues)
typeName
- The typeName describing the matching column family.keyValues
- The keys of the requested entry.public ColumnFamilyMetadata getColumnFamilyMetadata(String typeName)
ColumnFamilyMetadata
instance matching the provided typeNametypeName
- The typeName describing the matching column family.ColumnFamilyMetadata
instance if found, null otherwise.public Map<String,ColumnFamilyMetadata> getColumnFamiliesMetadata()
public CassandraConsistencyLevel getReadConsistencyLevel()
public CassandraConsistencyLevel getWriteConsistencyLevel()
Copyright © GigaSpaces.