Skip to content

Commit cdd9438

Browse files
committed
Renamed as_vector function to values
1 parent c8c3cb1 commit cdd9438

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
- Added support for libpqxx 8
44
- Changed `HalfVector` to use `std::float16_t` or `_Float16` when available
5-
- Replaced `std::vector` conversion with `as_vector` function for `Vector` and `HalfVector`
5+
- Replaced `std::vector` conversion with `values` function for `Vector` and `HalfVector`
66
- Removed default constructors (no longer needed for streaming)
77
- Dropped support for libpqxx 7
88
- Dropped support for C++17

include/pgvector/halfvec.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class HalfVector {
4646
return value_.size();
4747
}
4848

49-
/// Returns the half vector as a `std::vector`.
50-
const std::vector<Half>& as_vector() const {
49+
/// Returns the values.
50+
const std::vector<Half>& values() const {
5151
return value_;
5252
}
5353

include/pgvector/pqxx.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ template<> struct string_traits<pgvector::Vector> {
4747
}
4848

4949
static std::string_view to_buf(std::span<char> buf, const pgvector::Vector& value, ctx c = {}) {
50-
const std::vector<float>& values = value.as_vector();
50+
const std::vector<float>& values = value.values();
5151

5252
// important! size_buffer cannot throw an exception on overflow
5353
// so perform this check before writing any data
@@ -71,7 +71,7 @@ template<> struct string_traits<pgvector::Vector> {
7171
}
7272

7373
static size_t size_buffer(const pgvector::Vector& value) noexcept {
74-
const std::vector<float>& values = value.as_vector();
74+
const std::vector<float>& values = value.values();
7575

7676
// cannot throw an exception here on overflow
7777
// so throw in into_buf
@@ -113,7 +113,7 @@ template<> struct string_traits<pgvector::HalfVector> {
113113
}
114114

115115
static std::string_view to_buf(std::span<char> buf, const pgvector::HalfVector& value, ctx c = {}) {
116-
const std::vector<pgvector::Half>& values = value.as_vector();
116+
const std::vector<pgvector::Half>& values = value.values();
117117

118118
// important! size_buffer cannot throw an exception on overflow
119119
// so perform this check before writing any data
@@ -137,7 +137,7 @@ template<> struct string_traits<pgvector::HalfVector> {
137137
}
138138

139139
static size_t size_buffer(const pgvector::HalfVector& value) noexcept {
140-
const std::vector<pgvector::Half>& values = value.as_vector();
140+
const std::vector<pgvector::Half>& values = value.values();
141141

142142
// cannot throw an exception here on overflow
143143
// so throw in into_buf

include/pgvector/vector.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Vector {
3030
return value_.size();
3131
}
3232

33-
/// Returns the vector as a `std::vector`.
34-
const std::vector<float>& as_vector() const {
33+
/// Returns the values.
34+
const std::vector<float>& values() const {
3535
return value_;
3636
}
3737

test/halfvec_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ static void test_constructor_span() {
1616
assert_equal(vec.dimensions(), 3u);
1717
}
1818

19-
static void test_as_vector() {
19+
static void test_values() {
2020
HalfVector vec{{1, 2, 3}};
21-
assert_equal(vec.as_vector() == std::vector<pgvector::Half>{1, 2, 3}, true);
21+
assert_equal(vec.values() == std::vector<pgvector::Half>{1, 2, 3}, true);
2222
}
2323

2424
void test_halfvec() {
2525
test_constructor_vector();
2626
test_constructor_span();
27-
test_as_vector();
27+
test_values();
2828
}

test/vector_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ static void test_constructor_span() {
1616
assert_equal(vec.dimensions(), 3u);
1717
}
1818

19-
static void test_as_vector() {
19+
static void test_values() {
2020
Vector vec{{1, 2, 3}};
21-
assert_equal(vec.as_vector() == std::vector<float>{1, 2, 3}, true);
21+
assert_equal(vec.values() == std::vector<float>{1, 2, 3}, true);
2222
}
2323

2424
void test_vector() {
2525
test_constructor_vector();
2626
test_constructor_span();
27-
test_as_vector();
27+
test_values();
2828
}

0 commit comments

Comments
 (0)