@@ -35,8 +35,8 @@ class TKeyPrefix : public TBuffer
35
35
: Partition(partition)
36
36
{
37
37
Resize (UnmarkedSize ());
38
- * PtrType () = type;
39
- memcpy (PtrPartition (), Sprintf (" %.10" PRIu32, Partition.InternalPartitionId ).data (), 10 );
38
+ SetType ( type) ;
39
+ memcpy (PtrPartition (), Sprintf (" %.10" PRIu32, Partition.InternalPartitionId ).data (), 10 );
40
40
}
41
41
42
42
TKeyPrefix (EType type, const TPartitionId& partition, EMark mark)
@@ -62,25 +62,100 @@ class TKeyPrefix : public TBuffer
62
62
static constexpr ui32 MarkPosition () { return UnmarkedSize (); }
63
63
static constexpr ui32 MarkedSize () { return UnmarkedSize () + 1 ; }
64
64
65
- void SetType (EType type) {
66
- *PtrType () = type;
65
+
66
+ void SetType (EType type) {
67
+ if (!IsServicePartition ()) {
68
+ *PtrType () = type;
69
+ return ;
70
+ }
71
+
72
+ switch (*PtrType ()) {
73
+ case TypeNone:
74
+ *PtrType () = ServiceTypeNone;
75
+ return ;
76
+ case TypeData:
77
+ *PtrType () = ServiceTypeData;
78
+ return ;
79
+ case TypeTmpData:
80
+ *PtrType () = ServiceTypeTmpData;
81
+ return ;
82
+ case TypeInfo:
83
+ *PtrType () = ServiceTypeInfo;
84
+ return ;
85
+ case TypeMeta:
86
+ *PtrType () = ServiceTypeMeta;
87
+ return ;
88
+ case TypeTxMeta:
89
+ *PtrType () = ServiceTypeTxMeta;
90
+ return ;
91
+ default :
92
+ Y_ABORT ();
93
+ }
67
94
}
68
95
96
+
69
97
EType GetType () const {
70
- return EType (*PtrType ());
98
+ switch (*PtrType ()) {
99
+ case TypeNone:
100
+ case ServiceTypeNone:
101
+ return TypeNone;
102
+ case TypeData:
103
+ case ServiceTypeData:
104
+ return TypeData;
105
+ case TypeTmpData:
106
+ case ServiceTypeTmpData:
107
+ return TypeTmpData;
108
+ case TypeInfo:
109
+ case ServiceTypeInfo:
110
+ return TypeInfo;
111
+ case TypeMeta:
112
+ case ServiceTypeMeta:
113
+ return TypeMeta;
114
+ case TypeTxMeta:
115
+ case ServiceTypeTxMeta:
116
+ return TypeTxMeta;
117
+ default :
118
+ Y_ABORT ();
119
+ }
71
120
}
72
121
122
+ bool IsServicePartition () const {return ServicePartition.GetOrElse (false ) || Partition.WriteId .Defined ();}
123
+
73
124
const TPartitionId& GetPartition () const { return Partition; }
74
125
75
126
protected:
76
127
static constexpr ui32 UnmarkedSize () { return 1 + 10 ; }
77
128
78
- void ParsePartition ()
129
+ void ParsePartition ()
79
130
{
80
- Partition.InternalPartitionId = FromString<ui32>(TStringBuf{PtrPartition (), 10 });
131
+ Partition.OriginalPartitionId = FromString<ui32>(TStringBuf{PtrPartition (), 10 });
132
+ // ToDo: deside what to do here. We only save one number for partition
133
+ Partition.InternalPartitionId = Partition.OriginalPartitionId ;
134
+ switch (*PtrType ()) {
135
+ case TypeNone:
136
+ case TypeData:
137
+ case TypeTmpData:
138
+ case TypeInfo:
139
+ case TypeMeta:
140
+ case TypeTxMeta:
141
+ ServicePartition = false ;
142
+ break ;
143
+ default :
144
+ ServicePartition = true ;
145
+ }
81
146
}
82
147
148
+
83
149
private:
150
+ enum EServiceType : char {
151
+ ServiceTypeNone = 1 ,
152
+ ServiceTypeInfo = ' M' ,
153
+ ServiceTypeData = ' D' ,
154
+ ServiceTypeTmpData = ' X' ,
155
+ ServiceTypeMeta = ' J' ,
156
+ ServiceTypeTxMeta = ' K'
157
+ };
158
+
84
159
char * PtrType () { return Data (); }
85
160
char * PtrMark () { return Data () + UnmarkedSize (); }
86
161
char * PtrPartition () { return Data () + 1 ; }
@@ -90,6 +165,8 @@ class TKeyPrefix : public TBuffer
90
165
const char * PtrPartition () const { return Data () + 1 ; }
91
166
92
167
TPartitionId Partition;
168
+ TMaybe<bool > ServicePartition;
169
+
93
170
};
94
171
95
172
// {char type; ui32 partiton; ui64 offset; ui16 partNo; ui32 count, ui16 internalPartsCount}
0 commit comments