Skip to content

Commit 9fe99cf

Browse files
authored
Merge pull request #560 from alex268/master
Added support of SnapshotRW transaction level
2 parents c851506 + c8c8d48 commit 9fe99cf

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

common/src/main/java/tech/ydb/common/transaction/TxMode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public enum TxMode {
99

1010
SERIALIZABLE_RW,
1111
SNAPSHOT_RO,
12+
SNAPSHOT_RW,
1213
STALE_RO,
1314

1415
ONLINE_RO,

query/src/main/java/tech/ydb/query/impl/TxControl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class TxControl {
1616
.setSnapshotReadOnly(YdbQuery.SnapshotModeSettings.getDefaultInstance())
1717
.build();
1818

19+
private static final YdbQuery.TransactionSettings TS_SNAPSHOT_RW = YdbQuery.TransactionSettings.newBuilder()
20+
.setSnapshotReadWrite(YdbQuery.SnapshotRWModeSettings.getDefaultInstance())
21+
.build();
22+
1923
private static final YdbQuery.TransactionSettings TS_STALE = YdbQuery.TransactionSettings.newBuilder()
2024
.setStaleReadOnly(YdbQuery.StaleModeSettings.getDefaultInstance())
2125
.build();
@@ -55,15 +59,18 @@ public static YdbQuery.TransactionSettings txSettings(TxMode tx) {
5559
return TS_SERIALIZABLE;
5660
case SNAPSHOT_RO:
5761
return TS_SNAPSHOT;
62+
case SNAPSHOT_RW:
63+
return TS_SNAPSHOT_RW;
5864
case STALE_RO:
5965
return TS_STALE;
6066
case ONLINE_RO:
6167
return TS_ONLINE;
6268
case ONLINE_INCONSISTENT_RO:
6369
return TS_ONLINE_INCONSISTENT;
6470
case NONE:
65-
default:
6671
return null;
72+
default:
73+
throw new IllegalArgumentException("Tx mode " + tx + " is not supported");
6774
}
6875
}
6976

table/src/main/java/tech/ydb/table/impl/TxControlToPb.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ public static YdbTable.TransactionSettings txSettings(TxMode tx) {
6161
return TS_ONLINE;
6262
case ONLINE_INCONSISTENT_RO:
6363
return TS_ONLINE_INCONSISTENT;
64+
6465
case NONE:
66+
case SNAPSHOT_RW:
6567
default:
66-
return null;
68+
throw new IllegalArgumentException("Tx mode " + tx + " is not supported in TableService");
6769
}
6870
}
6971
}

0 commit comments

Comments
 (0)