Skip to content

Add a builder API for iterator options #2224

@FGasper

Description

@FGasper

Is your feature request related to a problem? Please describe

I almost missed that I was creating an iterator with PrefetchValues=false thus:

iterator, err := txn.NewIterator(badger.IteratorOptions{
    Prefix: ...
})

… which is not the intended “default” behavior (going on the values of badger.DefaultIteratorOptions).

Describe the solution you'd like

The Options struct has a nice builder where you do:

badger.DefaultOptions("/path/to/db").WithLogger(myCustomLogger)

The IteratorOptions should have something similar:

badger.DefaultIteratorOptions.WithPrefix([]byte("some.prefix."))

Describe alternatives you've considered

I was lucky & manually caught my inadvertent suboptimal use. Others may not be so lucky.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions