Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#include "lib/Api/pch/pch.h"
#include "LearningModelEvaluationResult.h"
 
namespace WINMLP {
hstring LearningModelEvaluationResult::CorrelationId() try { return m_correlationId; }
WINML_CATCH_ALL
 
void LearningModelEvaluationResult::CorrelationId(const hstring& correlationId) {
  m_correlationId = correlationId;
}
 
int32_t LearningModelEvaluationResult::ErrorStatus() try { return m_errorStatus; }
WINML_CATCH_ALL
 
void LearningModelEvaluationResult::ErrorStatus(int32_t errorStatus) {
  m_errorStatus = errorStatus;
}
 
bool LearningModelEvaluationResult::Succeeded() try { return m_succeeded; }
WINML_CATCH_ALL
 
void LearningModelEvaluationResult::Succeeded(bool succeeded) {
  m_succeeded = succeeded;
}
 
Windows::Foundation::Collections::IMapView<hstring, Windows::Foundation::IInspectable>
LearningModelEvaluationResult::Outputs() try {
  std::unordered_map<hstring, Windows::Foundation::IInspectable> outputs;
 
  for (auto& output : m_outputs) {
    auto key = _winml::Strings::HStringFromUTF8(output.first);
    auto value = output.second;
    outputs.emplace(key, value);
  }
 
  return winrt::single_threaded_map(std::move(outputs)).GetView();
}
WINML_CATCH_ALL
 
void LearningModelEvaluationResult::Outputs(
  Windows::Foundation::Collections::IMapView<hstring, Windows::Foundation::IInspectable> outputs
) {
  m_outputs.clear();
 
  for (auto pair : outputs) {
    auto key = _winml::Strings::UTF8FromHString(pair.Key());
    auto value = pair.Value();
    m_outputs.emplace(key, value);
  }
}
 
HRESULT LearningModelEvaluationResult::GetOutput(const wchar_t* name, UINT32 cchName, IUnknown** result) {
  *result = nullptr;
 
  auto outputName = _winml::Strings::UTF8FromUnicode(name, cchName);
  auto foundIt = m_outputs.find(outputName);
 
  if (foundIt == std::end(m_outputs)) {
    return E_FAIL;
  }
 
  auto inspectable = foundIt->second;
  *result = inspectable.as<::IUnknown>().detach();
 
  return S_OK;
}
 
HRESULT LearningModelEvaluationResult::SetOutputs(
  std::unordered_map<std::string, Windows::Foundation::IInspectable>&& outputs
) {
  m_outputs = std::move(outputs);
  return S_OK;
}
 
}  // namespace WINMLP