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

Function createMultiPartList

posting/list_test.go:1019–1065  ·  view source on GitHub ↗
(t *testing.T, size int, addFacet bool)

Source from the content-addressed store, hash-verified

1017}
1018
1019func createMultiPartList(t *testing.T, size int, addFacet bool) (*List, int) {
1020 // For testing, set the max list size to a lower threshold.
1021 defer setMaxListSize(maxListSize)
1022 maxListSize = 5000
1023
1024 key := x.DataKey(x.AttrInRootNamespace(uuid.New().String()), 1331)
1025 ol, err := readPostingListFromDisk(key, ps, math.MaxUint64)
1026 require.NoError(t, err)
1027 commits := 0
1028 for i := 1; i <= size; i++ {
1029 edge := &pb.DirectedEdge{
1030 ValueId: uint64(i),
1031 }
1032
1033 // Earlier we used to have label with the posting list to force creation of posting.
1034 if addFacet {
1035 edge.Facets = []*api.Facet{{Key: strconv.Itoa(i)}}
1036 }
1037
1038 txn := Txn{StartTs: uint64(i)}
1039 addMutationHelper(t, ol, edge, Set, &txn)
1040 require.NoError(t, ol.commitMutation(uint64(i), uint64(i)+1))
1041 if i%2000 == 0 {
1042 kvs, err := ol.Rollup(nil, math.MaxUint64)
1043 require.NoError(t, err)
1044 require.NoError(t, writePostingListToDisk(kvs))
1045 ol, err = readPostingListFromDisk(key, ps, math.MaxUint64)
1046 require.NoError(t, err)
1047 }
1048 commits++
1049 }
1050
1051 kvs, err := ol.Rollup(nil, math.MaxUint64)
1052 require.NoError(t, err)
1053 for _, kv := range kvs {
1054 require.Equal(t, uint64(size+1), kv.Version)
1055 }
1056 require.NoError(t, writePostingListToDisk(kvs))
1057 ol, err = readPostingListFromDisk(key, ps, math.MaxUint64)
1058 require.NoError(t, err)
1059 require.Nil(t, ol.plist.Pack)
1060 require.Equal(t, 0, len(ol.plist.Postings))
1061 require.True(t, len(ol.plist.Splits) > 0)
1062 verifySplits(t, ol.plist.Splits)
1063
1064 return ol, commits
1065}
1066
1067func createAndDeleteMultiPartList(t *testing.T, size int) (*List, int) {
1068 // For testing, set the max list size to a lower threshold.

Callers 7

TestMultiPartListBasicFunction · 0.85
TestMultiPartListMarshalFunction · 0.85
TestSingleListRollupFunction · 0.85

Calls 10

DataKeyFunction · 0.92
AttrInRootNamespaceFunction · 0.92
setMaxListSizeFunction · 0.85
addMutationHelperFunction · 0.85
verifySplitsFunction · 0.85
commitMutationMethod · 0.80
RollupMethod · 0.80
readPostingListFromDiskFunction · 0.70
writePostingListToDiskFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected