Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions ydb/core/blob_depot/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,3 @@ template<>
void Out<NKikimr::NBlobDepot::TGivenIdRange>(IOutputStream& s, const NKikimr::NBlobDepot::TGivenIdRange& x) {
x.Output(s);
}

template<>
void Out<NKikimr::NBlobDepot::TGenStep>(IOutputStream& s, const NKikimr::NBlobDepot::TGenStep& x) {
x.Output(s);
}
1 change: 1 addition & 0 deletions ydb/core/blob_depot/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <ydb/core/protos/blob_depot.pb.h>
#include <ydb/core/protos/counters_blob_depot.pb.h>
#include <ydb/core/util/format.h>
#include <ydb/core/util/gen_step.h>
#include <ydb/core/util/stlog.h>

#include <library/cpp/monlib/service/pages/templates.h>
Expand Down
63 changes: 4 additions & 59 deletions ydb/core/blob_depot/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ namespace NKikimr::NBlobDepot {
type == EBlobType::VG_FOOTER_BLOB || type == EBlobType::VG_GC_BLOB);
return cookie >> typeBits;
}

explicit operator TGenStep() const {
return {Generation, Step};
}
};

class TGivenIdRange {
Expand Down Expand Up @@ -195,65 +199,6 @@ namespace NKikimr::NBlobDepot {
return true;
}

class TGenStep {
ui64 Value = 0;

public:
TGenStep() = default;
TGenStep(const TGenStep&) = default;
TGenStep &operator=(const TGenStep& other) = default;

explicit TGenStep(ui64 value)
: Value(value)
{}

TGenStep(ui32 gen, ui32 step)
: Value(ui64(gen) << 32 | step)
{}

explicit TGenStep(const TLogoBlobID& id)
: TGenStep(id.Generation(), id.Step())
{}

explicit TGenStep(const TBlobSeqId& id)
: TGenStep(id.Generation, id.Step)
{}

explicit operator ui64() const {
return Value;
}

ui32 Generation() const {
return Value >> 32;
}

ui32 Step() const {
return Value;
}

void Output(IOutputStream& s) const {
s << Generation() << ":" << Step();
}

TString ToString() const {
TStringStream s;
Output(s);
return s.Str();
}

TGenStep Previous() const {
Y_ABORT_UNLESS(Value);
return TGenStep(Value - 1);
}

friend bool operator ==(const TGenStep& x, const TGenStep& y) { return x.Value == y.Value; }
friend bool operator !=(const TGenStep& x, const TGenStep& y) { return x.Value != y.Value; }
friend bool operator < (const TGenStep& x, const TGenStep& y) { return x.Value < y.Value; }
friend bool operator <=(const TGenStep& x, const TGenStep& y) { return x.Value <= y.Value; }
friend bool operator > (const TGenStep& x, const TGenStep& y) { return x.Value > y.Value; }
friend bool operator >=(const TGenStep& x, const TGenStep& y) { return x.Value >= y.Value; }
};

#define BDEV(MARKER, TEXT, ...) \
do { \
auto& ctx = *TlsActivationContext; \
Expand Down
6 changes: 6 additions & 0 deletions ydb/core/util/gen_step.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "gen_step.h"

template<>
void Out<NKikimr::TGenStep>(IOutputStream& s, const NKikimr::TGenStep& x) {
x.Output(s);
}
61 changes: 61 additions & 0 deletions ydb/core/util/gen_step.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#pragma once

#include <ydb/core/base/logoblob.h>

#include <util/generic/string.h>
#include <util/stream/output.h>
#include <util/stream/str.h>

namespace NKikimr {

class TGenStep {
ui64 Value = 0;

public:
TGenStep() = default;
TGenStep(const TGenStep&) = default;
TGenStep &operator=(const TGenStep&) = default;

explicit TGenStep(ui64 value)
: Value(value)
{}

TGenStep(ui32 gen, ui32 step)
: Value(ui64(gen) << 32 | step)
{}

explicit TGenStep(const TLogoBlobID& id)
: TGenStep(id.Generation(), id.Step())
{}

explicit operator ui64() const {
return Value;
}

ui32 Generation() const {
return Value >> 32;
}

ui32 Step() const {
return Value;
}

void Output(IOutputStream& s) const {
s << Generation() << ":" << Step();
}

TString ToString() const {
TStringStream s;
Output(s);
return s.Str();
}

TGenStep Previous() const {
Y_ABORT_UNLESS(Value);
return TGenStep(Value - 1);
}

friend auto operator <=>(const TGenStep& x, const TGenStep& y) = default;
};

} // NKikimr
2 changes: 2 additions & 0 deletions ydb/core/util/ya.make
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ SRCS(
format.h
fragmented_buffer.cpp
fragmented_buffer.h
gen_step.cpp
gen_step.h
hazard.cpp
hyperlog_counter.cpp
hyperlog_counter.h
Expand Down