Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#include "lib/Api/pch/pch.h"
 
#include "impl/StringData.h"
 
namespace _winml {
 
string_data::string_data(size_t size) : buffer_(size) {
}
 
std::shared_ptr<_winml::idata> string_data::create(size_t size) {
  return std::make_shared<string_data>(size);
}
 
size_t string_data::num_elements() {
  return buffer_.size();
}
 
size_t string_data::size_in_bytes() {
  WINML_THROW_HR(E_UNEXPECTED);
}
 
size_t string_data::num_buffers() {
  return 1;
}
 
bool string_data::flush() {
  // Vacuously true
  return true;
}
 
std::vector<wss::IBuffer>& string_data::buffers() {
  WINML_THROW_HR(E_UNEXPECTED);
}
 
gsl::span<byte> string_data::buffer(bool /*should_sync_buffer*/) {
  return gsl::span<byte>(reinterpret_cast<byte*>(buffer_.data()), buffer_.size());
}
 
void string_data::set(size_t num_elements, const std::string_view* data) {
  WINML_THROW_HR_IF_FALSE_MSG(
    E_INVALIDARG,
    num_elements <= buffer_.size(),
    "Argument size (%d) exceeds the tensor size (%d).",
    static_cast<int>(num_elements),
    static_cast<int>(buffer_.size())
  );
 
  // Copy
  std::copy(data, data + num_elements, buffer_.begin());
}
 
void string_data::set(size_t /*data_size*/, const byte* /*data*/) {
  WINML_THROW_HR(E_UNEXPECTED);
}
 
std::vector<std::string>& string_data::get_backing_vector() {
  return buffer_;
}
 
}  // namespace _winml