MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / TestMutableMap

Function TestMutableMap

posting/list_test.go:1546–1679  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1544}
1545
1546func TestMutableMap(t *testing.T) {
1547 create_pl := func(startTs, commitTs, uid uint64, op uint32) *pb.PostingList {
1548 return &pb.PostingList{
1549 Postings: []*pb.Posting{
1550 {
1551 Uid: uid,
1552 Op: op,
1553 StartTs: startTs,
1554 CommitTs: commitTs,
1555 },
1556 },
1557 CommitTs: commitTs,
1558 }
1559 }
1560
1561 create_deleteAll_pl := func(startTs, commitTs uint64) *pb.PostingList {
1562 return &pb.PostingList{
1563 Postings: []*pb.Posting{
1564 {
1565 Value: []byte(x.Star),
1566 Op: Del,
1567 StartTs: startTs,
1568 CommitTs: commitTs,
1569 },
1570 },
1571 CommitTs: commitTs,
1572 }
1573 }
1574
1575 t.Run("Populate delete all tests", func(t *testing.T) {
1576 ml := newMutableLayer()
1577 ml.insertCommittedPostings(create_pl(10, 11, 1, Set))
1578 ml.insertCommittedPostings(create_deleteAll_pl(8, 9))
1579 ml.insertCommittedPostings(create_pl(6, 7, 1, Set))
1580 ml.insertCommittedPostings(create_deleteAll_pl(4, 5))
1581 ml.insertCommittedPostings(create_pl(2, 3, 1, Set))
1582 ml.insertCommittedPostings(create_deleteAll_pl(1, 2))
1583
1584 require.Equal(t, uint64(9), ml.deleteAllMarker)
1585 require.Equal(t, 1, ml.length)
1586
1587 ml.setCurrentEntries(11, create_deleteAll_pl(11, 0))
1588 require.Equal(t, true, math.MaxUint64 == ml.deleteAllMarker)
1589 require.Equal(t, 1, ml.length)
1590
1591 require.Equal(t, uint64(11), ml.populateDeleteAll(11))
1592 require.Equal(t, uint64(9), ml.populateDeleteAll(10))
1593 require.Equal(t, uint64(5), ml.populateDeleteAll(5))
1594 require.Equal(t, uint64(2), ml.populateDeleteAll(4))
1595
1596 })
1597
1598 // Need to insert postings in reverse order
1599 t.Run("Current Entries has deleteAll", func(t *testing.T) {
1600 ml := newMutableLayer()
1601 ml.insertCommittedPostings(create_pl(1, 2, 1, Set))
1602 ml.setCurrentEntries(3, create_deleteAll_pl(3, 0))
1603

Callers

nothing calls this directly

Calls 7

newMutableLayerFunction · 0.85
setCurrentEntriesMethod · 0.80
populateDeleteAllMethod · 0.80
listLenMethod · 0.80
RunMethod · 0.45
findPostingMethod · 0.45

Tested by

no test coverage detected