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 : } 28 : 29 : // flushIterator implements the base.InternalIterator interface. 30 : var _ base.InternalIterator = (*flushIterator)(nil) 31 : 32 0 : func (it *flushIterator) String() string { 33 0 : return "memtable" 34 0 : } 35 : 36 0 : func (it *flushIterator) SeekGE(key []byte, flags base.SeekGEFlags) *base.InternalKV { 37 0 : panic("pebble: SeekGE unimplemented") 38 : } 39 : 40 0 : func (it *flushIterator) SeekPrefixGE(prefix, key []byte, flags base.SeekGEFlags) *base.InternalKV { 41 0 : panic("pebble: SeekPrefixGE unimplemented") 42 : } 43 : 44 0 : func (it *flushIterator) SeekLT(key []byte, flags base.SeekLTFlags) *base.InternalKV { 45 0 : panic("pebble: SeekLT unimplemented") 46 : } 47 : 48 : // First seeks position at the first entry in list. Returns the key and value 49 : // if the iterator is pointing at a valid entry, and (nil, nil) otherwise. Note 50 : // that First only checks the upper bound. It is up to the caller to ensure 51 : // that key is greater than or equal to the lower bound. 52 1 : func (it *flushIterator) First() *base.InternalKV { 53 1 : return it.Iterator.First() 54 1 : } 55 : 56 : // Next advances to the next position. Returns the key and value if the 57 : // iterator is pointing at a valid entry, and (nil, nil) otherwise. 58 : // Note: flushIterator.Next mirrors the implementation of Iterator.Next 59 : // due to performance. Keep the two in sync. 60 1 : func (it *flushIterator) Next() *base.InternalKV { 61 1 : it.nd = it.list.getNext(it.nd, 0) 62 1 : if it.nd == it.list.tail { 63 1 : return nil 64 1 : } 65 1 : it.decodeKey() 66 1 : it.kv.V = base.MakeInPlaceValue(it.value()) 67 1 : return &it.kv 68 : } 69 : 70 0 : func (it *flushIterator) NextPrefix(succKey []byte) *base.InternalKV { 71 0 : panic("pebble: NextPrefix unimplemented") 72 : } 73 : 74 0 : func (it *flushIterator) Prev() *base.InternalKV { 75 0 : panic("pebble: Prev unimplemented") 76 : }