-
Notifications
You must be signed in to change notification settings - Fork 12
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
Create graph data interface #510
base: main
Are you sure you want to change the base?
Conversation
Hilik Yochai seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
a6be265
to
c859d5c
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.
Following our discussion:
I suggest we remove the RAM implementation from this PR and stay with the general graph interface.
// this is replacing the id->metadata table and the element graph data | ||
// | ||
|
||
struct VectorMetaData |
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 should be part of the index, not the generic graph store
// vector methods | ||
virtual const char * | ||
getVectorByInternalId(idType internal_id) const = 0; | ||
|
||
virtual void | ||
multiGetVectors(const std::vector<idType> &, | ||
std::vector<const char *> &results) const = 0; | ||
|
||
virtual idType | ||
pushVector(const void *vector_data, | ||
int max_level, | ||
const labelType &label, | ||
WriteBatch *wb) = 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.
This is a part of the raw data, should not be part of the absGrpahData
// premanently delete the vector and the edges "free" the id | ||
virtual void | ||
deleteVectorAndEdges(idType internalId, | ||
WriteBatch *wb) = 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.
remove only the nodes and edges associated with the id
// vectorMetaData methods | ||
virtual const VectorMetaData & | ||
vectorMetaDataById(idType internal_id) const = 0; | ||
|
||
|
||
virtual VectorMetaData & | ||
vectorMetaDataById(idType internal_id, | ||
WriteBatch *wb); | ||
|
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.
meta data is part of the index
GetLevelOutgoingEdges(const graphNodeType &) const = 0; | ||
|
||
virtual absEdges & | ||
GetLevelOutgoingEdges(const graphNodeType &, |
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.
GetLevelOutgoingEdges(const graphNodeType &, | |
GetLevelOutgoingEdgesForUpdate(const graphNodeType &, |
NewRamGraphData(std::shared_ptr<VecSimAllocator> allocator, | ||
size_t block_size, | ||
size_t max_num_outgoing_links, | ||
size_t vector_size_bytes, |
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.
vector_size_bytes
and vector alignment
not needed here
static absGraphData * | ||
NewRamWBGraphData(std::shared_ptr<VecSimAllocator> allocator, | ||
size_t block_size, | ||
size_t max_num_outgoing_links, | ||
size_t vector_size_bytes, | ||
size_t initial_capacity, | ||
size_t vector_alignment); |
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.
remove
bool | ||
removeIdIfExists(idType element_id) override { | ||
for (size_t i = 0; i < num_links_; i++) { | ||
if (links_[i] == element_id) { | ||
// Swap the last element with the current one (equivalent to removing the element id from | ||
// the list). | ||
links_[i] = links_[num_links_-1]; | ||
num_links_--; | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
virtual void | ||
removeId(idType element_id) override { | ||
auto exists = removeIdIfExists(element_id); | ||
if (!exists) | ||
assert(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.
We do not use the remove methods today for outgoing edges, only for the incoming
class LevelData; | ||
class RamGraphData : public absGraphData { | ||
private: | ||
friend class absGraphData; |
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.
Why do you need the base class as a friend?
@@ -0,0 +1,216 @@ | |||
#include "graph_data_ram.h" | |||
struct LevelDataOnRam { | |||
static size_t max_num_outgoing_links; |
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.
Not sure that it can be static, since we may have several instances of HNSW index in redis with different M
values
unused - interface in data_store dir
Describe the changes in the pull request
A clear and concise description of what the PR is solving.
Which issues this PR fixes
Main objects this PR modified
Mark if applicable