Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] mock level8 #12

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions lib/NGT/Capi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,8 @@ ObjectID ngt_append_index(NGTIndex index, double *obj, uint32_t obj_dim, NGTErro
}
}

std::vector<float*> object_space;

ObjectID ngt_insert_index_as_float(NGTIndex index, float *obj, uint32_t obj_dim, NGTError error) {
if(index == NULL || obj == NULL || obj_dim == 0){
std::stringstream ss;
Expand All @@ -876,8 +878,13 @@ ObjectID ngt_insert_index_as_float(NGTIndex index, float *obj, uint32_t obj_dim,
}

try{
NGT::Index* pindex = static_cast<NGT::Index*>(index);
return pindex->insert(&obj[0], obj_dim);
// NGT::Index* pindex = static_cast<NGT::Index*>(index);
// std::vector<float> vobj(&obj[0], &obj[obj_dim]);
// return pindex->insert(vobj);
float* arr = new float[obj_dim];
memcpy(arr, obj, obj_dim);
object_space.push_back(arr);
return object_space.size()-1;
}catch(std::exception &err) {
std::stringstream ss;
ss << "Capi : " << __FUNCTION__ << "() : Error: " << err.what();
Expand Down Expand Up @@ -1100,7 +1107,7 @@ bool ngt_create_index(NGTIndex index, uint32_t pool_size, NGTError error) {
}

try{
(static_cast<NGT::Index*>(index))->createIndex(pool_size);
// (static_cast<NGT::Index*>(index))->createIndex(pool_size);
}catch(std::exception &err) {
std::stringstream ss;
ss << "Capi : " << __FUNCTION__ << "() : Error: " << err.what();
Expand All @@ -1119,7 +1126,9 @@ bool ngt_remove_index(NGTIndex index, ObjectID id, NGTError error) {
}

try{
(static_cast<NGT::Index*>(index))->remove(id);
// (static_cast<NGT::Index*>(index))->remove(id);
delete[] object_space[id];
object_space[id] = nullptr;
}catch(std::exception &err) {
std::stringstream ss;
ss << "Capi : " << __FUNCTION__ << "() : Error: " << err.what();
Expand Down