blob: acea9a0144b9431dff879e35763c38b53dc8c8a1 (
plain) (
blame)
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <cassert>
#include <cstdint>
#include <cstring>
#include <vector>
namespace search::test
{
/*
* Class used by hnsw graph/index unit tests to load hnsw index from a
* vector.
*/
class VectorBufferReader {
private:
const std::vector<char>& _data;
size_t _pos;
public:
VectorBufferReader(const std::vector<char>& data) : _data(data), _pos(0) {}
uint32_t readHostOrder() {
uint32_t result = 0;
assert(_pos + sizeof(uint32_t) <= _data.size());
std::memcpy(&result, _data.data() + _pos, sizeof(uint32_t));
_pos += sizeof(uint32_t);
return result;
}
};
}
|