github.com/grailbio/base@v0.0.11/recordio/recordioutil/v2.go (about) 1 // Copyright 2018 GRAIL, Inc. All rights reserved. 2 // Use of this source code is governed by the Apache-2.0 3 // license that can be found in the LICENSE file. 4 5 package recordioutil 6 7 import ( 8 "fmt" 9 10 "github.com/grailbio/base/fileio" 11 "github.com/grailbio/base/recordio" 12 "github.com/grailbio/base/recordio/recordioflate" 13 ) 14 15 // ScannerV2OptsFromName returns the options to use for the supplied pathname 16 // based on its suffix. 17 func ScannerOptsFromName(path string) (opts recordio.ScannerOpts, err error) { 18 compressed := false 19 switch fileio.DetermineType(path) { 20 case fileio.GrailRIOPackedCompressed: 21 compressed = true 22 case fileio.GrailRIOPackedEncrypted, fileio.GrailRIOPackedCompressedAndEncrypted: 23 return opts, fmt.Errorf("%s: decrypting v1 recordio not supported", path) 24 } 25 switch { 26 case compressed: 27 opts.LegacyTransform = recordioflate.FlateUncompress 28 } 29 return 30 }