@@ -46,6 +46,11 @@ public interface UpdateOption {}
|
46 | 46 | /** Marker interface to mark options applicable to list operations in admin API. */
|
47 | 47 | public interface ListOption {}
|
48 | 48 |
|
| 49 | +/** Specifying this instructs the transaction to request {@link CommitStats} from the backend. */ |
| 50 | +public static TransactionOption commitStats() { |
| 51 | +return COMMIT_STATS_OPTION; |
| 52 | +} |
| 53 | + |
49 | 54 | /**
|
50 | 55 | * Specifying this will cause the read to yield at most this many rows. This should be greater
|
51 | 56 | * than 0.
|
@@ -116,6 +121,16 @@ public static ListOption filter(String filter) {
|
116 | 121 | return new FilterOption(filter);
|
117 | 122 | }
|
118 | 123 |
|
| 124 | +/** Option to request {@link CommitStats} for read/write transactions. */ |
| 125 | +static final class CommitStatsOption extends InternalOption implements TransactionOption { |
| 126 | +@Override |
| 127 | +void appendToOptions(Options options) { |
| 128 | +options.withCommitStats = true; |
| 129 | +} |
| 130 | +} |
| 131 | + |
| 132 | +static final CommitStatsOption COMMIT_STATS_OPTION = new CommitStatsOption(); |
| 133 | + |
119 | 134 | /** Option pertaining to flow control. */
|
120 | 135 | static final class FlowControlOption extends InternalOption implements ReadAndQueryOption {
|
121 | 136 | final int prefetchChunks;
|
@@ -143,6 +158,7 @@ void appendToOptions(Options options) {
|
143 | 158 | }
|
144 | 159 | }
|
145 | 160 |
|
| 161 | +private boolean withCommitStats; |
146 | 162 | private Long limit;
|
147 | 163 | private Integer prefetchChunks;
|
148 | 164 | private Integer bufferRows;
|
@@ -153,6 +169,10 @@ void appendToOptions(Options options) {
|
153 | 169 | // Construction is via factory methods below.
|
154 | 170 | private Options() {}
|
155 | 171 |
|
| 172 | +boolean withCommitStats() { |
| 173 | +return withCommitStats; |
| 174 | +} |
| 175 | + |
156 | 176 | boolean hasLimit() {
|
157 | 177 | return limit != null;
|
158 | 178 | }
|
@@ -204,6 +224,9 @@ String filter() {
|
204 | 224 | @Override
|
205 | 225 | public String toString() {
|
206 | 226 | StringBuilder b = new StringBuilder();
|
| 227 | +if (withCommitStats) { |
| 228 | +b.append("withCommitStats: ").append(withCommitStats).append(' '); |
| 229 | +} |
207 | 230 | if (limit != null) {
|
208 | 231 | b.append("limit: ").append(limit).append(' ');
|
209 | 232 | }
|
@@ -234,7 +257,8 @@ public boolean equals(Object o) {
|
234 | 257 | }
|
235 | 258 |
|
236 | 259 | Options that = (Options) o;
|
237 |
| -return (!hasLimit() && !that.hasLimit() |
| 260 | +return Objects.equals(withCommitStats, that.withCommitStats) |
| 261 | +&& (!hasLimit() && !that.hasLimit() |
238 | 262 | || hasLimit() && that.hasLimit() && Objects.equals(limit(), that.limit()))
|
239 | 263 | && (!hasPrefetchChunks() && !that.hasPrefetchChunks()
|
240 | 264 | || hasPrefetchChunks()
|
@@ -253,6 +277,9 @@ public boolean equals(Object o) {
|
253 | 277 | @Override
|
254 | 278 | public int hashCode() {
|
255 | 279 | int result = 31;
|
| 280 | +if (withCommitStats) { |
| 281 | +result = 31 * result + 1231; |
| 282 | +} |
256 | 283 | if (limit != null) {
|
257 | 284 | result = 31 * result + limit.hashCode();
|
258 | 285 | }
|
|
0 commit comments