Skip to content

Commit 200f77c

Browse files
committed
add todos and fix logs
1 parent ea55ad5 commit 200f77c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

posting/index.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ func (r *rebuilder) Run(ctx context.Context) error {
531531
WithCompression(options.None).
532532
WithEventLogging(false).
533533
WithLogRotatesToFlush(10).
534-
WithMaxCacheSize(50)
534+
WithMaxCacheSize(50) // TODO(Aman): Disable cache altogether
535535
tmpDB, err := badger.OpenManaged(dbOpts)
536536
if err != nil {
537537
return errors.Wrap(err, "error opening temp badger for reindexing")
@@ -546,9 +546,15 @@ func (r *rebuilder) Run(ctx context.Context) error {
546546
// We set it to 1 in case there are no keys found and NewStreamAt is called with ts=0.
547547
var counter uint64 = 1
548548

549+
// Todo(Aman): Replace TxnWriter with WriteBatch. While we do that we should ensure that
550+
// WriteBatch has a mechanism for throttling. Also, find other places where TxnWriter
551+
// could be replaced with WriteBatch in the code
552+
// Todo(Aman): Replace TxnWriter with WriteBatch. While we do that we should ensure that
553+
// WriteBatch has a mechanism for throttling. Also, find other places where TxnWriter
554+
// could be replaced with WriteBatch in the code.
549555
tmpWriter := NewTxnWriter(tmpDB)
550556
stream := pstore.NewStreamAt(r.startTs)
551-
stream.LogPrefix = fmt.Sprintf("Rebuilding index for predicate %s:", r.attr)
557+
stream.LogPrefix = fmt.Sprintf("Rebuilding index for predicate %s (1/2):", r.attr)
552558
stream.Prefix = r.prefix
553559
stream.KeyToList = func(key []byte, itr *badger.Iterator) (*bpb.KVList, error) {
554560
// We should return quickly if the context is no longer valid.
@@ -619,7 +625,7 @@ func (r *rebuilder) Run(ctx context.Context) error {
619625

620626
writer := NewTxnWriter(pstore)
621627
tmpStream := tmpDB.NewStreamAt(counter)
622-
tmpStream.LogPrefix = fmt.Sprintf("Rebuilding index for predicate %s:", r.attr)
628+
tmpStream.LogPrefix = fmt.Sprintf("Rebuilding index for predicate %s (2/2):", r.attr)
623629
tmpStream.KeyToList = func(key []byte, itr *badger.Iterator) (*bpb.KVList, error) {
624630
l, err := ReadPostingList(key, itr)
625631
if err != nil {

0 commit comments

Comments
 (0)