github.com/m3db/m3@v1.5.0/src/dbnode/persist/fs/reader_open_options_matcher.go (about) 1 // Copyright (c) 2018 Uber Technologies, Inc. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 package fs 22 23 import ( 24 "fmt" 25 26 "github.com/m3db/m3/src/dbnode/persist" 27 ) 28 29 // ReaderOpenOptionsMatcher is a matcher for the DataReaderOpenOptions struct 30 type ReaderOpenOptionsMatcher struct { 31 ID FileSetFileIdentifier 32 FileSetType persist.FileSetType 33 StreamingEnabled bool 34 } 35 36 // Matches determine whether m matches a DataWriterOpenOptions 37 func (m ReaderOpenOptionsMatcher) Matches(x interface{}) bool { 38 readerOpenOptions, ok := x.(DataReaderOpenOptions) 39 if !ok { 40 return false 41 } 42 43 if !m.ID.Namespace.Equal(readerOpenOptions.Identifier.Namespace) { 44 return false 45 } 46 if m.ID.Shard != readerOpenOptions.Identifier.Shard { 47 return false 48 } 49 if !m.ID.BlockStart.Equal(readerOpenOptions.Identifier.BlockStart) { 50 return false 51 } 52 if m.ID.VolumeIndex != readerOpenOptions.Identifier.VolumeIndex { 53 return false 54 } 55 if m.FileSetType != readerOpenOptions.FileSetType { 56 return false 57 } 58 if m.StreamingEnabled != readerOpenOptions.StreamingEnabled { 59 return false 60 } 61 62 return true 63 } 64 65 func (m ReaderOpenOptionsMatcher) String() string { 66 return fmt.Sprintf( 67 "namespace: %s, shard: %d, blockstart: %d, volumeIndex: %d, filesetType: %s, streamingEnabled: %t", // nolint: lll 68 m.ID.Namespace.String(), m.ID.Shard, m.ID.BlockStart.Seconds(), m.ID.VolumeIndex, 69 m.FileSetType, m.StreamingEnabled, 70 ) 71 }