MCPcopy
hub / github.com/dgraph-io/dgraph / TestSplitLength

Function TestSplitLength

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

Source from the content-addressed store, hash-verified

1705}
1706
1707func TestSplitLength(t *testing.T) {
1708 defer setMaxListSize(maxListSize)
1709 maxListSize = mb / 2
1710
1711 // Create a list that should be split recursively.
1712 size := uint64(1e5)
1713 key := x.DataKey(x.AttrInRootNamespace(uuid.New().String()), 1333)
1714 ol, err := readPostingListFromDisk(key, ps, math.MaxUint64)
1715 require.NoError(t, err)
1716 commits := 0
1717 for i := uint64(1); i <= size; i++ {
1718 commits++
1719 edge := &pb.DirectedEdge{
1720 ValueId: i,
1721 }
1722 edge.Facets = []*api.Facet{{Key: fmt.Sprintf("%d", i)}}
1723
1724 txn := Txn{StartTs: i}
1725 addMutationHelper(t, ol, edge, Set, &txn)
1726 require.NoError(t, ol.commitMutation(i, i+1))
1727
1728 // Do not roll-up the list here to ensure the final list should
1729 // be split more than once.
1730 }
1731
1732 // Rollup the list. The final output should have more than two parts.
1733 kvs, err := ol.Rollup(nil, math.MaxUint64)
1734 require.NoError(t, err)
1735 require.NoError(t, writePostingListToDisk(kvs))
1736 ol, err = readPostingListFromDisk(key, ps, math.MaxUint64)
1737 require.NoError(t, err)
1738 require.True(t, len(ol.plist.Splits) > 2)
1739
1740 ol.RLock()
1741 require.Equal(t, int(size), ol.GetLength(size+10))
1742 ol.RUnlock()
1743
1744}
1745
1746func TestRecursiveSplits(t *testing.T) {
1747 // For testing, set the max list size to a lower threshold.

Callers

nothing calls this directly

Calls 12

DataKeyFunction · 0.92
AttrInRootNamespaceFunction · 0.92
setMaxListSizeFunction · 0.85
addMutationHelperFunction · 0.85
commitMutationMethod · 0.80
RollupMethod · 0.80
RLockMethod · 0.80
GetLengthMethod · 0.80
RUnlockMethod · 0.80
readPostingListFromDiskFunction · 0.70
writePostingListToDiskFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected