Skip to content

Commit

Permalink
Fix(bulk): Correctly append all the slices of cbuf while reduce phase (
Browse files Browse the repository at this point in the history
…#7110)

The bulk loader was not considering the last slice of cbuf in appendToList
function. This change fixes the issue.
  • Loading branch information
ahsanbarkati committed Dec 11, 2020
1 parent 12def6d commit 004ca03
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dgraph/cmd/bulk/reduce.go
Expand Up @@ -611,7 +611,7 @@ func (r *reducer) toList(req *encodeRequest) {
enc := codec.Encoder{BlockSize: 256}
var lastUid uint64
slice, next := []byte{}, start
for next >= 0 && (next < end || end == 0) {
for next >= 0 && (next < end || end == -1) {
slice, next = cbuf.Slice(next)
me := MapEntry(slice)

Expand Down
44 changes: 44 additions & 0 deletions systest/bulk_live/common/bulk_live_cases.go
Expand Up @@ -55,6 +55,10 @@ func RunBulkCases(t *testing.T) {
testCountIndex(t)
suite.cleanup()

suite = indexedPredicateSetup(t, true)
testIndexedPredicate(t)
suite.cleanup()

suite = loadTypesSetup(t, true)
testLoadTypes(t)
suite.cleanup()
Expand All @@ -78,6 +82,10 @@ func RunLiveCases(t *testing.T) {
testFacets(t)
suite.cleanup()

suite = indexedPredicateSetup(t, false)
testIndexedPredicate(t)
suite.cleanup()

suite = countIndexSetup(t, false)
testCountIndex(t)
suite.cleanup()
Expand Down Expand Up @@ -217,6 +225,42 @@ func testFacets(t *testing.T) {
`))
}

func indexedPredicateSetup(t *testing.T, isBulkLoader bool) *suite {
if isBulkLoader {
s := newBulkOnlySuite(t, `
name: string @index(exact) .
`, `
_:a <name> "alice" .
_:b <name> "alice" .
`, "")
return s
}

s := newLiveOnlySuite(t, `
name: string @index(exact) .
`, `
_:a <name> "alice" .
_:b <name> "alice" .
`, "")
return s
}

func testIndexedPredicate(t *testing.T) {
t.Run("Count query", testCase(`
{
get_count(func: eq(name, "alice")) {
count(uid)
},
}
`, `
{
"get_count": [
{ "count": 2 }
]
}
`))
}

func countIndexSetup(t *testing.T, isBulkLoader bool) *suite {
schema := `
name: string @index(exact) .
Expand Down

0 comments on commit 004ca03

Please sign in to comment.