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

Create graph data interface #510

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alonre24
Copy link
Collaborator

Describe the changes in the pull request

A clear and concise description of what the PR is solving.

Which issues this PR fixes

  1. #...
  2. MOD...

Main objects this PR modified

  1. ...
  2. ...

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

@CLAassistant
Copy link

CLAassistant commented Jul 22, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ alonre24
❌ Hilik Yochai


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.

@hilikredis hilikredis force-pushed the hilik/Redis-search-graph-data-interface branch from a6be265 to c859d5c Compare July 22, 2024 11:19
Copy link
Collaborator Author

@alonre24 alonre24 left a 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
Copy link
Collaborator Author

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

Comment on lines 98 to 110
// 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;
Copy link
Collaborator Author

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

Comment on lines 112 to 115
// premanently delete the vector and the edges "free" the id
virtual void
deleteVectorAndEdges(idType internalId,
WriteBatch *wb) = 0;
Copy link
Collaborator Author

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

Comment on lines 118 to 126
// vectorMetaData methods
virtual const VectorMetaData &
vectorMetaDataById(idType internal_id) const = 0;


virtual VectorMetaData &
vectorMetaDataById(idType internal_id,
WriteBatch *wb);

Copy link
Collaborator Author

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 &,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,
Copy link
Collaborator Author

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

Comment on lines 186 to 192
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);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Comment on lines +61 to +80
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);
}
Copy link
Collaborator Author

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;
Copy link
Collaborator Author

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;
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants