@@ -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,84 @@ class TKeyPrefix : public TBuffer
62
62
static constexpr ui32 MarkPosition () { return UnmarkedSize (); }
63
63
static constexpr ui32 MarkedSize () { return UnmarkedSize () + 1 ; }
64
64
65
+
65
66
void SetType (EType type) {
66
- *PtrType () = type;
67
+ if (!IsServicePartition ()) {
68
+ *PtrType () = type;
69
+ return ;
70
+ }
71
+ switch (type) {
72
+ case TypeNone:
73
+ *PtrType () = TypeNone;
74
+ return ;
75
+ case TypeData:
76
+ *PtrType () = ServiceTypeData;
77
+ return ;
78
+ case TypeTmpData:
79
+ *PtrType () = ServiceTypeTmpData;
80
+ return ;
81
+ case TypeInfo:
82
+ *PtrType () = ServiceTypeInfo;
83
+ return ;
84
+ case TypeMeta:
85
+ *PtrType () = ServiceTypeMeta;
86
+ return ;
87
+ case TypeTxMeta:
88
+ *PtrType () = ServiceTypeTxMeta;
89
+ return ;
90
+ default :
91
+ Y_ABORT ();
92
+ }
67
93
}
68
94
95
+
69
96
EType GetType () const {
70
- return EType (*PtrType ());
97
+ switch (*PtrType ()) {
98
+ case TypeNone:
99
+ return TypeNone;
100
+ case TypeData:
101
+ case ServiceTypeData:
102
+ return TypeData;
103
+ case TypeTmpData:
104
+ case ServiceTypeTmpData:
105
+ return TypeTmpData;
106
+ case TypeInfo:
107
+ case ServiceTypeInfo:
108
+ return TypeInfo;
109
+ case TypeMeta:
110
+ case ServiceTypeMeta:
111
+ return TypeMeta;
112
+ case TypeTxMeta:
113
+ case ServiceTypeTxMeta:
114
+ return TypeTxMeta;
115
+ }
116
+ Y_ABORT ();
117
+ return TypeNone;
71
118
}
72
119
120
+ bool IsServicePartition () const {return Partition.WriteId .Defined ();}
121
+
73
122
const TPartitionId& GetPartition () const { return Partition; }
74
123
75
124
protected:
76
125
static constexpr ui32 UnmarkedSize () { return 1 + 10 ; }
77
126
78
127
void ParsePartition ()
79
128
{
80
- Partition.InternalPartitionId = FromString<ui32>(TStringBuf{PtrPartition (), 10 });
129
+ Partition.OriginalPartitionId = FromString<ui32>(TStringBuf{PtrPartition (), 10 });
130
+ Partition.InternalPartitionId = Partition.OriginalPartitionId ;
81
131
}
82
132
133
+
83
134
private:
135
+ enum EServiceType : char {
136
+ ServiceTypeInfo = ' M' ,
137
+ ServiceTypeData = ' D' ,
138
+ ServiceTypeTmpData = ' X' ,
139
+ ServiceTypeMeta = ' J' ,
140
+ ServiceTypeTxMeta = ' K'
141
+ };
142
+
84
143
char * PtrType () { return Data (); }
85
144
char * PtrMark () { return Data () + UnmarkedSize (); }
86
145
char * PtrPartition () { return Data () + 1 ; }
@@ -90,6 +149,7 @@ class TKeyPrefix : public TBuffer
90
149
const char * PtrPartition () const { return Data () + 1 ; }
91
150
92
151
TPartitionId Partition;
152
+
93
153
};
94
154
95
155
// {char type; ui32 partiton; ui64 offset; ui16 partNo; ui32 count, ui16 internalPartsCount}
0 commit comments