16 #ifndef TENSORFLOW_SERVING_CORE_SERVABLE_ID_H_
17 #define TENSORFLOW_SERVING_CORE_SERVABLE_ID_H_
21 #include <unordered_map>
23 #include "tensorflow/core/lib/strings/strcat.h"
24 #include "tensorflow/core/platform/types.h"
25 #include "tensorflow_serving/util/hash.h"
27 namespace tensorflow {
47 string DebugString()
const {
48 return strings::StrCat(
"{name: ", name,
" version: ", version,
"}");
53 uint64_t operator()(
const ServableId&
id)
const {
64 const uint64_t version_hash = [&]() -> uint64_t {
65 if (
id.version >= 0) {
66 return std::hash<int64_t>()(
id.version) *
73 return HashCombine(version_hash, std::hash<string>()(
id.name));
78 return a.version == b.version && a.name == b.name;
81 inline bool operator!=(
const ServableId& a,
const ServableId& b) {
85 inline bool operator<(
const ServableId& a,
const ServableId& b) {
86 const int strcmp_result = a.name.compare(b.name);
87 if (strcmp_result != 0) {
88 return strcmp_result < 0;
90 return a.version < b.version;
93 inline std::ostream& operator<<(std::ostream& out,
const ServableId&
id) {
94 return out <<
id.DebugString();