@Override public void discardMutations() { primary.discardMutations(); secondary.discardMutations(); writeMetada.set(new ArrayList<WriteMetadata>()); }
@Override public void shutdown() { if (mutation.getRowCount() > 0) { try { mutation.execute(); } catch (ConnectionException e) { mutation.discardMutations(); } } } }
public static void deleteRowsForColumnRange(Keyspace keyspace) throws Exception { for (char keyName = 'A'; keyName <= 'Z'; keyName++) { MutationBatch m = keyspace.prepareMutationBatch(); String rowKey = Character.toString(keyName); m.withRow(CF_COLUMN_RANGE_TEST, rowKey).delete(); m.execute(); m.discardMutations(); } } }
private void deleteRowsForColumnRange() throws Exception { for (char keyName = 'A'; keyName <= 'Z'; keyName++) { MutationBatch m = keyspace.prepareMutationBatch(); String rowKey = Character.toString(keyName); m.withRow(CF_COLUMN_RANGE_TEST, rowKey).delete(); m.execute(); m.discardMutations(); } }
public static void populateRowsForColumnRange(Keyspace keyspace) throws Exception { MutationBatch m = keyspace.prepareMutationBatch(); for (char keyName = 'A'; keyName <= 'Z'; keyName++) { String rowKey = Character.toString(keyName); ColumnListMutation<String> colMutation = m.withRow(CF_COLUMN_RANGE_TEST, rowKey); for (char cName = 'a'; cName <= 'z'; cName++) { colMutation.putColumn(Character.toString(cName), (int) (cName - 'a') + 1, null); } m.withCaching(true); m.execute(); m.discardMutations(); } }
private static void populateRowsForColumnRange() throws Exception { MutationBatch m = keyspace.prepareMutationBatch(); for (char keyName = 'A'; keyName <= 'Z'; keyName++) { String rowKey = Character.toString(keyName); ColumnListMutation<String> colMutation = m.withRow(CF_ROW_RANGE, rowKey); for (char cName = 'a'; cName <= 'z'; cName++) { colMutation.putColumn(Character.toString(cName), (int) (cName - 'a') + 1, null); } m.withCaching(true); m.execute(); m.discardMutations(); } }
public static void deleteRowsForAccountsTable(Keyspace keyspace) throws Exception { for (char keyName = 'A'; keyName <= 'Z'; keyName++) { MutationBatch m = keyspace.prepareMutationBatch(); String rowKey = Character.toString(keyName); m.withRow(CF_ACCOUNTS, rowKey).delete(); m.execute(); m.discardMutations(); } } }
private void populateRowsForColumnRange() throws Exception { MutationBatch m = keyspace.prepareMutationBatch(); for (char keyName = 'A'; keyName <= 'Z'; keyName++) { String rowKey = Character.toString(keyName); ColumnListMutation<String> colMutation = m.withRow(CF_COLUMN_RANGE_TEST, rowKey); for (char cName = 'a'; cName <= 'z'; cName++) { colMutation.putColumn(Character.toString(cName), (int) (cName - 'a') + 1, null); } m.withCaching(true); m.execute(); m.discardMutations(); } }
mutation.discardMutations(); throw new RuntimeException(e);
public void deleteRows(int numRows) throws Exception { MutationBatch mb = keyspace.prepareMutationBatch(); for (int i=0; i<numRows; i++) { mb.withRow(CF_USER_INFO, "acct_" + i).delete(); mb.execute(); mb.discardMutations(); } }
public static void populateRowsForAccountsTable(Keyspace keyspace) throws Exception { MutationBatch m = keyspace.prepareMutationBatch(); for (char keyName = 'A'; keyName <= 'Z'; keyName++) { String character = Character.toString(keyName); ColumnListMutation<String> colMutation = m.withRow(CF_ACCOUNTS, character); colMutation.putColumn("user", "user" + character).putColumn("pswd", "pswd" + character); m.execute(); m.discardMutations(); } }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_ALL_ROWS_READER, null); CF_ALL_ROWS_READER.describe(keyspace); /** POPULATE ROWS FOR TESTS */ MutationBatch m = keyspace.prepareMutationBatch(); for (char keyName = 'A'; keyName <= 'Z'; keyName++) { String rowKey = Character.toString(keyName); ColumnListMutation<String> cfmStandard = m.withRow(CF_ALL_ROWS_READER, rowKey); for (char cName = 'a'; cName <= 'z'; cName++) { cfmStandard.putColumn(Character.toString(cName), (int) (cName - 'a') + 1, null); } m.execute(); m.discardMutations(); } }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_ALL_ROWS, null); CF_ALL_ROWS.describe(keyspace); /** POPULATE ROWS FOR TESTS */ MutationBatch m = keyspace.prepareMutationBatch(); for (char keyName = 'A'; keyName <= 'Z'; keyName++) { String rowKey = Character.toString(keyName); ColumnListMutation<String> cfmStandard = m.withRow(CF_ALL_ROWS, rowKey); for (char cName = 'a'; cName <= 'z'; cName++) { cfmStandard.putColumn(Character.toString(cName), (int) (cName - 'a') + 1, null); } m.withCaching(true); m.execute(); m.discardMutations(); } }
@Test public void testFunctionalQuery() throws Exception { MutationBatch m = keyspace.prepareMutationBatch(); for (char keyName = 'A'; keyName <= 'Z'; keyName++) { String rowKey = Character.toString(keyName); ColumnListMutation<String> cfmStandard = m.withRow(CF_STANDARD1, rowKey); for (char cName = 'a'; cName <= 'z'; cName++) { cfmStandard.putColumn(Character.toString(cName), (int) (cName - 'a') + 1, null); } m.withCaching(true); m.execute(); m.discardMutations(); } OperationResult<ColumnList<String>> r1 = keyspace .prepareQuery(CF_STANDARD1).getKey("A").execute(); Assert.assertTrue(26 <= r1.getResult().size()); }
public void populateRows(int numRows) throws Exception { MutationBatch mb = keyspace.prepareMutationBatch(); for (int i=0; i<numRows; i++) { Date date = OriginalDate.plusMinutes(i).toDate(); mb.withRow(CF_USER_INFO, "acct_" + i) .putColumn("firstname", "john_" + i, null) .putColumn("lastname", "smith_" + i, null) .putColumn("address", "john smith address " + i, null) .putColumn("age", 30+i, null) .putColumn("ageShort", new Integer(30+i).shortValue(), null) .putColumn("ageLong", new Integer(30+i).longValue(), null) .putColumn("percentile", 30.1) .putColumn("married", true) .putColumn("single", false) .putColumn("birthdate", date) .putColumn("bytes", TestBytes) .putColumn("uuid", TestUUID) .putEmptyColumn("empty"); mb.execute(); mb.discardMutations(); } }
progress.run(); execute(mutation); mutation.discardMutations();
private static void populateRowsForUserInfo(int numRows) throws Exception { MutationBatch mb = keyspace.prepareMutationBatch(); for (int i=0; i<numRows; i++) { Date date = OriginalDate.plusMinutes(i).toDate(); mb.withRow(CF_USER_INFO, "acct_" + i) .putColumn("firstname", "john_" + i, null) .putColumn("lastname", "smith_" + i, null) .putColumn("address", "john smith address " + i, null) .putColumn("age", 30+i, null) .putColumn("ageShort", new Integer(30+i).shortValue(), null) .putColumn("ageLong", new Integer(30+i).longValue(), null) .putColumn("percentile", 30.1) .putColumn("married", true) .putColumn("single", false) .putColumn("birthdate", date) .putColumn("bytes", TestBytes) .putColumn("uuid", TestUUID) .putEmptyColumn("empty"); mb.execute(); mb.discardMutations(); } }
@Override public void purge(AstyanaxStorage storage, Runnable progress) { DeltaPlacement placement = (DeltaPlacement) storage.getPlacement(); CassandraKeyspace keyspace = placement.getKeyspace(); // Scan all the shards and delete all the rows we find. MutationBatch mutation = keyspace.prepareMutationBatch(SorConsistencies.toAstyanax(WriteConsistency.STRONG)); Iterator<String> keyIter = _keyScanner.scanKeys(storage, ReadConsistency.STRONG); while (keyIter.hasNext()) { ByteBuffer rowKey = storage.getRowKey(keyIter.next()); mutation.withRow(placement.getDeltaColumnFamily(), rowKey).delete(); mutation.withRow(placement.getBlockedDeltaColumnFamily(), rowKey).delete(); if (mutation.getRowCount() >= 100) { progress.run(); execute(mutation, "purge %d records from placement %s", mutation.getRowCount(), placement.getName()); mutation.discardMutations(); } } if (!mutation.isEmpty()) { progress.run(); execute(mutation, "purge %d records from placement %s", mutation.getRowCount(), placement.getName()); } }
@Override public void purge(AstyanaxStorage storage, Runnable progress) { DeltaPlacement placement = (DeltaPlacement) storage.getPlacement(); CassandraKeyspace keyspace = placement.getKeyspace(); // Scan all the shards and delete all the rows we find. MutationBatch mutation = keyspace.prepareMutationBatch(SorConsistencies.toAstyanax(WriteConsistency.STRONG)); Iterator<String> keyIter = _keyScanner.scanKeys(storage, ReadConsistency.STRONG); while (keyIter.hasNext()) { ByteBuffer rowKey = storage.getRowKey(keyIter.next()); mutation.withRow(placement.getDeltaColumnFamily(), rowKey).delete(); mutation.withRow(placement.getBlockedDeltaColumnFamily(), rowKey).delete(); if (mutation.getRowCount() >= 100) { progress.run(); execute(mutation, "purge %d records from placement %s", mutation.getRowCount(), placement.getName()); mutation.discardMutations(); } } if (!mutation.isEmpty()) { progress.run(); execute(mutation, "purge %d records from placement %s", mutation.getRowCount(), placement.getName()); } }
m.withRow(CF_TIME_UUID, rowKey).delete(); m.execute(); m.discardMutations();