code: func DecompressStream(archive io.Reader) (io.ReadCloser, error) {
  	p := pools.BufioReader32KPool
  	buf := p.Get(archive)
  	bs, err := buf.Peek(10)
  	if err != nil && err != io.EOF {
  		// Note: we'll ignore any io.EOF error because there are some odd
  		// cases where the layer.tar file will be empty (zero bytes) and
  		// that results in an io.EOF from the Peek() call. So, in those
  		// cases we'll just treat it as a non-compressed stream and
  		// that means just create an empty layer.
  		// See Issue 18170
  		return nil, err
  	}
  
  	compression := DetectCompression(bs)
  	switch compression {
  	case Uncompressed:
  		readBufWrapper := p.NewReadCloserWrapper(buf, buf)
  		return readBufWrapper, nil
  	case Gzip:
  		ctx, cancel := context.WithCancel(context.Background())
  
  		gzReader, err := gzDecompress(ctx, buf)
  		if err != nil {
  			cancel()
  			return nil, err
  		}
  		readBufWrapper := p.NewReadCloserWrapper(buf, gzReader)
  		return wrapReadCloser(readBufWrapper, cancel), nil
  	case Bzip2:
  		bz2Reader := bzip2.NewReader(buf)
  		readBufWrapper := p.NewReadCloserWrapper(buf, bz2Reader)
  		return readBufWrapper, nil
  	case Xz:
  		ctx, cancel := context.WithCancel(context.Background())
  
  		xzReader, err := xzDecompress(ctx, buf)
  		if err != nil {
  			cancel()
  			return nil, err
  		}
  		readBufWrapper := p.NewReadCloserWrapper(buf, xzReader)
  		return wrapReadCloser(readBufWrapper, cancel), nil
  	default:
  		return nil, fmt.Errorf("Unsupported compression format %s", (&compression).Extension())
  	}
  }
docs: // DecompressStream decompresses the archive and returns a ReaderCloser with the decompressed archive.