aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/vespa/searchlib/tensor/hnsw_index_traits.h
blob: e8abc7b1399996db07ec1471cb60abf942e330b9 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "hnsw_index_type.h"

namespace search::tensor {

class HnswSimpleNode;
class HnswNode;
class HnswIdentityMapping;
class HnswMultiBestNeighbors;
class HnswNodeidMapping;
class HnswSingleBestNeighbors;

/*
 * Class that selects what node type and id mapping to use based on
 * hnsw index type.
 */
template <HnswIndexType type>
class HnswIndexTraits;

/*
 * Node type and id mapping for hnsw index type SINGLE.
 *
 * One node per document.
 * Identity mapping between nodeid and docid.
 */
template <>
class HnswIndexTraits<HnswIndexType::SINGLE>
{
public:
    using NodeType = HnswSimpleNode;
    using IdMapping = HnswIdentityMapping;
    using SearchBestNeighbors = HnswSingleBestNeighbors;
};

/*
 * Node type and id mapping for hnsw index type MULTI.
 *
 * Multiple nodes per document.
 * Managed mapping between nodeid and docid.
 */
template <>
class HnswIndexTraits<HnswIndexType::MULTI>
{
public:
    using NodeType = HnswNode;
    using IdMapping = HnswNodeidMapping;
    using SearchBestNeighbors = HnswMultiBestNeighbors;
};

}