(t *testing.T, size int)
| 1065 | } |
| 1066 | |
| 1067 | func createAndDeleteMultiPartList(t *testing.T, size int) (*List, int) { |
| 1068 | // For testing, set the max list size to a lower threshold. |
| 1069 | defer setMaxListSize(maxListSize) |
| 1070 | maxListSize = 10000 |
| 1071 | |
| 1072 | key := x.DataKey(x.AttrInRootNamespace(uuid.New().String()), 1331) |
| 1073 | ol, err := readPostingListFromDisk(key, ps, math.MaxUint64) |
| 1074 | require.NoError(t, err) |
| 1075 | commits := 0 |
| 1076 | for i := 1; i <= size; i++ { |
| 1077 | edge := &pb.DirectedEdge{ |
| 1078 | ValueId: uint64(i), |
| 1079 | } |
| 1080 | |
| 1081 | txn := Txn{StartTs: uint64(i)} |
| 1082 | addMutationHelper(t, ol, edge, Set, &txn) |
| 1083 | require.NoError(t, ol.commitMutation(uint64(i), uint64(i)+1)) |
| 1084 | if i%2000 == 0 { |
| 1085 | kvs, err := ol.Rollup(nil, math.MaxUint64) |
| 1086 | require.NoError(t, err) |
| 1087 | require.NoError(t, writePostingListToDisk(kvs)) |
| 1088 | ol, err = readPostingListFromDisk(key, ps, math.MaxUint64) |
| 1089 | require.NoError(t, err) |
| 1090 | } |
| 1091 | commits++ |
| 1092 | } |
| 1093 | require.True(t, len(ol.plist.Splits) > 0) |
| 1094 | verifySplits(t, ol.plist.Splits) |
| 1095 | |
| 1096 | // Delete all the previously inserted entries from the list. |
| 1097 | baseStartTs := uint64(size) + 1 |
| 1098 | for i := 1; i <= size; i++ { |
| 1099 | edge := &pb.DirectedEdge{ |
| 1100 | ValueId: uint64(i), |
| 1101 | } |
| 1102 | txn := Txn{StartTs: baseStartTs + uint64(i)} |
| 1103 | addMutationHelper(t, ol, edge, Del, &txn) |
| 1104 | require.NoError(t, ol.commitMutation(baseStartTs+uint64(i), baseStartTs+uint64(i)+1)) |
| 1105 | if i%2000 == 0 { |
| 1106 | kvs, err := ol.Rollup(nil, math.MaxUint64) |
| 1107 | require.NoError(t, err) |
| 1108 | require.NoError(t, writePostingListToDisk(kvs)) |
| 1109 | ol, err = readPostingListFromDisk(key, ps, math.MaxUint64) |
| 1110 | require.NoError(t, err) |
| 1111 | } |
| 1112 | commits++ |
| 1113 | } |
| 1114 | require.Equal(t, 0, len(ol.plist.Splits)) |
| 1115 | |
| 1116 | return ol, commits |
| 1117 | } |
| 1118 | |
| 1119 | func TestLargePlistSplit(t *testing.T) { |
| 1120 | key := x.DataKey(uuid.New().String(), 1331) |
no test coverage detected