@@ -33,6 +33,26 @@ class TExpirationCondition: public IEraseRowsCondition {
33
33
}
34
34
}
35
35
36
+ TMaybe<TString> GetWallClockDyNumber () const {
37
+ const auto instantValue = InstantValue (WallClockInstant, Unit);
38
+ if (!instantValue) {
39
+ LOG_CRIT_S (*TlsActivationContext, NKikimrServices::TX_DATASHARD,
40
+ " Unsupported unit: " << static_cast <ui32>(Unit));
41
+ CannotSerialize = true ;
42
+ return Nothing ();
43
+ }
44
+
45
+ const auto strInstant = ToString (*instantValue);
46
+ WallClockSerialized = NDyNumber::ParseDyNumberString (strInstant);
47
+ if (!WallClockSerialized) {
48
+ CannotSerialize = true ;
49
+ LOG_CRIT_S (*TlsActivationContext, NKikimrServices::TX_DATASHARD,
50
+ " Cannot parse DyNumber from: " << strInstant.Quote ());
51
+ }
52
+
53
+ return WallClockSerialized;
54
+ }
55
+
36
56
void ParsePgFromText (const TString& value) const {
37
57
const auto & result = NPg::PgNativeBinaryFromNativeText (value, Type.GetPgTypeDesc ());
38
58
if (result.Error ) {
@@ -44,6 +64,34 @@ class TExpirationCondition: public IEraseRowsCondition {
44
64
}
45
65
}
46
66
67
+ TMaybe<TString> GetWallClockPg () const {
68
+ switch (NPg::PgTypeIdFromTypeDesc (Type.GetPgTypeDesc ())) {
69
+ case DATEOID:
70
+ case TIMESTAMPOID: {
71
+ const auto & wallClockIsoString = WallClockInstant.ToString ();
72
+ ParsePgFromText (wallClockIsoString);
73
+ break ;
74
+ }
75
+ case INT4OID:
76
+ case INT8OID: {
77
+ const auto instantValue = InstantValue (WallClockInstant, Unit);
78
+ if (!instantValue) {
79
+ LOG_CRIT_S (*TlsActivationContext, NKikimrServices::TX_DATASHARD,
80
+ " Unsupported unit: " << static_cast <ui32>(Unit));
81
+ CannotSerialize = true ;
82
+ return Nothing ();
83
+ }
84
+ const auto strInstant = ToString (*instantValue);
85
+ ParsePgFromText (strInstant);
86
+ break ;
87
+ }
88
+ default :
89
+ CannotSerialize = true ;
90
+ LOG_CRIT_S (*TlsActivationContext, NKikimrServices::TX_DATASHARD, " Unsupported PG type" );
91
+ }
92
+ return WallClockSerialized;
93
+ }
94
+
47
95
TMaybe<TString> GetWallClockSerialized () const {
48
96
if (WallClockSerialized) {
49
97
return WallClockSerialized;
@@ -54,53 +102,13 @@ class TExpirationCondition: public IEraseRowsCondition {
54
102
}
55
103
56
104
switch (Type.GetTypeId ()) {
57
- case NScheme::NTypeIds::DyNumber: {
58
- const auto instantValue = InstantValue (WallClockInstant, Unit);
59
- if (!instantValue) {
60
- LOG_CRIT_S (*TlsActivationContext, NKikimrServices::TX_DATASHARD,
61
- " Unsupported unit: " << static_cast <ui32>(Unit));
62
- return Nothing ();
63
- }
64
-
65
- const auto strInstant = ToString (*instantValue);
66
- const auto wallClockDyNumber = NDyNumber::ParseDyNumberString (strInstant);
67
- if (!wallClockDyNumber) {
68
- CannotSerialize = true ;
69
- LOG_CRIT_S (*TlsActivationContext, NKikimrServices::TX_DATASHARD,
70
- " Cannot parse DyNumber from: " << strInstant.Quote ());
71
- } else {
72
- WallClockSerialized = *wallClockDyNumber;
73
- }
74
- break ;
75
- }
76
- case NScheme::NTypeIds::Pg: {
77
- switch (NPg::PgTypeIdFromTypeDesc (Type.GetPgTypeDesc ())) {
78
- case DATEOID:
79
- case TIMESTAMPOID: {
80
- const auto & wallClockIsoString = WallClockInstant.ToString ();
81
- ParsePgFromText (wallClockIsoString);
82
- break ;
83
- }
84
- case INT4OID:
85
- case INT8OID: {
86
- const auto instantValue = InstantValue (WallClockInstant, Unit);
87
- if (!instantValue) {
88
- LOG_CRIT_S (*TlsActivationContext, NKikimrServices::TX_DATASHARD,
89
- " Unsupported unit: " << static_cast <ui32>(Unit));
90
- return Nothing ();
91
- }
92
- const auto strInstant = ToString (*instantValue);
93
- ParsePgFromText (strInstant);
94
- break ;
95
- }
96
- default :
97
- CannotSerialize = true ;
98
- LOG_CRIT_S (*TlsActivationContext, NKikimrServices::TX_DATASHARD, " Unsupported PG type" );
99
- }
100
- break ;
101
- }
105
+ case NScheme::NTypeIds::DyNumber:
106
+ return GetWallClockDyNumber ();
107
+ case NScheme::NTypeIds::Pg:
108
+ return GetWallClockPg ();
109
+ default :
110
+ Y_ABORT (" Unreachable" );
102
111
}
103
- return WallClockSerialized;
104
112
}
105
113
106
114
bool CheckUi64 (ui64 value) const {
@@ -154,15 +162,15 @@ class TExpirationCondition: public IEraseRowsCondition {
154
162
}
155
163
156
164
bool CheckSerialized (TStringBuf value) const {
157
- if (const auto & wallClockDSerialized = GetWallClockSerialized ()) {
165
+ if (const auto & wallClockSerialized = GetWallClockSerialized ()) {
158
166
switch (Type.GetTypeId ()) {
159
167
// 'value since epoch' mode
160
168
case NScheme::NTypeIds::DyNumber:
161
- return value <= *wallClockDSerialized ;
169
+ return value <= *wallClockSerialized ;
162
170
case NScheme::NTypeIds::Pg: {
163
171
int result = NPg::PgNativeBinaryCompare (
164
172
value.Data (), value.Size (),
165
- wallClockDSerialized ->Data (), wallClockDSerialized ->Size (),
173
+ wallClockSerialized ->Data (), wallClockSerialized ->Size (),
166
174
Type.GetPgTypeDesc ());
167
175
return result <= 0 ;
168
176
}
0 commit comments