Top Inners Fields Constructors Methods
org.terracotta.statistics.derived.histogram

public Class Striped<T>

extends Object
Class Inheritance
Known Direct Subclasses
org.terracotta.statistics.derived.histogram.StripedHistogram
Imports
java.util.Spliterator, java.util.concurrent.ThreadLocalRandom, java.util.concurrent.atomic.AtomicInteger, .AtomicIntegerFieldUpdater, java.util.function.Consumer, .Supplier, java.util.stream.Stream, .StreamSupport

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final Striped.Cell<T>
private volatile Striped.Cell<T>[]
private final Supplier<T>
private static final int
private final AtomicInteger
private static final ThreadLocal<Integer>

Constructor Summary

AccessConstructor and Description
public
Striped(Supplier<T> constructor)

Method Summary

Modifier and TypeMethod and Description
pack-priv static final int
advanceProbe(int probe)

protected final void
process(Consumer<T> process)

private void
processWithContention(int hash, Consumer<T> process, boolean contended)

protected final Stream<T>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

baseback to summary
private final Striped.Cell<T> base
cellsback to summary
private volatile Striped.Cell<T>[] cells
constructorback to summary
private final Supplier<T> constructor
NCPUback to summary
private static final int NCPU
stripeGuardback to summary
private final AtomicInteger stripeGuard
threadHashback to summary
private static final ThreadLocal<Integer> threadHash

Constructor Detail

Stripedback to summary
public Striped(Supplier<T> constructor)

Method Detail

advanceProbeback to summary
pack-priv static final int advanceProbe(int probe)
processback to summary
protected final void process(Consumer<T> process)
processWithContentionback to summary
private void processWithContention(int hash, Consumer<T> process, boolean contended)
streamback to summary
protected final Stream<T> stream()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.terracotta.statistics.derived.histogram back to summary

pack-priv final Class Striped.Cell<T>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final T
pack-priv volatile int
pack-priv static final AtomicIntegerFieldUpdater<Striped.Cell<T>>

Constructor Summary

AccessConstructor and Description
pack-priv
Cell(T value)

Method Summary

Modifier and TypeMethod and Description
pack-priv final boolean
process(Consumer<T> process)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

entityback to summary
pack-priv final T entity
guardback to summary
pack-priv volatile int guard
GUARD_UPDATERback to summary
pack-priv static final AtomicIntegerFieldUpdater<Striped.Cell<T>> GUARD_UPDATER
Annotations
@SuppressWarnings:rawtypes

Constructor Detail

Cellback to summary
pack-priv Cell(T value)

Method Detail

processback to summary
pack-priv final boolean process(Consumer<T> process)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.terracotta.statistics.derived.histogram back to summary

pack-priv final Class Striped.CellSpliterator<T>

extends Object
implements Spliterator<Striped.Cell<T>>
Class Inheritance
  • java.lang.Object
  • org.terracotta.statistics.derived.histogram.Striped.CellSpliterator
All Implemented Interfaces
java.util.Spliterator

Field Summary

Modifier and TypeField and Description
private final Striped.Cell<T>[]
private int
private final int

Constructor Summary

AccessConstructor and Description
public
private
CellSpliterator(Striped.Cell<T>[] array, int origin, int fence)

Method Summary

Modifier and TypeMethod and Description
public int
characteristics()

Implements java.util.Spliterator.characteristics.

Returns a set of characteristics of this Spliterator and its elements.
public long
estimateSize()

Implements java.util.Spliterator.estimateSize.

Returns an estimate of the number of elements that would be encountered by a forEachRemaining traversal, or returns Long#MAX_VALUE if infinite, unknown, or too expensive to compute.
public void
forEachRemaining(Consumer<? super Striped.Cell<T>>
The action
action
)

Overrides default java.util.Spliterator.forEachRemaining.

Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception.
public boolean
tryAdvance(Consumer<? super Striped.Cell<T>>
The action whose operation is performed at-most once
action
)

Implements java.util.Spliterator.tryAdvance.

If a remaining element exists: performs the given action on it, returning true; else returns false.
public Spliterator<Striped.Cell<T>>
trySplit()

Implements java.util.Spliterator.trySplit.

If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.
private static <T> void
visitCell(Striped.Cell<T> cell, Consumer<? super Striped.Cell<T>> action)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayback to summary
private final Striped.Cell<T>[] array
indexback to summary
private int index
limitback to summary
private final int limit

Constructor Detail

CellSpliteratorback to summary
public CellSpliterator(Striped.Cell<T>[] array)
CellSpliteratorback to summary
private CellSpliterator(Striped.Cell<T>[] array, int origin, int fence)

Method Detail

characteristicsback to summary
public int characteristics()

Implements java.util.Spliterator.characteristics.

Doc from java.util.Spliterator.characteristics.

Returns a set of characteristics of this Spliterator and its elements. The result is represented as ORed values from ORDERED, DISTINCT, SORTED, SIZED, NONNULL, IMMUTABLE, CONCURRENT, SUBSIZED. Repeated calls to characteristics() on a given spliterator, prior to or in-between calls to trySplit, should always return the same result.

If a Spliterator reports an inconsistent set of characteristics (either those returned from a single invocation or across multiple invocations), no guarantees can be made about any computation using this Spliterator.

Returns:int

a representation of characteristics

Annotations
@Override
estimateSizeback to summary
public long estimateSize()

Implements java.util.Spliterator.estimateSize.

Doc from java.util.Spliterator.estimateSize.

Returns an estimate of the number of elements that would be encountered by a forEachRemaining traversal, or returns Long#MAX_VALUE if infinite, unknown, or too expensive to compute.

If this Spliterator is SIZED and has not yet been partially traversed or split, or this Spliterator is SUBSIZED and has not yet been partially traversed, this estimate must be an accurate count of elements that would be encountered by a complete traversal. Otherwise, this estimate may be arbitrarily inaccurate, but must decrease as specified across invocations of trySplit.

Returns:long

the estimated size, or Long.MAX_VALUE if infinite, unknown, or too expensive to compute.

Annotations
@Override
forEachRemainingback to summary
public void forEachRemaining(Consumer<? super Striped.Cell<T>> action)

Overrides default java.util.Spliterator.forEachRemaining.

Doc from java.util.Spliterator.forEachRemaining.

Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception. If this Spliterator is ORDERED, actions are performed in encounter order. Exceptions thrown by the action are relayed to the caller.

Subsequent behavior of a spliterator is unspecified if the action throws an exception.

Parameters
action:Consumer<? super Striped.Cell<T>>

The action

Annotations
@Override
tryAdvanceback to summary
public boolean tryAdvance(Consumer<? super Striped.Cell<T>> action)

Implements java.util.Spliterator.tryAdvance.

Doc from java.util.Spliterator.tryAdvance.

If a remaining element exists: performs the given action on it, returning true; else returns false. If this Spliterator is ORDERED the action is performed on the next element in encounter order. Exceptions thrown by the action are relayed to the caller.

Subsequent behavior of a spliterator is unspecified if the action throws an exception.

Parameters
action:Consumer<? super Striped.Cell<T>>

The action whose operation is performed at-most once

Returns:boolean

false if no remaining elements existed upon entry to this method, else true.

Annotations
@Override
trySplitback to summary
public Spliterator<Striped.Cell<T>> trySplit()

Implements java.util.Spliterator.trySplit.

Doc from java.util.Spliterator.trySplit.

If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.

If this Spliterator is ORDERED, the returned Spliterator must cover a strict prefix of the elements.

Unless this Spliterator covers an infinite number of elements, repeated calls to trySplit() must eventually return null. Upon non-null return:

  • the value reported for estimateSize() before splitting, must, after splitting, be greater than or equal to estimateSize() for this and the returned Spliterator; and
  • if this Spliterator is SUBSIZED, then estimateSize() for this spliterator before splitting must be equal to the sum of estimateSize() for this and the returned Spliterator after splitting.

This method may return null for any reason, including emptiness, inability to split after traversal has commenced, data structure constraints, and efficiency considerations.

Returns:Spliterator<Striped.Cell<T>>

a Spliterator covering some portion of the elements, or null if this spliterator cannot be split

Annotations
@Override
visitCellback to summary
private static <T> void visitCell(Striped.Cell<T> cell, Consumer<? super Striped.Cell<T>> action)