Example #1
0
func (s *levelDB) readOptions(opts *keyvalue.Options) *levigo.ReadOptions {
	if snap := opts.GetSnapshot(); snap != nil {
		ro := levigo.NewReadOptions()
		ro.SetSnapshot(snap.(*snapshot).s)
		ro.SetFillCache(!opts.IsLargeRead())
		return ro
	}
	if opts.IsLargeRead() {
		return s.largeReadOpts
	}
	return s.readOpts
}
Example #2
0
// iterator creates a new levigo Iterator based on the given options.  It also
// returns any ReadOptions that should be Closed once the Iterator is Closed.
func (s *levelDB) iterator(opts *keyvalue.Options) (*levigo.Iterator, *levigo.ReadOptions) {
	if snap := opts.GetSnapshot(); snap != nil {
		ro := levigo.NewReadOptions()
		ro.SetSnapshot(snap.(*snapshot).s)
		ro.SetFillCache(!opts.IsLargeRead())
		return s.db.NewIterator(ro), ro
	}
	if opts.IsLargeRead() {
		return s.db.NewIterator(s.largeReadOpts), nil
	}
	return s.db.NewIterator(s.readOpts), nil
}