Java Code Examples for me.prettyprint.hector.api.mutation.Mutator#addCounter()

The following examples show how to use me.prettyprint.hector.api.mutation.Mutator#addCounter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CounterUtils.java    From usergrid with Apache License 2.0 6 votes vote down vote up
private void handleAggregateCounterRow( Mutator<ByteBuffer> m, String key, long column, long value,
                                        UUID applicationId ) {
    if ( logger.isTraceEnabled() ) {
        logger.trace( "HACR: aggregateRow for app {} with key {} column {} and value {}",
                applicationId, key, column, value );
    }
    if ( "o".equals( counterType ) || "p".equals( counterType ) ) {
        if ( m != null ) {
            HCounterColumn<Long> c = createCounterColumn( column, value, le );
            m.addCounter( bytebuffer( key ), APPLICATION_AGGREGATE_COUNTERS.toString(), c );
        }
    }
    if ( "n".equals( counterType ) || "p".equals( counterType ) ) {
        // create and add Count
        PrefixedSerializer ps =
                new PrefixedSerializer( applicationId, ue, se );
        batcher.add(
                new Count( APPLICATION_AGGREGATE_COUNTERS.toString(), ps.toByteBuffer( key ), column, value ) );
    }
}
 
Example 2
Source File: CounterUtils.java    From usergrid with Apache License 2.0 6 votes vote down vote up
private Mutator<ByteBuffer> batchIncrementEntityCounter( Mutator<ByteBuffer> m, UUID entityId, String name,
                                                         Long value, long timestamp, UUID applicationId ) {
    if ( logger.isTraceEnabled() ) {
        logger.trace( "BIEC: Incrementing property {} of entity {} by value {}",
                name, entityId, value );
    }
    addInsertToMutator( m, ENTITY_DICTIONARIES, key( entityId, DICTIONARY_COUNTERS ), name, null, timestamp );
    if ( "o".equals( counterType ) || "p".equals( counterType ) ) {
        HCounterColumn<String> c = createCounterColumn( name, value );
        m.addCounter( bytebuffer( entityId ), ENTITY_COUNTERS.toString(), c );
    }
    if ( "n".equals( counterType ) || "p".equals( counterType ) ) {
        PrefixedSerializer ps = new PrefixedSerializer( applicationId, ue, ue );
        batcher.add( new Count( ENTITY_COUNTERS.toString(), ps.toByteBuffer( entityId ), name, value ) );
    }
    return m;
}
 
Example 3
Source File: CounterUtils.java    From usergrid with Apache License 2.0 6 votes vote down vote up
public Mutator<ByteBuffer> batchIncrementQueueCounter( Mutator<ByteBuffer> m, UUID queueId, String name, long value,
                                                       long timestamp, UUID applicationId ) {
    if ( logger.isTraceEnabled() ) {
        logger.trace( "BIQC: Incrementing property {} of queue {} by value {}",
                name, queueId, value );
    }
    m.addInsertion( bytebuffer( key( queueId, DICTIONARY_COUNTERS ).toString() ),
            QueuesCF.QUEUE_DICTIONARIES.toString(),
            createColumn( name, ByteBuffer.allocate( 0 ), timestamp, se, be ) );
    if ( "o".equals( counterType ) || "p".equals( counterType ) ) {
        HCounterColumn<String> c = createCounterColumn( name, value );
        ByteBuffer keybytes = bytebuffer( queueId );
        m.addCounter( keybytes, QueuesCF.COUNTERS.toString(), c );
    }
    if ( "n".equals( counterType ) || "p".equals( counterType ) ) {
        PrefixedSerializer ps = new PrefixedSerializer( applicationId, ue, ue );
        batcher.add( new Count( QueuesCF.COUNTERS.toString(), ps.toByteBuffer( queueId ), name, value ) );
    }
    return m;
}