Row Level Isolation

10 views
Skip to first unread message

avins...@gmail.com

unread,
May 15, 2013, 2:39:31 PM5/15/13
to hector...@googlegroups.com
I am new to Cassandra and have been using the Hector Template API's. My question here is how do I use Row Level Isolation when I am trying to update. 

My typical get looks something like:

 public String getAttributeValueForKey( String columnName, String key ) throws StoreException {


        String result = null;

        try {

            ColumnFamilyResult<String, String> columnFamilyResult = getTemplate().queryColumns( key );

            if( null != columnFamilyResult ) {

                result = columnFamilyResult.getString( columnName );

            }

        }

        catch( HectorException e ) {

            LOGGER.error( e );

            throw new StoreException( e );

        }


        return result;

    }


And the puts looks something like:

  public void putKeyWithValuesAndTimeout( String rowKey, Map<String, String> columns, long timeInMilliSeconds ) throws StoreException {


        ColumnFamilyUpdater<String, String> updater = getTemplate().createUpdater(rowKey);

        for( String attributeKey : columns.keySet() ) {

            HColumn<String, String> column = new HColumnImpl<String,String>(StringSerializer.get(), StringSerializer.get());

            column.setClock(getTemplate().getClock());

            column.setName(attributeKey);

            column.setValue( columns.get(attributeKey));

            column.setTtl((int)timeInMilliSeconds);


            updater.setColumn(column);

        }

        try {

            getTemplate().update( updater );

        }

        catch( HectorException e ) {

            LOGGER.error( e );

            throw new StoreException( e );

        }

    }




Reply all
Reply to author
Forward
0 new messages