-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
74 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters