ProfilingCassandraClient implements AutoDelegate_CassandraClient { @Override public Map<ByteBuffer, List<ColumnOrSuperColumn>> multiget_slice(String kvsMethodName, TableReference tableRef, List<ByteBuffer> keys, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { int numberOfKeys = keys.size(); int numberOfColumns = predicate.slice_range.count; long startTime = System.currentTimeMillis(); return KvsProfilingLogger.maybeLog( (KvsProfilingLogger.CallableCheckedException<Map<ByteBuffer, List<ColumnOrSuperColumn>>, TException>) () -> client.multiget_slice(kvsMethodName, tableRef, keys, predicate, consistency_level), (logger, timer) -> logger.log("CassandraClient.multiget_slice({}, {}, {}, {}) at time {}, on kvs.{} took {} ms", LoggingArgs.tableRef(tableRef), LoggingArgs.keyCount(numberOfKeys), LoggingArgs.columnCount(numberOfColumns), SafeArg.of("consistency", consistency_level.toString()), LoggingArgs.startTimeMillis(startTime), SafeArg.of("kvsMethodName", kvsMethodName), LoggingArgs.durationMillis(timer)), (logger, rowsToColumns) -> logger.log("and returned {} cells in {} rows with {} bytes", LoggingArgs.cellCount(countCells(rowsToColumns.values())), LoggingArgs.rowCount(rowsToColumns.size()), LoggingArgs.sizeInBytes(ThriftObjectSizeUtils.getApproximateSizeOfColsByKey(rowsToColumns)))); } ProfilingCassandraClient(CassandraClient client); @Override CassandraClient delegate(); @Override Map<ByteBuffer, List<ColumnOrSuperColumn>> multiget_slice(String kvsMethodName,
            TableReference tableRef,
            List<ByteBuffer> keys,
            SlicePredicate predicate,
            ConsistencyLevel consistency_level); @Override Map<ByteBuffer, List<List<ColumnOrSuperColumn>>> multiget_multislice(String kvsMethodName,
            TableReference tableRef,
            List<KeyPredicate> keyPredicates,
            ConsistencyLevel consistency_level); @Override List<KeySlice> get_range_slices(String kvsMethodName,
            TableReference tableRef,
            SlicePredicate predicate,
            KeyRange range,
            ConsistencyLevel consistency_level); @Override void remove(String kvsMethodName, TableReference tableRef, byte[] row, long timestamp,
            ConsistencyLevel consistency_level); @Override void batch_mutate(String kvsMethodName,
            Map<ByteBuffer, Map<String, List<Mutation>>> mutation_map,
            ConsistencyLevel consistency_level); @Override ColumnOrSuperColumn get(TableReference tableReference,
            ByteBuffer key,
            byte[] column,
            ConsistencyLevel consistency_level); @Override CASResult cas(TableReference tableReference,
            ByteBuffer key,
            List<Column> expected,
            List<Column> updates,
            ConsistencyLevel serial_consistency_level,
            ConsistencyLevel commit_consistency_level); @Override CqlResult execute_cql3_query(CqlQuery cqlQuery, Compression compression, ConsistencyLevel consistency);  }
@Test public void handlesNullMultigetSliceResponseFromDelegate() throws TException { ByteBuffer byteBuffer = ByteBuffer.wrap(PtBytes.toBytes("foo")); List<ColumnOrSuperColumn> columns = ImmutableList.of( new ColumnOrSuperColumn().setColumn(new Column(byteBuffer))); ImmutableMap<ByteBuffer, List<ColumnOrSuperColumn>> resultMap = ImmutableMap.of(byteBuffer, columns); when(delegate.multiget_slice(any(), any(), any(), any(), any())).thenReturn(resultMap); assertThat(delegate.multiget_slice( "getRows", TableReference.createFromFullyQualifiedName("a.b"), ImmutableList.of(byteBuffer), new SlicePredicate(), ConsistencyLevel.QUORUM)).isEqualTo(resultMap); verify(delegate).multiget_slice( "getRows", TableReference.createFromFullyQualifiedName("a.b"), ImmutableList.of(byteBuffer), new SlicePredicate(), ConsistencyLevel.QUORUM); }