本文整理汇总了Java中me.prettyprint.hector.api.Keyspace类的典型用法代码示例。如果您正苦于以下问题:Java Keyspace类的具体用法?Java Keyspace怎么用?Java Keyspace使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Keyspace类属于me.prettyprint.hector.api包,在下文中一共展示了Keyspace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEntityCounters
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
@Override
public Map<String, Long> getEntityCounters( UUID entityId ) throws Exception {
Map<String, Long> counters = new HashMap<String, Long>();
Keyspace ko = cass.getApplicationKeyspace( applicationId );
SliceCounterQuery<UUID, String> q = createCounterSliceQuery( ko, ue, se );
q.setColumnFamily( ENTITY_COUNTERS.toString() );
q.setRange( null, null, false, ALL_COUNT );
//Adding graphite metrics
Timer.Context timeEntityCounters = entGetEntityCountersTimer.time();
QueryResult<CounterSlice<String>> r = q.setKey( entityId ).execute();
timeEntityCounters.stop();
for ( HCounterColumn<String> column : r.get().getColumns() ) {
counters.put( column.getName(), column.getValue() );
}
return counters;
}
示例2: getOrCreateKeyspace
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
@Override public Keyspace getOrCreateKeyspace(String keyspaceName, int replicationFactor, Cluster cluster) {
KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(keyspaceName);
List<ColumnFamilyDefinition> cfDefs = new LinkedList<ColumnFamilyDefinition>();
// If keyspace does not exist create it without CFs.
if (keyspaceDef == null) {
keyspaceDef = HFactory.createKeyspaceDefinition(keyspaceName, ThriftKsDef.DEF_STRATEGY_CLASS, replicationFactor, cfDefs);
cluster.addKeyspace(keyspaceDef);
}
Keyspace keyspace = HFactory.createKeyspace(keyspaceName, cluster);
ConfigurableConsistencyLevel consistencyLevel = new ConfigurableConsistencyLevel();
consistencyLevel.setDefaultReadConsistencyLevel(HConsistencyLevel.QUORUM);
consistencyLevel.setDefaultWriteConsistencyLevel(HConsistencyLevel.QUORUM);
keyspace.setConsistencyLevelPolicy(consistencyLevel);
return keyspace;
}
示例3: getTopCount
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
@Override
public <R, T> int getTopCount(Keyspace keyspace, String columnFamily, DataOperationsProfile dataOperationsProfile, RowSerializer<R, T> rowSerializer, R rowKey, T from, T to, Integer count) {
CountQuery<R, T> query = HFactory.createCountQuery(keyspace, rowSerializer.getRowKeySerializer(), rowSerializer.getTopKeySerializer());
query.setColumnFamily(columnFamily);
query.setKey(rowKey);
query.setRange(from, to, getBoundedTopCount(count));
QueryResult<Integer> result;
StopWatch monitor = monitoring.start(HerculesMonitoringGroup.HERCULES_DD, "Get top count " + columnFamily);
try {
result = query.execute();
} finally {
long time = monitor.stop();
if (dataOperationsProfile != null) {
dataOperationsProfile.ms += time;
dataOperationsProfile.dbQueries++;
}
}
return result.get();
}
示例4: insert
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
@Override
public <R, T> void insert(Keyspace keyspace, String columnFamily, DataOperationsProfile dataOperationsProfile, RowSerializer<R, T> rowSerializer, R rowKey, Map<T, Object> values, final Map<T, Integer> ttls) {
Map<R, Map<T, Object>> valuesToInsert = new HashMap<R, Map<T, Object>>();
valuesToInsert.put(rowKey, values);
insert(keyspace, columnFamily, dataOperationsProfile, rowSerializer, valuesToInsert, new TTLProvider<R, T>() {
@Override public int get(R row, T top) {
if (ttls == null) {
return DataDriver.EMPTY_TTL;
}
Integer ttl = ttls.get(top);
if (ttl == null) {
return DataDriver.EMPTY_TTL;
}
return ttl;
}
});
}
示例5: delete
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
@Override
public <R, T> void delete(Keyspace keyspace, String columnFamily, DataOperationsProfile dataOperationsProfile, RowSerializer<R, T> rowSerializer, Map<R, Iterable<T>> values) {
Serializer<R> rowKeySerializer = rowSerializer.getRowKeySerializer();
Mutator<ByteBuffer> mutator = HFactory.createMutator(keyspace, ByteBufferSerializer.get());
for (R rowKey : values.keySet()) {
ByteBuffer serializedRowKey = rowKeySerializer.toByteBuffer(rowKey);
if (serializedRowKey == null) {
continue;
}
for (T topKey : values.get(rowKey)) {
mutator.addDeletion(serializedRowKey, columnFamily, topKey, rowSerializer.getTopKeySerializer());
}
}
executeDeletionMutator(columnFamily, dataOperationsProfile, mutator);
}
示例6: QueryRunner
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
public QueryRunner(Keyspace keyspace, String columnFamily,
KairosDataPointFactory kairosDataPointFactory,
List<DataPointsRowKey> rowKeys, long startTime, long endTime,
QueryCallback csResult,
int singleRowReadSize, int multiRowReadSize, int limit, Order order)
{
m_keyspace = keyspace;
m_columnFamily = columnFamily;
m_rowKeys = rowKeys;
m_kairosDataPointFactory = kairosDataPointFactory;
long m_tierRowTime = rowKeys.get(0).getTimestamp();
if (startTime < m_tierRowTime)
m_startTime = 0;
else
m_startTime = getColumnName(m_tierRowTime, startTime);
if (endTime > (m_tierRowTime + ROW_WIDTH))
m_endTime = getColumnName(m_tierRowTime, m_tierRowTime + ROW_WIDTH) +1;
else
m_endTime = getColumnName(m_tierRowTime, endTime) +1; //add 1 so we get 0x1 for last bit
m_queryCallback = csResult;
m_singleRowReadSize = singleRowReadSize;
m_multiRowReadSize = multiRowReadSize;
if (limit != 0)
{
m_limit = true;
m_singleRowReadSize = limit;
m_multiRowReadSize = limit;
}
if (order == Order.DESC)
m_descending = true;
}
示例7: WriteBuffer
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
public WriteBuffer(Keyspace keyspace, String cfName,
int writeDelay, int maxWriteSize, Serializer<RowKeyType> keySerializer,
Serializer<ColumnKeyType> columnKeySerializer,
Serializer<ValueType> valueSerializer,
WriteBufferStats stats,
ReentrantLock mutatorLock,
int threadCount,
int jobQueueSize)
{
m_executorService = new ThreadPoolExecutor(threadCount, threadCount,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(jobQueueSize),
new ThreadFactoryBuilder().setNameFormat("WriteBuffer-"+cfName+"-%d").build());
m_keyspace = keyspace;
m_cfName = cfName;
m_writeDelay = writeDelay;
m_initialMaxBufferSize = m_maxBufferSize = maxWriteSize;
m_rowKeySerializer = keySerializer;
m_columnKeySerializer = columnKeySerializer;
m_valueSerializer = valueSerializer;
m_writeStats = stats;
m_mutatorLock = mutatorLock;
m_buffer = new ArrayList<>();
m_mutator = new MutatorImpl<>(keyspace, keySerializer);
m_writeThread = new Thread(this, "WriteBuffer Scheduler for "+cfName);
m_writeThread.start();
}
示例8: POSSlicesQueryIterator
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
/**
* Builds a new iterator with the given data.
*
* @param dictionary the store dictionary.
* @param isq the indexed slice query.
* @param limit the result limit.
* @param cf the column family name.
* @param keyspace the keyspace.
*/
POSSlicesQueryIterator(
final ITopLevelDictionary dictionary,
final IndexedSlicesQuery<byte[], Composite, byte[]> isq,
final int limit,
final String cf,
final Keyspace keyspace) {
_dictionary = dictionary;
_limit = limit;
_cf = cf;
_keyspace = keyspace;
_rows = new IndexedSlicesIterator<byte[], Composite, byte[]>(isq, new byte[0]);
}
示例9: CAndPCSlicesQueryIterator
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
/**
* Creates a new iterator iterating over the results of the given query.
*
* @param query The query.
* @param limit The maximum amount of results to return.
* @param cf The column family to query.
* @param keyspace The keyspace to use.
* @param dictionary the CumulusRDF dictionary.
* @param isPC True, if this is a PC query, false, if this is a C query.
*/
CAndPCSlicesQueryIterator(
final RangeSlicesQuery<byte[], Composite, byte[]> query,
final int limit,
final String cf,
final Keyspace keyspace,
final ITopLevelDictionary dictionary,
final boolean isPC) {
_rows = new RangeSlicesIterator<byte[], Composite, byte[]>(query, new byte[0], new byte[0]);
_limit = limit;
_cf = cf;
_keyspace = keyspace;
_dictionary = dictionary;
_isPC = isPC;
}
示例10: CassandraStore
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
/** Constructor. */
public CassandraStore(String name, Keyspace keyspace,
ColumnFamilyTemplate<byte[], String> template) {
super(name);
this.keyspace = keyspace;
this.template = template;
}
示例11: KeyspaceTemplate
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
public KeyspaceTemplate(Keyspace keyspace, Serializer<K> keySerializer) {
if (keySerializer == null) {
throw new IllegalArgumentException("keySerializer is null");
}
if (keyspace == null) {
throw new IllegalArgumentException("keyspace is null");
}
this.keyspace = keyspace;
this.keySerializer = keySerializer;
}
示例12: ColumnFamilyTemplate
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
public ColumnFamilyTemplate(Keyspace keyspace,
@Nullable String defaultColumnFamily,
Serializer<K> keySerializer,
Serializer<N> columnNameSerializer,
Serializer<V> valueSerializer) {
super(keyspace,
defaultColumnFamily,
keySerializer,
Validate.notNull(columnNameSerializer),
Validate.notNull(valueSerializer));
}
示例13: AbstractColumnFamilyTemplate
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
/**
* Constructor.
*
* @param keyspace the Keyspace
* @param columnFamily the name of the column family or null if this is not specific to a column family.
* @param keySerializer the serializer for row keys
* @param topSerializer the serializer for the top columns (columns for a Column Family,
* superColumns for a Super Column Family).
* If null, then this instance is not specific to one Column Family.
*/
protected AbstractColumnFamilyTemplate(Keyspace keyspace,
@Nullable String columnFamily,
Serializer<K> keySerializer,
@Nullable Serializer<N> topSerializer,
@Nullable Serializer<V> valueSerializer) {
super(keyspace, keySerializer);
this.topSerializer = topSerializer;
this.columnFamily = columnFamily;
this.valueSerializer = valueSerializer;
}
示例14: SuperColumnFamilyTemplate
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
public SuperColumnFamilyTemplate(Keyspace keyspace,
@Nullable String columnFamily,
Serializer<K> keySerializer,
Serializer<SN> supercolumnNameSerializer,
Serializer<N> subcolumnNameSerializer,
Serializer<V> valueSerializer) {
super(keyspace,
columnFamily,
keySerializer,
Validate.notNull(supercolumnNameSerializer),
Validate.notNull(valueSerializer));
subSerializer = Validate.notNull(subcolumnNameSerializer);
}
示例15: shouldMultiGetAllSuperColumns
import me.prettyprint.hector.api.Keyspace; //导入依赖的package包/类
@Test(groups = "system")
public void shouldMultiGetAllSuperColumns() throws Exception {
Keyspace keyspace = getKeyspace();
SuperColumnFamilyTemplate<String,String,String,String> template = new
SuperColumnFamilyTemplate<String,String,String,String>(
keyspace,
SUPER_COLUMN_FAMILY,
StringSerializer.get(),
StringSerializer.get(),
StringSerializer.get(),
StringSerializer.get());
template.multiGetAllSuperColumns(Arrays.asList(ALEX_ROW_KEY, MIKE_ROW_KEY),
new SuperColumnFamilyRowMapper<Object,String,String,String,String>() {
@Override
public Void mapRow(String rowKey, List<HSuperColumn<String,String,String>> hColumns) {
if (LOG.isDebugEnabled()) {
LOG.debug("Mapping SuperColumns: rowKey=" + rowKey +
";hColumns=" + hColumns);
}
if (rowKey.equals(ALEX_ROW_KEY)) {
assertEquals(hColumns.size(), 2);
assertEquals(hColumns.get(0).getName(), "alex");
assertEquals(hColumns.get(1).getName(), "tom");
}
if (rowKey.equals(MIKE_ROW_KEY)) {
assertEquals(hColumns.size(), 1);
assertEquals(hColumns.get(0).getName(), "mike");
}
return null;
}
});
}