未验证 提交 24c39535 编写于 作者: J Jin Hai 提交者: GitHub

Merge pull request #1639 from dvzubarev/fix-crashes

Fix crashes with sptag index
......@@ -10,6 +10,7 @@
// or implied. See the License for the specific language governing permissions and limitations under the License.
#include "knowhere/adapter/SptagAdapter.h"
#include "VectorAdapter.h"
namespace knowhere {
......@@ -19,7 +20,7 @@ ConvertToMetadataSet(const DatasetPtr& dataset) {
auto elems = dataset->Get<int64_t>(meta::ROWS);
auto p_data = dataset->Get<const int64_t*>(meta::IDS);
auto p_offset = (int64_t*)malloc(sizeof(int64_t) * elems);
auto p_offset = (int64_t*)malloc(sizeof(int64_t) * (elems + 1));
for (auto i = 0; i <= elems; ++i) p_offset[i] = i * 8;
std::shared_ptr<SPTAG::MetadataSet> metaset(
......
......@@ -11,6 +11,8 @@
#pragma once
#include <string.h>
#include <map>
#include <memory>
#include <string>
......@@ -28,6 +30,13 @@ struct Binary {
};
using BinaryPtr = std::shared_ptr<Binary>;
inline uint8_t*
CopyBinary(const BinaryPtr& bin) {
uint8_t* newdata = new uint8_t[bin->size];
memcpy(newdata, bin->data.get(), bin->size);
return newdata;
}
class BinarySet {
public:
BinaryPtr
......
......@@ -104,7 +104,7 @@ CPUSPTAGRNG::Load(const BinarySet& binary_set) {
index_blobs.push_back(SPTAG::ByteArray(deleteid->data.get(), deleteid->size, false));
auto metadata1 = binary_set.GetByName("metadata1");
index_blobs.push_back(SPTAG::ByteArray(metadata1->data.get(), metadata1->size, false));
index_blobs.push_back(SPTAG::ByteArray(CopyBinary(metadata1), metadata1->size, true));
auto metadata2 = binary_set.GetByName("metadata2");
index_blobs.push_back(SPTAG::ByteArray(metadata2->data.get(), metadata2->size, false));
......
......@@ -39,9 +39,10 @@ BuildIndexJob::AddToIndexFiles(const engine::meta::TableFileSchemaPtr& to_index_
<< ", location: " << to_index_file->location_;
to_index_files_[to_index_file->id_] = to_index_file;
return true;
}
Status&
void
BuildIndexJob::WaitBuildIndexFinish() {
std::unique_lock<std::mutex> lock(mutex_);
cv_.wait(lock, [this] { return to_index_files_.empty(); });
......
......@@ -44,7 +44,7 @@ class BuildIndexJob : public Job, public server::CacheConfigHandler {
bool
AddToIndexFiles(const TableFileSchemaPtr& to_index_file);
Status&
void
WaitBuildIndexFinish();
void
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册