Skip to content

Commit 11f1b07

Browse files
committed
* Added table/options.ReadFromSnapshot() option for session.StreamReadTable()
1 parent 3d2afa2 commit 11f1b07

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Added `table/options.ReadFromSnapshot(bool)` option for `session.StreamReadTable()`
2+
13
## v3.51.1
24
* Added checking condition for `tx.Rollback()` in `retry.DoTx`
35

table/options/options.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ type (
10121012

10131013
readColumnsOption []string
10141014
readOrderedOption struct{}
1015+
readSnapshotOption bool
10151016
readKeyRangeOption KeyRange
10161017
readGreaterOrEqualOption struct{ types.Value }
10171018
readLessOrEqualOption struct{ types.Value }
@@ -1053,10 +1054,18 @@ func (columns readColumnsOption) ApplyReadTableOption(desc *ReadTableDesc, a *al
10531054
desc.Columns = append(desc.Columns, columns...)
10541055
}
10551056

1056-
func (r readOrderedOption) ApplyReadTableOption(desc *ReadTableDesc, a *allocator.Allocator) {
1057+
func (readOrderedOption) ApplyReadTableOption(desc *ReadTableDesc, a *allocator.Allocator) {
10571058
desc.Ordered = true
10581059
}
10591060

1061+
func (b readSnapshotOption) ApplyReadTableOption(desc *ReadTableDesc, a *allocator.Allocator) {
1062+
if b {
1063+
desc.UseSnapshot = FeatureEnabled.ToYDB()
1064+
} else {
1065+
desc.UseSnapshot = FeatureDisabled.ToYDB()
1066+
}
1067+
}
1068+
10601069
func (x readKeyRangeOption) ApplyReadTableOption(desc *ReadTableDesc, a *allocator.Allocator) {
10611070
desc.initKeyRange()
10621071
if x.From != nil {
@@ -1086,10 +1095,14 @@ func ReadColumns(names ...string) readColumnsOption {
10861095
return names
10871096
}
10881097

1089-
func ReadOrdered() readOrderedOption {
1098+
func ReadOrdered() ReadTableOption {
10901099
return readOrderedOption{}
10911100
}
10921101

1102+
func ReadFromSnapshot(b bool) ReadTableOption {
1103+
return readSnapshotOption(b)
1104+
}
1105+
10931106
// ReadKeyRange returns ReadTableOption which makes ReadTable read values
10941107
// in range [x.From, x.To).
10951108
//

0 commit comments

Comments
 (0)