LCOV - code coverage report
Current view: top level - pebble/internal/keyspan - seek.go (source / functions) Hit Total Coverage
Test: 2024-06-10 08:16Z 47da75f0 - meta test only.lcov Lines: 9 11 81.8 %
Date: 2024-06-10 08:17:11 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2018 The LevelDB-Go and Pebble Authors. All rights reserved. Use
       2             : // of this source code is governed by a BSD-style license that can be found in
       3             : // the LICENSE file.
       4             : 
       5             : package keyspan
       6             : 
       7             : import "github.com/cockroachdb/pebble/internal/base"
       8             : 
       9             : // SeekLE seeks to the span that contains or is before the target key. If an
      10             : // error occurs while seeking iter, a nil span and non-nil error is returned.
      11           1 : func SeekLE(cmp base.Compare, iter FragmentIterator, key []byte) (*Span, error) {
      12           1 :         // Seek to the smallest span that contains a key ≥ key. If some span
      13           1 :         // contains the key `key`, SeekGE will return it.
      14           1 :         iterSpan, err := iter.SeekGE(key)
      15           1 :         if err != nil {
      16           0 :                 return nil, err
      17           0 :         }
      18           1 :         if iterSpan != nil && cmp(key, iterSpan.Start) >= 0 {
      19           1 :                 return iterSpan, nil
      20           1 :         }
      21             :         // No span covers exactly `key`. Step backwards to move onto the largest
      22             :         // span < key.
      23           1 :         return iter.Prev()
      24             : }

Generated by: LCOV version 1.14