We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5cdf935 commit f1917e6Copy full SHA for f1917e6
1 file changed
include/pgvector/sparsevec.hpp
@@ -8,6 +8,7 @@
8
9
#include <algorithm>
10
#include <cstddef>
11
+#include <limits>
12
#include <ostream>
13
#include <span>
14
#include <stdexcept>
@@ -33,7 +34,9 @@ class SparseVector {
33
34
35
/// Creates a sparse vector from a span.
36
explicit SparseVector(std::span<const float> value) {
- // TODO throw exception
37
+ if (value.size() > std::numeric_limits<int>::max()) {
38
+ throw std::invalid_argument{"too many dimensions"};
39
+ }
40
dimensions_ = static_cast<int>(value.size());
41
for (size_t i = 0; i < value.size(); i++) {
42
float v = value[i];
0 commit comments