From 95520a808ae2fba8c3be7fba8823931aa8382a87 Mon Sep 17 00:00:00 2001 From: Kosuke Morimoto Date: Wed, 4 Oct 2023 13:37:52 +0900 Subject: [PATCH 1/4] mock level6 --- lib/NGT/Capi.cpp | 8 ++++++-- lib/NGT/Index.h | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) 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 From 1c85b9868d7e6f3ebfe510cea5bfeb3ee2a8a850 Mon Sep 17 00:00:00 2001 From: Kosuke Morimoto Date: Wed, 4 Oct 2023 14:10:49 +0900 Subject: [PATCH 2/4] mock level6.1 --- lib/NGT/ObjectRepository.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/NGT/ObjectRepository.h b/lib/NGT/ObjectRepository.h index b5933d9..94066cd 100644 --- a/lib/NGT/ObjectRepository.h +++ b/lib/NGT/ObjectRepository.h @@ -251,7 +251,8 @@ namespace NGT { } else if (type == typeid(float)) { float *obj = static_cast(object); for (size_t i = 0; i < size; i++) { - obj[i] = static_cast(o[i]); + // obj[i] = static_cast(o[i]); + obj[i] = 0; } #ifdef NGT_HALF_FLOAT } else if (type == typeid(float16)) { From b2ff734b0197d9546726140d27a78af7fe444b6b Mon Sep 17 00:00:00 2001 From: Kosuke Morimoto Date: Wed, 4 Oct 2023 14:59:40 +0900 Subject: [PATCH 3/4] mock level6.2 --- lib/NGT/ObjectRepository.h | 50 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/NGT/ObjectRepository.h b/lib/NGT/ObjectRepository.h index 94066cd..b2f1301 100644 --- a/lib/NGT/ObjectRepository.h +++ b/lib/NGT/ObjectRepository.h @@ -241,31 +241,31 @@ namespace NGT { 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]); - obj[i] = 0; - } -#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; +// 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; + return nullptr; } template From 3b9b45891e5f6270c0f1d50c22f81d54a9cc4fce Mon Sep 17 00:00:00 2001 From: Kosuke Morimoto Date: Wed, 4 Oct 2023 17:45:19 +0900 Subject: [PATCH 4/4] mock level6.3 --- lib/NGT/ObjectRepository.h | 49 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/lib/NGT/ObjectRepository.h b/lib/NGT/ObjectRepository.h index b2f1301..8c61c2c 100644 --- a/lib/NGT/ObjectRepository.h +++ b/lib/NGT/ObjectRepository.h @@ -228,43 +228,44 @@ 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); + 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]); -// } +// 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]); -// } +// 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]); -// } +// 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(); +// std::cerr << "ObjectSpace::allocateObject: Fatal error: unsupported type!" << std::endl; +// abort(); // } // return po; + delete po; return nullptr; }