Skip to content

Commit

Permalink
fix test case error
Browse files Browse the repository at this point in the history
  • Loading branch information
ljcui committed Aug 16, 2024
1 parent c428d38 commit ef40d67
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/core/edge_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ std::unique_ptr<KvIterator> InitEdgeIndexIterator(KvTransaction& txn, KvTable& t
return std::unique_ptr<KvIterator>();
}

Value InitKeyEndValue(const Value& key, VertexId vid1, VertexId vid2, IndexType type) {
Value InitKeyEndValue(const Value& key, IndexType type) {
switch (type) {
case IndexType::GlobalUniqueIndex:
return Value::MakeCopy(key);
case IndexType::PairUniqueIndex:
return _detail::PatchPairUniqueIndexKey(key, vid1, vid2);
return _detail::PatchPairUniqueIndexKey(key, -1, -1);
case IndexType::NonuniqueIndex:
return _detail::PatchNonuniqueIndexKey(key, -1, -1, -1, -1, -1);
}
Expand Down Expand Up @@ -197,7 +197,7 @@ EdgeIndexIterator::EdgeIndexIterator(EdgeIndex* idx, Transaction* txn, KvTable&
index_(idx),
it_(_detail::InitEdgeIndexIterator(
txn->GetTxn(), table, key_start, vid, vid2, lid, tid, eid, type)),
key_end_(_detail::InitKeyEndValue(key_end, vid, vid2, type)),
key_end_(_detail::InitKeyEndValue(key_end, type)),
iv_(),
valid_(false),
pos_(0),
Expand All @@ -216,7 +216,7 @@ EdgeIndexIterator::EdgeIndexIterator(EdgeIndex* idx, KvTransaction* txn, KvTable
index_(idx),
it_(_detail::InitEdgeIndexIterator(
*txn, table, key_start, vid, vid2, lid, tid, eid, type)),
key_end_(_detail::InitKeyEndValue(key_end, vid, vid2, type)),
key_end_(_detail::InitKeyEndValue(key_end, type)),
iv_(),
valid_(false),
pos_(0),
Expand Down
5 changes: 4 additions & 1 deletion src/lgraph_api/lgraph_txn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,10 @@ int Transaction::UpsertEdge(int64_t src, int64_t dst, size_t label_id,
field_values[pair_unique_pos.value()],
field_values[pair_unique_pos.value()]);
if (iter.IsValid()) {
euid = iter.GetUid();
auto uid = iter.GetUid();
if (uid.src == src && uid.dst == dst && uid.lid == label_id) {
euid = uid;
}
}
} else {
auto iter = txn_->GetOutEdgeIterator(EdgeUid(src, dst, label_id, 0, 0), false);
Expand Down
8 changes: 7 additions & 1 deletion test/test_lgraph_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,14 +1249,20 @@ TEST_F(TestLGraphApi, pairUniqueIndex) {
like_lid, fid, vids[i], vids[i + 1], FieldData::Int32(i), FieldData::Int32(i));
UT_EXPECT_TRUE(iter.IsValid());
auto euid = iter.GetUid();
UT_EXPECT_EQ(euid.src, vids[i]);
UT_EXPECT_EQ(euid.dst, vids[i+1]);
UT_EXPECT_EQ(euid.lid, like_lid);
auto iter2 = txn.GetOutEdgeIterator(euid);
UT_EXPECT_EQ(iter2.GetField("id"), FieldData::Int32(i));
}
{
auto iter = txn.GetEdgePairUniqueIndexIterator(like_lid, fid, vids[i], vids[i + 1],
FieldData::Int32(i + 1),
FieldData::Int32(i + 1));
UT_EXPECT_FALSE(iter.IsValid());
if (iter.IsValid()) {
auto euid = iter.GetUid();
UT_EXPECT_FALSE(euid.src == vids[i] && euid.dst == vids[i + 1] && euid.lid == like_lid);
}
}
txn.Abort();
}
Expand Down

0 comments on commit ef40d67

Please sign in to comment.