Packages

package utils

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. utils
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. implicit final class AugmentedFuture[A] extends AnyVal

    Implicit extensions for Future types.

  2. class BufferedIterator[T] extends Iterator[T]

    Iterator that pre-fetches elements from a wrapped iterator.

    Iterator that pre-fetches elements from a wrapped iterator.

    T

    The value type of the iterator.

  3. implicit final class BufferedIteratorWrapper[T] extends AnyVal

    Augments scala.collection.Iterator with a buffered method that wraps it into a BufferedIterator.

    Augments scala.collection.Iterator with a buffered method that wraps it into a BufferedIterator.

    T

    The value type of the iterator.

  4. implicit final class MapValuesWithKey[K, V] extends AnyVal

    Augments scala.collection.Map with an mapValuesWithKey method that allows mapping the values while having the keys available.

    Augments scala.collection.Map with an mapValuesWithKey method that allows mapping the values while having the keys available. Similar to the corresponding RDD operation.

    K

    The key type of the map.

    V

    The value type of the map.

  5. implicit final class MergeableMap[K, V] extends AnyVal

    Adds a mergeWith method to Map types.

  6. class OnEmptyIterator[T] extends Iterator[T]

    Iterator wrapper that calls a user function when there are no elements left.

    Iterator wrapper that calls a user function when there are no elements left.

    T

    The value type of the iterator.

  7. implicit final class OnEmptyIteratorWrapper[T] extends AnyVal

    Augments scala.collection.Iterator with an onLast method that registers a function to be called when there are no elements left.

    Augments scala.collection.Iterator with an onLast method that registers a function to be called when there are no elements left.

    T

    The value type of the iterator.

Value Members

  1. def bytesToHex(bytes: Array[Byte], lowerCase: Boolean = false): String

    Converts given byte array to hexadecimal string.

    Converts given byte array to hexadecimal string.

    bytes

    the bytes to convert

    lowerCase

    if true returns a lowercase string. By default the returned string contains uppercase characters

    returns

    the hexadecimal string

  2. def classForNameIfDerivingFrom[T](name: String)(implicit tag: ClassTag[T]): Try[Class[_ <: T]]

    Tries to get a class instance extending T given a class name, or returns a relevant exception if not possible.

    Tries to get a class instance extending T given a class name, or returns a relevant exception if not possible.

    T

    the parent class/interface that the class, specified by name, must extend

    name

    the name of the class to get

    tag

    the ClassTag for T

    returns

    a class instance extending T

  3. def fullOuterJoinIterator[K, V, W](iter: Iterator[(K, V)], other: Iterator[(K, W)]): Iterator[(K, (Option[V], Option[W]))]

    Performs a full outer join of iter and other.

    Performs a full outer join of iter and other. For each element (k, v) in iter, the resulting iterator will either contain all pairs (k, (Some(v), Some(w))) for w in other, or the pair (k, (Some(v), None)) if no elements in other have key k. Similarly, for each element (k, w) in other, the resulting iterator will either contain all pairs (k, (Some(v), Some(w))) for v in iter, or the pair (k, (None, Some(w))) if no elements in iter have key k. other is eagerly traversed. iter, instead, is lazily traversed.

  4. implicit def functionToPartialFunction[A, B](f: Function[A, B]): PartialFunction[A, B]

    An implicit conversion that allows a function to be used as a partial function.

    An implicit conversion that allows a function to be used as a partial function.

    Used for instantiating OneToOne, OneToMany, ManyToOne, and ManyToMany.

  5. def hexToBytes(hex: String): Array[Byte]

    Converts the given hexadecimal string to byte array.

    Converts the given hexadecimal string to byte array.

    hex

    even number of hexadecimal digits to convert

    returns

    the converted bytes, or empty array for empty string

  6. def isSorted[T](l: Seq[T])(implicit ev1: (T) ⇒ Ordered[T]): Boolean

    Checks whether a sequence of items is ordered.

    Checks whether a sequence of items is ordered.

    T

    the type the sequence is made of

    l

    the sequence to be checked

    returns

    true if the sequence is ordered

  7. def iteratorToSortedSeq[T, B](i: Iterator[T], f: (T) ⇒ B)(implicit arg0: ClassTag[T], o: Ordering[B]): IndexedSeq[T]

    Sorts elements referred by an iterator returning a sorted IndexedSeq.

    Sorts elements referred by an iterator returning a sorted IndexedSeq.

    Iterator referred elements are stored in an array which is sorted and then returned as IndexedSeq. This is mainly needed to avoid temporary collections creation in Spark mapPartitions operations requiring that the partition elements are sorted.

    T

    the type of the element referenced by the iterator

    B

    the ordered type to sort on

    i

    the iterator whose element should be sorted

    f

    the mapping function providing the ordered data type to sort on

    o

    the ordering object

    returns

    the array contained the sorted elements as Seq

    Note

    the used stable sort function, by specification, uses java.util.Arrays.sort unless K is a primitive type. On the contrary some specialized version of MergeSort is used. This is considered a compromise as the mentioned Java sorting function is implemented using the adaptive Timsort algorithm.

  8. def leftOuterJoinIterator[K, V, W](iter: Iterator[(K, V)], other: Iterator[(K, W)]): Iterator[(K, (V, Option[W]))]

    Performs a left outer join of iter and other.

    Performs a left outer join of iter and other. For each element (k, v) in iter, the resulting iterator will either contain all pairs (k, (v, Some(w))) for w in other, or the pair (k, (v, None)) if no elements in other have key k. other is eagerly traversed. iter, instead, is lazily traversed.

  9. def newInstanceOrFail[T <: AnyRef](className: String)(implicit arg0: ClassTag[T]): T

    Tries to create a new instance of a class given its name.

    Tries to create a new instance of a class given its name. Throws an exception if a class with that name extending T cannot be found, or if a default constructor for that class does not exist.

    T

    The type or supertype of the class.

    className

    The name of the class.

    returns

    A new instance of the class as instance of type T.

  10. def nonNegativeMod(x: Int, mod: Int): Int

    Calculates 'x' modulo 'mod', takes to consideration sign of x, i.e.

    Calculates 'x' modulo 'mod', takes to consideration sign of x, i.e. if 'x' is negative, than 'x' % 'mod' is negative too so function return (x % mod) + mod in that case.

    x

    the modulo operation dividend

    mod

    the modulo operation divisor. Negative divisors are not supported

    returns

    'x' modulo 'mod' with taking into account sign of 'x'

  11. def retry[T](retryCount: Int, sleepMillis: Int)(fn: ⇒ T): T

    Calls fn, and in case it throws an exception, retry at most retryCount-1 times.

    Calls fn, and in case it throws an exception, retry at most retryCount-1 times.

    T

    the return type of the function

    retryCount

    the maximum number of tries, including the initial try

    sleepMillis

    the base sleep time between retries (in milliseconds). An exponential backoff strategy is used: sleep time is sleepMillis * pow(2, retry-number).

    fn

    the function to call

    returns

    the value returned by the function

    Annotations
    @tailrec()
  12. def rightOuterJoinIterator[K, V, W](iter: Iterator[(K, V)], other: Iterator[(K, W)]): Iterator[(K, (Option[V], W))]

    Performs a right outer join of iter and other.

    Performs a right outer join of iter and other. For each element (k, w) in other, the resulting iterator will either contain all pairs (k, (Some(v), w)) for v in iter, or the pair (k, (None, w)) if no elements in iter have key k. other is eagerly traversed. iter, instead, is lazily traversed.

  13. def shuffle[T](array: Array[T], rnd: Random = Random): array.type

    Shuffles an array.

    Shuffles an array.

    T

    The type of the array's elements.

    array

    The array to be shuffled.

    rnd

    The random generator. If unspecified, the global Random generator will be used.

    returns

    The modified array.

    Note

    This function mutates the array. The array is returned for convenience. The function is thread safe.

  14. def timeIt[R](block: ⇒ R): (R, Long)

    Evaluates a block of code and returns its value and the time needed for the evaluation.

    Evaluates a block of code and returns its value and the time needed for the evaluation.

    R

    the type of the value returned by the evaluation

    block

    the code or expression to evaluate

    returns

    a tuple of the value returned from the block and time it took to execute it

  15. def tryAndWarnOnly(logger: ContextAwareLogger, message: String)(f: ⇒ Unit): Unit

    Calls a function and logs a warning if an exception is thrown, without re-throwing it.

    Calls a function and logs a warning if an exception is thrown, without re-throwing it.

    logger

    The ContextAwareLogger used to log the warning.

    message

    The error message.

    f

    The function to be called.

  16. def using[X <: AnyRef { def close(): Unit }, A](resource: X)(f: (X) ⇒ A): A

    A wrapper that automatically closes streams.

    A wrapper that automatically closes streams. Should be used like this

    using(stream) { stream => doSomethingWith(stream) }

    resource

    the input stream

  17. object ConfigExtensions

    Typesafe Config extensions

  18. object FicusValueReaders

    Group of implicit ValueReaders to read config values using Ficus

  19. object Id

    A utility object for handling string IDs in DPL.

  20. object Json4s

Inherited from AnyRef

Inherited from Any

Ungrouped