LCOV - code coverage report
Current view: top level - pebble/internal/keyspan - get.go (source / functions) Hit Total Coverage
Test: 2024-01-16 08:16Z 27d566eb - meta test only.lcov Lines: 12 12 100.0 %
Date: 2024-01-16 08:17:02 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 := iter.SeekGE(key)
      20           1 :         switch {
      21           1 :         case iterSpan == nil:
      22           1 :                 return nil, iter.Error()
      23           1 :         case 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