tools/stress/src/org/apache/cassandra/stress/operations/FacebookWorkload.java
//This is a copy of MultiGetter.run with columnsPerKey and keysPerRead being used instead of the session parameters
This is a copy of MultiGetter.run with columnsPerKey and keysPerRead being used instead of the session parameters
This is a copy of MultiGetter . run with columnsPerKey and keysPerRead being used instead of the session parameters
public void read(ClientLibrary clientLibrary, int keysPerRead) throws IOException
    {
        SlicePredicate nColumnsPredicate = new SlicePredicate().setSlice_range(new SliceRange().setStart(ByteBufferUtil.EMPTY_BYTE_BUFFER)
                .setFinish(ByteBufferUtil.EMPTY_BYTE_BUFFER)
                .setReversed(false)
                .setCount(1024));
        Map<ByteBuffer,List<ColumnOrSuperColumn>> results;
        int columnCount = 0;
        long bytesCount = 0;
        if (session.getColumnFamilyType() == ColumnFamilyType.Super)
        {
            assert false : "Untested";
        List<ByteBuffer> keys = generateKeys(keysPerRead);
        for (int j = 0; j < session.getSuperColumns(); j++)
        {
            ColumnParent parent = new ColumnParent("Super1").setSuper_column(ByteBufferUtil.bytes("S" + j));
            long startNano = System.nanoTime();
            boolean success = false;
            String exceptionMessage = null;
            for (int t = 0; t < session.getRetryTimes(); t++)
            {
                if (success)
                    break;
                try
                {
                    results = clientLibrary.transactional_multiget_slice(keys, parent, nColumnsPredicate);
                    success = (results.size() == keysPerRead);
                    if (!success)
                        exceptionMessage = "Wrong number of keys: " + results.size() + " instead of " + keysPerRead;
                    for (List<ColumnOrSuperColumn> result : results.values()) {
                        columnCount += result.size();
                        for (ColumnOrSuperColumn cosc : result) {
                            bytesCount += ColumnOrSuperColumnHelper.findLength(cosc);
                        }
                    }
                }
                catch (Exception e)
                {
                    exceptionMessage = getExceptionMessage(e);
                }
            }
            if (!success)
            {
                error(String.format("Operation [%d] retried %d times - error on calling multiget_slice for keys %s %s%n",
                        index,
                        session.getRetryTimes(),
                        keys,
                        (exceptionMessage == null) ? "" : "(" + exceptionMessage + ")"));
            }
            session.operations.getAndIncrement();
            session.keys.getAndAdd(keys.size());
            session.columnCount.getAndAdd(columnCount);
            session.bytes.getAndAdd(bytesCount);
            long latencyNano = System.nanoTime() - startNano;
            session.latency.getAndAdd(latencyNano/1000000);
            session.latencies.add(latencyNano/1000);
        }
        }
        else
        {
            ColumnParent parent = new ColumnParent("Standard1");
            List<ByteBuffer> keys = generateKeys(keysPerRead);
            long startNano = System.nanoTime();
            boolean success = false;
            String exceptionMessage = null;
            for (int t = 0; t < session.getRetryTimes(); t++)
            {
                if (success)
                    break;
                try
                {
                    columnCount = 0;
                    bytesCount = 0;
                    results = clientLibrary.transactional_multiget_slice(keys, parent, nColumnsPredicate);
                    success = (results.size() == keysPerRead);
                    if (!success)
                        exceptionMessage = "Wrong number of keys: " + results.size() + " instead of " + keysPerRead;
                    for (Entry<ByteBuffer, List<ColumnOrSuperColumn>> entry : results.entrySet())
                    {
                        ByteBuffer key = entry.getKey();
                        List<ColumnOrSuperColumn> columns = entry.getValue();
                        columnCount += columns.size();
                        success = (columns.size() > 0);
                        if (!success) {
                            exceptionMessage = "No columns returned for " + ByteBufferUtil.string(key);
                            break;
                        }
                        int keyByteTotal = 0;
                        for (ColumnOrSuperColumn cosc : columns) {
                            keyByteTotal += ColumnOrSuperColumnHelper.findLength(cosc);
                        }
                        bytesCount += keyByteTotal;
                    }
                }
                catch (Exception e)
                {
                    exceptionMessage = getExceptionMessage(e);
                    success = false;
                }
            }
            if (!success)
            {
                List<String> raw_keys = new ArrayList<String>();
                for (ByteBuffer key : keys) {
                    raw_keys.add(ByteBufferUtil.string(key));
                }
                error(String.format("Operation [%d] retried %d times - error on calling multiget_slice for keys %s %s%n",
                        index,
                        session.getRetryTimes(),
                        raw_keys,
                        (exceptionMessage == null) ? "" : "(" + exceptionMessage + ")"));
            }
            session.operations.getAndIncrement();
            session.keys.getAndAdd(keys.size());
            session.columnCount.getAndAdd(columnCount);
            session.bytes.getAndAdd(bytesCount);
            long latencyNano = System.nanoTime() - startNano;
            session.latency.getAndAdd(latencyNano/1000000);
            session.latencies.add(latencyNano/1000);
        }
    }
public void read ( ClientLibrary clientLibrary , int keysPerRead ) throws IOException { SlicePredicate nColumnsPredicate = new SlicePredicate ( ) . setSlice_range ( new SliceRange ( ) . setStart ( ByteBufferUtil . EMPTY_BYTE_BUFFER ) . setFinish ( ByteBufferUtil . EMPTY_BYTE_BUFFER ) . setReversed ( false ) . setCount ( 1024 ) ) ; Map < ByteBuffer , List < ColumnOrSuperColumn > > results ; int columnCount = 0 ; long bytesCount = 0 ; if ( session . getColumnFamilyType ( ) == ColumnFamilyType . Super ) { assert false : "Untested" ; List < ByteBuffer > keys = generateKeys ( keysPerRead ) ; for ( int j = 0 ; j < session . getSuperColumns ( ) ; j ++ ) { ColumnParent parent = new ColumnParent ( "Super1" ) . setSuper_column ( ByteBufferUtil . bytes ( "S" + j ) ) ; long startNano = System . nanoTime ( ) ; boolean success = false ; String exceptionMessage = null ; for ( int t = 0 ; t < session . getRetryTimes ( ) ; t ++ ) { if ( success ) break ; try { results = clientLibrary . transactional_multiget_slice ( keys , parent , nColumnsPredicate ) ; success = ( results . size ( ) == keysPerRead ) ; if ( ! success ) exceptionMessage = "Wrong number of keys: " + results . size ( ) + " instead of " + keysPerRead ; for ( List < ColumnOrSuperColumn > result : results . values ( ) ) { columnCount += result . size ( ) ; for ( ColumnOrSuperColumn cosc : result ) { bytesCount += ColumnOrSuperColumnHelper . findLength ( cosc ) ; } } } catch ( Exception e ) { exceptionMessage = getExceptionMessage ( e ) ; } } if ( ! success ) { error ( String . format ( "Operation [%d] retried %d times - error on calling multiget_slice for keys %s %s%n" , index , session . getRetryTimes ( ) , keys , ( exceptionMessage == null ) ? "" : "(" + exceptionMessage + ")" ) ) ; } session . operations . getAndIncrement ( ) ; session . keys . getAndAdd ( keys . size ( ) ) ; session . columnCount . getAndAdd ( columnCount ) ; session . bytes . getAndAdd ( bytesCount ) ; long latencyNano = System . nanoTime ( ) - startNano ; session . latency . getAndAdd ( latencyNano / 1000000 ) ; session . latencies . add ( latencyNano / 1000 ) ; } } else { ColumnParent parent = new ColumnParent ( "Standard1" ) ; List < ByteBuffer > keys = generateKeys ( keysPerRead ) ; long startNano = System . nanoTime ( ) ; boolean success = false ; String exceptionMessage = null ; for ( int t = 0 ; t < session . getRetryTimes ( ) ; t ++ ) { if ( success ) break ; try { columnCount = 0 ; bytesCount = 0 ; results = clientLibrary . transactional_multiget_slice ( keys , parent , nColumnsPredicate ) ; success = ( results . size ( ) == keysPerRead ) ; if ( ! success ) exceptionMessage = "Wrong number of keys: " + results . size ( ) + " instead of " + keysPerRead ; for ( Entry < ByteBuffer , List < ColumnOrSuperColumn > > entry : results . entrySet ( ) ) { ByteBuffer key = entry . getKey ( ) ; List < ColumnOrSuperColumn > columns = entry . getValue ( ) ; columnCount += columns . size ( ) ; success = ( columns . size ( ) > 0 ) ; if ( ! success ) { exceptionMessage = "No columns returned for " + ByteBufferUtil . string ( key ) ; break ; } int keyByteTotal = 0 ; for ( ColumnOrSuperColumn cosc : columns ) { keyByteTotal += ColumnOrSuperColumnHelper . findLength ( cosc ) ; } bytesCount += keyByteTotal ; } } catch ( Exception e ) { exceptionMessage = getExceptionMessage ( e ) ; success = false ; } } if ( ! success ) { List < String > raw_keys = new ArrayList < String > ( ) ; for ( ByteBuffer key : keys ) { raw_keys . add ( ByteBufferUtil . string ( key ) ) ; } error ( String . format ( "Operation [%d] retried %d times - error on calling multiget_slice for keys %s %s%n" , index , session . getRetryTimes ( ) , raw_keys , ( exceptionMessage == null ) ? "" : "(" + exceptionMessage + ")" ) ) ; } session . operations . getAndIncrement ( ) ; session . keys . getAndAdd ( keys . size ( ) ) ; session . columnCount . getAndAdd ( columnCount ) ; session . bytes . getAndAdd ( bytesCount ) ; long latencyNano = System . nanoTime ( ) - startNano ; session . latency . getAndAdd ( latencyNano / 1000000 ) ; session . latencies . add ( latencyNano / 1000 ) ; } }
This is a copy of MultiGetter.run with columnsPerKey and keysPerRead being used instead of the session parameters
This is a copy of MultiGetter . run with columnsPerKey and keysPerRead being used instead of the session parameters
// We grab all columns for the key, they have been set there by the populator / writes // TODO ensure/make writes blow away all old columns //String allReads = "Read "; //allReads += ByteBufferUtil.string(key) + " = " + columns.size() + " cols = " + keyByteTotal + "B, "; //allReads = allReads.substring(0, allReads.length() - 2); //System.out.println(allReads);