/** * Adds a new statement to the BATCH statement these options are part of. * * @param statement the statement to add. * @return the BATCH statement these options are part of. */ public Batch add(RegularStatement statement) { return this.statement.add(statement); } }
Batch(RegularStatement[] statements, boolean logged) { super(null, null, null); this.statements = statements.length == 0 ? new ArrayList<RegularStatement>() : new ArrayList<RegularStatement>(statements.length); this.logged = logged; this.usings = new Options(this); for (int i = 0; i < statements.length; i++) add(statements[i]); }
@Override public void add(RegularStatement statement) { batch.add(statement); }
@Test(groups = "short") public void batchNonBuiltStatementTest() throws Exception { SimpleStatement simple = new SimpleStatement("INSERT INTO " + TABLE1 + " (k, t) VALUES ('batchTest1', 'val1')"); RegularStatement built = insertInto(TABLE1).value("k", "batchTest2").value("t", "val2"); session().execute(batch().add(simple).add(built)); List<Row> rows = session().execute(select().from(TABLE1).where(in("k", "batchTest1", "batchTest2"))).all(); assertEquals(2, rows.size()); Row r1 = rows.get(0); assertEquals("batchTest1", r1.getString("k")); assertEquals("val1", r1.getString("t")); Row r2 = rows.get(1); assertEquals("batchTest2", r2.getString("k")); assertEquals("val2", r2.getString("t")); }
/** * Adds a new statement to the BATCH statement these options are part of. * * @param statement the statement to add. * @return the BATCH statement these options are part of. */ public Batch add(RegularStatement statement) { return this.statement.add(statement); } }
/** * Adds a new statement to the BATCH statement these options are part of. * * @param statement the statement to add. * @return the BATCH statement these options are part of. */ public Batch add(RegularStatement statement) { return this.statement.add(statement); } }
/** * Adds a new statement to the BATCH statement these options are part of. * * @param statement the statement to add. * @return the BATCH statement these options are part of. */ public Batch add(RegularStatement statement) { return this.statement.add(statement); } }
/** * Adds a new statement to the BATCH statement these options are part of. * * @param statement the statement to add. * @return the BATCH statement these options are part of. */ public Batch add(RegularStatement statement) { return this.statement.add(statement); } }
protected void write(int n, boolean batch, ConsistencyLevel cl) { // We don't use insert for our test because the resultSet don't ship the queriedHost // Also note that we don't use tracing because this would trigger requests that screw up the // test for (int i = 0; i < n; ++i) if (batch) // BUG: WriteType == SIMPLE session() .execute( batch() .add(insertInto(tableName).values(new String[] {"k", "i"}, new Object[] {0, 0})) .setConsistencyLevel(cl)); else session() .execute( new SimpleStatement(String.format("INSERT INTO %s(k, i) VALUES (0, 0)", tableName)) .setConsistencyLevel(cl)); }
private void testWideBatchRows(int key) throws Throwable { // Write data Batch q = batch(); for (int i = 0; i < 4000; ++i) { q = q.add(insertInto("wide_batch_rows").value("k", key).value("i", i)); } session().execute(q.setConsistencyLevel(ConsistencyLevel.QUORUM)); // Read data ResultSet rs = session().execute(select("i").from("wide_batch_rows").where(eq("k", key))); // Verify data int i = 0; for (Row row : rs) { assertTrue(row.getInt("i") == i++); } }
batch = batch() .add(update("foo").with(incr("a", 1))) .add(update("foo").with(incr("b", 2))) .add(update("foo").with(incr("c", 3))) .using(timestamp(42)); assertEquals(batch.toString(), query); batch = batch() .add(update("foo").with(incr("a"))) .add(update("foo").with(incr("b"))) .add(update("foo").with(incr("c"))) .using(timestamp(42)); assertEquals(batch.toString(), query); batch = batch() .add(update("foo").with(decr("a", 1))) .add(update("foo").with(decr("b", 2))) .add(update("foo").with(decr("c", 3))) .using(timestamp(42)); assertEquals(batch.toString(), query); batch = batch() .add(update("foo").with(decr("a"))) .add(update("foo").with(decr("b"))) .add(update("foo").with(decr("c")))
batch = batch() .add(insertInto(table).values(new String[] {"k", "a"}, new Object[] {42, 1})) .add(update(table).using(ttl(400))); assertEquals(batch.getRoutingKey(protocolVersion, codecRegistry), bb); assertEquals(batch.toString(), batch_query); batch_query += "SELECT * FROM foo WHERE k=42;"; batch_query += "APPLY BATCH;"; batch = batch().add(select().from("foo").where(eq("k", 42))); assertEquals(batch.getRoutingKey(protocolVersion, codecRegistry), null); assertEquals(batch.toString(), batch_query);
Batch(RegularStatement[] statements, boolean logged) { super(null, null, null); this.statements = statements.length == 0 ? new ArrayList<RegularStatement>() : new ArrayList<RegularStatement>(statements.length); this.logged = logged; this.usings = new Options(this); for (int i = 0; i < statements.length; i++) add(statements[i]); }
Batch(RegularStatement[] statements, boolean logged) { super(null, null, null); this.statements = statements.length == 0 ? new ArrayList<RegularStatement>() : new ArrayList<RegularStatement>(statements.length); this.logged = logged; this.usings = new Options(this); for (int i = 0; i < statements.length; i++) add(statements[i]); }
Batch(RegularStatement[] statements, boolean logged) { super(null, null, null); this.statements = statements.length == 0 ? new ArrayList<RegularStatement>() : new ArrayList<RegularStatement>(statements.length); this.logged = logged; this.usings = new Options(this); for (int i = 0; i < statements.length; i++) add(statements[i]); }
Batch(RegularStatement[] statements, boolean logged) { super((String)null); this.statements = statements.length == 0 ? new ArrayList<RegularStatement>() : new ArrayList<RegularStatement>(statements.length); this.logged = logged; this.usings = new Options(this); for (int i = 0; i < statements.length; i++) add(statements[i]); }
@Override public CassandraBatchOperations update(Iterable<?> entities, WriteOptions options) { assertNotExecuted(); Assert.notNull(entities, "Entities must not be null"); Assert.notNull(options, "WriteOptions must not be null"); for (Object entity : entities) { Assert.notNull(entity, "Entity must not be null"); batch.add(QueryUtils.createUpdateQuery(getTableName(entity), entity, options, operations.getConverter())); } return this; }
@Override public CassandraBatchOperations delete(Iterable<?> entities) { assertNotExecuted(); Assert.notNull(entities, "Entities must not be null"); for (Object entity : entities) { Assert.notNull(entity, "Entity must not be null"); batch.add( QueryUtils.createDeleteQuery(getTableName(entity), entity, QueryOptions.empty(), operations.getConverter())); } return this; }