XVector
xvec_knn_exact_index.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2026 XCENA Inc.
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
34 #pragma once
35 
36 #ifdef __cplusplus
37 
38 #include <string>
39 
40 #include "xvector/xvec_types.h"
41 
43 
44 namespace xvec
45 {
46 
58 {
59 public:
69  static KnnExactIndex fromRawVectors(xvecExecutionContextTag* context,
70  const xvecFloat32* vectors,
71  xvecVectorIdType vectorCount,
72  xvecDimensionType dimension,
73  xvecDistanceType distanceType);
74 
81  static KnnExactIndex fromFaissFile(xvecExecutionContextTag* context, const std::string& path);
82 
83  virtual ~KnnExactIndex();
84 
85  KnnExactIndex(KnnExactIndex&& other) noexcept;
87 
88  KnnExactIndex(const KnnExactIndex&) = delete;
90 
94  xvecKnnExactIndexTag* handle() const noexcept;
95 
96 private:
97  KnnExactIndex(xvecExecutionContextTag* context, xvecKnnExactIndexTag* handle);
98 
99  xvecExecutionContextTag* context_ = nullptr;
100  xvecKnnExactIndexTag* handle_ = nullptr;
101 };
102 
103 } // namespace xvec
104 
105 #endif // __cplusplus
RAII wrapper for xvecKnnExactIndexTag.
KnnExactIndex(KnnExactIndex &&other) noexcept
KnnExactIndex(const KnnExactIndex &)=delete
KnnExactIndex & operator=(const KnnExactIndex &)=delete
KnnExactIndex & operator=(KnnExactIndex &&other) noexcept
static KnnExactIndex fromFaissFile(xvecExecutionContextTag *context, const std::string &path)
Load a KNN index from a Faiss file.
static KnnExactIndex fromRawVectors(xvecExecutionContextTag *context, const xvecFloat32 *vectors, xvecVectorIdType vectorCount, xvecDimensionType dimension, xvecDistanceType distanceType)
Load a KNN index from raw float32 vectors.
virtual ~KnnExactIndex()
xvecKnnExactIndexTag * handle() const noexcept
Get the underlying C API handle.
Exception types for C++ XVECTOR wrappers.
Core types, enums, and structures for the XVector library.
uint32_t xvecDimensionType
Type for vector dimension.
Definition: xvec_types.h:194
xvecDistanceType
Distance/similarity metrics for vector search.
Definition: xvec_types.h:172
float xvecFloat32
32-bit floating point type for vector components.
Definition: xvec_types.h:111
uint64_t xvecVectorIdType
Type for vector identifiers.
Definition: xvec_types.h:209