@@ -61,6 +61,9 @@ public interface ReadOption {}
61
61
public interface ReadQueryUpdateTransactionOption
62
62
extends ReadOption , QueryOption , UpdateOption , TransactionOption {}
63
63
64
+ /** Marker interface to mark options applicable to Update and Write operations */
65
+ public interface UpdateTransactionOption extends UpdateOption , TransactionOption {}
66
+
64
67
/**
65
68
* Marker interface to mark options applicable to Create, Update and Delete operations in admin
66
69
* API.
@@ -108,6 +111,17 @@ public static TransactionOption commitStats() {
108
111
public static TransactionOption optimisticLock () {
109
112
return OPTIMISTIC_LOCK_OPTION ;
110
113
}
114
+
115
+ /**
116
+ * Specifying this instructs the transaction to be excluded from being recorded in change streams
117
+ * with the DDL option `allow_txn_exclusion=true`. This does not exclude the transaction from
118
+ * being recorded in the change streams with the DDL option `allow_txn_exclusion` being false or
119
+ * unset.
120
+ */
121
+ public static UpdateTransactionOption excludeTxnFromChangeStreams () {
122
+ return EXCLUDE_TXN_FROM_CHANGE_STREAMS_OPTION ;
123
+ }
124
+
111
125
/**
112
126
* Specifying this will cause the read to yield at most this many rows. This should be greater
113
127
* than 0.
@@ -282,6 +296,18 @@ void appendToOptions(Options options) {
282
296
283
297
static final OptimisticLockOption OPTIMISTIC_LOCK_OPTION = new OptimisticLockOption ();
284
298
299
+ /** Option to request the transaction to be excluded from change streams. */
300
+ static final class ExcludeTxnFromChangeStreamsOption extends InternalOption
301
+ implements UpdateTransactionOption {
302
+ @ Override
303
+ void appendToOptions (Options options ) {
304
+ options .withExcludeTxnFromChangeStreams = true ;
305
+ }
306
+ }
307
+
308
+ static final ExcludeTxnFromChangeStreamsOption EXCLUDE_TXN_FROM_CHANGE_STREAMS_OPTION =
309
+ new ExcludeTxnFromChangeStreamsOption ();
310
+
285
311
/** Option pertaining to flow control. */
286
312
static final class FlowControlOption extends InternalOption implements ReadAndQueryOption {
287
313
final int prefetchChunks ;
@@ -406,6 +432,7 @@ void appendToOptions(Options options) {
406
432
private String etag ;
407
433
private Boolean validateOnly ;
408
434
private Boolean withOptimisticLock ;
435
+ private Boolean withExcludeTxnFromChangeStreams ;
409
436
private Boolean dataBoostEnabled ;
410
437
private DirectedReadOptions directedReadOptions ;
411
438
private DecodeMode decodeMode ;
@@ -509,6 +536,10 @@ Boolean withOptimisticLock() {
509
536
return withOptimisticLock ;
510
537
}
511
538
539
+ Boolean withExcludeTxnFromChangeStreams () {
540
+ return withExcludeTxnFromChangeStreams ;
541
+ }
542
+
512
543
boolean hasDataBoostEnabled () {
513
544
return dataBoostEnabled != null ;
514
545
}
@@ -572,6 +603,11 @@ public String toString() {
572
603
if (withOptimisticLock != null ) {
573
604
b .append ("withOptimisticLock: " ).append (withOptimisticLock ).append (' ' );
574
605
}
606
+ if (withExcludeTxnFromChangeStreams != null ) {
607
+ b .append ("withExcludeTxnFromChangeStreams: " )
608
+ .append (withExcludeTxnFromChangeStreams )
609
+ .append (' ' );
610
+ }
575
611
if (dataBoostEnabled != null ) {
576
612
b .append ("dataBoostEnabled: " ).append (dataBoostEnabled ).append (' ' );
577
613
}
@@ -617,6 +653,7 @@ public boolean equals(Object o) {
617
653
&& Objects .equals (etag (), that .etag ())
618
654
&& Objects .equals (validateOnly (), that .validateOnly ())
619
655
&& Objects .equals (withOptimisticLock (), that .withOptimisticLock ())
656
+ && Objects .equals (withExcludeTxnFromChangeStreams (), that .withExcludeTxnFromChangeStreams ())
620
657
&& Objects .equals (dataBoostEnabled (), that .dataBoostEnabled ())
621
658
&& Objects .equals (directedReadOptions (), that .directedReadOptions ());
622
659
}
@@ -663,6 +700,9 @@ public int hashCode() {
663
700
if (withOptimisticLock != null ) {
664
701
result = 31 * result + withOptimisticLock .hashCode ();
665
702
}
703
+ if (withExcludeTxnFromChangeStreams != null ) {
704
+ result = 31 * result + withExcludeTxnFromChangeStreams .hashCode ();
705
+ }
666
706
if (dataBoostEnabled != null ) {
667
707
result = 31 * result + dataBoostEnabled .hashCode ();
668
708
}
0 commit comments