当前位置: 首页>>代码示例>>Java>>正文


Java SliceQuery.setRange方法代码示例

本文整理汇总了Java中me.prettyprint.hector.api.query.SliceQuery.setRange方法的典型用法代码示例。如果您正苦于以下问题:Java SliceQuery.setRange方法的具体用法?Java SliceQuery.setRange怎么用?Java SliceQuery.setRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在me.prettyprint.hector.api.query.SliceQuery的用法示例。


在下文中一共展示了SliceQuery.setRange方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
    }
 
开发者ID:oneops,项目名称:oneops,代码行数:17,代码来源:OpsCiStateDao.java

示例2: 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);
    }
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:19,代码来源:SliceDataSpecificator.java

示例3: 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 );
}
 
开发者ID:apache,项目名称:usergrid,代码行数:13,代码来源:QueueManagerImpl.java

示例4: 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;
}
 
开发者ID:apache,项目名称:usergrid,代码行数:16,代码来源:QueueManagerImpl.java

示例5: 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 );
}
 
开发者ID:apache,项目名称:usergrid,代码行数:12,代码来源:QueueManagerImpl.java

示例6: 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;
}
 
开发者ID:apache,项目名称:usergrid,代码行数:39,代码来源:ConsumerTransaction.java

示例7: 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;
}
 
开发者ID:apache,项目名称:usergrid,代码行数:9,代码来源:ConsumerTransaction.java

示例8: getAllColumns

import me.prettyprint.hector.api.query.SliceQuery; //导入方法依赖的package包/类
/**
 * Gets the columns.
 *
 * @param ko the keyspace
 * @param columnFamily the column family
 * @param key the key
 *
 * @return columns
 *
 * @throws Exception the exception
 */
public <N, V> List<HColumn<N, V>> getAllColumns( Keyspace ko, Object columnFamily, Object key,
                                                 Serializer<N> nameSerializer, Serializer<V> valueSerializer )
        throws Exception {

    if ( db_logger.isTraceEnabled() ) {
        db_logger.trace( "getColumns cf={} key={}", columnFamily, key );
    }

    SliceQuery<ByteBuffer, N, V> q = createSliceQuery( ko, be, nameSerializer, valueSerializer );
    q.setColumnFamily( columnFamily.toString() );
    q.setKey( bytebuffer( key ) );
    q.setRange( null, null, false, ALL_COUNT );
    QueryResult<ColumnSlice<N, V>> r = q.execute();
    ColumnSlice<N, V> slice = r.get();
    List<HColumn<N, V>> results = slice.getColumns();

    if ( db_logger.isTraceEnabled() ) {
        if ( results == null ) {
            db_logger.trace( "getColumns returned null" );
        }
        else {
            db_logger.trace( "getColumns returned {} columns", results.size() );
        }
    }

    return results;
}
 
开发者ID:apache,项目名称:usergrid,代码行数:39,代码来源:CassandraService.java

示例9: getColumns

import me.prettyprint.hector.api.query.SliceQuery; //导入方法依赖的package包/类
/**
 * Gets the columns.
 *
 * @param ko the keyspace
 * @param columnFamily the column family
 * @param key the key
 * @param start the start
 * @param finish the finish
 * @param count the count
 * @param reversed the reversed
 *
 * @return columns
 *
 * @throws Exception the exception
 */
public List<HColumn<ByteBuffer, ByteBuffer>> getColumns( Keyspace ko, Object columnFamily, Object key, Object start,
                                                         Object finish, int count, boolean reversed )
        throws Exception {

    if ( db_logger.isTraceEnabled() ) {
        db_logger.debug( "getColumns cf=" + columnFamily + " key=" + key + " start=" + start + " finish=" + finish
                + " count=" + count + " reversed=" + reversed );
    }

    SliceQuery<ByteBuffer, ByteBuffer, ByteBuffer> q = createSliceQuery( ko, be, be, be );
    q.setColumnFamily( columnFamily.toString() );
    q.setKey( bytebuffer( key ) );

    ByteBuffer start_bytes = null;
    if ( start instanceof DynamicComposite ) {
        start_bytes = ( ( DynamicComposite ) start ).serialize();
    }
    else if ( start instanceof List ) {
        start_bytes = DynamicComposite.toByteBuffer( ( List<?> ) start );
    }
    else {
        start_bytes = bytebuffer( start );
    }

    ByteBuffer finish_bytes = null;
    if ( finish instanceof DynamicComposite ) {
        finish_bytes = ( ( DynamicComposite ) finish ).serialize();
    }
    else if ( finish instanceof List ) {
        finish_bytes = DynamicComposite.toByteBuffer( ( List<?> ) finish );
    }
    else {
        finish_bytes = bytebuffer( finish );
    }

/*
 * if (reversed) { q.setRange(finish_bytes, start_bytes, reversed, count); }
 * else { q.setRange(start_bytes, finish_bytes, reversed, count); }
 */
    q.setRange( start_bytes, finish_bytes, reversed, count );
    QueryResult<ColumnSlice<ByteBuffer, ByteBuffer>> r = q.execute();
    ColumnSlice<ByteBuffer, ByteBuffer> slice = r.get();
    List<HColumn<ByteBuffer, ByteBuffer>> results = slice.getColumns();

    if ( db_logger.isTraceEnabled() ) {
        if ( results == null ) {
            db_logger.trace("getColumns returned null");
        }
        else {
            db_logger.trace("getColumns returned {} columns", results.size());
        }
    }

    return results;
}
 
开发者ID:apache,项目名称:usergrid,代码行数:71,代码来源:CassandraService.java


注:本文中的me.prettyprint.hector.api.query.SliceQuery.setRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。