(t *testing.T)
| 1705 | } |
| 1706 | |
| 1707 | func 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 | |
| 1746 | func TestRecursiveSplits(t *testing.T) { |
| 1747 | // For testing, set the max list size to a lower threshold. |
nothing calls this directly
no test coverage detected