LCOV - code coverage report
Current view: top level - pebble/internal/keyspan - get.go (source / functions) Hit Total Coverage
Test: 2024-05-17 08:16Z 2ac449bb - meta test only.lcov Lines: 10 12 83.3 %
Date: 2024-05-17 08:17:14 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             : // Get returns the newest span that contains the target key. If no span contains
      10             : // the target key, an empty span is returned. The iterator must contain
      11             : // fragmented spans: no span may overlap another.
      12             : //
      13             : // If an error occurs while seeking iter, a nil span and non-nil error is
      14             : // returned.
      15           1 : func Get(cmp base.Compare, iter FragmentIterator, key []byte) (*Span, error) {
      16           1 :         // NB: FragmentIterator.SeekGE moves the iterator to the first span covering
      17           1 :         // a key greater than or equal to the given key. This is equivalent to
      18           1 :         // seeking to the first span with an end key greater than the given key.
      19           1 :         iterSpan, err := iter.SeekGE(key)
      20           1 :         switch {
      21           0 :         case err != nil:
      22           0 :                 return nil, err
      23           1 :         case iterSpan != nil && cmp(iterSpan.Start, key) > 0:
      24           1 :                 return nil, nil
      25           1 :         default:
      26           1 :                 return iterSpan, nil
      27             :         }
      28             : }

Generated by: LCOV version 1.14