Skip to content

Commit 0c00d08

Browse files
Fixed one bug
1 parent fe3995d commit 0c00d08

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

posting/list.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ func NewPosting(t *pb.DirectedEdge) *pb.Posting {
321321
return p
322322
}
323323

324+
func HasDeleteAll(mpost *pb.Posting) bool {
325+
return hasDeleteAll(mpost)
326+
}
327+
324328
func hasDeleteAll(mpost *pb.Posting) bool {
325329
return mpost.Op == Del && bytes.Equal(mpost.Value, []byte(x.Star)) && len(mpost.LangTag) == 0
326330
}

posting/lists.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,20 @@ func (lc *LocalCache) getInternal(key []byte, readFromDisk bool) (*List, error)
253253

254254
func (lc *LocalCache) GetSinglePosting(key []byte) (*pb.PostingList, error) {
255255
pl := &pb.PostingList{}
256+
validatePl := func() {
257+
for _, postings := range pl.Postings {
258+
if hasDeleteAll(postings) {
259+
pl = nil
260+
return
261+
}
262+
}
263+
}
256264
lc.RLock()
257265
if delta, ok := lc.deltas[string(key)]; ok && len(delta) > 0 {
258266
err := pl.Unmarshal(delta)
259267
lc.RUnlock()
260268
if err != nil {
269+
validatePl()
261270
return pl, nil
262271
}
263272
} else {
@@ -267,6 +276,7 @@ func (lc *LocalCache) GetSinglePosting(key []byte) (*pb.PostingList, error) {
267276
txn := pstore.NewTransactionAt(lc.startTs, false)
268277
item, err := txn.Get(key)
269278
if err != nil {
279+
validatePl()
270280
return pl, err
271281
}
272282

@@ -278,9 +288,11 @@ func (lc *LocalCache) GetSinglePosting(key []byte) (*pb.PostingList, error) {
278288
})
279289

280290
if err != nil {
291+
validatePl()
281292
return pl, err
282293
}
283294

295+
validatePl()
284296
return pl, nil
285297
}
286298

worker/task.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,21 @@ func (qs *queryState) handleValuePostings(ctx context.Context, args funcArgs) er
398398
fcs := &pb.FacetsList{FacetsList: make([]*pb.Facets, 0)} // TODO Figure out how it is stored
399399

400400
if !pickMultiplePostings {
401-
pl, _ := qs.cache.GetSinglePosting(key)
401+
pl, err := qs.cache.GetSinglePosting(key)
402+
if pl == nil || err == posting.ErrNoValue {
403+
out.UidMatrix = append(out.UidMatrix, &pb.List{})
404+
out.FacetMatrix = append(out.FacetMatrix, &pb.FacetsList{})
405+
out.ValueMatrix = append(out.ValueMatrix,
406+
&pb.ValueList{Values: []*pb.TaskValue{}})
407+
if q.ExpandAll {
408+
// To keep the cardinality same as that of ValueMatrix.
409+
out.LangMatrix = append(out.LangMatrix, &pb.LangList{})
410+
}
411+
continue
412+
}
413+
if err != nil {
414+
return err
415+
}
402416
vals = make([]types.Val, len(pl.Postings))
403417
for i, p := range pl.Postings {
404418
vals[i] = types.Val{

0 commit comments

Comments
 (0)