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 ) ); } }
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; }
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; }
public KeyRange prefixKeyRange(KeyRange unprefixed) { KeyRange prefixed = new KeyRange(); prefixed.count = unprefixed.count; prefixed.end_token = unprefixed.end_token; prefixed.end_key = ps.toByteBuffer(unprefixed.end_key); prefixed.start_token = unprefixed.start_token; prefixed.start_key = ps.toByteBuffer(unprefixed.start_key); return prefixed; }
@Override public ColumnOrSuperColumn get(ByteBuffer key, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, NotFoundException, UnavailableException, TimedOutException, TException { return super.get(ps.toByteBuffer(key), column_path, consistency_level); }
@Override public int get_count(ByteBuffer key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { return super.get_count(ps.toByteBuffer(key), column_parent, predicate, consistency_level); }
public KeySlice prefixKeySlice(KeySlice unprefixed) { KeySlice prefixed = new KeySlice(); prefixed.key = ps.toByteBuffer(unprefixed.key); prefixed.columns = unprefixed.columns; return prefixed; }
@Override public void insert(ByteBuffer key, ColumnParent column_parent, Column column, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { super .insert(ps.toByteBuffer(key), column_parent, column, consistency_level); }
@Override public void remove(ByteBuffer key, ColumnPath column_path, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { super.remove(ps.toByteBuffer(key), column_path, timestamp, consistency_level); }
@Override public SuperColumn getSuperColumn(ByteBuffer key, ColumnPath columnPath) throws HectorException { return super.getSuperColumn(ps.toByteBuffer(key), columnPath); }
@Override public List<CounterSuperColumn> getCounterSuperSlice(ByteBuffer key, ColumnParent columnParent, SlicePredicate predicate) throws HectorException { return super.getCounterSuperSlice(ps.toByteBuffer(key), columnParent, predicate); }
@Override public void removeCounter(ByteBuffer key, ColumnPath columnPath) throws HectorException { super.removeCounter(ps.toByteBuffer(key), columnPath); }
@Override public List<ColumnOrSuperColumn> get_slice(ByteBuffer key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { return super.get_slice(ps.toByteBuffer(key), column_parent, predicate, consistency_level); }
@Override public List<CounterColumn> getCounterSlice(ByteBuffer key, ColumnParent columnParent, SlicePredicate predicate) throws HectorException { return super.getCounterSlice(ps.toByteBuffer(key), columnParent, predicate); }
@Override public CounterColumn getCounter(ByteBuffer key, ColumnPath columnPath) throws HectorException { return super.getCounter(ps.toByteBuffer(key), columnPath); }
@Override public void add(ByteBuffer key, ColumnParent column_parent, CounterColumn column, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { super.add(ps.toByteBuffer(key), column_parent, column, consistency_level); }
@Override public List<Column> getSlice(ByteBuffer key, ColumnParent columnParent, SlicePredicate predicate) throws HectorException { return super.getSlice(ps.toByteBuffer(key), columnParent, predicate); }
@Override public SuperColumn getSuperColumn(ByteBuffer key, ColumnPath columnPath, boolean reversed, int size) throws HectorException { return super.getSuperColumn(ps.toByteBuffer(key), columnPath, reversed, size); }
@Override public void insert(ByteBuffer key, ColumnParent columnParent, Column column) throws HectorException { super.insert(ps.toByteBuffer(key), columnParent, column); }
@Test public void test() { UUIDSerializer ue = new UUIDSerializer(); StringSerializer se = new StringSerializer(); PrefixedSerializer<UUID, String> pe = new PrefixedSerializer<UUID, String>( prefixUUID, ue, se); Assert.assertEquals(str, pe.fromByteBuffer(pe.toByteBuffer(str))); }