@@ -106,6 +106,7 @@ struct VecSimIndexAbstract : public VecSimIndexInterface {
106106 inline VecSimMetric getMetric () const { return metric; }
107107 inline size_t getDataSize () const { return dataSize; }
108108 inline size_t getBlockSize () const { return blockSize; }
109+ inline auto getAlignment () const { return alignment; }
109110 virtual inline VecSimIndexStatsInfo statisticInfo () const override {
110111 return VecSimIndexStatsInfo{
111112 .memory = this ->getAllocationSize (),
@@ -214,33 +215,37 @@ struct VecSimIndexAbstract : public VecSimIndexInterface {
214215
215216protected:
216217 virtual int addVectorWrapper (const void *blob, labelType label, void *auxiliaryCtx) override {
217- char PORTABLE_ALIGN aligned_mem[this ->dataSize ];
218- const void *processed_blob = processBlob (blob, aligned_mem);
218+ auto aligned_mem =
219+ this ->getAllocator ()->allocate_aligned_unique (this ->dataSize , this ->alignment );
220+ const void *processed_blob = processBlob (blob, aligned_mem.get ());
219221
220222 return this ->addVector (processed_blob, label, auxiliaryCtx);
221223 }
222224
223225 virtual VecSimQueryReply *topKQueryWrapper (const void *queryBlob, size_t k,
224226 VecSimQueryParams *queryParams) const override {
225- char PORTABLE_ALIGN aligned_mem[this ->dataSize ];
226- const void *processed_blob = processBlob (queryBlob, aligned_mem);
227+ auto aligned_mem =
228+ this ->getAllocator ()->allocate_aligned_unique (this ->dataSize , this ->alignment );
229+ const void *processed_blob = processBlob (queryBlob, aligned_mem.get ());
227230
228231 return this ->topKQuery (processed_blob, k, queryParams);
229232 }
230233
231234 virtual VecSimQueryReply *rangeQueryWrapper (const void *queryBlob, double radius,
232235 VecSimQueryParams *queryParams,
233236 VecSimQueryReply_Order order) const override {
234- char PORTABLE_ALIGN aligned_mem[this ->dataSize ];
235- const void *processed_blob = processBlob (queryBlob, aligned_mem);
237+ auto aligned_mem =
238+ this ->getAllocator ()->allocate_aligned_unique (this ->dataSize , this ->alignment );
239+ const void *processed_blob = processBlob (queryBlob, aligned_mem.get ());
236240
237241 return this ->rangeQuery (processed_blob, radius, queryParams, order);
238242 }
239243
240244 virtual VecSimBatchIterator *
241245 newBatchIteratorWrapper (const void *queryBlob, VecSimQueryParams *queryParams) const override {
242- char PORTABLE_ALIGN aligned_mem[this ->dataSize ];
243- const void *processed_blob = processBlob (queryBlob, aligned_mem);
246+ auto aligned_mem =
247+ this ->getAllocator ()->allocate_aligned_unique (this ->dataSize , this ->alignment );
248+ const void *processed_blob = processBlob (queryBlob, aligned_mem.get ());
244249
245250 return this ->newBatchIterator (processed_blob, queryParams);
246251 }
0 commit comments