Skip to content

Commit a6b7ae0

Browse files
updated comments
1 parent 48c434f commit a6b7ae0

File tree

4 files changed

+53
-16
lines changed

4 files changed

+53
-16
lines changed

posting/list_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package posting
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"math"
2223
"math/rand"
2324
"os"
@@ -461,10 +462,12 @@ func TestReadSingleValue(t *testing.T) {
461462
}
462463
writer.Flush()
463464

464-
for j := 3; j < i+6; j++ {
465+
for j := 2; j < i+6; j++ {
465466
k, err, _ := GetSingleValueForKey(key, uint64(j))
466467
require.NoError(t, err)
467-
checkValue(t, ol, string(k.Postings[0].Value), uint64(j))
468+
p := getFirst(t, k, uint64(j))
469+
fmt.Println("Here", p)
470+
checkValue(t, ol, string(p.Value), uint64(j))
468471
}
469472

470473
}

posting/lists.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (lc *LocalCache) getSingleInternal(key []byte, readFromDisk bool) (*List, e
178178
var err error
179179
pl, err, k = GetSingleValueForKey(key, lc.startTs)
180180
if err != nil {
181-
return nil, err
181+
return pl, err
182182
}
183183
} else {
184184
pl = &List{
@@ -196,6 +196,7 @@ func (lc *LocalCache) getSingleInternal(key []byte, readFromDisk bool) (*List, e
196196
pl.setMutation(lc.startTs, delta)
197197
}
198198
lc.RUnlock()
199+
fmt.Println("Here6")
199200
return pl, nil
200201
}
201202

posting/mvcc.go

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -493,20 +493,42 @@ func GetSingleValueForKey(key []byte, readTs uint64) (*List, error, int) {
493493
txn := pstore.NewTransactionAt(readTs, false)
494494
item, err := txn.Get(key)
495495
if err != nil {
496-
return nil, err, 0
496+
return l, err, 0
497497
}
498498
k := 0
499499

500-
err = item.Value(func(val []byte) error {
501-
k = len(key) + len(val)
502-
if err := l.plist.Unmarshal(val); err != nil {
503-
return err
500+
l.maxTs = x.Max(l.maxTs, item.Version())
501+
502+
switch item.UserMeta() {
503+
case BitEmptyPosting:
504+
l.minTs = item.Version()
505+
case BitCompletePosting:
506+
if err := unmarshalOrCopy(l.plist, item); err != nil {
507+
return l, nil, k
504508
}
505-
return nil
506-
})
509+
l.minTs = item.Version()
507510

508-
if err != nil {
509-
return nil, err, 0
511+
case BitDeltaPosting:
512+
err := item.Value(func(val []byte) error {
513+
pl := &pb.PostingList{}
514+
if err := pl.Unmarshal(val); err != nil {
515+
return err
516+
}
517+
pl.CommitTs = item.Version()
518+
for _, mpost := range pl.Postings {
519+
// commitTs, startTs are meant to be only in memory, not
520+
// stored on disk.
521+
mpost.CommitTs = item.Version()
522+
}
523+
if l.mutationMap == nil {
524+
l.mutationMap = make(map[uint64]*pb.PostingList)
525+
}
526+
l.mutationMap[pl.CommitTs] = pl
527+
return nil
528+
})
529+
if err != nil {
530+
return l, nil, k
531+
}
510532
}
511533

512534
return l, nil, k

worker/task.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,26 @@ func (qs *queryState) handleValuePostings(ctx context.Context, args funcArgs) er
392392

393393
// Get or create the posting list for an entity, attribute combination.
394394
var pl *posting.List
395-
pickMultiplePostings := q.ExpandAll || (listType && len(q.Langs) == 0)
395+
pickMultiplePostings := q.DoCount || q.ExpandAll || listType || len(q.Langs) > 0
396396

397397
var vals []types.Val
398398
fcs := &pb.FacetsList{FacetsList: make([]*pb.Facets, 0)} // TODO Figure out how it is stored
399399

400-
if pickMultiplePostings {
401-
pl, err = qs.cache.Get(key)
400+
if !pickMultiplePostings {
401+
//fmt.Println("HERE GETTING SINGLE KEY", key)
402+
//vals, fcs, err = retrieveValuesAndFacets(args, pl, facetsTree, listType)
403+
pl, _ = qs.cache.GetSingle(key)
404+
405+
//vals1, _, _ := retrieveValuesAndFacets(args, pl1, facetsTree, listType)
406+
//fmt.Println("Here getting key", len(vals), vals, len(vals1), vals1, len(vals) != len(vals1))
407+
//if len(vals) != len(vals1) {
408+
// fmt.Println("HERE")
409+
//}
410+
//vals, fcs, err = retrieveValuesAndFacets(args, pl, facetsTree, listType)
411+
//fmt.Println("Here getting full key", len(vals), len(fcs.FacetsList), vals[0])
402412
} else {
403-
pl, err = qs.cache.GetSingle(key)
413+
414+
pl, err = qs.cache.Get(key)
404415
}
405416
if err != nil {
406417
return err

0 commit comments

Comments
 (0)