github.com/dolthub/dolt/go@v0.40.5-0.20240520175717-68db7794bea6/store/nbs/empty_chunk_source.go (about) 1 // Copyright 2019 Dolthub, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 // This file incorporates work covered by the following copyright and 16 // permission notice: 17 // 18 // Copyright 2016 Attic Labs, Inc. All rights reserved. 19 // Licensed under the Apache License, version 2.0: 20 // http://www.apache.org/licenses/LICENSE-2.0 21 22 package nbs 23 24 import ( 25 "bytes" 26 "context" 27 "io" 28 29 "golang.org/x/sync/errgroup" 30 31 "github.com/dolthub/dolt/go/store/chunks" 32 "github.com/dolthub/dolt/go/store/hash" 33 ) 34 35 type emptyChunkSource struct{} 36 37 func (ecs emptyChunkSource) has(h hash.Hash) (bool, error) { 38 return false, nil 39 } 40 41 func (ecs emptyChunkSource) hasMany(addrs []hasRecord) (bool, error) { 42 return true, nil 43 } 44 45 func (ecs emptyChunkSource) get(ctx context.Context, h hash.Hash, stats *Stats) ([]byte, error) { 46 return nil, nil 47 } 48 49 func (ecs emptyChunkSource) getMany(ctx context.Context, eg *errgroup.Group, reqs []getRecord, found func(context.Context, *chunks.Chunk), stats *Stats) (bool, error) { 50 return true, nil 51 } 52 53 func (ecs emptyChunkSource) getManyCompressed(ctx context.Context, eg *errgroup.Group, reqs []getRecord, found func(context.Context, CompressedChunk), stats *Stats) (bool, error) { 54 return true, nil 55 } 56 57 func (ecs emptyChunkSource) count() (uint32, error) { 58 return 0, nil 59 } 60 61 func (ecs emptyChunkSource) uncompressedLen() (uint64, error) { 62 return 0, nil 63 } 64 65 func (ecs emptyChunkSource) hash() hash.Hash { 66 return hash.Hash{} 67 } 68 69 func (ecs emptyChunkSource) index() (tableIndex, error) { 70 return onHeapTableIndex{}, nil 71 } 72 73 func (ecs emptyChunkSource) reader(context.Context) (io.ReadCloser, uint64, error) { 74 return io.NopCloser(&bytes.Buffer{}), 0, nil 75 } 76 77 func (ecs emptyChunkSource) getRecordRanges(lookups []getRecord) (map[hash.Hash]Range, error) { 78 return map[hash.Hash]Range{}, nil 79 } 80 81 func (ecs emptyChunkSource) currentSize() uint64 { 82 return 0 83 } 84 85 func (ecs emptyChunkSource) calcReads(reqs []getRecord, blockSize uint64) (reads int, remaining bool, err error) { 86 return 0, true, nil 87 } 88 89 func (ecs emptyChunkSource) close() error { 90 return nil 91 } 92 93 func (ecs emptyChunkSource) clone() (chunkSource, error) { 94 return ecs, nil 95 }