(t *testing.T)
| 323 | } |
| 324 | |
| 325 | func TestScalarPredicateRevCount(t *testing.T) { |
| 326 | dir, err := os.MkdirTemp("", "storetest_") |
| 327 | x.Check(err) |
| 328 | defer os.RemoveAll(dir) |
| 329 | |
| 330 | opt := badger.DefaultOptions(dir) |
| 331 | ps, err := badger.OpenManaged(opt) |
| 332 | x.Check(err) |
| 333 | pstore = ps |
| 334 | posting.Init(ps, 0, false) |
| 335 | Init(ps) |
| 336 | err = schema.ParseBytes([]byte("scalarPredicateCount2: uid @reverse @count ."), 1) |
| 337 | require.NoError(t, err) |
| 338 | |
| 339 | ctx := context.Background() |
| 340 | attr := x.AttrInRootNamespace("scalarPredicateCount2") |
| 341 | |
| 342 | runM := func(startTs, commitTs uint64, edges []*pb.DirectedEdge) { |
| 343 | txn := posting.Oracle().RegisterStartTs(startTs) |
| 344 | for _, edge := range edges { |
| 345 | x.Check(runMutation(ctx, edge, txn)) |
| 346 | } |
| 347 | txn.Update() |
| 348 | writer := posting.NewTxnWriter(pstore) |
| 349 | require.NoError(t, txn.CommitToDisk(writer, commitTs)) |
| 350 | require.NoError(t, writer.Flush()) |
| 351 | txn.UpdateCachedKeys(commitTs) |
| 352 | } |
| 353 | |
| 354 | runM(9, 11, []*pb.DirectedEdge{{ |
| 355 | ValueId: 3, |
| 356 | ValueType: pb.Posting_UID, |
| 357 | Attr: attr, |
| 358 | Entity: 1, |
| 359 | Op: pb.DirectedEdge_SET, |
| 360 | }, { |
| 361 | ValueId: 3, |
| 362 | ValueType: pb.Posting_UID, |
| 363 | Attr: attr, |
| 364 | Entity: 1, |
| 365 | Op: pb.DirectedEdge_DEL, |
| 366 | }}) |
| 367 | |
| 368 | txn := posting.Oracle().RegisterStartTs(13) |
| 369 | key := x.DataKey(attr, 1) |
| 370 | l, err := txn.Get(key) |
| 371 | require.Nil(t, err) |
| 372 | l.RLock() |
| 373 | require.Equal(t, 0, l.GetLength(13)) |
| 374 | l.RUnlock() |
| 375 | |
| 376 | runM(15, 17, []*pb.DirectedEdge{{ |
| 377 | ValueId: 3, |
| 378 | ValueType: pb.Posting_UID, |
| 379 | Attr: attr, |
| 380 | Entity: 1, |
| 381 | Op: pb.DirectedEdge_SET, |
| 382 | }}) |
nothing calls this directly
no test coverage detected