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