diff --git a/lib/NGT/Capi.cpp b/lib/NGT/Capi.cpp index d2608aa..794bd02 100644 --- a/lib/NGT/Capi.cpp +++ b/lib/NGT/Capi.cpp @@ -1100,7 +1100,9 @@ bool ngt_create_index(NGTIndex index, uint32_t pool_size, NGTError error) { } try{ - (static_cast(index))->createIndex(pool_size); + // (static_cast(index))->createIndex(pool_size); + auto _ps = pool_size; + return _ps == pool_size; }catch(std::exception &err) { std::stringstream ss; ss << "Capi : " << __FUNCTION__ << "() : Error: " << err.what(); @@ -1119,7 +1121,9 @@ bool ngt_remove_index(NGTIndex index, ObjectID id, NGTError error) { } try{ - (static_cast(index))->remove(id); + // (static_cast(index))->remove(id); + auto _id = id; + return _id == id; }catch(std::exception &err) { std::stringstream ss; ss << "Capi : " << __FUNCTION__ << "() : Error: " << err.what(); diff --git a/lib/NGT/Index.h b/lib/NGT/Index.h index 94cac0d..66efe83 100644 --- a/lib/NGT/Index.h +++ b/lib/NGT/Index.h @@ -1825,7 +1825,9 @@ size_t NGT::Index::insert(const T* object, size_t size) getObjectSpace().getRepository().initialize(); } - auto *o = getObjectSpace().getRepository().allocateNormalizedPersistentObject(object, size); - size_t oid = getObjectSpace().getRepository().insert(dynamic_cast(o)); - return oid; -} + // auto *o = getObjectSpace().getRepository().allocateNormalizedPersistentObject(object, size); + // size_t oid = getObjectSpace().getRepository().insert(dynamic_cast(o)); + // return oid; + getObjectSpace().getRepository().allocateNormalizedPersistentObject(object, size); + return 0; +} \ No newline at end of file diff --git a/lib/NGT/ObjectRepository.h b/lib/NGT/ObjectRepository.h index b5933d9..8c61c2c 100644 --- a/lib/NGT/ObjectRepository.h +++ b/lib/NGT/ObjectRepository.h @@ -228,43 +228,45 @@ namespace NGT { } template - Object *allocateObject(T *o, size_t size) { + Object *allocateObject(T *o, size_t size) { size_t osize = paddedByteSize; if (sparse) { - size_t vsize = size * (type == typeid(float) ? 4 : 1); - osize = osize < vsize ? vsize : osize; + size_t vsize = size * (type == typeid(float) ? 4 : 1); + osize = osize < vsize ? vsize : osize; } else { - if (dimension != size) { - std::stringstream msg; - msg << "ObjectSpace::allocateObject: Fatal error! The specified dimension is invalid. The indexed objects=" - << dimension << " The specified object=" << size; - NGTThrowException(msg); - } + if (dimension != size) { + std::stringstream msg; + msg << "ObjectSpace::allocateObject: Fatal error! The specified dimension is invalid. The indexed objects=" + << dimension << " The specified object=" << size; + NGTThrowException(msg); + } } Object *po = new Object(osize); - void *object = static_cast(&(*po)[0]); - if (type == typeid(uint8_t)) { - uint8_t *obj = static_cast(object); - for (size_t i = 0; i < size; i++) { - obj[i] = static_cast(o[i]); - } - } else if (type == typeid(float)) { - float *obj = static_cast(object); - for (size_t i = 0; i < size; i++) { - obj[i] = static_cast(o[i]); - } -#ifdef NGT_HALF_FLOAT - } else if (type == typeid(float16)) { - float16 *obj = static_cast(object); - for (size_t i = 0; i < size; i++) { - obj[i] = static_cast(o[i]); - } -#endif - } else { - std::cerr << "ObjectSpace::allocateObject: Fatal error: unsupported type!" << std::endl; - abort(); - } - return po; +// void *object = static_cast(&(*po)[0]); +// if (type == typeid(uint8_t)) { +// uint8_t *obj = static_cast(object); +// for (size_t i = 0; i < size; i++) { +// obj[i] = static_cast(o[i]); +// } +// } else if (type == typeid(float)) { +// float *obj = static_cast(object); +// for (size_t i = 0; i < size; i++) { +// obj[i] = static_cast(o[i]); +// } +// #ifdef NGT_HALF_FLOAT +// } else if (type == typeid(float16)) { +// float16 *obj = static_cast(object); +// for (size_t i = 0; i < size; i++) { +// obj[i] = static_cast(o[i]); +// } +// #endif +// } else { +// std::cerr << "ObjectSpace::allocateObject: Fatal error: unsupported type!" << std::endl; +// abort(); +// } +// return po; + delete po; + return nullptr; } template