11
11
#include " VecSim/algorithms/hnsw/hnsw_tiered.h"
12
12
#include " VecSim/types/bfloat16.h"
13
13
#include " VecSim/types/float16.h"
14
- #if HAVE_SVS
15
14
#include " VecSim/index_factories/svs_factory.h"
15
+
16
+ #if HAVE_SVS
16
17
#include " VecSim/algorithms/svs/svs_tiered.h"
17
18
#endif
18
19
@@ -118,10 +119,8 @@ VecSimIndex *NewIndex(const TieredIndexParams *params) {
118
119
}
119
120
} // namespace TieredHNSWFactory
120
121
121
- #if HAVE_SVS
122
122
namespace TieredSVSFactory {
123
-
124
- static inline BFParams NewBFParams (const TieredIndexParams *params) {
123
+ BFParams NewBFParams (const TieredIndexParams *params) {
125
124
auto &svs_params = params->primaryIndexParams ->algoParams .svsParams ;
126
125
return BFParams{.type = svs_params.type ,
127
126
.dim = svs_params.dim ,
@@ -130,6 +129,7 @@ static inline BFParams NewBFParams(const TieredIndexParams *params) {
130
129
.blockSize = svs_params.blockSize };
131
130
}
132
131
132
+ #if HAVE_SVS
133
133
template <typename DataType>
134
134
inline VecSimIndex *NewIndex (const TieredIndexParams *params) {
135
135
@@ -191,7 +191,7 @@ inline size_t EstimateInitialSize(const TieredIndexParams *params) {
191
191
}
192
192
193
193
VecSimIndex *NewIndex (const TieredIndexParams *params) {
194
- // Tiered index that contains HNSW index as primary index
194
+ // Tiered index that contains SVS index as primary index
195
195
VecSimType type = params->primaryIndexParams ->algoParams .svsParams .type ;
196
196
switch (type) {
197
197
case VecSimType_FLOAT32:
@@ -204,19 +204,25 @@ VecSimIndex *NewIndex(const TieredIndexParams *params) {
204
204
}
205
205
return nullptr ; // Invalid type.
206
206
}
207
- } // namespace TieredSVSFactory
207
+
208
+ // This is a temporary solution to avoid breaking the build when SVS is not available
209
+ // and to allow the code to compile without SVS support.
210
+ // TODO: remove HAVE_SVS when SVS will support all Redis platfoms and compilers
211
+ #else // HAVE_SVS
212
+ inline VecSimIndex *NewIndex (const TieredIndexParams *params) { return nullptr ; }
213
+ inline size_t EstimateInitialSize (const TieredIndexParams *params) { return 0 ; }
214
+ inline size_t EstimateElementSize (const TieredIndexParams *params) { return 0 ; }
208
215
#endif
216
+ } // namespace TieredSVSFactory
209
217
210
218
VecSimIndex *NewIndex (const TieredIndexParams *params) {
211
219
switch (params->primaryIndexParams ->algo ) {
212
220
// Tiered index that contains HNSW index as primary index
213
221
case VecSimAlgo_HNSWLIB:
214
222
return TieredHNSWFactory::NewIndex (params);
215
- #if HAVE_SVS
216
- // Tiered index that contains SVS index as primary index
223
+ // Tiered index that contains SVS index as primary index
217
224
case VecSimAlgo_SVS:
218
225
return TieredSVSFactory::NewIndex (params);
219
- #endif
220
226
default :
221
227
return nullptr ; // Invalid algorithm.
222
228
}
@@ -232,12 +238,10 @@ size_t EstimateInitialSize(const TieredIndexParams *params) {
232
238
est += TieredHNSWFactory::EstimateInitialSize (params);
233
239
bf_params = TieredHNSWFactory::NewBFParams (params);
234
240
break ;
235
- #if HAVE_SVS
236
241
case VecSimAlgo_SVS:
237
242
est += TieredSVSFactory::EstimateInitialSize (params);
238
243
bf_params = TieredSVSFactory::NewBFParams (params);
239
244
break ;
240
- #endif
241
245
default :
242
246
assert (false && " Invalid algorithm" );
243
247
}
@@ -252,11 +256,9 @@ size_t EstimateElementSize(const TieredIndexParams *params) {
252
256
case VecSimAlgo_HNSWLIB:
253
257
est = HNSWFactory::EstimateElementSize (¶ms->primaryIndexParams ->algoParams .hnswParams );
254
258
break ;
255
- #if HAVE_SVS
256
259
case VecSimAlgo_SVS:
257
260
est = SVSFactory::EstimateElementSize (¶ms->primaryIndexParams ->algoParams .svsParams );
258
261
break ;
259
- #endif
260
262
default :
261
263
assert (false && " Invalid algorithm" );
262
264
}
0 commit comments