Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't traverse immutable layer if deleteBelowTs > 0 #4204

Merged
merged 4 commits into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions posting/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ func (it *pIterator) init(l *List, afterUid, deleteBelowTs uint64) error {

it.afterUid = afterUid
it.deleteBelowTs = deleteBelowTs
if deleteBelowTs > 0 {
// We don't need to iterate over the immutable layer if this is > 0. Returning here would
// mean it.uids is empty and valid() would return false.
return nil
}

it.uidPosting = &pb.Posting{}
it.dec = &codec.Decoder{Pack: it.plist.Pack}
Expand Down
36 changes: 36 additions & 0 deletions systest/bulk_live_cases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
package main

import (
"context"
"os"
"testing"
"time"

"github.com/dgraph-io/dgo/v2/protos/api"
"github.com/stretchr/testify/require"
)

// TODO: This test was used just to make sure some really basic examples work.
Expand Down Expand Up @@ -445,6 +449,38 @@ func TestBulkSingleUid(t *testing.T) {
`))
}

func TestDeleteEdgeWithStar(t *testing.T) {
s := newBulkOnlySuite(t, `
friend: [uid] .
`, `
<0x1> <friend> <0x2> .
<0x1> <friend> <0x3> .

<0x2> <name> "Alice" .
<0x3> <name> "Bob" .
`)
defer s.cleanup()

_, err := s.bulkCluster.client.NewTxn().Mutate(context.Background(), &api.Mutation{
DelNquads: []byte(`<0x1> <friend> * .`),
CommitNow: true,
})
require.NoError(t, err)

t.Run("Get list of friends", s.testCase(`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have s.testCase( to be on a new line for readability.

{
me(func: uid(0x1)) {
friend {
name
}
}
}`, `
{
"me": []
}`))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this format would be better for readability:

    }`,
  ),
)


}

// TODO: Fix this later.
func DONOTRUNTestGoldenData(t *testing.T) {
if testing.Short() {
Expand Down