Package com.netflix.astyanax

Examples of com.netflix.astyanax.MutationBatch.withRow()


    ColumnList<C> columnList = rowQuery.execute().getResult();
   
    CqlKeyspaceImpl ksImpl = new CqlKeyspaceImpl(ksContext);
   
    MutationBatch mBatch = ksImpl.prepareMutationBatch();
    CqlColumnListMutationImpl<K,C> colListMutation = (CqlColumnListMutationImpl<K, C>)mBatch.withRow(cf, rowKey);
   
    Iterator<Column<C>> iter = columnList.iterator();

    boolean first = true;
   
View Full Code Here


    public String isUnique(K key) throws ConnectionException {
        String unique = uniqueColumnSupplier.get();

        // Phase 1: Write a unique column
        MutationBatch m = keyspace.prepareMutationBatch().setConsistencyLevel(consistencyLevel);
        m.withRow(columnFamily, key).putEmptyColumn(prefix + unique, ttl);

        m.execute();

        // Phase 2: Read back all columns. There should be only 1
        ColumnList<String> result = keyspace.prepareQuery(columnFamily).setConsistencyLevel(consistencyLevel)
View Full Code Here

        if (this.monitor != null)
            this.monitor.onViolation(key, prefix + unique);

        // Rollback
        m = keyspace.prepareMutationBatch().setConsistencyLevel(consistencyLevel);
        m.withRow(columnFamily, key).deleteColumn(prefix + unique);
        m.execute().getResult();

        return null;
    }
}
View Full Code Here

    private void addRowToKS(Keyspace ks, int rowKey, int start, int end) throws ConnectionException {

        MutationBatch mb = ks.prepareMutationBatch();
        for (long i=start; i<end; i++) {
            mb.withRow(CF_DUAL_WRITES, rowKey).putColumn(i, "foo");
        }
        mb.execute();
    }

    private void deleteRowFromKS(Keyspace ks, int ... rowKeys) throws ConnectionException {
View Full Code Here

    private void deleteRowFromKS(Keyspace ks, int ... rowKeys) throws ConnectionException {

        MutationBatch mb = ks.prepareMutationBatch();
        for (int rowKey : rowKeys) {
            mb.withRow(CF_DUAL_WRITES, rowKey).delete();
        }
        mb.execute();
    }

    private AstyanaxContext<Keyspace> getKeyspaceContext(final String ks, final String seedHost) {
View Full Code Here

        //Assert.assertNull(column);

        baseAmount = 0;
       
        MutationBatch m = keyspace.prepareMutationBatch();
        m.withRow(CF_COUNTER1, "CounterRow1").incrementCounterColumn("MyCounter", incrAmount);
        m.execute();
//
//        column = keyspace.prepareQuery(CF_COUNTER1).getRow("CounterRow1").getColumn("MyCounter").execute().getResult();
//        Assert.assertNotNull(column);
//        Assert.assertEquals(baseAmount + incrAmount, column.getLongValue());
View Full Code Here

        String rowKey = "CounterRowDelete1";
        String counterName = "MyCounter";

        // Increment the column
        MutationBatch m = keyspace.prepareMutationBatch();
        m.withRow(CF_COUNTER1, rowKey).incrementCounterColumn(counterName, 1);
        m.execute();

//        // Read back the value
//        column = keyspace.prepareQuery(CF_COUNTER1).getRow(rowKey).getColumn(counterName).execute().getResult();
//        Assert.assertNotNull(column);
View Full Code Here

  public void testColumnTimestamps() throws Exception {
   
    CF_COL_TIMESTAMP.describe(keyspace);

        MutationBatch mb = keyspace.prepareMutationBatch();
        mb.withRow(CF_COL_TIMESTAMP, 1L)
            .setTimestamp(1).putColumn(1L, 1L)
            .setTimestamp(10).putColumn(2L, 2L)
            ;
        mb.execute();
       
View Full Code Here

        Assert.assertEquals(2, result1.size());
        Assert.assertNotNull(result1.getColumnByName(1L));
        Assert.assertNotNull(result1.getColumnByName(2L));
       
        mb = keyspace.prepareMutationBatch();
        mb.withRow(CF_COL_TIMESTAMP,  1L)
            .setTimestamp(result1.getColumnByName(1L).getTimestamp()-1)
            .deleteColumn(1L)
            .setTimestamp(result1.getColumnByName(2L).getTimestamp()-1)
            .deleteColumn(2L)
            .putEmptyColumn(3L, null);
View Full Code Here

       
        result1 = keyspace.prepareQuery(CF_COL_TIMESTAMP).getRow(1L).execute().getResult();
        Assert.assertEquals(3, result1.size());
       
        mb = keyspace.prepareMutationBatch();
        mb.withRow(CF_COL_TIMESTAMP,  1L)
            .setTimestamp(result1.getColumnByName(1L).getTimestamp()+1)
            .deleteColumn(1L)
            .setTimestamp(result1.getColumnByName(2L).getTimestamp()+1)
            .deleteColumn(2L);
        mb.execute();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.