Skip to content

Commit c931b99

Browse files
Merge 728ad96 into 15f3d76
2 parents 15f3d76 + 728ad96 commit c931b99

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

ydb/core/persqueue/key.h

+41-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class TKeyPrefix : public TBuffer
3535
: Partition(partition)
3636
{
3737
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);
4040
}
4141

4242
TKeyPrefix(EType type, const TPartitionId& partition, EMark mark)
@@ -62,25 +62,61 @@ class TKeyPrefix : public TBuffer
6262
static constexpr ui32 MarkPosition() { return UnmarkedSize(); }
6363
static constexpr ui32 MarkedSize() { return UnmarkedSize() + 1; }
6464

65+
6566
void SetType(EType type) {
6667
*PtrType() = type;
6768
}
6869

70+
6971
EType GetType() const {
70-
return EType(*PtrType());
72+
switch (*PtrType()) {
73+
case TypeNone:
74+
case ServiceTypeNone:
75+
return TypeNone;
76+
case TypeData:
77+
case ServiceTypeData:
78+
return TypeData;
79+
case TypeTmpData:
80+
case ServiceTypeTmpData:
81+
return TypeTmpData;
82+
case TypeInfo:
83+
case ServiceTypeInfo:
84+
return TypeInfo;
85+
case TypeMeta:
86+
case ServiceTypeMeta:
87+
return TypeMeta;
88+
case TypeTxMeta:
89+
case ServiceTypeTxMeta:
90+
return TypeTxMeta;
91+
}
92+
Y_ABORT();
93+
return TypeNone;
7194
}
7295

96+
bool IsServicePartition() const {return Partition.WriteId.Defined();}
97+
7398
const TPartitionId& GetPartition() const { return Partition; }
7499

75100
protected:
76101
static constexpr ui32 UnmarkedSize() { return 1 + 10; }
77102

78103
void ParsePartition()
79104
{
80-
Partition.InternalPartitionId = FromString<ui32>(TStringBuf{PtrPartition(), 10});
105+
Partition.OriginalPartitionId = FromString<ui32>(TStringBuf{PtrPartition(), 10});
106+
Partition.InternalPartitionId = Partition.OriginalPartitionId;
81107
}
82108

109+
83110
private:
111+
enum EServiceType : char {
112+
ServiceTypeNone = 1,
113+
ServiceTypeInfo = 'M',
114+
ServiceTypeData = 'D',
115+
ServiceTypeTmpData = 'X',
116+
ServiceTypeMeta = 'J',
117+
ServiceTypeTxMeta = 'K'
118+
};
119+
84120
char* PtrType() { return Data(); }
85121
char* PtrMark() { return Data() + UnmarkedSize(); }
86122
char* PtrPartition() { return Data() + 1; }
@@ -90,6 +126,7 @@ class TKeyPrefix : public TBuffer
90126
const char* PtrPartition() const { return Data() + 1; }
91127

92128
TPartitionId Partition;
129+
93130
};
94131

95132
// {char type; ui32 partiton; ui64 offset; ui16 partNo; ui32 count, ui16 internalPartsCount}

0 commit comments

Comments
 (0)