summaryrefslogtreecommitdiffstats
path: root/yql/essentials/core/layers/layers_fwd.h
blob: fbef115ca06529e35a41fb2c51e72cd8517733fe (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once

#include <yql/essentials/utils/yql_panic.h>

#include <util/generic/string.h>
#include <util/generic/vector.h>
#include <util/generic/maybe.h>
#include <util/generic/hash.h>

namespace NYql::NLayers {
struct TLocation {
    TString System;
    TString Cluster;
    TString Path;
    TMaybe<TString> Format;
};

using TLocations = TVector<TLocation>;

class TKey {
public:
    TKey(TMaybe<TString>&& name, TMaybe<TString>&& url = {})
        : Name(name)
        , Url(url)
    {
        YQL_ENSURE(Name || Url);
    }
    TKey(const TKey&) = default;
    TKey(TKey&&) = default;
    TKey& operator=(const TKey& rhs) = default;
    TKey& operator=(TKey&&) = default;
    bool operator==(const TKey& rhs) const {
        return Name == rhs.Name && Url == rhs.Url;
    }
    TString ToString() const {
        TStringBuilder sb;
        sb << "(";
        if (Name) {
            sb << "Name=" << Name->Quote();
        }
        if (Url) {
            if (Name) {
                sb << ", ";
            }
            sb << "Url=" << Url->Quote();
        }
        sb << ")";
        return sb;
    }
    TMaybe<TString> Name;
    TMaybe<TString> Url;
};

struct TLayerInfo {
    TLocations Locations;
    TString Url;
    TMaybe<TKey> Parent;
};
} // namespace NYql::NLayers

template <>
struct THash<NYql::NLayers::TKey> {
    size_t operator()(const NYql::NLayers::TKey& v) const noexcept {
        return CombineHashes(THash<decltype(v.Name)>()(v.Name), THash<decltype(v.Url)>()(v.Url));
    }
};