com.netflix.atlas.core.util

Members list

Type members

Classlikes

object ArrayHelper

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
class BoundedPriorityBuffer[T <: AnyRef](maxSize: Int, comparator: Comparator[T])

Fixed size buffer that can be used for computing the top-K items.

Fixed size buffer that can be used for computing the top-K items.

Value parameters

comparator

Comparator used for checking the relative priority of entries.

maxSize

Maximum size of the buffer.

Attributes

Supertypes
class Object
trait Matchable
class Any
class ByteBufferInputStream(buffer: ByteBuffer) extends InputStream

Wraps a ByteBuffer so it can be used with interfaces that require an InputStream. The buffer should not be modified outside of the reader until reading is complete.

Wraps a ByteBuffer so it can be used with interfaces that require an InputStream. The buffer should not be modified outside of the reader until reading is complete.

Attributes

Supertypes
class InputStream
trait Closeable
trait AutoCloseable
class Object
trait Matchable
class Any
Show all
class CaffeineInterner[T](maxSize: Int) extends Interner[T]

Interner based on a Caffeine cache. This implementation should only be used for memory reduction and not reference equality. If the cache is full, then some values will not be deduped.

Interner based on a Caffeine cache. This implementation should only be used for memory reduction and not reference equality. If the cache is full, then some values will not be deduped.

Value parameters

maxSize

Maximum number of strings to intern.

Attributes

Supertypes
trait Interner[T]
class Object
trait Matchable
class Any

Utility for cheaply estimating the number of distinct values for a set of objects.

Utility for cheaply estimating the number of distinct values for a set of objects.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
class CharBufferReader(buffer: CharBuffer) extends Reader

Wraps a CharBuffer so it can be used with interfaces that require a Reader. The buffer should not be modified outside of the reader until reading is complete.

Wraps a CharBuffer so it can be used with interfaces that require a Reader. The buffer should not be modified outside of the reader until reading is complete.

Attributes

Supertypes
class Reader
trait Closeable
trait AutoCloseable
trait Readable
class Object
trait Matchable
class Any
Show all
class ComparableComparator[T <: Comparable[T]] extends Comparator[T]

Comparator for classes that implement Comparable.

Comparator for classes that implement Comparable.

Attributes

Supertypes
trait Comparator[T]
class Object
trait Matchable
class Any
class ConcurrentInternMap[K <: AnyRef](newMap: => InternMap[K], concurrencyLevel: Int) extends InternMap[K]

Attributes

Supertypes
trait InternMap[K]
trait Interner[K]
class Object
trait Matchable
class Any
class DoubleIntHashMap(noData: Double, capacity: Int)

Mutable double to integer map based on an underlying LongIntHashMap. Primary use-case is computing a count for the number of times a particular value was encountered.

Mutable double to integer map based on an underlying LongIntHashMap. Primary use-case is computing a count for the number of times a particular value was encountered.

Value parameters

capacity

Initial capacity guideline. The actual size of the underlying buffer will be the next prime >= capacity. Default is 10.

noData

Value to use to represent no data in the array. This value should not be used in the input. Default is NaN.

Attributes

Supertypes
class Object
trait Matchable
class Any
final class FastGzipOutputStream(out: OutputStream) extends GZIPOutputStream

Wrap GZIPOutputStream to set the best speed compression level.

Wrap GZIPOutputStream to set the best speed compression level.

Attributes

Supertypes
class GZIPOutputStream
class DeflaterOutputStream
class FilterOutputStream
class OutputStream
trait Flushable
trait Closeable
trait AutoCloseable
class Object
trait Matchable
class Any
Show all
object Hash

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Hash.type
final case class IdMap(id: Id) extends Map[String, String]

Wraps a Spectator Id so it can be used as Scala Map. Modifications will result in a different map type being returned.

Wraps a Spectator Id so it can be used as Scala Map. Modifications will result in a different map type being returned.

Attributes

Supertypes
trait Serializable
trait Product
trait Map[String, String]
trait MapOps[String, String, Map, Map[String, String]]
trait Map[String, String]
trait Equals
trait MapFactoryDefaults[String, String, Map, Iterable]
trait MapOps[String, String, Map, Map[String, String]]
trait PartialFunction[String, String]
trait String => String
trait Iterable[(String, String)]
trait Iterable[(String, String)]
trait IterableFactoryDefaults[(String, String), Iterable]
trait IterableOps[(String, String), Iterable, Map[String, String]]
trait IterableOnceOps[(String, String), Iterable, Map[String, String]]
trait IterableOnce[(String, String)]
class Object
trait Matchable
class Any
Show all
class IdentityMap[K <: AnyRef, V] extends Map[K, V]

Wraps the java IdentityHashMap as an immutable scala Map. Modifications will result in a copy of the wrapped map being created and used with the new instance.

Wraps the java IdentityHashMap as an immutable scala Map. Modifications will result in a copy of the wrapped map being created and used with the new instance.

Attributes

Companion
object
Supertypes
trait Map[K, V]
trait MapOps[K, V, Map, Map[K, V]]
trait Map[K, V]
trait Equals
trait MapFactoryDefaults[K, V, Map, Iterable]
trait MapOps[K, V, Map, Map[K, V]]
trait PartialFunction[K, V]
trait K => V
trait Iterable[(K, V)]
trait Iterable[(K, V)]
trait IterableFactoryDefaults[(K, V), Iterable]
trait IterableOps[(K, V), Iterable, Map[K, V]]
trait IterableOnceOps[(K, V), Iterable, Map[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
object IdentityMap

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
class IntHashSet(noData: Int, capacity: Int)

Mutable integer set based on open-addressing. Primary use-case is deduping integers so it only supports add and foreach.

Mutable integer set based on open-addressing. Primary use-case is deduping integers so it only supports add and foreach.

Value parameters

capacity

Initial capacity guideline. The actual size of the underlying buffer will be the next prime >= capacity. Default is 10.

noData

Value to use to represent no data in the array. This value should not be used in the input.

Attributes

Supertypes
class Object
trait Matchable
class Any
class IntIntHashMap(noData: Int, capacity: Int)

Mutable integer map based on open-addressing. Primary use-case is computing a count for the number of times a particular value was encountered.

Mutable integer map based on open-addressing. Primary use-case is computing a count for the number of times a particular value was encountered.

Value parameters

capacity

Initial capacity guideline. The actual size of the underlying buffer will be the next prime >= capacity. Default is 10.

noData

Value to use to represent no data in the array. This value should not be used in the input.

Attributes

Supertypes
class Object
trait Matchable
class Any
class IntRefHashMap[T <: AnyRef](noData: Int, capacity: Int)

Mutable integer map based on open-addressing. Primary use-case is computing a count for the number of times a particular value was encountered.

Mutable integer map based on open-addressing. Primary use-case is computing a count for the number of times a particular value was encountered.

Value parameters

capacity

Initial capacity guideline. The actual size of the underlying buffer will be the next prime >= capacity. Default is 10.

Attributes

Supertypes
class Object
trait Matchable
class Any
object InternMap

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
InternMap.type
trait InternMap[K <: AnyRef] extends Interner[K]

Attributes

Companion
object
Supertypes
trait Interner[K]
class Object
trait Matchable
class Any
Known subtypes
object Interner

Helper functions for interners.

Helper functions for interners.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Interner.type
trait Interner[T]

Keeps track of canonical references for a type of object. Typically used to reduce memory overhead if an application potentially creates many copies of equal objects and will need to keep them around for some period of time.

Keeps track of canonical references for a type of object. Typically used to reduce memory overhead if an application potentially creates many copies of equal objects and will need to keep them around for some period of time.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class CaffeineInterner[T]
trait InternMap[K]
class NoopInterner[T]
Show all

Helper for parsing the variations of ISO date/time formats that are used with Atlas. Since the DateTimeFormatter doesn't have a way to check if a string matches, this class uses pattern matching to normalize to a small number of cases (with and without zone) and avoid using exceptions as the control flow.

Helper for parsing the variations of ISO date/time formats that are used with Atlas. Since the DateTimeFormatter doesn't have a way to check if a string matches, this class uses pattern matching to normalize to a small number of cases (with and without zone) and avoid using exceptions as the control flow.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object ListHelper

Helper functions for working with lists.

Helper functions for working with lists.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
ListHelper.type
class LongHashSet(noData: Long, capacity: Int)

Mutable integer set based on open-addressing. Primary use-case is deduping integers so it only supports add and foreach.

Mutable integer set based on open-addressing. Primary use-case is deduping integers so it only supports add and foreach.

Value parameters

capacity

Initial capacity guideline. The actual size of the underlying buffer will be the next prime >= capacity. Default is 10.

noData

Value to use to represent no data in the array. This value should not be used in the input.

Attributes

Supertypes
class Object
trait Matchable
class Any
class LongIntHashMap(noData: Long, capacity: Int)

Mutable long to integer map based on open-addressing. Primary use-case is computing a count for the number of times a particular value was encountered.

Mutable long to integer map based on open-addressing. Primary use-case is computing a count for the number of times a particular value was encountered.

Value parameters

capacity

Initial capacity guideline. The actual size of the underlying buffer will be the next prime >= capacity. Default is 10.

noData

Value to use to represent no data in the array. This value should not be used in the input.

Attributes

Supertypes
class Object
trait Matchable
class Any
object Math

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Math.type
class NoopInterner[T] extends Interner[T]

Does nothing, the original value will always be returned.

Does nothing, the original value will always be returned.

Attributes

Supertypes
trait Interner[T]
class Object
trait Matchable
class Any
class OpenHashInternMap[K <: AnyRef](initialCapacity: Int, clock: Clock) extends InternMap[K]

Attributes

Supertypes
trait InternMap[K]
trait Interner[K]
class Object
trait Matchable
class Any
class PredefinedInterner[T](predefValues: Seq[T], fallback: Interner[T]) extends Interner[T]

Interner that starts with a predefined set of values. If a request is made to intern a value that is not in the predefined list, then it will be forwarded to the specified fallback interner.

Interner that starts with a predefined set of values. If a request is made to intern a value that is not in the predefined list, then it will be forwarded to the specified fallback interner.

Attributes

Supertypes
trait Interner[T]
class Object
trait Matchable
class Any
class RefDoubleHashMap[T <: AnyRef](capacity: Int)

Mutable reference to double map based on open-addressing. Primary use-case is computing an aggregate double value based on a key.

Mutable reference to double map based on open-addressing. Primary use-case is computing an aggregate double value based on a key.

Value parameters

capacity

Initial capacity guideline. The actual size of the underlying buffer will be the next prime >= capacity. Default is 10.

Attributes

Supertypes
class Object
trait Matchable
class Any
class RefIntHashMap[T <: AnyRef](capacity: Int)

Mutable reference to integer map based on open-addressing. Primary use-case is computing a count for the number of times a particular value was encountered.

Mutable reference to integer map based on open-addressing. Primary use-case is computing a count for the number of times a particular value was encountered.

Value parameters

capacity

Initial capacity guideline. The actual size of the underlying buffer will be the next prime >= capacity. Default is 10.

Attributes

Supertypes
class Object
trait Matchable
class Any
case class RollingInterval(offset: Duration, duration: Duration, unit: ChronoUnit)

Interval that moves over time in increments of a given unit. When in the middle of a unit it will round to the next even boundary. For example, if the unit is HOURS and it is 10:37, then it will round too 11:00.

Interval that moves over time in increments of a given unit. When in the middle of a unit it will round to the next even boundary. For example, if the unit is HOURS and it is 10:37, then it will round too 11:00.

The offset and duration must be an even multiple of the unit.

Value parameters

duration

The length of the interval. The start time is now - offset - duration.

offset

Offset subtracted from the current time, now - offset is used as the end time for this interval.

unit

The unit to use when moving along. This is typically HOURS or DAYS.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object Shards

Utility functions for mapping ids or indices to a shard. For our purposes, a shard is an instance with a set of server groups. The union of data from all groups comprises a full copy of the overall dataset. To allow for smaller deployment units, an individual group or subset of the groups can be replicated. For redundancy, groups could be replicated all the time. At Netflix, we typically replicate the overall set of server groups in another region or zone instead.

Utility functions for mapping ids or indices to a shard. For our purposes, a shard is an instance with a set of server groups. The union of data from all groups comprises a full copy of the overall dataset. To allow for smaller deployment units, an individual group or subset of the groups can be replicated. For redundancy, groups could be replicated all the time. At Netflix, we typically replicate the overall set of server groups in another region or zone instead.

This class specifically focuses on relatively simple sharding schemes where the component making the decision only needs to know the set of instances and a slot for each instance. Edda is one example of a system that provides this information for AWS auto-scaling groups. More complex sharding schemes that require additional infrastructure, e.g, zookeeper, are out of scope here. There are two sharding modes supported by this class:

  1. Mapping an id for a tagged item to a shard. This is typically done while data is flowing into the system and each datapoint can be routed based on the id.

  2. Mapping an positional index to a shard. This is typically done for loading data that has been processed via Hadoop or similar tools and stored in a fixed number of files. There should be a manifest with an order list of the files for a given time and the position can be used to map to a shard. When using this approach it is recommended to use a highly composite number for the number of files. This makes it easier to pick a number of groups and sizes for the groups such that each instance will get the same number of files.

When mapping this to AWS an overall deployment is typically a set of auto-scaling groups (ASG). Each instance should get the same amount of data if possible given the set of files. Deployments are typically done as a red/black push of one ASG at a time. So the amount of additional capacity during a push is the size of one of these groups if deployments across the groups are performed serially. While multiple ASGs for a particular group are active the data will be replicated across them.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Shards.type
object SmallHashMap

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
final class SmallHashMap[K, V] extends Map[K, V]

Simple immutable hash map implementation intended for use-cases where the number of entries is known to be small. This implementation is backed by a single array and uses open addressing with linear probing to resolve conflicts. The underlying array is created to exactly fit the data size so hash collisions tend to be around 50%, but have a fairly low number of probes to find the actual entry. With a cheap equals function for the keys lookups should be fast and there is low memory overhead.

Simple immutable hash map implementation intended for use-cases where the number of entries is known to be small. This implementation is backed by a single array and uses open addressing with linear probing to resolve conflicts. The underlying array is created to exactly fit the data size so hash collisions tend to be around 50%, but have a fairly low number of probes to find the actual entry. With a cheap equals function for the keys lookups should be fast and there is low memory overhead.

You probably don't want to use this implementation if you expect more than around 50 keys in the map. If you have millions of small immutable maps, such as tag data associated with metrics, it may be a good fit.

Value parameters

data

array with the items

dataLength

number of pairs contained within the array starting at index 0.

Attributes

Companion
object
Supertypes
trait Map[K, V]
trait MapOps[K, V, Map, Map[K, V]]
trait Map[K, V]
trait Equals
trait MapFactoryDefaults[K, V, Map, Iterable]
trait MapOps[K, V, Map, Map[K, V]]
trait PartialFunction[K, V]
trait K => V
trait Iterable[(K, V)]
trait Iterable[(K, V)]
trait IterableFactoryDefaults[(K, V), Iterable]
trait IterableOps[(K, V), Iterable, Map[K, V]]
trait IterableOnceOps[(K, V), Iterable, Map[K, V]]
trait IterableOnce[(K, V)]
class Object
trait Matchable
class Any
Show all
final class SortedTagMap extends Map[String, String], Comparable[SortedTagMap]

Immutable map implementation for tag maps using a sorted array as the underlying storage.

Immutable map implementation for tag maps using a sorted array as the underlying storage.

Attributes

Companion
object
Supertypes
trait Comparable[SortedTagMap]
trait Map[String, String]
trait MapOps[String, String, Map, Map[String, String]]
trait Map[String, String]
trait Equals
trait MapFactoryDefaults[String, String, Map, Iterable]
trait MapOps[String, String, Map, Map[String, String]]
trait PartialFunction[String, String]
trait String => String
trait Iterable[(String, String)]
trait Iterable[(String, String)]
trait IterableFactoryDefaults[(String, String), Iterable]
trait IterableOps[(String, String), Iterable, Map[String, String]]
trait IterableOnceOps[(String, String), Iterable, Map[String, String]]
trait IterableOnce[(String, String)]
class Object
trait Matchable
class Any
Show all
object SortedTagMap

Helper functions for working with sorted tag maps.

Helper functions for working with sorted tag maps.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
object Step

Utilities for computing and rounding times based on the step size for a dataset.

Utilities for computing and rounding times based on the step size for a dataset.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Step.type
object Streams

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Streams.type
object StringInterner extends Interner[String]

Delegate to String.intern().

Delegate to String.intern().

Attributes

Supertypes
trait Interner[String]
class Object
trait Matchable
class Any
Self type
object Strings

Helper functions for working with strings.

Helper functions for working with strings.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Strings.type
object TimeWave

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
TimeWave.type
case class TimeWave(wavelength: Duration, step: Long) extends Long => Double

Sine function based on timestamps. The sine values will be pre-computed for a single wavelength and then looked up for all others. This can be significantly faster than using the sine function directly for longer spans.

Sine function based on timestamps. The sine values will be pre-computed for a single wavelength and then looked up for all others. This can be significantly faster than using the sine function directly for longer spans.

Value parameters

step

How often to compute the sine value within the wavelength.

wavelength

Span of time for the repeating pattern of the wave.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Long => Double
class Object
trait Matchable
class Any
Show all
object UnitPrefix

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
UnitPrefix.type
case class UnitPrefix(symbol: String, text: String, factor: Double)

Common prefixes used for units or human readable strings.

Common prefixes used for units or human readable strings.

Value parameters

factor

the multiplication factor for the prefix

symbol

the symbol shown for the prefix

text

text for the prefix

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all