ZJULearning / nsg

Navigating Spreading-out Graph For Approximate Nearest Neighbor Search
MIT License
621 stars 148 forks source link

an Error when reading binary file #9

Closed s5248 closed 6 years ago

s5248 commented 6 years ago

In file nsg/tests/test_nsg_index.cpp:9, for function load_data, you read a variable dim from the head of binary file, then move the file pointer to the end of file to get its bytes, then calculate total number of features, then move the file pointer to the begin of file. Just at this time, you have not read a variable but read the features directly, this may lead to some problem. BTW, thank you for sharing the source code. Best regards,

fc731097343 commented 6 years ago

I would suggest that you read the code carefully. The load data function would move 4 bytes ahead whenever it reads a feature vector. So there is no problem with the function.

s5248 commented 6 years ago

Sorry,the code is absolutely right. But I would wonder why it has to keep 4 bytes before each feature, rather than just keep 4 bytes at the begin of the binary file then N features of the same dimension dim, Thanks