kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 7d0ac686760d4d5cfe9955c6fbee4205ada9044ada5a0505b4424efa6f68fc7c |
|---|---|
| Author | Michael Spiegel <spiegel@addthis.com> · 2014-09-03 15:08 -04:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-09-14 20:33 -07:00 |
| Parents | 4c69fa26c718 |
2 files changed
modified driver-core/src/main/java/com/datastax/driver/core/BatchStatement.java +9 −0
| @@ -171,6 +171,15 @@ | ||
| 171 | 171 | return this; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | + /** | |
| 175 | + * Returns the number of elements in this batch. | |
| 176 | + * | |
| 177 | + * @return the number of elements in this batch. | |
| 178 | + */ | |
| 179 | + public int size() { | |
| 180 | + return statements.size(); | |
| 181 | + } | |
| 182 | + | |
| 174 | 183 | /** |
| 175 | 184 | * Throws an {@code UnsupportedOperationException} as setting the serial consistency is |
| 176 | 185 | * currently not supported for protocol batches by Cassandra. |
modified driver-core/src/test/java/com/datastax/driver/core/BatchStatementTest.java +4 −0
| @@ -44,6 +44,8 @@ | ||
| 44 | 44 | batch.add(st.bind("key1", 1)); |
| 45 | 45 | batch.add(st.bind("key2", 0)); |
| 46 | 46 | |
| 47 | + assertEquals(3, batch.size()); | |
| 48 | + | |
| 47 | 49 | session.execute(batch); |
| 48 | 50 | |
| 49 | 51 | ResultSet rs = session.execute("SELECT * FROM test"); |
| @@ -90,6 +92,8 @@ | ||
| 90 | 92 | batch.add(st.bind("key1", 1)); |
| 91 | 93 | batch.add(st.bind("key1", 2)); |
| 92 | 94 | |
| 95 | + assertEquals(3, batch.size()); | |
| 96 | + | |
| 93 | 97 | ResultSet rs = session.execute(batch); |
| 94 | 98 | Row r = rs.one(); |
| 95 | 99 | assertTrue(!r.isNull("[applied]")); |