-
Notifications
You must be signed in to change notification settings - Fork 22
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
implement the interfaces for add, knnsearch, serialize in pyramid #231
Conversation
22b8903
to
5d932f3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/index/pyramid.cpp
Outdated
// Function to convert BinarySet to a Binary | ||
Binary | ||
binaryset_to_binary(const BinarySet binarySet) { | ||
size_t totalSize = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totalSize -> total_size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/index/pyramid.cpp
Outdated
namespace vsag { | ||
|
||
// Function to convert BinarySet to a Binary | ||
Binary | ||
binaryset_to_binary(const BinarySet binarySet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
binarySet -> binary_set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/index/pyramid.cpp
Outdated
size_t offset = 0; | ||
|
||
for (const auto& key : keys) { | ||
size_t keySize = key.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keySize -> key_size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/index/pyramid.cpp
Outdated
|
||
BinarySet | ||
binary_to_binaryset(const Binary binary) { | ||
BinarySet binarySet; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
binarySet -> binary_set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/index/pyramid.cpp
Outdated
size_t offset = 0; | ||
|
||
while (offset < binary.size) { | ||
size_t keySize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keySize -> key_size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/index/pyramid.cpp
Outdated
start = end + 1; | ||
end = str.find(delimiter, start); | ||
} | ||
std::string lastToken = str.substr(start); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lastToken -> last_token
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/index/pyramid.cpp
Outdated
template <typename T> | ||
using Deque = std::deque<T, vsag::AllocatorWrapper<T>>; | ||
|
||
constexpr static const char PART_SLASH = '/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to file head ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
constexpr static const char PART_SLASH = '/'; | ||
constexpr static const char PART_OCTOTHORPE = '#'; | ||
std::vector<std::string> | ||
split(const std::string& str, char delimiter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use std lib or boost lib split
implement ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that there is no split function in the standard library. Currently, vsag has no dependencies on Boost, so it would be a bit excessive to introduce Boost just for the split function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,can move to common utils file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reference high performance implement (eg. boost / absl)
src/index/pyramid.cpp
Outdated
if (indexes_.find(result[0]) == indexes_.end()) { | ||
indexes_[result[0]] = std::make_shared<IndexNode>(commom_param_.allocator_.get()); | ||
} | ||
std::shared_ptr<IndexNode> node = indexes_.at(result[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: here can reduce one find cost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/index/pyramid.cpp
Outdated
node->children[result[j]] = | ||
std::make_shared<IndexNode>(commom_param_.allocator_.get()); | ||
} | ||
node = node->children.at(result[j]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
2ee1a92
to
3b6956c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅ |
constexpr static const char PART_SLASH = '/'; | ||
constexpr static const char PART_OCTOTHORPE = '#'; | ||
std::vector<std::string> | ||
split(const std::string& str, char delimiter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,can move to common utils file
src/index/pyramid.cpp
Outdated
auto data_vectors = base->GetFloat32Vectors(); | ||
for (int i = 0; i < data_num; ++i) { | ||
std::string current_path = path[i]; | ||
auto result = split(current_path, PART_SLASH); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result -> path_slices ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
constexpr static const char PART_SLASH = '/'; | ||
constexpr static const char PART_OCTOTHORPE = '#'; | ||
std::vector<std::string> | ||
split(const std::string& str, char delimiter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reference high performance implement (eg. boost / absl)
src/index/pyramid.cpp
Outdated
auto path = query->GetPaths(); | ||
|
||
std::string current_path = path[0]; | ||
auto parsed_path = split(current_path, PART_SLASH); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parsed_path -> path_slices ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/index/pyramid.cpp
Outdated
ret->Dim(0)->NumElements(1); | ||
return ret; | ||
} | ||
std::shared_ptr<IndexNode> root = indexes_.at(parsed_path[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: reduce cost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/index/pyramid.cpp
Outdated
ret->Dim(0)->NumElements(1); | ||
return ret; | ||
} | ||
std::shared_ptr<IndexNode> root = indexes_.at(parsed_path[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: reduce cost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/index/pyramid.cpp
Outdated
ret->Dim(0)->NumElements(1); | ||
return ret; | ||
} | ||
std::shared_ptr<IndexNode> root = indexes_.at(parsed_path[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: reduce cost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/index/pyramid.cpp
Outdated
ret->Dim(0)->NumElements(1); | ||
return ret; | ||
} | ||
std::shared_ptr<IndexNode> root = indexes_.at(parsed_path[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: reduce cost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
auto result = node->index->KnnSearch(query, k, parameters, invalid); | ||
if (result.has_value()) { | ||
DatasetPtr r = result.value(); | ||
for (int i = 0; i < r->GetDim(); ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r->GetDim() ?
is r->GetElements() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r->GetDim() denotes the number of the results for single query. r->GetElements() denotes the number of queries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reminder: Update in next PR
} | ||
} else { | ||
for (const auto& item : node->children) { | ||
candidate_indexes.emplace_back(item.second); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do search for all sub tree ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a node has an index, then its child nodes will not be searched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's necessary to introduce retrieval logic that recursively flows from higher layers to lower layers.
c263cdd
to
d02dcaa
Compare
auto result = node->index->KnnSearch(query, k, parameters, invalid); | ||
if (result.has_value()) { | ||
DatasetPtr r = result.value(); | ||
for (int i = 0; i < r->GetDim(); ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reminder: Update in next PR
7b23037
to
5f571db
Compare
Signed-off-by: jinjiabao.jjb <[email protected]>
0270eea
to
3d47fe7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some issues will fix in next PR
#166