github.com/matrixorigin/matrixone@v1.2.0/pkg/fileservice/io_vector.go (about) 1 // Copyright 2022 Matrix Origin 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 package fileservice 16 17 import "math" 18 19 func (i *IOVector) allDone() bool { 20 for _, entry := range i.Entries { 21 if !entry.done { 22 return false 23 } 24 } 25 return true 26 } 27 28 func (i *IOVector) Release() { 29 for _, entry := range i.Entries { 30 if entry.CachedData != nil { 31 entry.CachedData.Release() 32 } 33 } 34 } 35 36 func (i *IOVector) readRange() (min *int64, max *int64, readFull bool) { 37 readFull = i.Policy.CacheFullFile() && 38 !i.Policy.Any(SkipDiskCache) 39 40 if readFull { 41 // full range 42 min = ptrTo[int64](0) 43 max = (*int64)(nil) 44 45 } else { 46 // minimal range 47 min = ptrTo(int64(math.MaxInt)) 48 max = ptrTo(int64(0)) 49 for _, entry := range i.Entries { 50 entry := entry 51 if entry.done { 52 continue 53 } 54 if entry.Offset < *min { 55 min = &entry.Offset 56 } 57 if entry.Size < 0 { 58 entry.Size = 0 59 max = nil 60 } 61 if max != nil { 62 if end := entry.Offset + entry.Size; end > *max { 63 max = &end 64 } 65 } 66 } 67 } 68 69 return 70 }