LCOV - code coverage report
Current view: top level - pebble/internal/arenaskl - flush_iterator.go (source / functions) Hit Total Coverage
Test: 2024-01-21 08:16Z 5b092519 - tests only.lcov Lines: 15 28 53.6 %
Date: 2024-01-21 08:16:45 Functions: 0 0 -

          Line data    Source code
       1             : /*
       2             :  * Copyright 2017 Dgraph Labs, Inc. and Contributors
       3             :  * Modifications copyright (C) 2017 Andy Kimball and Contributors
       4             :  *
       5             :  * Licensed under the Apache License, Version 2.0 (the "License");
       6             :  * you may not use this file except in compliance with the License.
       7             :  * You may obtain a copy of the License at
       8             :  *
       9             :  *     http://www.apache.org/licenses/LICENSE-2.0
      10             :  *
      11             :  * Unless required by applicable law or agreed to in writing, software
      12             :  * distributed under the License is distributed on an "AS IS" BASIS,
      13             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14             :  * See the License for the specific language governing permissions and
      15             :  * limitations under the License.
      16             :  */
      17             : 
      18             : package arenaskl
      19             : 
      20             : import "github.com/cockroachdb/pebble/internal/base"
      21             : 
      22             : // flushIterator is an iterator over the skiplist object. Use Skiplist.NewFlushIter
      23             : // to construct an iterator. The current state of the iterator can be cloned by
      24             : // simply value copying the struct.
      25             : type flushIterator struct {
      26             :         Iterator
      27             :         bytesIterated *uint64
      28             : }
      29             : 
      30             : // flushIterator implements the base.InternalIterator interface.
      31             : var _ base.InternalIterator = (*flushIterator)(nil)
      32             : 
      33           0 : func (it *flushIterator) String() string {
      34           0 :         return "memtable"
      35           0 : }
      36             : 
      37             : func (it *flushIterator) SeekGE(
      38             :         key []byte, flags base.SeekGEFlags,
      39           0 : ) (*base.InternalKey, base.LazyValue) {
      40           0 :         panic("pebble: SeekGE unimplemented")
      41             : }
      42             : 
      43             : func (it *flushIterator) SeekPrefixGE(
      44             :         prefix, key []byte, flags base.SeekGEFlags,
      45           0 : ) (*base.InternalKey, base.LazyValue) {
      46           0 :         panic("pebble: SeekPrefixGE unimplemented")
      47             : }
      48             : 
      49             : func (it *flushIterator) SeekLT(
      50             :         key []byte, flags base.SeekLTFlags,
      51           0 : ) (*base.InternalKey, base.LazyValue) {
      52           0 :         panic("pebble: SeekLT unimplemented")
      53             : }
      54             : 
      55             : // First seeks position at the first entry in list. Returns the key and value
      56             : // if the iterator is pointing at a valid entry, and (nil, nil) otherwise. Note
      57             : // that First only checks the upper bound. It is up to the caller to ensure
      58             : // that key is greater than or equal to the lower bound.
      59           1 : func (it *flushIterator) First() (*base.InternalKey, base.LazyValue) {
      60           1 :         key, val := it.Iterator.First()
      61           1 :         if key == nil {
      62           1 :                 return nil, base.LazyValue{}
      63           1 :         }
      64           1 :         *it.bytesIterated += uint64(it.nd.allocSize)
      65           1 :         return key, val
      66             : }
      67             : 
      68             : // Next advances to the next position. Returns the key and value if the
      69             : // iterator is pointing at a valid entry, and (nil, nil) otherwise.
      70             : // Note: flushIterator.Next mirrors the implementation of Iterator.Next
      71             : // due to performance. Keep the two in sync.
      72           1 : func (it *flushIterator) Next() (*base.InternalKey, base.LazyValue) {
      73           1 :         it.nd = it.list.getNext(it.nd, 0)
      74           1 :         if it.nd == it.list.tail {
      75           1 :                 return nil, base.LazyValue{}
      76           1 :         }
      77           1 :         it.decodeKey()
      78           1 :         *it.bytesIterated += uint64(it.nd.allocSize)
      79           1 :         return &it.key, base.MakeInPlaceValue(it.value())
      80             : }
      81             : 
      82           0 : func (it *flushIterator) NextPrefix(succKey []byte) (*base.InternalKey, base.LazyValue) {
      83           0 :         panic("pebble: NextPrefix unimplemented")
      84             : }
      85             : 
      86           0 : func (it *flushIterator) Prev() (*base.InternalKey, base.LazyValue) {
      87           0 :         panic("pebble: Prev unimplemented")
      88             : }

Generated by: LCOV version 1.14