Skip to content

Commit 50074e8

Browse files
author
Vadim Averin
authored
Refactor EYtSettingType enum (#6524)
1 parent b0dd23a commit 50074e8

File tree

4 files changed

+131
-74
lines changed

4 files changed

+131
-74
lines changed

ydb/library/yql/providers/yt/dq_task_preprocessor/ya.make

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ PEERDIR(
1515
ydb/library/yql/providers/common/codec
1616
ydb/library/yql/providers/dq/interface
1717
ydb/library/yql/providers/yt/codec
18+
ydb/library/yql/providers/yt/provider
1819
ydb/library/yql/providers/yt/gateway/lib
1920
ydb/library/yql/providers/yt/lib/yson_helpers
2021
)

ydb/library/yql/providers/yt/gateway/lib/ya.make

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ PEERDIR(
2929
ydb/library/yql/core/type_ann
3030
ydb/library/yql/providers/common/codec
3131
ydb/library/yql/providers/common/gateway
32+
ydb/library/yql/providers/yt/provider
3233
ydb/library/yql/providers/yt/common
3334
ydb/library/yql/providers/yt/lib/hash
3435
ydb/library/yql/providers/yt/lib/res_pull

ydb/library/yql/providers/yt/provider/yql_yt_op_settings.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,9 @@ bool ValidateSettings(const TExprNode& settingsNode, EYtSettingTypes accepted, T
869869
}
870870
break;
871871
}
872+
case EYtSettingType::LAST: {
873+
YQL_ENSURE(false);
874+
}
872875
}
873876
}
874877

@@ -1219,4 +1222,16 @@ ui32 GetMinChildrenForIndexedKeyFilter(EYtSettingType type) {
12191222
return 3u;
12201223
}
12211224

1225+
EYtSettingTypes operator|(EYtSettingTypes left, const EYtSettingTypes& right) {
1226+
return left |= right;
1227+
}
1228+
1229+
EYtSettingTypes operator&(EYtSettingTypes left, const EYtSettingTypes& right) {
1230+
return left &= right;
1231+
}
1232+
1233+
EYtSettingTypes operator|(EYtSettingType left, EYtSettingType right) {
1234+
return EYtSettingTypes(left) | EYtSettingTypes(right);
1235+
}
1236+
12221237
} // NYql

ydb/library/yql/providers/yt/provider/yql_yt_op_settings.h

+114-74
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <util/str_stl.h>
1010

1111
#include <utility>
12+
#include <bitset>
1213

1314
namespace NYql {
1415

@@ -45,83 +46,122 @@ struct TSampleParams {
4546

4647
enum class EYtSettingType: ui64 {
4748
// Table reads
48-
Initial = 1ull << 0 /* "initial" */,
49-
InferScheme = 1ull << 1 /* "infer_scheme" "inferscheme" "infer_schema" "inferschema" */,
50-
ForceInferScheme = 1ull << 2 /* "force_infer_schema" "forceinferschema" */,
51-
DoNotFailOnInvalidSchema = 1ull << 3 /* "do_not_fail_on_invalid_schema" */,
52-
DirectRead = 1ull << 4 /* "direct_read" "directread"*/,
53-
View = 1ull << 5 /* "view" */,
54-
Mode = 1ull << 6 /* "mode" */,
55-
Scheme = 1ull << 7 /* "scheme" */,
56-
WeakConcat = 1ull << 8 /* "weak_concat" */,
57-
Anonymous = 1ull << 9 /* "anonymous" */,
58-
WithQB = 1ull << 10 /* "with_qb" */,
59-
Inline = 1ull << 11 /* "inline" */,
60-
Sample = 1ull << 12 /* "sample" */,
61-
JoinLabel = 1ull << 13 /* "joinLabel" */,
62-
IgnoreNonExisting = 1ull << 14 /* "ignore_non_existing" "ignorenonexisting" */,
63-
WarnNonExisting = 1ull << 15 /* "warn_non_existing" "warnnonexisting" */,
64-
XLock = 1ull << 16 /* "xlock" */,
65-
Unordered = 1ull << 17 /* "unordered" */,
66-
NonUnique = 1ull << 18 /* "nonUnique" */,
67-
UserSchema = 1ull << 19 /* "userschema" */,
68-
UserColumns = 1ull << 20 /* "usercolumns" */,
69-
StatColumns = 1ull << 21 /* "statcolumns" */,
70-
SysColumns = 1ull << 22 /* "syscolumns" */,
71-
IgnoreTypeV3 = 1ull << 23 /* "ignoretypev3" "ignore_type_v3" */,
72-
// Table content
73-
MemUsage = 1ull << 24 /* "memUsage" */,
74-
ItemsCount = 1ull << 25 /* "itemsCount" */,
75-
RowFactor = 1ull << 26 /* "rowFactor" */,
76-
// Operations
77-
Ordered = 1ull << 27 /* "ordered" */, // hybrid supported
78-
KeyFilter = 1ull << 28 /* "keyFilter" */,
79-
KeyFilter2 = 1ull << 29 /* "keyFilter2" */,
80-
Take = 1ull << 30 /* "take" */,
81-
Skip = 1ull << 31 /* "skip" */,
82-
Limit = 1ull << 32 /* "limit" */, // hybrid supported
83-
SortLimitBy = 1ull << 33 /* "sortLimitBy" */, // hybrid supported
84-
SortBy = 1ull << 34 /* "sortBy" */, // hybrid supported
85-
ReduceBy = 1ull << 35 /* "reduceBy" */, // hybrid supported
86-
ReduceFilterBy = 1ull << 36 /* "reduceFilterBy" */,
87-
ForceTransform = 1ull << 37 /* "forceTransform" */, // hybrid supported
88-
WeakFields = 1ull << 38 /* "weakFields" */,
89-
Sharded = 1ull << 39 /* "sharded" */,
90-
CombineChunks = 1ull << 40 /* "combineChunks" */,
91-
JobCount = 1ull << 41 /* "jobCount" */, // hybrid supported
92-
JoinReduce = 1ull << 42 /* "joinReduce" */, // hybrid supported
93-
FirstAsPrimary = 1ull << 43 /* "firstAsPrimary" */, // hybrid supported
94-
Flow = 1ull << 44 /* "flow" */, // hybrid supported
95-
KeepSorted = 1ull << 45 /* "keepSorted" */, // hybrid supported
96-
KeySwitch = 1ull << 46 /* "keySwitch" */, // hybrid supported
97-
// Out tables
98-
UniqueBy = 1ull << 47 /* "uniqueBy" */,
99-
OpHash = 1ull << 48 /* "opHash" */,
100-
// Operations
101-
MapOutputType = 1ull << 49 /* "mapOutputType" */, // hybrid supported
102-
ReduceInputType = 1ull << 50 /* "reduceInputType" */, // hybrid supported
103-
NoDq = 1ull << 51 /* "noDq" */,
104-
// Read
105-
Split = 1ull << 52 /* "split" */,
106-
// Write hints
107-
CompressionCodec = 1ull << 53 /* "compression_codec" "compressioncodec"*/,
108-
ErasureCodec = 1ull << 54 /* "erasure_codec" "erasurecodec" */,
109-
Expiration = 1ull << 55 /* "expiration" */,
110-
ReplicationFactor = 1ull << 56 /* "replication_factor" "replicationfactor" */,
111-
UserAttrs = 1ull << 57 /* "user_attrs", "userattrs" */,
112-
Media = 1ull << 58 /* "media" */,
113-
PrimaryMedium = 1ull << 59 /* "primary_medium", "primarymedium" */,
114-
KeepMeta = 1ull << 60 /* "keep_meta", "keepmeta" */,
115-
MonotonicKeys = 1ull << 61 /* "monotonic_keys", "monotonickeys" */,
116-
MutationId = 1ull << 62 /* "mutationid", "mutation_id" */,
117-
ColumnGroups = 1ull << 63 /* "column_groups", "columngroups" */,
49+
Initial /* "initial" */,
50+
InferScheme /* "infer_scheme" "inferscheme" "infer_schema" "inferschema" */,
51+
ForceInferScheme /* "force_infer_schema" "forceinferschema" */,
52+
DoNotFailOnInvalidSchema /* "do_not_fail_on_invalid_schema" */,
53+
DirectRead /* "direct_read" "directread"*/,
54+
View /* "view" */,
55+
Mode /* "mode" */,
56+
Scheme /* "scheme" */,
57+
WeakConcat /* "weak_concat" */,
58+
Anonymous /* "anonymous" */,
59+
WithQB /* "with_qb" */,
60+
Inline /* "inline" */,
61+
Sample /* "sample" */,
62+
JoinLabel /* "joinLabel" */,
63+
IgnoreNonExisting /* "ignore_non_existing" "ignorenonexisting" */,
64+
WarnNonExisting /* "warn_non_existing" "warnnonexisting" */,
65+
XLock /* "xlock" */,
66+
Unordered /* "unordered" */,
67+
NonUnique /* "nonUnique" */,
68+
UserSchema /* "userschema" */,
69+
UserColumns /* "usercolumns" */,
70+
StatColumns /* "statcolumns" */,
71+
SysColumns /* "syscolumns" */,
72+
IgnoreTypeV3 /* "ignoretypev3" "ignore_type_v3" */,
73+
// Table content
74+
MemUsage /* "memUsage" */,
75+
ItemsCount /* "itemsCount" */,
76+
RowFactor /* "rowFactor" */,
77+
// Operations
78+
Ordered /* "ordered" */, // hybrid supported
79+
KeyFilter /* "keyFilter" */,
80+
KeyFilter2 /* "keyFilter2" */,
81+
Take /* "take" */,
82+
Skip /* "skip" */,
83+
Limit /* "limit" */, // hybrid supported
84+
SortLimitBy /* "sortLimitBy" */, // hybrid supported
85+
SortBy /* "sortBy" */, // hybrid supported
86+
ReduceBy /* "reduceBy" */, // hybrid supported
87+
ReduceFilterBy /* "reduceFilterBy" */,
88+
ForceTransform /* "forceTransform" */, // hybrid supported
89+
WeakFields /* "weakFields" */,
90+
Sharded /* "sharded" */,
91+
CombineChunks /* "combineChunks" */,
92+
JobCount /* "jobCount" */, // hybrid supported
93+
JoinReduce /* "joinReduce" */, // hybrid supported
94+
FirstAsPrimary /* "firstAsPrimary" */, // hybrid supported
95+
Flow /* "flow" */, // hybrid supported
96+
KeepSorted /* "keepSorted" */, // hybrid supported
97+
KeySwitch /* "keySwitch" */, // hybrid supported
98+
// Out tables
99+
UniqueBy /* "uniqueBy" */,
100+
OpHash /* "opHash" */,
101+
// Operations
102+
MapOutputType /* "mapOutputType" */, // hybrid supported
103+
ReduceInputType /* "reduceInputType" */, // hybrid supported
104+
NoDq /* "noDq" */,
105+
// Read
106+
Split /* "split" */,
107+
// Write hints
108+
CompressionCodec /* "compression_codec" "compressioncodec"*/,
109+
ErasureCodec /* "erasure_codec" "erasurecodec" */,
110+
Expiration /* "expiration" */,
111+
ReplicationFactor /* "replication_factor" "replicationfactor" */,
112+
UserAttrs /* "user_attrs", "userattrs" */,
113+
Media /* "media" */,
114+
PrimaryMedium /* "primary_medium", "primarymedium" */,
115+
KeepMeta /* "keep_meta", "keepmeta" */,
116+
MonotonicKeys /* "monotonic_keys", "monotonickeys" */,
117+
MutationId /* "mutationid", "mutation_id" */,
118+
ColumnGroups /* "column_groups", "columngroups" */,
119+
120+
LAST
118121
};
119122

120-
Y_DECLARE_FLAGS(EYtSettingTypes, EYtSettingType);
121-
Y_DECLARE_OPERATORS_FOR_FLAGS(EYtSettingTypes);
123+
constexpr auto YtSettingTypesCount = static_cast<ui64>(EYtSettingType::LAST);
122124

123-
constexpr auto DqReadSupportedSettings = EYtSettingType::SysColumns | EYtSettingType::Sample | EYtSettingType::Unordered | EYtSettingType::NonUnique | EYtSettingType::KeyFilter2;
124-
constexpr auto DqOpSupportedSettings = EYtSettingType::Ordered | EYtSettingType::Limit | EYtSettingType::SortLimitBy | EYtSettingType::SortBy |
125+
class EYtSettingTypes : std::bitset<YtSettingTypesCount> {
126+
using TBase = std::bitset<YtSettingTypesCount>;
127+
explicit EYtSettingTypes(const std::bitset<YtSettingTypesCount>& bitset)
128+
: TBase(bitset)
129+
{}
130+
131+
public:
132+
using ::NYql::EYtSettingTypes::bitset::bitset;
133+
134+
EYtSettingTypes(EYtSettingType type)
135+
: TBase(std::bitset<YtSettingTypesCount>(1) << static_cast<ui64>(type))
136+
{}
137+
138+
EYtSettingTypes& operator|=(const EYtSettingTypes& other) {
139+
TBase::operator|=(other);
140+
return *this;
141+
}
142+
143+
friend EYtSettingTypes operator|(EYtSettingTypes, const EYtSettingTypes&);
144+
145+
EYtSettingTypes& operator&=(const EYtSettingTypes& other) {
146+
TBase::operator&=(other);
147+
return *this;
148+
}
149+
150+
friend EYtSettingTypes operator&(EYtSettingTypes, const EYtSettingTypes&);
151+
152+
bool HasFlags(const EYtSettingTypes& other) {
153+
return *this & other;
154+
}
155+
156+
operator bool() const {
157+
return count() != 0;
158+
}
159+
};
160+
161+
EYtSettingTypes operator|(EYtSettingType left, EYtSettingType right);
162+
163+
const auto DqReadSupportedSettings = EYtSettingType::SysColumns | EYtSettingType::Sample | EYtSettingType::Unordered | EYtSettingType::NonUnique | EYtSettingType::KeyFilter2;
164+
const auto DqOpSupportedSettings = EYtSettingType::Ordered | EYtSettingType::Limit | EYtSettingType::SortLimitBy | EYtSettingType::SortBy |
125165
EYtSettingType::ReduceBy | EYtSettingType::ForceTransform | EYtSettingType::JobCount | EYtSettingType::JoinReduce |
126166
EYtSettingType::FirstAsPrimary | EYtSettingType::Flow | EYtSettingType::KeepSorted | EYtSettingType::KeySwitch |
127167
EYtSettingType::ReduceInputType | EYtSettingType::MapOutputType | EYtSettingType::Sharded;

0 commit comments

Comments
 (0)