@@ -2,7 +2,6 @@ package is.hail.io.fs
22
33import is .hail .io .compress .{BGzipInputStream , BGzipOutputStream }
44import is .hail .io .fs .FSUtil .{containsWildcard , dropTrailingSlash }
5- import is .hail .services ._
65import is .hail .utils ._
76
87import scala .collection .mutable
@@ -48,8 +47,9 @@ class WrappedPositionOutputStream(os: OutputStream) extends OutputStream with Po
4847 def getPosition : Long = count
4948}
5049
51- trait FSURL {
52- def getPath : String
50+ abstract class FSURL [URL <: FSURL [URL ]] {
51+ def path : String
52+ def / (component : String ): URL
5353}
5454
5555trait FileStatus {
@@ -253,30 +253,13 @@ abstract class FSPositionedOutputStream(val capacity: Int) extends OutputStream
253253}
254254
255255trait FS extends Serializable with Logging {
256- type URL <: FSURL
256+ type URL <: FSURL [ URL ]
257257
258258 def parseUrl (filename : String ): URL
259259
260260 def validUrl (filename : String ): Boolean
261261
262- def urlAddPathComponent (url : URL , component : String ): URL
263-
264- final def openCachedNoCompression (filename : String ): SeekableDataInputStream =
265- openNoCompression(filename)
266-
267- def openCachedNoCompression (url : URL ): SeekableDataInputStream = openNoCompression(url)
268-
269- final def createCachedNoCompression (filename : String ): PositionedDataOutputStream =
270- createNoCompression(filename)
271-
272- def createCachedNoCompression (url : URL ): PositionedDataOutputStream = createNoCompression(url)
273-
274- final def writeCached (filename : String )(writer : PositionedDataOutputStream => Unit ) =
275- writePDOS(filename)(writer)
276-
277- def writeCached (url : URL )(writer : PositionedDataOutputStream => Unit ) = writePDOS(url)(writer)
278-
279- def getCodecFromExtension (extension : String , gzAsBGZ : Boolean = false ): CompressionCodec = {
262+ def getCodecFromExtension (extension : String , gzAsBGZ : Boolean = false ): CompressionCodec =
280263 extension match {
281264 case " .gz" =>
282265 if (gzAsBGZ)
@@ -290,7 +273,6 @@ trait FS extends Serializable with Logging {
290273 case _ =>
291274 null
292275 }
293- }
294276
295277 def getCodecFromPath (path : String , gzAsBGZ : Boolean = false ): CompressionCodec =
296278 getCodecFromExtension(getExtension(path), gzAsBGZ)
@@ -316,11 +298,6 @@ trait FS extends Serializable with Logging {
316298 throw new AssertionError (" unreachable" )
317299 }
318300
319- def stripCodecExtension (path : String ): String = {
320- val ext = getCodecExtension(path)
321- path.dropRight(ext.length)
322- }
323-
324301 def getCodecExtension (path : String ): String = {
325302 val ext = getExtension(path)
326303 if (ext == " .gz" || ext == " .bgz" || ext == " .tbi" )
@@ -334,12 +311,6 @@ trait FS extends Serializable with Logging {
334311
335312 def openNoCompression (url : URL ): SeekableDataInputStream
336313
337- final def readNoCompression (filename : String ): Array [Byte ] = readNoCompression(parseUrl(filename))
338-
339- def readNoCompression (url : URL ): Array [Byte ] = retryTransientErrors {
340- using(openNoCompression(url))(is => IOUtils .toByteArray(is))
341- }
342-
343314 final def createNoCompression (filename : String ): PositionedDataOutputStream =
344315 createNoCompression(parseUrl(filename))
345316
@@ -399,7 +370,7 @@ trait FS extends Serializable with Logging {
399370 }
400371 }
401372 } else
402- f(urlAddPathComponent( prefix, c) , null , i + 1 )
373+ f(prefix / c , null , i + 1 )
403374 }
404375 }
405376
@@ -499,13 +470,6 @@ trait FS extends Serializable with Logging {
499470
500471 def makeQualified (path : String ): String
501472
502- final def deleteOnExit (filename : String ): Unit = deleteOnExit(parseUrl(filename))
503-
504- def deleteOnExit (url : URL ): Unit =
505- Runtime .getRuntime.addShutdownHook(
506- new Thread (() => delete(url, recursive = false ))
507- )
508-
509473 final def open (filename : String , codec : CompressionCodec ): InputStream =
510474 open(parseUrl(filename), codec)
511475
@@ -515,7 +479,6 @@ trait FS extends Serializable with Logging {
515479 codec.makeInputStream(is)
516480 else
517481 is
518-
519482 }
520483
521484 final def open (filename : String ): InputStream = open(parseUrl(filename))
@@ -527,14 +490,14 @@ trait FS extends Serializable with Logging {
527490 open(parseUrl(filename), gzAsBGZ)
528491
529492 def open (url : URL , gzAsBGZ : Boolean ): InputStream =
530- open(url, getCodecFromPath(url.getPath , gzAsBGZ))
493+ open(url, getCodecFromPath(url.path , gzAsBGZ))
531494
532495 final def create (filename : String ): OutputStream = create(parseUrl(filename))
533496
534497 def create (url : URL ): OutputStream = {
535498 val os = createNoCompression(url)
536499
537- val codec = getCodecFromPath(url.getPath , gzAsBGZ = false )
500+ val codec = getCodecFromPath(url.path , gzAsBGZ = false )
538501 if (codec != null )
539502 codec.makeOutputStream(os)
540503 else
0 commit comments