本文整理汇总了Java中me.prettyprint.hector.api.query.SliceQuery类的典型用法代码示例。如果您正苦于以下问题:Java SliceQuery类的具体用法?Java SliceQuery怎么用?Java SliceQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SliceQuery类属于me.prettyprint.hector.api.query包,在下文中一共展示了SliceQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCiStateHistory
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
public List<CiChangeStateEvent> getCiStateHistory(long ciId, Long startTime, Long endTime, Integer count) {
if (count == null) count = 1000;
List<CiChangeStateEvent> states = new ArrayList<CiChangeStateEvent>();
SliceQuery<Long, Long, String> sliceQuery = HFactory.createSliceQuery(keyspace, longSerializer, longSerializer, stringSerializer);
sliceQuery.setColumnFamily(SchemaBuilder.CI_STATE_HIST_CF);
sliceQuery.setRange(startTime, endTime, false, count);
sliceQuery.setKey(ciId);
QueryResult<ColumnSlice<Long, String>> result = sliceQuery.execute();
ColumnSlice<Long, String> resultCols = result.get();
for (HColumn<Long, String> col : resultCols.getColumns()) {
CiChangeStateEvent event = gson.fromJson(col.getValue(), CiChangeStateEvent.class);
states.add(event);
}
return states;
}
示例2: queryStringIndex
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
private Iterable<String> queryStringIndex(final String key) {
SliceQuery<String, String, String> sliceQuery =
HFactory.createSliceQuery(m_keyspace, StringSerializer.get(), StringSerializer.get(),
StringSerializer.get());
sliceQuery.setColumnFamily(CF_STRING_INDEX);
sliceQuery.setKey(key);
ColumnSliceIterator<String, String, String> columnIterator =
new ColumnSliceIterator<String, String, String>(sliceQuery, "", (String) null, false, m_singleRowReadSize);
List<String> ret = new ArrayList<String>();
while (columnIterator.hasNext()) {
ret.add(columnIterator.next().getName());
}
return ret;
}
示例3: createSliceIterator
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
private ColumnSliceIterator<String, DataPointsRowKey, String> createSliceIterator(
SliceQuery<String, DataPointsRowKey, String> sliceQuery,
String metricName, long startTime, long endTime)
{
DataPointsRowKey startKey = new DataPointsRowKey(metricName,
calculateRowTime(startTime), "");
DataPointsRowKey endKey = new DataPointsRowKey(metricName,
calculateRowTime(endTime), "");
endKey.setEndSearchKey(true);
ColumnSliceIterator<String, DataPointsRowKey, String> iterator = new ColumnSliceIterator<String, DataPointsRowKey, String>(sliceQuery,
startKey, endKey, false, m_singleRowReadSize);
return (iterator);
}
示例4: doGetUserListOfRole
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
/**
* Get the list of users mapped to a role.
*/
@Override
public String[] doGetUserListOfRole(String roleName, String filter) throws UserStoreException {
List<String> usersList = new ArrayList<String>();
Composite key = new Composite();
key.addComponent(roleName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
SliceQuery<Composite, String, String> query = HFactory
.createSliceQuery(keyspace, CompositeSerializer.get(), StringSerializer.get(), StringSerializer.get())
.setKey(key).setColumnFamily(CFConstants.UM_ROLE_USER_INDEX);
ColumnSliceIterator<Composite, String, String> iterator = new ColumnSliceIterator<Composite, String, String>(
query, null, "\uFFFF", false);
while (iterator.hasNext()) {
HColumn<String, String> column = iterator.next();
usersList.add(column.getValue());
}
return usersList.toArray(new String[usersList.size()]);
}
示例5: doGetExternalRoleListOfUser
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
/**
* Gets the external role list of a user.
*/
@Override
public String[] doGetExternalRoleListOfUser(String userName, String filter) throws UserStoreException {
List<String> roles = new ArrayList<String>();
int arrayLength = 0;
Composite key = new Composite();
key.addComponent(userName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
SliceQuery<Composite, String, String> query = HFactory
.createSliceQuery(keyspace, CompositeSerializer.get(), StringSerializer.get(), StringSerializer.get())
.setKey(key).setColumnFamily(CFConstants.UM_USER_ROLE);
ColumnSliceIterator<Composite, String, String> iterator = new ColumnSliceIterator<Composite, String, String>(
query, null, "\uFFFF", false);
while (iterator.hasNext()) {
HColumn<String, String> column = iterator.next();
roles.add(column.getValue());
}
return roles.toArray(new String[arrayLength]);
}
示例6: readColumnsAsMap
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
/**
* Read the columns as a map from a single row specifying start, finish, count, and reversed.
*
*
* @param rowKey the row key of type K
* @return map of columns, key is type N and values are type V.
*/
@Override
public Map<N,V> readColumnsAsMap(K rowKey, N start, N finish, int count, boolean reversed) {
Map<N,V> maps = new HashMap<N,V>();
SliceQuery<K,N,V> query = HFactory.createSliceQuery(getKeyspace(),
getKeySerializer(),
getColumnNameSerializer(),
getValueSerializer());
QueryResult<ColumnSlice<N,V>> result = query.setKey(rowKey).
setColumnFamily(getColumnFamily()).
setRange(start, finish, reversed, count).
execute();
ColumnSlice<N,V> slice = result.get();
for (HColumn<N,V> column : slice.getColumns()) {
maps.put(column.getName(),
column.getValue());
}
// we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
return maps;
}
示例7: readColumns
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
@Override
public <T> List<T> readColumns(K rowKey,
N start,
N finish,
int count,
boolean reversed,
ColumnMapper<T,N,V> columnMapper) {
List<T> resultList = new ArrayList<T>();
SliceQuery<K,N,V> query = HFactory.createSliceQuery(getKeyspace(),
getKeySerializer(),
getColumnNameSerializer(),
getValueSerializer());
QueryResult<ColumnSlice<N,V>> result = query.setKey(rowKey).
setColumnFamily(getColumnFamily()).
setRange(start, finish, reversed, count).
execute();
ColumnSlice<N,V> slice = result.get();
for (HColumn<N,V> column : slice.getColumns()) {
resultList.add(columnMapper.mapColumn(column.getName(), column.getValue()));
}
// we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
return resultList;
}
示例8: swallowOrderedExecution
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
/**
* This method intentionally swallows ordered execution issues. For some reason, our Time UUID ordering does
* not agree with the cassandra comparator as our micros get very close
* @param query
* @param <K>
* @param <UUID>
* @param <V>
* @return
*/
protected static <K, UUID, V> List<HColumn<UUID, V>> swallowOrderedExecution( final SliceQuery<K, UUID, V> query ) {
try {
return query.execute().get().getColumns();
}
catch ( HInvalidRequestException e ) {
//invalid request. Occasionally we get order issues when there shouldn't be, disregard them.
final Throwable invalidRequestException = e.getCause();
if ( invalidRequestException instanceof InvalidRequestException
//we had a range error
&& ( ( InvalidRequestException ) invalidRequestException ).getWhy().contains(
"range finish must come after start in the order of traversal" )) {
return Collections.emptyList();
}
throw e;
}
}
示例9: fillSliceQuery
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
public <K, V> void fillSliceQuery(SliceQuery<K, N, V> sliceQuery) {
if (type == SliceDataSpecificatorType.COLUMNS) {
if (columnsArray != null) {
sliceQuery.setColumnNames(columnsArray);
} else {
((ThriftSliceQuery) sliceQuery).setColumnNames(columnsCollection);
}
} else if (type == SliceDataSpecificatorType.RANGE) {
if (orderDesc) { // Cassandra's WTF requirement
sliceQuery.setRange(highEnd, lowEnd, orderDesc, limit);
} else {
sliceQuery.setRange(lowEnd, highEnd, orderDesc, limit);
}
} else {
throw new IllegalStateException("Invalid type: " + type);
}
}
示例10: FilteredRowKeyIterator
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
public FilteredRowKeyIterator(String metricName, long startTime, long endTime,
SetMultimap<String, String> filterTags)
{
m_filterTags = filterTags;
SliceQuery<String, DataPointsRowKey, String> sliceQuery =
HFactory.createSliceQuery(m_keyspace, StringSerializer.get(),
new DataPointsRowKeySerializer(true), StringSerializer.get());
sliceQuery.setColumnFamily(CF_ROW_KEY_INDEX)
.setKey(metricName);
if ((startTime < 0) && (endTime >= 0))
{
m_sliceIterator = createSliceIterator(sliceQuery, metricName,
startTime, -1L);
SliceQuery<String, DataPointsRowKey, String> sliceQuery2 =
HFactory.createSliceQuery(m_keyspace, StringSerializer.get(),
new DataPointsRowKeySerializer(true), StringSerializer.get());
sliceQuery2.setColumnFamily(CF_ROW_KEY_INDEX)
.setKey(metricName);
m_continueSliceIterator = createSliceIterator(sliceQuery2, metricName,
0, endTime);
}
else
{
m_sliceIterator = createSliceIterator(sliceQuery, metricName,
startTime, endTime);
}
}
示例11: getMessage
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
@Override
public Message getMessage( UUID messageId ) {
SliceQuery<UUID, String, ByteBuffer> q =
createSliceQuery( cass.getApplicationKeyspace( applicationId ), ue, se, be );
q.setColumnFamily( MESSAGE_PROPERTIES.getColumnFamily() );
q.setKey( messageId );
q.setRange( null, null, false, ALL_COUNT );
QueryResult<ColumnSlice<String, ByteBuffer>> r = q.execute();
ColumnSlice<String, ByteBuffer> slice = r.get();
List<HColumn<String, ByteBuffer>> results = slice.getColumns();
return deserializeMessage( results );
}
示例12: getQueueCounterNames
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
@Override
public Set<String> getQueueCounterNames( String queuePath ) throws Exception {
Set<String> names = new HashSet<String>();
Keyspace ko = cass.getApplicationKeyspace( applicationId );
SliceQuery<String, String, ByteBuffer> q = createSliceQuery( ko, se, se, be );
q.setColumnFamily( QueuesCF.QUEUE_DICTIONARIES.toString() );
q.setKey( CassandraPersistenceUtils.key( getQueueId( queuePath ), DICTIONARY_COUNTERS ).toString() );
q.setRange( null, null, false, ALL_COUNT );
List<HColumn<String, ByteBuffer>> columns = q.execute().get().getColumns();
for ( HColumn<String, ByteBuffer> column : columns ) {
names.add( column.getName() );
}
return names;
}
示例13: getQueue
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
public Queue getQueue( String queuePath, UUID queueId ) {
SliceQuery<UUID, String, ByteBuffer> q =
createSliceQuery( cass.getApplicationKeyspace( applicationId ), ue, se, be );
q.setColumnFamily( QUEUE_PROPERTIES.getColumnFamily() );
q.setKey( queueId );
q.setRange( null, null, false, ALL_COUNT );
QueryResult<ColumnSlice<String, ByteBuffer>> r = q.execute();
ColumnSlice<String, ByteBuffer> slice = r.get();
List<HColumn<String, ByteBuffer>> results = slice.getColumns();
return deserializeQueue( results );
}
示例14: getConsumerIds
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
/**
* Get all pending transactions that have timed out
*
* @param queueId The queue id
* @param consumerId The consumer id
* @param params The server params
* @param startTimeUUID The start time
*/
protected List<TransactionPointer> getConsumerIds( UUID queueId, UUID consumerId, SearchParam params,
UUID startTimeUUID )
{
SliceQuery<ByteBuffer, UUID, UUID> q = createSliceQuery( ko, be, ue, ue );
q.setColumnFamily( CONSUMER_QUEUE_TIMEOUTS.getColumnFamily() );
q.setKey( getQueueClientTransactionKey( queueId, consumerId ) );
q.setRange( params.startId, startTimeUUID, false, params.limit + 1 );
List<HColumn<UUID, UUID>> cassResults = swallowOrderedExecution(q);
List<TransactionPointer> results = new ArrayList<TransactionPointer>( params.limit );
for ( HColumn<UUID, UUID> column : cassResults )
{
if ( logger.isTraceEnabled() )
{
logger.trace( "Adding uuid '{}' for original message '{}' to results for queue '{}' and consumer '{}'",
column.getName(), column.getValue(), queueId, consumerId );
logger.trace( "Max timeuuid : '{}', Current timeuuid : '{}', comparison '{}'",
startTimeUUID, column.getName(), UUIDUtils.compare( startTimeUUID, column.getName() )
);
}
results.add( new TransactionPointer( column.getName(), column.getValue() ) );
}
return results;
}
示例15: hasOutstandingTransactions
import me.prettyprint.hector.api.query.SliceQuery; //导入依赖的package包/类
public boolean hasOutstandingTransactions( UUID queueId, UUID consumerId )
{
SliceQuery<ByteBuffer, UUID, UUID> q = createSliceQuery( ko, be, ue, ue );
q.setColumnFamily( CONSUMER_QUEUE_TIMEOUTS.getColumnFamily() );
q.setKey( getQueueClientTransactionKey( queueId, consumerId ) );
q.setRange( null, null, false, 1 );
return q.execute().get().getColumns().size() > 0;
}