-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c47b7d
commit 5711be9
Showing
11 changed files
with
240 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,31 @@ | ||
package zio.compress | ||
|
||
sealed abstract class Bzip2BlockSize(val jValue: Int) | ||
/** Bzip2 block size. | ||
* | ||
* @param hundredKbIncrements | ||
* a bzip2 block size in 100KB increments, valid values: 1 to 9 | ||
*/ | ||
final case class Bzip2BlockSize(hundredKbIncrements: Int) | ||
|
||
object Bzip2BlockSize { | ||
case object BlockSize100KB extends Bzip2BlockSize(1) | ||
case object BlockSize200KB extends Bzip2BlockSize(2) | ||
case object BlockSize300KB extends Bzip2BlockSize(3) | ||
case object BlockSize400KB extends Bzip2BlockSize(4) | ||
case object BlockSize500KB extends Bzip2BlockSize(5) | ||
case object BlockSize600KB extends Bzip2BlockSize(6) | ||
case object BlockSize700KB extends Bzip2BlockSize(7) | ||
case object BlockSize800KB extends Bzip2BlockSize(8) | ||
case object BlockSize900KB extends Bzip2BlockSize(9) | ||
|
||
private val Values: Seq[Bzip2BlockSize] = | ||
Seq( | ||
BlockSize100KB, | ||
BlockSize200KB, | ||
BlockSize300KB, | ||
BlockSize400KB, | ||
BlockSize500KB, | ||
BlockSize600KB, | ||
BlockSize700KB, | ||
BlockSize800KB, | ||
BlockSize900KB, | ||
) | ||
|
||
/** Converts a bzip2 block size from `Int` to [[Bzip2BlockSize]]. | ||
/** Makes a bzip2 block size. | ||
* | ||
* @param blockSize100KB | ||
* @param hundredKbIncrements | ||
* a bzip2 block size in 100KB increments, valid values: 1 to 9 | ||
* @return | ||
* a [[Bzip2BlockSize]] or `None` if the block size is not valid | ||
*/ | ||
def fromBzip2BlockSize(blockSize100KB: Int): Option[Bzip2BlockSize] = | ||
Values.find(_.jValue == blockSize100KB) | ||
def apply(hundredKbIncrements: Int): Option[Bzip2BlockSize] = | ||
if (1 <= hundredKbIncrements && hundredKbIncrements <= 9) Some(new Bzip2BlockSize(hundredKbIncrements)) else None | ||
|
||
val BlockSize100KB = new Bzip2BlockSize(1) | ||
val BlockSize200KB = new Bzip2BlockSize(2) | ||
val BlockSize300KB = new Bzip2BlockSize(3) | ||
val BlockSize400KB = new Bzip2BlockSize(4) | ||
val BlockSize500KB = new Bzip2BlockSize(5) | ||
val BlockSize600KB = new Bzip2BlockSize(6) | ||
val BlockSize700KB = new Bzip2BlockSize(7) | ||
val BlockSize800KB = new Bzip2BlockSize(8) | ||
val BlockSize900KB = new Bzip2BlockSize(9) | ||
} |
37 changes: 37 additions & 0 deletions
37
core/src/main/scala/zio/compress/DeflateCompressionLevel.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package zio.compress | ||
|
||
/** Deflate compression level, used for ZIP and GZIP. | ||
* | ||
* @param level | ||
* compression level, valid values: 0 (no compression) to 9 (maximum compression) | ||
*/ | ||
final case class DeflateCompressionLevel private (level: Int) | ||
|
||
object DeflateCompressionLevel { | ||
|
||
/** Deflate compression level, used for ZIP and GZIP. | ||
* | ||
* @param level | ||
* compression level, valid values: 0 (no compression) to 9 (maximum compression) | ||
* @return | ||
* a [[DeflateCompressionLevel]] or `None` if the level is not valid | ||
*/ | ||
def apply(level: Int): Option[DeflateCompressionLevel] = | ||
if (0 <= level && level <= 9) Some(new DeflateCompressionLevel(level)) else None | ||
|
||
val CompressionLevel0 = new DeflateCompressionLevel(0) | ||
val CompressionLevel1 = new DeflateCompressionLevel(1) | ||
val CompressionLevel2 = new DeflateCompressionLevel(2) | ||
val CompressionLevel3 = new DeflateCompressionLevel(3) | ||
val CompressionLevel4 = new DeflateCompressionLevel(4) | ||
val CompressionLevel5 = new DeflateCompressionLevel(5) | ||
val CompressionLevel6 = new DeflateCompressionLevel(6) | ||
val CompressionLevel7 = new DeflateCompressionLevel(7) | ||
val CompressionLevel8 = new DeflateCompressionLevel(8) | ||
val CompressionLevel9 = new DeflateCompressionLevel(9) | ||
|
||
val NoCompressionLevel: DeflateCompressionLevel = CompressionLevel0 | ||
val FastestCompressionLevel: DeflateCompressionLevel = CompressionLevel1 | ||
val DefaultCompressionLevel: DeflateCompressionLevel = CompressionLevel5 | ||
val BestCompressionLevel: DeflateCompressionLevel = CompressionLevel9 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package zio.compress | ||
|
||
sealed trait DeflateStrategy | ||
|
||
object DeflateStrategy { | ||
case object Filtered extends DeflateStrategy | ||
case object HuffmanOnly extends DeflateStrategy | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
lz4/src/main/scala/zio/compress/Lz4CompressorBlockSize.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package zio.compress | ||
|
||
sealed trait Lz4CompressorBlockSize | ||
|
||
object Lz4CompressorBlockSize { | ||
case object BlockSize64KiB extends Lz4CompressorBlockSize | ||
case object BlockSize256KiB extends Lz4CompressorBlockSize | ||
case object BlockSize1MiB extends Lz4CompressorBlockSize | ||
case object BlockSize4MiB extends Lz4CompressorBlockSize | ||
|
||
/** Converts a Lz4 block size indicator into a [[Lz4CompressorBlockSize]]. | ||
* | ||
* @param indicator | ||
* the Lz4 block size indicator, valid values: 4 (64KiB), 5 (256KiB), 6 (1MiB), 7 (4MiB) | ||
*/ | ||
def fromLz4BlockSizeIndicator(indicator: Int): Option[Lz4CompressorBlockSize] = | ||
indicator match { | ||
case 4 => Some(BlockSize64KiB) | ||
case 5 => Some(BlockSize256KiB) | ||
case 6 => Some(BlockSize1MiB) | ||
case 7 => Some(BlockSize4MiB) | ||
case _ => None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package zio.compress | ||
|
||
sealed trait ZipMethod | ||
|
||
object ZipMethod { | ||
case object Stored extends ZipMethod | ||
case object Deflated extends ZipMethod | ||
} |
Oops, something went wrong.