Line data Source code
1 : // Copyright 2024 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 sstable 6 : 7 : import ( 8 : "context" 9 : "math" 10 : 11 : "github.com/cockroachdb/pebble/internal/base" 12 : "github.com/cockroachdb/pebble/internal/keyspan" 13 : "github.com/cockroachdb/pebble/sstable/block" 14 : ) 15 : 16 : // CommonReader abstracts functionality over a Reader or a VirtualReader. This 17 : // can be used by code which doesn't care to distinguish between a reader and a 18 : // virtual reader. 19 : type CommonReader interface { 20 : NewRawRangeKeyIter( 21 : ctx context.Context, transforms FragmentIterTransforms, 22 : ) (keyspan.FragmentIterator, error) 23 : 24 : NewRawRangeDelIter( 25 : ctx context.Context, transforms FragmentIterTransforms, 26 : ) (keyspan.FragmentIterator, error) 27 : 28 : NewPointIter( 29 : ctx context.Context, 30 : transforms IterTransforms, 31 : lower, upper []byte, 32 : filterer *BlockPropertiesFilterer, 33 : filterBlockSizeLimit FilterBlockSizeLimit, 34 : stats *base.InternalIteratorStats, 35 : statsAccum IterStatsAccumulator, 36 : rp ReaderProvider, 37 : ) (Iterator, error) 38 : 39 : NewCompactionIter( 40 : transforms IterTransforms, 41 : statsAccum IterStatsAccumulator, 42 : rp ReaderProvider, 43 : bufferPool *block.BufferPool, 44 : ) (Iterator, error) 45 : 46 : EstimateDiskUsage(start, end []byte) (uint64, error) 47 : 48 : CommonProperties() *CommonProperties 49 : } 50 : 51 : // FilterBlockSizeLimit is a size limit for bloom filter blocks - if a bloom 52 : // filter is present, it is used only when it is at most this size. 53 : type FilterBlockSizeLimit uint32 54 : 55 : const ( 56 : // NeverUseFilterBlock indicates that bloom filter blocks should never be used. 57 : NeverUseFilterBlock FilterBlockSizeLimit = 0 58 : // AlwaysUseFilterBlock indicates that bloom filter blocks should always be 59 : // used, regardless of size. 60 : AlwaysUseFilterBlock FilterBlockSizeLimit = math.MaxUint32 61 : ) 62 : 63 : type ( 64 : // BufferPool re-exports block.BufferPool. 65 : BufferPool = block.BufferPool 66 : // IterTransforms re-exports block.IterTransforms. 67 : IterTransforms = block.IterTransforms 68 : // FragmentIterTransforms re-exports block.FragmentIterTransforms. 69 : FragmentIterTransforms = block.FragmentIterTransforms 70 : // SyntheticSeqNum re-exports block.SyntheticSeqNum. 71 : SyntheticSeqNum = block.SyntheticSeqNum 72 : // SyntheticSuffix re-exports block.SyntheticSuffix. 73 : SyntheticSuffix = block.SyntheticSuffix 74 : // SyntheticPrefix re-exports block.SyntheticPrefix. 75 : SyntheticPrefix = block.SyntheticPrefix 76 : // SyntheticPrefixAndSuffix re-exports block.SyntheticPrefixAndSuffix. 77 : SyntheticPrefixAndSuffix = block.SyntheticPrefixAndSuffix 78 : ) 79 : 80 : // NoTransforms is the default value for IterTransforms. 81 : var NoTransforms = block.NoTransforms 82 : 83 : // NoFragmentTransforms is the default value for FragmentIterTransforms. 84 : var NoFragmentTransforms = block.NoFragmentTransforms 85 : 86 : // MakeSyntheticPrefixAndSuffix returns a SyntheticPrefixAndSuffix with the 87 : // given prefix and suffix. 88 : func MakeSyntheticPrefixAndSuffix( 89 : prefix SyntheticPrefix, suffix SyntheticSuffix, 90 2 : ) SyntheticPrefixAndSuffix { 91 2 : return block.MakeSyntheticPrefixAndSuffix(prefix, suffix) 92 2 : } 93 : 94 : // NoSyntheticSeqNum is the default zero value for SyntheticSeqNum, which 95 : // disables overriding the sequence number. 96 : const NoSyntheticSeqNum = block.NoSyntheticSeqNum