(t *testing.T)
| 930 | } |
| 931 | |
| 932 | func TestAfterUIDCountWithCommit(t *testing.T) { |
| 933 | key := x.DataKey(x.AttrInRootNamespace("value"), 26) |
| 934 | ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) |
| 935 | require.NoError(t, err) |
| 936 | |
| 937 | // Set value to cars and merge to BadgerDB. |
| 938 | edge := &pb.DirectedEdge{} |
| 939 | |
| 940 | txn := &Txn{StartTs: 1} |
| 941 | for i := 100; i < 400; i++ { |
| 942 | edge.ValueId = uint64(i) |
| 943 | addMutationHelper(t, ol, edge, Set, txn) |
| 944 | } |
| 945 | require.EqualValues(t, 300, ol.Length(txn.StartTs, 0)) |
| 946 | require.EqualValues(t, 200, ol.Length(txn.StartTs, 199)) |
| 947 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 400)) |
| 948 | |
| 949 | // Commit to database. |
| 950 | require.NoError(t, ol.commitMutation(txn.StartTs, txn.StartTs+1)) |
| 951 | |
| 952 | txn = &Txn{StartTs: 3} |
| 953 | // Mutation layer starts afresh from here. |
| 954 | // Delete half of the edges. |
| 955 | for i := 100; i < 400; i += 2 { |
| 956 | edge.ValueId = uint64(i) |
| 957 | addMutationHelper(t, ol, edge, Del, txn) |
| 958 | } |
| 959 | require.EqualValues(t, 150, ol.Length(txn.StartTs, 0)) |
| 960 | require.EqualValues(t, 100, ol.Length(txn.StartTs, 199)) |
| 961 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 400)) |
| 962 | |
| 963 | // Try to delete half of the edges. Redundant deletes. |
| 964 | for i := 100; i < 400; i += 2 { |
| 965 | edge.ValueId = uint64(i) |
| 966 | addMutationHelper(t, ol, edge, Del, txn) |
| 967 | } |
| 968 | require.EqualValues(t, 150, ol.Length(txn.StartTs, 0)) |
| 969 | require.EqualValues(t, 100, ol.Length(txn.StartTs, 199)) |
| 970 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 400)) |
| 971 | |
| 972 | // Delete everything. |
| 973 | for i := 100; i < 400; i++ { |
| 974 | edge.ValueId = uint64(i) |
| 975 | addMutationHelper(t, ol, edge, Del, txn) |
| 976 | } |
| 977 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 0)) |
| 978 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 199)) |
| 979 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 400)) |
| 980 | |
| 981 | // Insert 1/4 of the edges. |
| 982 | for i := 100; i < 300; i += 4 { |
| 983 | edge.ValueId = uint64(i) |
| 984 | addMutationHelper(t, ol, edge, Set, txn) |
| 985 | } |
| 986 | require.EqualValues(t, 50, ol.Length(txn.StartTs, 0)) |
| 987 | require.EqualValues(t, 25, ol.Length(txn.StartTs, 199)) |
| 988 | require.EqualValues(t, 0, ol.Length(txn.StartTs, 300)) |
| 989 |
nothing calls this directly
no test coverage detected