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

Fix typo #708

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/Bolt/go_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {
panic(err)
return
}
_, err = session.Run(ctx, "CALL db.createVertexLabel('person', 'id' , 'id' ,INT32, false, 'name' ,STRING, false)", nil)
_, err = session.Run(ctx, "CALL db.createVertexLabel('person', 'id' , 'id' ,'INT32', false, 'name' ,'STRING', false)", nil)
if err != nil {
panic(err)
return
Expand Down
2 changes: 1 addition & 1 deletion demo/Bolt/java_example.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static void main( final String[] args ) {
Driver driver = GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("admin", "73@TuGraph"));
Session session = driver.session(SessionConfig.forDatabase("default"));
session.run("CALL db.dropDB()");
session.run("CALL db.createVertexLabel('person', 'id' , 'id' ,INT32, false, 'name' ,STRING, false)");
session.run("CALL db.createVertexLabel('person', 'id' , 'id' ,'INT32', false, 'name', 'STRING', false)");
session.run("CALL db.createEdgeLabel('is_friend','[[\"person\",\"person\"]]')");
session.run("create (n1:person {name:'jack',id:1}), (n2:person {name:'lucy',id:2})");
session.run("match (n1:person {id:1}), (n2:person {id:2}) create (n1)-[r:is_friend]->(n2)");
Expand Down
2 changes: 1 addition & 1 deletion demo/Bolt/js_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var session = driver.session({database: 'default'})
await session.run("CALL db.dropDB()");
console.log("clean db");
await session.run("CALL db.createVertexLabel('person', 'id' , 'id' ,INT32, false, 'name' ,STRING, false)");
await session.run("CALL db.createVertexLabel('person', 'id' , 'id', 'INT32', false, 'name', 'STRING', false)");
console.log("add vertex label");
await session.run("CALL db.createEdgeLabel('is_friend','[[\"person\",\"person\"]]')");
console.log("add edge label");
Expand Down
2 changes: 1 addition & 1 deletion demo/Bolt/python_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
with GraphDatabase.driver(URI, auth=AUTH) as client:
session = client.session(database="default")
session.run("CALL db.dropDB()")
session.run("CALL db.createVertexLabel('person', 'id' , 'id' ,INT32, false, 'name' ,STRING, false)")
session.run("CALL db.createVertexLabel('person', 'id' , 'id', 'INT32', false, 'name', 'STRING', false)")
session.run("CALL db.createEdgeLabel('is_friend','[[\"person\",\"person\"]]')")
session.run("create (n1:person {name:'jack',id:1}), (n2:person {name:'lucy',id:2})")
session.run("match (n1:person {id:1}), (n2:person {id:2}) create (n1)-[r:is_friend]->(n2)")
Expand Down
2 changes: 1 addition & 1 deletion demo/Bolt/rust_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async fn main() {
let graph = Graph::connect(config).await.unwrap();
{
graph.run(query("CALL db.dropDB()")).await.unwrap();
graph.run(query("CALL db.createVertexLabel('person', 'id' , 'id' ,INT32, false, 'name' ,STRING, false)")).await.unwrap();
graph.run(query("CALL db.createVertexLabel('person', 'id' , 'id', 'INT32', false, 'name', 'STRING', false)")).await.unwrap();
graph.run(query("CALL db.createEdgeLabel('is_friend','[[\"person\",\"person\"]]')")).await.unwrap();
graph.run(query("create (n1:person {name:'jack',id:1}), (n2:person {name:'lucy',id:2})")).await.unwrap();
graph.run(query("match (n1:person {id:1}), (n2:person {id:2}) create (n1)-[r:is_friend]->(n2)")).await.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions include/lgraph/lgraph_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1296,8 +1296,8 @@ struct VectorIndexSpec {
std::string index_type;
int dimension;
std::string distance_type;
int hnsm_m;
int hnsm_ef_construction;
int hnsw_m;
int hnsw_ef_construction;
};

struct EdgeUid {
Expand Down
10 changes: 5 additions & 5 deletions src/core/index_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ IndexManager::IndexManager(KvTransaction& txn, SchemaManager* v_schema_manager,
std::unique_ptr<VectorIndex> vsag_index;
vsag_index.reset(dynamic_cast<lgraph::VectorIndex*> (
new HNSW(idx.label, idx.field, idx.distance_type, idx.index_type,
idx.dimension, {idx.hnsm_m, idx.hnsm_ef_construction})));
idx.dimension, {idx.hnsw_m, idx.hnsw_ef_construction})));
uint64_t count = 0;
std::vector<std::vector<float>> floatvector;
std::vector<int64_t> vids;
Expand Down Expand Up @@ -185,8 +185,8 @@ bool IndexManager::AddVectorIndex(KvTransaction& txn, const std::string& label,
idx.index_type = index_type;
idx.dimension = vec_dimension;
idx.distance_type = distance_type;
idx.hnsm_m = index_spec[0];
idx.hnsm_ef_construction = index_spec[1];
idx.hnsw_m = index_spec[0];
idx.hnsw_ef_construction = index_spec[1];
auto table_name = GetVertexVectorIndexTableName(label, field);
auto it = index_list_table_->GetIterator(txn, Value::ConstRef(table_name));
if (it->IsValid()) return false; // already exist
Expand Down Expand Up @@ -315,8 +315,8 @@ std::vector<VectorIndexSpec> IndexManager::ListVectorIndex(KvTransaction& txn) {
vs.index_type = vi.index_type;
vs.dimension = vi.dimension;
vs.distance_type = vi.distance_type;
vs.hnsm_m = vi.hnsm_m;
vs.hnsm_ef_construction = vi.hnsm_ef_construction;
vs.hnsw_m = vi.hnsw_m;
vs.hnsw_ef_construction = vi.hnsw_ef_construction;
ret.emplace_back(vs);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/index_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,20 @@ struct VectorIndexEntry {
std::string index_type;
int dimension;
std::string distance_type;
int hnsm_m;
int hnsm_ef_construction;
int hnsw_m;
int hnsw_ef_construction;
template <typename StreamT>
size_t Serialize(StreamT& buf) const {
return BinaryWrite(buf, label) + BinaryWrite(buf, field) + BinaryWrite(buf, index_type) +
BinaryWrite(buf, dimension) + BinaryWrite(buf, distance_type) +
BinaryWrite(buf, hnsm_m) + BinaryWrite(buf, hnsm_ef_construction);
BinaryWrite(buf, hnsw_m) + BinaryWrite(buf, hnsw_ef_construction);
}

template <typename StreamT>
size_t Deserialize(StreamT& buf) {
return BinaryRead(buf, label) + BinaryRead(buf, field) + BinaryRead(buf, index_type) +
BinaryRead(buf, dimension) + BinaryRead(buf, distance_type) +
BinaryRead(buf, hnsm_m) + BinaryRead(buf, hnsm_ef_construction);
BinaryRead(buf, hnsw_m) + BinaryRead(buf, hnsw_ef_construction);
}
};

Expand Down
30 changes: 15 additions & 15 deletions src/cypher/procedure/procedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4189,19 +4189,19 @@ void VectorFunc::AddVertexVectorIndex(RTContext *ctx, const cypher::Record *reco
}
CYPHER_ARG_CHECK((distance_type == "l2" || distance_type == "ip"),
"Distance type should be one of them : l2, ip");
int hnsm_m = 16;
if (parameter.count("hnsm_m")) {
hnsm_m = (int)parameter.at("hnsm_m").AsInt64();
}
CYPHER_ARG_CHECK((hnsm_m <= 64 && hnsm_m >= 5),
"hnsm.m should be an integer in the range [5, 64]");
int hnsm_ef_construction = 100;
if (parameter.count("hnsm_ef_construction")) {
hnsm_ef_construction = (int)parameter.at("hnsm_ef_construction").AsInt64();
}
CYPHER_ARG_CHECK((hnsm_ef_construction <= 1000 && hnsm_ef_construction >= hnsm_m),
"hnsm.efConstruction should be an integer in the range [hnsm.m,1000]");
std::vector<int> index_spec = {hnsm_m, hnsm_ef_construction};
int hnsw_m = 16;
if (parameter.count("hnsw_m")) {
hnsw_m = (int)parameter.at("hnsw_m").AsInt64();
}
CYPHER_ARG_CHECK((hnsw_m <= 64 && hnsw_m >= 5),
"hnsw.m should be an integer in the range [5, 64]");
int hnsw_ef_construction = 100;
if (parameter.count("hnsw_ef_construction")) {
hnsw_ef_construction = (int)parameter.at("hnsw_ef_construction").AsInt64();
}
CYPHER_ARG_CHECK((hnsw_ef_construction <= 1000 && hnsw_ef_construction >= hnsw_m),
"hnsw.efConstruction should be an integer in the range [hnsw.m,1000]");
std::vector<int> index_spec = {hnsw_m, hnsw_ef_construction};
auto ac_db = ctx->galaxy_->OpenGraph(ctx->user_, ctx->graph_);
bool success = ac_db.AddVectorIndex(true, label, field, index_type,
dimension, distance_type, index_spec);
Expand Down Expand Up @@ -4252,8 +4252,8 @@ void VectorFunc::ShowVertexVectorIndex(RTContext *ctx, const cypher::Record *rec
r.AddConstant(lgraph::FieldData(item.index_type));
r.AddConstant(lgraph::FieldData(item.dimension));
r.AddConstant(lgraph::FieldData(item.distance_type));
r.AddConstant(lgraph::FieldData(item.hnsm_m));
r.AddConstant(lgraph::FieldData(item.hnsm_ef_construction));
r.AddConstant(lgraph::FieldData(item.hnsw_m));
r.AddConstant(lgraph::FieldData(item.hnsw_ef_construction));
records->emplace_back(r.Snapshot());
}
FillProcedureYieldItem("db.showVertexVectorIndex", yield_items, records);
Expand Down
4 changes: 2 additions & 2 deletions src/cypher/procedure/procedure.h
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,8 @@ static std::vector<Procedure> global_procedures = {
{"index_type", {2, lgraph_api::LGraphType::STRING}},
{"dimension", {3, lgraph_api::LGraphType::INTEGER}},
{"distance_type", {4, lgraph_api::LGraphType::STRING}},
{"hnsm.m", {5, lgraph_api::LGraphType::INTEGER}},
{"hnsm.ef_construction", {6, lgraph_api::LGraphType::INTEGER}},
{"hnsw.m", {5, lgraph_api::LGraphType::INTEGER}},
{"hnsw.ef_construction", {6, lgraph_api::LGraphType::INTEGER}},
}),

Procedure("db.vertexVectorKnnSearch", VectorFunc::VertexVectorKnnSearch,
Expand Down
6 changes: 3 additions & 3 deletions test/resource/unit_test/procedure/cypher/procedure.result

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CALL db.addVertexVectorIndex('person','embedding2', {dimension:4});
CALL db.addVertexVectorIndex('person','name', {dimension:4});
[VectorIndexException] Only FLOAT_VECTOR type supports vector index
CALL db.showVertexVectorIndex();
[{"dimension":4,"distance_type":"l2","field_name":"embedding1","hnsm.ef_construction":100,"hnsm.m":16,"index_type":"hnsw","label_name":"person"},{"dimension":4,"distance_type":"l2","field_name":"embedding2","hnsm.ef_construction":100,"hnsm.m":16,"index_type":"hnsw","label_name":"person"}]
[{"dimension":4,"distance_type":"l2","field_name":"embedding1","hnsw.ef_construction":100,"hnsw.m":16,"index_type":"hnsw","label_name":"person"},{"dimension":4,"distance_type":"l2","field_name":"embedding2","hnsw.ef_construction":100,"hnsw.m":16,"index_type":"hnsw","label_name":"person"}]
CREATE (n:person {id:1, name:'name1', embedding1: [1.0,1.0,1.0,1.0], embedding2: [11.0,11.0,11.0,11.0]});
[{"<SUMMARY>":"created 1 vertices, created 0 edges."}]
CREATE (n:person {id:2, name:'name2', embedding1: [2.0,2.0,2.0,2.0], embedding2: [12.0,12.0,12.0,12.0]});
Expand Down Expand Up @@ -35,7 +35,7 @@ CALL db.vertexVectorRangeSearch('person','embedding1', [1.0,2.0,3.0,4.0], {radiu
CALL db.alterLabelDelFields('vertex', 'person', ['embedding1']);
[{"record_affected":3}]
CALL db.showVertexVectorIndex();
[{"dimension":4,"distance_type":"l2","field_name":"embedding2","hnsm.ef_construction":100,"hnsm.m":16,"index_type":"hnsw","label_name":"person"}]
[{"dimension":4,"distance_type":"l2","field_name":"embedding2","hnsw.ef_construction":100,"hnsw.m":16,"index_type":"hnsw","label_name":"person"}]
CALL db.vertexVectorKnnSearch('person','embedding1',[1,2,3,4], {top_k:2, hnsw_ef_search:10}) yield node return node.id;
[FieldNotFound] Field [embedding1] does not exist.
CALL db.vertexVectorKnnSearch('person','embedding2',[1,2,3,4], {top_k:2, hnsw_ef_search:10}) yield node return node.id;
Expand Down
Loading