XVector
xvec_ivf_flat.h
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 
29 #pragma once
30 
31 #include "xvec_types.h"
32 
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
38 
39  // =============================================================================
40  // Index Loading and Management
41  // =============================================================================
42 
59  xvecStatus xvecIvfFlatLoadIndexFromFaissFile(xvecExecutionContextTag* context,
60  const char* indexFilePath,
61  xvecIvfFlatIndexTag** outIndexHandle);
62 
73  typedef struct xvecIvfFlatDescriptor
74  {
85 
106  xvecStatus xvecIvfFlatLoadIndexFromDescriptor(xvecExecutionContextTag* context,
107  const xvecIvfFlatDescriptor* descriptor,
108  xvecIvfFlatIndexTag** outIndexHandle);
109 
124  xvecStatus xvecIvfFlatDestroyIndex(xvecExecutionContextTag* context,
125  xvecIvfFlatIndexTag* indexHandle);
126 
127  // =============================================================================
128  // Kernel Preparation
129  // =============================================================================
130 
148  xvecStatus xvecIvfFlatPrepareKernel(xvecExecutionContextTag* context);
149 
150  // =============================================================================
151  // Search APIs
152  // =============================================================================
153 
180  xvecStatus xvecIvfFlatSearchFineSearchOnly(xvecExecutionContextTag* context,
181  xvecIvfFlatIndexTag* indexHandle,
182  xvecIvfFlatFineSearchQueryFloat32* fineSearchQuery,
183  xvecBufferTag* resultsBufferHandle,
184  xvecIvfFlatSearchTiming* outTiming);
185 
186 #ifdef __cplusplus
187 }
188 #endif
FAISS-free description of an IVF-Flat index.
Definition: xvec_ivf_flat.h:74
xvecDistanceType distanceType
Distance metric.
Definition: xvec_ivf_flat.h:78
xvecClusterIdType numClusters
Number of IVF clusters (nlist).
Definition: xvec_ivf_flat.h:76
const xvecVectorIdType * listSizes
Vectors per cluster [numClusters]; entries sum to numVectors.
Definition: xvec_ivf_flat.h:81
const xvecVectorIdType * ids
Original id per vector [numVectors], in the same grouped order.
Definition: xvec_ivf_flat.h:82
const xvecFloat32 * vectors
Vectors grouped by cluster, row-major [numVectors * dimension].
Definition: xvec_ivf_flat.h:80
const xvecFloat32 * centroids
Cluster centroids, row-major [numClusters * dimension].
Definition: xvec_ivf_flat.h:79
xvecDimensionType dimension
Dimension of each vector (d).
Definition: xvec_ivf_flat.h:75
xvecVectorIdType numVectors
Total number of vectors; must equal the sum of listSizes.
Definition: xvec_ivf_flat.h:77
Search query parameters for IVF-Flat fine search only.
Definition: xvec_types.h:330
xvecStatus xvecIvfFlatLoadIndexFromFaissFile(xvecExecutionContextTag *context, const char *indexFilePath, xvecIvfFlatIndexTag **outIndexHandle)
Loads an IVF-Flat index from a Faiss index file.
xvecStatus xvecIvfFlatPrepareKernel(xvecExecutionContextTag *context)
Pre-initializes PXL resources (Job, Module, Function) for IVF-Flat search.
struct xvecIvfFlatDescriptor xvecIvfFlatDescriptor
FAISS-free description of an IVF-Flat index.
xvecStatus xvecIvfFlatSearchFineSearchOnly(xvecExecutionContextTag *context, xvecIvfFlatIndexTag *indexHandle, xvecIvfFlatFineSearchQueryFloat32 *fineSearchQuery, xvecBufferTag *resultsBufferHandle, xvecIvfFlatSearchTiming *outTiming)
Performs an IVF-Flat fine search only (skips coarse search).
xvecStatus xvecIvfFlatDestroyIndex(xvecExecutionContextTag *context, xvecIvfFlatIndexTag *indexHandle)
Destroys an IVF-Flat index handle and releases its host-side data.
xvecStatus xvecIvfFlatLoadIndexFromDescriptor(xvecExecutionContextTag *context, const xvecIvfFlatDescriptor *descriptor, xvecIvfFlatIndexTag **outIndexHandle)
Loads an IVF-Flat index from a FAISS-free descriptor.
struct xvecIvfFlatSearchTiming xvecIvfFlatSearchTiming
Definition: xvec_ivf_flat.h:37
Core types, enums, and structures for the XVector library.
uint64_t xvecClusterIdType
Type for cluster identifiers in IVF indices.
Definition: xvec_types.h:204
uint32_t xvecDimensionType
Type for vector dimension.
Definition: xvec_types.h:194
xvecStatus
Status codes returned by XVector API functions.
Definition: xvec_types.h:133
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