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

Generated by: LCOV version 1.14