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 : categoryAndQoS CategoryAndQoS, 36 : statsCollector *CategoryStatsCollector, 37 : rp ReaderProvider, 38 : ) (Iterator, error) 39 : 40 : NewCompactionIter( 41 : transforms IterTransforms, 42 : categoryAndQoS CategoryAndQoS, 43 : statsCollector *CategoryStatsCollector, 44 : rp ReaderProvider, 45 : bufferPool *block.BufferPool, 46 : ) (Iterator, error) 47 : 48 : EstimateDiskUsage(start, end []byte) (uint64, error) 49 : 50 : CommonProperties() *CommonProperties 51 : } 52 : 53 : // FilterBlockSizeLimit is a size limit for bloom filter blocks - if a bloom 54 : // filter is present, it is used only when it is at most this size. 55 : type FilterBlockSizeLimit uint32 56 : 57 : const ( 58 : // NeverUseFilterBlock indicates that bloom filter blocks should never be used. 59 : NeverUseFilterBlock FilterBlockSizeLimit = 0 60 : // AlwaysUseFilterBlock indicates that bloom filter blocks should always be 61 : // used, regardless of size. 62 : AlwaysUseFilterBlock FilterBlockSizeLimit = math.MaxUint32 63 : ) 64 : 65 : type ( 66 : // BufferPool re-exports block.BufferPool. 67 : BufferPool = block.BufferPool 68 : // IterTransforms re-exports block.IterTransforms. 69 : IterTransforms = block.IterTransforms 70 : // FragmentIterTransforms re-exports block.FragmentIterTransforms. 71 : FragmentIterTransforms = block.FragmentIterTransforms 72 : // SyntheticSeqNum re-exports block.SyntheticSeqNum. 73 : SyntheticSeqNum = block.SyntheticSeqNum 74 : // SyntheticSuffix re-exports block.SyntheticSuffix. 75 : SyntheticSuffix = block.SyntheticSuffix 76 : // SyntheticPrefix re-exports block.SyntheticPrefix. 77 : SyntheticPrefix = block.SyntheticPrefix 78 : // SyntheticPrefixAndSuffix re-exports block.SyntheticPrefixAndSuffix. 79 : SyntheticPrefixAndSuffix = block.SyntheticPrefixAndSuffix 80 : ) 81 : 82 : // NoTransforms is the default value for IterTransforms. 83 : var NoTransforms = block.NoTransforms 84 : 85 : // NoFragmentTransforms is the default value for FragmentIterTransforms. 86 : var NoFragmentTransforms = block.NoFragmentTransforms 87 : 88 : // MakeSyntheticPrefixAndSuffix returns a SyntheticPrefixAndSuffix with the 89 : // given prefix and suffix. 90 : func MakeSyntheticPrefixAndSuffix( 91 : prefix SyntheticPrefix, suffix SyntheticSuffix, 92 2 : ) SyntheticPrefixAndSuffix { 93 2 : return block.MakeSyntheticPrefixAndSuffix(prefix, suffix) 94 2 : } 95 : 96 : // NoSyntheticSeqNum is the default zero value for SyntheticSeqNum, which 97 : // disables overriding the sequence number. 98 : const NoSyntheticSeqNum = block.NoSyntheticSeqNum