Skip to content

Commit 59a68f4

Browse files
authored
---
yaml --- r: 9145 b: refs/heads/batching-expr c: 186b72b h: refs/heads/master i: 9143: 2b24c3f
1 parent 8045408 commit 59a68f4

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ refs/tags/v0.27.0: 015e56421f67042037ed276353d3c0852483d570
8484
refs/tags/v0.28.0: 0d4c4daeda94e17ab70577334ae4a228b8774742
8585
refs/tags/v0.29.0: d702b33b70f2e81853a142b4158227c5a88c8781
8686
refs/tags/v0.30.0: 9ea3a32084835d0499934e7c070af9f120747e88
87-
refs/heads/batching-expr: 5d55feb8960a0b884355f923b0eac5776a9dee5d
87+
refs/heads/batching-expr: 186b72b9ad58fad554cf66c24ae3f1f3cfa19319
8888
"refs/heads/datastore_orderby_tostring": 24a5a107969714ebb69a5a098f47658f7b1e8689
8989
"refs/heads/mrschmidt-__name___": effe27458f7d31b1d5ae1af6a5a228ce89c33462
9090
refs/heads/mrschmidt-emptymerge: 447dbddebbcb8b88fe5dc480d16c0c7697712d11

branches/batching-expr/google-cloud-core/src/main/java/com/google/cloud/batchingexperimental/RequestAccumulator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ public List<SettableApiFuture<ResponseT>> futureBatch() {
130130
return futures;
131131
}
132132

133+
/** Returns the combined size of items in {@link #batch()}. */
134+
public long bytes() {
135+
return curBytes - oversizedBytes;
136+
}
137+
133138
/** Consumes the current batch. */
134139
public void next() {
135140
batch().clear();

branches/batching-expr/google-cloud-core/src/test/java/com/google/cloud/batchingexperimental/RequestAccumulatorTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void testCount() {
3232
acc.add("b", 1, null);
3333
assertThat(acc.hasBatch()).isTrue();
3434
assertThat(acc.batch()).containsExactly("a", "b");
35+
assertThat(acc.bytes()).isEqualTo(2);
3536

3637
acc.next();
3738
assertThat(acc.hasBatch()).isFalse();
@@ -42,6 +43,7 @@ public void testCount() {
4243
acc.add("d", 1, null);
4344
assertThat(acc.hasBatch()).isTrue();
4445
assertThat(acc.batch()).containsExactly("c", "d");
46+
assertThat(acc.bytes()).isEqualTo(2);
4547

4648
acc.next();
4749
assertThat(acc.hasBatch()).isFalse();
@@ -58,6 +60,7 @@ public void testSize() {
5860
acc.add("bc", 2, null);
5961
assertThat(acc.hasBatch()).isTrue();
6062
assertThat(acc.batch()).containsExactly("a", "bc");
63+
assertThat(acc.bytes()).isEqualTo(3);
6164

6265
acc.next();
6366
assertThat(acc.hasBatch()).isFalse();
@@ -68,6 +71,7 @@ public void testSize() {
6871
acc.add("fg", 2, null);
6972
assertThat(acc.hasBatch()).isTrue();
7073
assertThat(acc.batch()).containsExactly("de", "fg");
74+
assertThat(acc.bytes()).isEqualTo(4);
7175

7276
acc.next();
7377
assertThat(acc.hasBatch()).isFalse();
@@ -79,6 +83,7 @@ public void testOversizeAlone() {
7983
acc.add("abc", 3, null);
8084
assertThat(acc.hasBatch()).isTrue();
8185
assertThat(acc.batch()).containsExactly("abc");
86+
assertThat(acc.bytes()).isEqualTo(3);
8287
}
8388

8489
@Test
@@ -90,10 +95,12 @@ public void testOversize() {
9095
acc.add("xyz", 3, null);
9196
assertThat(acc.hasBatch()).isTrue();
9297
assertThat(acc.batch()).containsExactly("a");
98+
assertThat(acc.bytes()).isEqualTo(1);
9399

94100
acc.next();
95101
assertThat(acc.hasBatch()).isTrue();
96102
assertThat(acc.batch()).containsExactly("xyz");
103+
assertThat(acc.bytes()).isEqualTo(3);
97104

98105
acc.next();
99106
assertThat(acc.hasBatch()).isFalse();

0 commit comments

Comments
 (0)