aboutsummaryrefslogtreecommitdiffstats
path: root/ydb/core/base/location.h
blob: fa6e4ff00d6f9da9e18d20de71a70ed2731089f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once
#include "defs.h"

#include <util/digest/murmur.h>
#include <util/generic/string.h>

namespace NKikimr {
    inline ui32 DataCenterFromString(const TString &dc)
    {
        ui32 res = 0;
        strncpy(reinterpret_cast<char *>(&res), dc.data(), sizeof(res));
        return res;
    }

    inline TString DataCenterToString(ui32 dc)
    {
        char str[sizeof(dc) + 1];
        str[sizeof(dc)] = 0;
        strncpy(str, reinterpret_cast<char *>(&dc), sizeof(dc));
        return str;
    }

    inline ui32 RackFromString(const TString &rack)
    {
        return MurmurHash<ui32>(rack.data(), rack.size());
    }
} // namespace NKikimr