<commit_before>package is.hail.io.fs

import java.io.{ByteArrayInputStream, FileNotFoundException, InputStream, OutputStream}
import java.net.URI
import java.nio.ByteBuffer
import java.nio.file.FileSystems

import org.apache.log4j.{LogManager, Logger}
import com.google.auth.oauth2.ServiceAccountCredentials
import com.google.cloud.{ReadChannel, WriteChannel}
import com.google.cloud.storage.Storage.BlobListOption
import com.google.cloud.storage.{Blob, BlobId, BlobInfo, Storage, StorageOptions}
import is.hail.HailContext
import is.hail.services.retryTransientErrors

import scala.collection.JavaConverters._
import scala.collection.mutable

object GoogleStorageFS {
  private val log = Logger.getLogger(getClass.getName())

  def containsWildcard(path: String): Boolean = {
    var i = 0
    while (i < path.length) {
      val c = path(i)
      if (c == '\\') {
        i += 1
        if (i < path.length)
          i += 1
        else
          return false
      } else if (c == '*' || c == '{' || c == '?' || c == '[')
        return true

      i += 1
    }

    false
  }

  def getBucketPath(filename: String): (String, String) = {
    val uri = new URI(filename).normalize()

    val scheme = uri.getScheme
    assert(scheme != null && scheme == "gs", (uri.getScheme, filename))

    val bucket = uri.getHost
    assert(bucket != null)

    var path = uri.getPath
    if (path.nonEmpty && path.head == '/')
      path = path.drop(1)

    (bucket, path)
  }

  def dropTrailingSlash(path: String): String = {
    if (path.isEmpty)<commit_msg>[query/service] use authority, not host (#11736)<commit_after>package is.hail.io.fs

import java.io.{ByteArrayInputStream, FileNotFoundException, InputStream, OutputStream}
import java.net.URI
import java.nio.ByteBuffer
import java.nio.file.FileSystems

import org.apache.log4j.{LogManager, Logger}
import com.google.auth.oauth2.ServiceAccountCredentials
import com.google.cloud.{ReadChannel, WriteChannel}
import com.google.cloud.storage.Storage.BlobListOption
import com.google.cloud.storage.{Blob, BlobId, BlobInfo, Storage, StorageOptions}
import is.hail.HailContext
import is.hail.services.retryTransientErrors

import scala.collection.JavaConverters._
import scala.collection.mutable

object GoogleStorageFS {
  private val log = Logger.getLogger(getClass.getName())

  def containsWildcard(path: String): Boolean = {
    var i = 0
    while (i < path.length) {
      val c = path(i)
      if (c == '\\') {
        i += 1
        if (i < path.length)
          i += 1
        else
          return false
      } else if (c == '*' || c == '{' || c == '?' || c == '[')
        return true

      i += 1
    }

    false
  }

  def getBucketPath(filename: String): (String, String) = {
    val uri = new URI(filename).normalize()

    val scheme = uri.getScheme
    assert(scheme != null && scheme == "gs", (uri.getScheme, filename))

    val bucket = uri.getAuthority
    assert(bucket != null, (filename, uri.toString(), uri.getScheme, uri.getAuthority, uri.getRawAuthority(), uri.getUserInfo()))

    var path = uri.getPath
    if (path.nonEmpty && path.head == '/')
      path = path.drop(1)

    (bucket, path)
  }

  def dropTrailingSlash(path: String): String = {
    if (path.isEmpty)
{'fraction_non_alphanumeric': 0.13242993532491532, 'fraction_numerical': 0.005851555281798583, 'mean_word_length': 3.185567010309278, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1083262', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1020, 'n_words': 246}