Skip to content

Commit 296103a

Browse files
minor refactor
1 parent 8ccfe88 commit 296103a

File tree

4 files changed

+22
-34
lines changed

4 files changed

+22
-34
lines changed

posting/list.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,6 @@ 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-
328324
func hasDeleteAll(mpost *pb.Posting) bool {
329325
return mpost.Op == Del && bytes.Equal(mpost.Value, []byte(x.Star)) && len(mpost.LangTag) == 0
330326
}

posting/lists.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (lc *LocalCache) getSingleInternal(key []byte, readFromDisk bool) (*List, e
157157
lc.RLock()
158158
defer lc.RUnlock()
159159
if lc.plists == nil {
160-
pl, err, _ := GetSingleValueForKey(key, lc.startTs)
160+
pl, err := GetSingleValueForKey(key, lc.startTs)
161161
return pl, err
162162
}
163163
return nil, nil
@@ -173,27 +173,23 @@ func (lc *LocalCache) getSingleInternal(key []byte, readFromDisk bool) (*List, e
173173
}
174174

175175
var pl *List
176-
var k int
177176
var err error
178177
if readFromDisk {
179-
pl, err, k = GetSingleValueForKey(key, lc.startTs)
178+
pl, err = GetSingleValueForKey(key, lc.startTs)
180179
} else {
181180
pl = &List{
182181
key: key,
183182
plist: new(pb.PostingList),
184183
}
185184
}
186185

187-
fmt.Println(k)
188-
189186
// If we just brought this posting list into memory and we already have a delta for it, let's
190187
// apply it before returning the list.
191188
lc.RLock()
192189
if delta, ok := lc.deltas[skey]; ok && len(delta) > 0 {
193190
pl.setMutation(lc.startTs, delta)
194191
}
195192
lc.RUnlock()
196-
fmt.Println("Here6")
197193
return pl, err
198194
}
199195

posting/mvcc.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ func ReadPostingList(key []byte, it *badger.Iterator) (*List, error) {
457457
return l, nil
458458
}
459459

460-
func GetSingleValueForKey(key []byte, readTs uint64) (*List, error, int) {
460+
func GetSingleValueForKey(key []byte, readTs uint64) (*List, error) {
461461
cachedVal, ok := lCache.Get(key)
462462
if ok {
463463
l, ok := cachedVal.(*List)
@@ -477,25 +477,23 @@ func GetSingleValueForKey(key []byte, readTs uint64) (*List, error, int) {
477477
}
478478
}
479479
l.RUnlock()
480-
return lCopy, nil, 0
480+
return lCopy, nil
481481
}
482482
}
483483

484484
if pstore.IsClosed() {
485-
return nil, badger.ErrDBClosed, 0
485+
return nil, badger.ErrDBClosed
486486
}
487487

488488
l := new(List)
489489
l.key = key
490490
l.plist = new(pb.PostingList)
491491

492-
//fmt.Println("KEY:", key)
493492
txn := pstore.NewTransactionAt(readTs, false)
494493
item, err := txn.Get(key)
495494
if err != nil {
496-
return l, err, 0
495+
return l, err
497496
}
498-
k := 0
499497

500498
l.maxTs = x.Max(l.maxTs, item.Version())
501499

@@ -504,7 +502,7 @@ func GetSingleValueForKey(key []byte, readTs uint64) (*List, error, int) {
504502
l.minTs = item.Version()
505503
case BitCompletePosting:
506504
if err := unmarshalOrCopy(l.plist, item); err != nil {
507-
return l, nil, k
505+
return l, nil
508506
}
509507
l.minTs = item.Version()
510508

@@ -527,11 +525,11 @@ func GetSingleValueForKey(key []byte, readTs uint64) (*List, error, int) {
527525
return nil
528526
})
529527
if err != nil {
530-
return l, nil, k
528+
return l, nil
531529
}
532530
}
533531

534-
return l, nil, k
532+
return l, nil
535533
}
536534

537535
func getNew(key []byte, pstore *badger.DB, readTs uint64) (*List, error) {

worker/task.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -400,27 +400,25 @@ func (qs *queryState) handleValuePostings(ctx context.Context, args funcArgs) er
400400

401401
if !getMultiplePosting {
402402
pl, _ := qs.cache.GetSinglePosting(key)
403-
if pl != nil {
404-
vals = make([]types.Val, len(pl.Postings))
405-
for i, p := range pl.Postings {
406-
vals[i] = types.Val{
407-
Tid: types.TypeID(p.ValType),
408-
Value: p.Value,
409-
}
410-
411-
// TODO Apply facet tree before
412-
if q.FacetParam != nil {
413-
fcs.FacetsList = append(fcs.FacetsList, &pb.Facets{Facets: facets.CopyFacets(p.Facets, q.FacetParam)})
414-
}
415-
}
416-
}
417-
if pl == nil || len(vals) == 0 {
403+
if pl == nil || len(pl.Postings) == 0 {
418404
out.UidMatrix = append(out.UidMatrix, &pb.List{})
419405
out.FacetMatrix = append(out.FacetMatrix, &pb.FacetsList{})
420406
out.ValueMatrix = append(out.ValueMatrix,
421407
&pb.ValueList{Values: []*pb.TaskValue{}})
422408
continue
423409
}
410+
vals = make([]types.Val, len(pl.Postings))
411+
for i, p := range pl.Postings {
412+
vals[i] = types.Val{
413+
Tid: types.TypeID(p.ValType),
414+
Value: p.Value,
415+
}
416+
417+
// TODO Apply facet tree before
418+
if q.FacetParam != nil {
419+
fcs.FacetsList = append(fcs.FacetsList, &pb.Facets{Facets: facets.CopyFacets(p.Facets, q.FacetParam)})
420+
}
421+
}
424422
} else {
425423
pl, err := qs.cache.Get(key)
426424
if err != nil {

0 commit comments

Comments
 (0)