github.com/Schaudge/grailbase@v0.0.0-20240223061707-44c758a471c0/recordio/recordioutil/suffix.go (about)

     1  // Copyright 2017 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  	"github.com/Schaudge/grailbase/fileio"
     9  	"github.com/klauspost/compress/flate"
    10  )
    11  
    12  // SuffixFromWriterOpts returns the file name suffix to use for the specified
    13  // Writer options.
    14  func SuffixFromWriterOpts(opts WriterOpts) string {
    15  	filetype := fileio.Other
    16  	compressed := false
    17  	if opts.FlateLevel != flate.NoCompression {
    18  		compressed = true
    19  	}
    20  	switch {
    21  	case compressed:
    22  		filetype = fileio.GrailRIOPackedCompressed
    23  	default:
    24  		filetype = fileio.GrailRIOPacked
    25  	}
    26  	return fileio.FileSuffix(filetype)
    27  }