Tag a type T
with Tag
.
Tag a type T
with Tag
. The resulting type is a subtype of T
.
The resulting type is used to discriminate between type class instances.
Abstract class to ease Bijection creation from Java.
For Java and avoiding trait bloat
Abstract class to ease Injection creation from Java (and reduce instance size in scala).
Abstract class to ease Injection creation from Java (and reduce instance size in scala). Prefer to subclass this for anonymous instances.
Injections may not be defined for their inverse conversion.
Injections may not be defined for their inverse conversion. This type represents the attempted conversion. A failure will result in a scala.util.Failure containing the InversionFailure. A success will result in a scala.util.Success containing the inverted value.
TODO: Remove in 0.6.0.
A Bijection[A, B] is a pair of functions that transform an element between types A and B isomorphically; that is, for all items,
A Bijection[A, B] is a pair of functions that transform an element between types A and B isomorphically; that is, for all items,
item == someBijection.inverse(someBijection.apply(item))
A collection of utilities for encoding strings and byte arrays to and decoding from strings compressed from with gzip.
A collection of utilities for encoding strings and byte arrays to and decoding from strings compressed from with gzip.
This object is thread-safe because there are no streams shared outside of method scope, and therefore no contention for shared byte arrays.
Bufferable[T] is a typeclass to work with java.nio.ByteBuffer for serialization/injections to Array[Byte] Always call .duplicate before using the ByteBuffer so the original is not modified (though obviously the backing array is)
Bufferable[T] is a typeclass to work with java.nio.ByteBuffer for serialization/injections to Array[Byte] Always call .duplicate before using the ByteBuffer so the original is not modified (though obviously the backing array is)
Bijection between Class objects and string.
Injection between Class objects and string.
Using Injections for serialization is a common pattern.
Using Injections for serialization is a common pattern. Currying the byte array parameter makes it easier to write code like this:
def getProducer[T: Codec] = ...
Convert allows the user to convert an instance of type A to type B given an implicit Conversion that goes between the two.
Convert allows the user to convert an instance of type A to type B given an implicit Conversion that goes between the two.
For example, with an implicit Bijection[String,Array[Byte]], the following works: Array(1.toByte, 2.toByte).as[String]
Thanks to [hylotech](https://github.com/hylotech/suits/blob/master/src/main/scala/hylotech/util/Bijection.scala) for the following "as" pattern.
Type class for summoning the function that can check whether the instance can be tagged with Rep
An Injection[A, B] is a function from A to B, and from some B back to A.
An Injection[A, B] is a function from A to B, and from some B back to A. see: http://mathworld.wolfram.com/Injection.html
A common injection on numbers: N -> (m = N mod K, (N-m)/K) The first element in result tuple is always [0, modulus)
When Injection inversion attempts are known to fail, the attempt will encode an InversionFailure to represent that failure
Use Java serialization to write/read bytes.
Use Java serialization to write/read bytes. We avoid manifests here to make it easier from Java
A common injection on numbers: N -> (m = N mod K, (N-m)/K) The first element in result tuple is always [0, modulus)
Pivot is useful in moving from a 1D space of K to a 2D mapping space of K1 x K2.
Pivot is useful in moving from a 1D space of K to a 2D mapping space of K1 x K2. If the elements within the K space have many repeated elements -- imagine the "time" component of a Key in a timeseries key-value store -- pivoting the changing component into an inner K2 while leaving the repeated component in an outer K1 can assist in compressing a datastore's space requirements.
Type Parameters:
K: Original Key K1: Outer Key K2: Inner Key
Trivial: Pivot[(Event, Timestamp), Event, Timestamp] would pivot the timestamp component out of a compound key.
Type tag used to indicate that an instance of a type such as String contains a valid representation of another type, such as Int or URL.
When you have conversion between A and B where B is a subclass of A, which is often free, i.e.
When you have conversion between A and B where B is a subclass of A, which is often free, i.e. A is already an instance of A, then this can be faster
Tagging infrastructure.
Injection to cast back and forth between two types.
Injection to cast back and forth between two types. WARNING: this uses java's Class.cast, which is subject to type erasure. If you have a type parameterized type, like List[String] => List[Any], the cast will succeed, but the inner items will not be correct. This is intended for experts.
Factory for applying inversion attempts
Factory for producing InversionFailures
Useful HasRep
Bijection for joining together iterables of strings into a single string and splitting them back out.
Bijection for joining together iterables of strings into a single string and splitting them back out. Useful for storing sequences of strings in Config maps.
Bijection that flips the order of items in a Tuple2.
1/18/14
Bijection trait with numerous implementations.
A Bijection[A, B] is an invertible function from A -> B. Knowing that two types have this relationship can be very helpful for serialization (Bijection[T, Array[Byte]]]), communication between libraries (Bijection[MyTrait, YourTrait]) and many other purposes.