LCOV - code coverage report
Current view: top level - pebble/internal/keyspan - internal_iter_shim.go (source / functions) Hit Total Coverage
Test: 2023-10-27 08:17Z f522e2f9 - meta test only.lcov Lines: 28 49 57.1 %
Date: 2023-10-27 08:17:54 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright 2022 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             : // InternalIteratorShim is a temporary iterator type used as a shim between
      10             : // keyspan.MergingIter and base.InternalIterator. It's used temporarily for
      11             : // range deletions during compactions, allowing range deletions to be
      12             : // interleaved by a compaction input iterator.
      13             : //
      14             : // TODO(jackson): This type should be removed, and the usages converted to using
      15             : // an InterleavingIterator type that interleaves keyspan.Spans from a
      16             : // keyspan.FragmentIterator with point keys.
      17             : type InternalIteratorShim struct {
      18             :         miter   MergingIter
      19             :         mbufs   MergingBuffers
      20             :         span    *Span
      21             :         iterKey base.InternalKey
      22             : }
      23             : 
      24             : // Assert that InternalIteratorShim implements InternalIterator.
      25             : var _ base.InternalIterator = &InternalIteratorShim{}
      26             : 
      27             : // Init initializes the internal iterator shim to merge the provided fragment
      28             : // iterators.
      29           1 : func (i *InternalIteratorShim) Init(cmp base.Compare, iters ...FragmentIterator) {
      30           1 :         i.miter.Init(cmp, noopTransform, &i.mbufs, iters...)
      31           1 : }
      32             : 
      33             : // Span returns the span containing the full set of keys over the key span at
      34             : // the current iterator position.
      35           1 : func (i *InternalIteratorShim) Span() *Span {
      36           1 :         return i.span
      37           1 : }
      38             : 
      39             : // SeekGE implements (base.InternalIterator).SeekGE.
      40             : func (i *InternalIteratorShim) SeekGE(
      41             :         key []byte, flags base.SeekGEFlags,
      42           0 : ) (*base.InternalKey, base.LazyValue) {
      43           0 :         panic("unimplemented")
      44             : }
      45             : 
      46             : // SeekPrefixGE implements (base.InternalIterator).SeekPrefixGE.
      47             : func (i *InternalIteratorShim) SeekPrefixGE(
      48             :         prefix, key []byte, flags base.SeekGEFlags,
      49           0 : ) (*base.InternalKey, base.LazyValue) {
      50           0 :         panic("unimplemented")
      51             : }
      52             : 
      53             : // SeekLT implements (base.InternalIterator).SeekLT.
      54             : func (i *InternalIteratorShim) SeekLT(
      55             :         key []byte, flags base.SeekLTFlags,
      56           0 : ) (*base.InternalKey, base.LazyValue) {
      57           0 :         panic("unimplemented")
      58             : }
      59             : 
      60             : // First implements (base.InternalIterator).First.
      61           1 : func (i *InternalIteratorShim) First() (*base.InternalKey, base.LazyValue) {
      62           1 :         i.span = i.miter.First()
      63           1 :         for i.span != nil && i.span.Empty() {
      64           0 :                 i.span = i.miter.Next()
      65           0 :         }
      66           1 :         if i.span == nil {
      67           1 :                 return nil, base.LazyValue{}
      68           1 :         }
      69           1 :         i.iterKey = base.InternalKey{UserKey: i.span.Start, Trailer: i.span.Keys[0].Trailer}
      70           1 :         return &i.iterKey, base.MakeInPlaceValue(i.span.End)
      71             : }
      72             : 
      73             : // Last implements (base.InternalIterator).Last.
      74           0 : func (i *InternalIteratorShim) Last() (*base.InternalKey, base.LazyValue) {
      75           0 :         panic("unimplemented")
      76             : }
      77             : 
      78             : // Next implements (base.InternalIterator).Next.
      79           1 : func (i *InternalIteratorShim) Next() (*base.InternalKey, base.LazyValue) {
      80           1 :         i.span = i.miter.Next()
      81           1 :         for i.span != nil && i.span.Empty() {
      82           0 :                 i.span = i.miter.Next()
      83           0 :         }
      84           1 :         if i.span == nil {
      85           1 :                 return nil, base.LazyValue{}
      86           1 :         }
      87           1 :         i.iterKey = base.InternalKey{UserKey: i.span.Start, Trailer: i.span.Keys[0].Trailer}
      88           1 :         return &i.iterKey, base.MakeInPlaceValue(i.span.End)
      89             : }
      90             : 
      91             : // NextPrefix implements (base.InternalIterator).NextPrefix.
      92           0 : func (i *InternalIteratorShim) NextPrefix([]byte) (*base.InternalKey, base.LazyValue) {
      93           0 :         panic("unimplemented")
      94             : }
      95             : 
      96             : // Prev implements (base.InternalIterator).Prev.
      97           0 : func (i *InternalIteratorShim) Prev() (*base.InternalKey, base.LazyValue) {
      98           0 :         panic("unimplemented")
      99             : }
     100             : 
     101             : // Error implements (base.InternalIterator).Error.
     102           1 : func (i *InternalIteratorShim) Error() error {
     103           1 :         return i.miter.Error()
     104           1 : }
     105             : 
     106             : // Close implements (base.InternalIterator).Close.
     107           1 : func (i *InternalIteratorShim) Close() error {
     108           1 :         return i.miter.Close()
     109           1 : }
     110             : 
     111             : // SetBounds implements (base.InternalIterator).SetBounds.
     112           0 : func (i *InternalIteratorShim) SetBounds(lower, upper []byte) {
     113           0 : }
     114             : 
     115             : // String implements fmt.Stringer.
     116           0 : func (i *InternalIteratorShim) String() string {
     117           0 :         return i.miter.String()
     118           0 : }

Generated by: LCOV version 1.14