Skip to content

Commit

Permalink
fix cpplint
Browse files Browse the repository at this point in the history
  • Loading branch information
ljcui committed Aug 15, 2024
1 parent 4fdb984 commit c428d38
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion include/lgraph/lgraph_txn.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ class Transaction {

EdgeIndexIterator GetEdgePairUniqueIndexIterator(size_t label_id, size_t field_id,
int64_t src_vid, int64_t dst_vid,
const FieldData& key_start, const FieldData& key_end);
const FieldData& key_start,
const FieldData& key_end);

/**
* @brief Gets vertex index iterator. The iterator has field value [key_start, key_end]. So
Expand Down
7 changes: 4 additions & 3 deletions src/cypher/procedure/procedure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ void BuiltinProcedure::DbUpsertEdge(RTContext *ctx, const Record *record,
CYPHER_ARG_CHECK(args.size() == 4 || args.size() == 5,
"need 4 or 5 parameters, "
"e.g. db.upsertEdge(label_name, start_spec, end_spec, list_data) or "
"db.upsertEdge(label_name, start_spec, end_spec, list_data, pair_unique_field)")
"db.upsertEdge(label_name, start_spec, end_spec, list_data, pair_unique_field)")
CYPHER_ARG_CHECK(args[0].IsString(), "label_name type should be string")
CYPHER_ARG_CHECK(args[1].IsMap(), "start_spec type should be map")
CYPHER_ARG_CHECK(args[2].IsMap(), "end_spec type should be map")
Expand Down Expand Up @@ -844,7 +844,8 @@ void BuiltinProcedure::DbUpsertEdge(RTContext *ctx, const Record *record,
txn = db.CreateWriteTxn();
for (auto& l : lines) {
int ret = txn.UpsertEdge(std::get<0>(l), std::get<1>(l),
label_id, std::get<2>(l), std::get<3>(l), std::get<4>(l), std::get<5>(l));
label_id, std::get<2>(l), std::get<3>(l),
std::get<4>(l), std::get<5>(l));
if (ret == 0) {
index_conflict++;
} else if (ret == 1) {
Expand All @@ -869,7 +870,7 @@ void BuiltinProcedure::DbUpsertEdgeByJson(RTContext *ctx, const Record *record,
CYPHER_ARG_CHECK(args.size() == 4 || args.size() == 5,
"need 4 or 5 parameters, "
"e.g. db.upsertEdgeByJson(label_name, start_spec, end_spec, list_data) or "
"db.upsertEdgeByJson(label_name, start_spec, end_spec, list_data, pair_unique_field)")
"db.upsertEdgeByJson(label_name, start_spec, end_spec, list_data, pair_unique_field)")
CYPHER_ARG_CHECK(args[0].IsString(), "label_name type should be string")
CYPHER_ARG_CHECK(args[1].IsString(), "start_spec type should be json string")
CYPHER_ARG_CHECK(args[2].IsString(), "end_spec type should be json string")
Expand Down
5 changes: 3 additions & 2 deletions test/test_lgraph_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,8 @@ TEST_F(TestLGraphApi, pairUniqueIndex) {
VertexOptions vo("id");
vo.detach_property = true;
UT_EXPECT_TRUE(db.AddVertexLabel("Person",
std::vector<FieldSpec>({{"id", FieldType::INT32, false}}), vo));
std::vector<FieldSpec>({{"id", FieldType::INT32, false}}),
vo));
EdgeOptions eo;
eo.detach_property = true;
UT_EXPECT_TRUE(db.AddEdgeLabel("like",
Expand Down Expand Up @@ -1259,4 +1260,4 @@ TEST_F(TestLGraphApi, pairUniqueIndex) {
}
txn.Abort();
}
}
}
19 changes: 10 additions & 9 deletions test/test_upsert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ TEST_F(TestUpsert, upsertWithPairUniqueError) {
nlohmann::json end;
end["type"] = "node2";
end["key"] = "node2_id";
std::string cypher = FMA_FMT("CALL db.upsertEdgeByJson('edge1','{}', '{}', '{}', 'num')", start.dump(),
std::string cypher = FMA_FMT("CALL db.upsertEdgeByJson('edge1','{}', '{}', '{}', 'num')",
start.dump(),
end.dump(), array.dump());
ret = client.CallCypher(str, cypher);
UT_EXPECT_FALSE(ret);
Expand Down Expand Up @@ -159,8 +160,8 @@ TEST_F(TestUpsert, upsertWithPairUnique) {
nlohmann::json end;
end["type"] = "node2";
end["key"] = "node2_id";
std::string cypher = FMA_FMT("CALL db.upsertEdgeByJson('edge1','{}', '{}', '{}', 'num')", start.dump(),
end.dump(), array.dump());
std::string cypher = FMA_FMT("CALL db.upsertEdgeByJson('edge1','{}', '{}', '{}', 'num')",
start.dump(), end.dump(), array.dump());
ret = client.CallCypher(str, cypher);
UT_EXPECT_TRUE(ret);
UT_EXPECT_EQ(str, R"([{"data_error":0,"index_conflict":0,"insert":10,"total":10,"update":0}])");
Expand All @@ -184,8 +185,8 @@ TEST_F(TestUpsert, upsertWithPairUnique) {
nlohmann::json end;
end["type"] = "node2";
end["key"] = "node2_id";
std::string cypher = FMA_FMT("CALL db.upsertEdgeByJson('edge1','{}', '{}', '{}', 'num')", start.dump(),
end.dump(), array.dump());
std::string cypher = FMA_FMT("CALL db.upsertEdgeByJson('edge1','{}', '{}', '{}', 'num')",
start.dump(), end.dump(), array.dump());
ret = client.CallCypher(str, cypher);
UT_EXPECT_TRUE(ret);
UT_EXPECT_EQ(str, R"([{"data_error":0,"index_conflict":0,"insert":0,"total":10,"update":10}])");
Expand Down Expand Up @@ -219,8 +220,8 @@ TEST_F(TestUpsert, upsertWithPairUnique) {
nlohmann::json end;
end["type"] = "node2";
end["key"] = "node2_id";
std::string cypher = FMA_FMT("CALL db.upsertEdgeByJson('edge1','{}', '{}', '{}', 'num')", start.dump(),
end.dump(), array.dump());
std::string cypher = FMA_FMT("CALL db.upsertEdgeByJson('edge1','{}', '{}', '{}', 'num')",
start.dump(), end.dump(), array.dump());
ret = client.CallCypher(str, cypher);
UT_EXPECT_TRUE(ret);
UT_EXPECT_EQ(str, R"([{"data_error":0,"index_conflict":0,"insert":10,"total":10,"update":0}])");
Expand Down Expand Up @@ -252,8 +253,8 @@ TEST_F(TestUpsert, upsertWithPairUnique) {
nlohmann::json end;
end["type"] = "node2";
end["key"] = "node2_id";
std::string cypher = FMA_FMT("CALL db.upsertEdgeByJson('edge1','{}', '{}', '{}', 'num')", start.dump(),
end.dump(), array.dump());
std::string cypher = FMA_FMT("CALL db.upsertEdgeByJson('edge1','{}', '{}', '{}', 'num')",
start.dump(), end.dump(), array.dump());
ret = client.CallCypher(str, cypher);
UT_EXPECT_TRUE(ret);
UT_EXPECT_EQ(str, R"([{"data_error":0,"index_conflict":0,"insert":0,"total":10,"update":10}])");
Expand Down

0 comments on commit c428d38

Please sign in to comment.