/** * Creates a new {@code AtomicDoubleArray} of the given length, with all elements initially zero. * * @param length the length of the array */ public AtomicDoubleArray(int length) { this.longs = new AtomicLongArray(length); }
public Histogram(long... ranges){ this.ranges = ranges; this.rangeCounters = new AtomicLongArray(ranges.length + 1); }
/** * Creates a new {@code AtomicDoubleArray} of the given length, with all elements initially zero. * * @param length the length of the array */ public AtomicDoubleArray(int length) { this.longs = new AtomicLongArray(length); }
/** * Creates a new {@code AtomicDoubleArray} of the given length, with all elements initially zero. * * @param length the length of the array */ public AtomicDoubleArray(int length) { this.longs = new AtomicLongArray(length); }
public MovingAverage( int numberOfTrackedValues ) { this.values = new AtomicLongArray( numberOfTrackedValues ); }
/** * Creates a new {@code AtomicDoubleArray} with the same length as, and all elements copied from, * the given array. * * @param array the array to copy elements from * @throws NullPointerException if array is null */ public AtomicDoubleArray(double[] array) { final int len = array.length; long[] longArray = new long[len]; for (int i = 0; i < len; i++) { longArray[i] = doubleToRawLongBits(array[i]); } this.longs = new AtomicLongArray(longArray); }
public Histogram(TimeUnit timeUnit, long... ranges){ this.ranges = new long[ranges.length]; for (int i = 0; i < ranges.length; i++) { this.ranges[i] = TimeUnit.MILLISECONDS.convert(ranges[i], timeUnit); } rangeCounters = new AtomicLongArray(ranges.length + 1); }
/** * Clear metrics. */ public void clear() { taggedCounters = new AtomicLongArray(size); lastHitTimes = new AtomicLongArray(size); }
public void reset() { count.set(0); values = new AtomicLongArray(DEFAULT_SIZE); } }
ParallelDispatcher(Subscriber<? super T>[] subscribers, int prefetch) { this.subscribers = subscribers; this.prefetch = prefetch; this.limit = prefetch - (prefetch >> 2); int m = subscribers.length; this.requests = new AtomicLongArray(m + m + 1); this.requests.lazySet(m + m, m); this.emissions = new long[m]; }
/** * Creates a new {@code AtomicDoubleArray} with the same length as, and all elements copied from, * the given array. * * @param array the array to copy elements from * @throws NullPointerException if array is null */ public AtomicDoubleArray(double[] array) { final int len = array.length; long[] longArray = new long[len]; for (int i = 0; i < len; i++) { longArray[i] = doubleToRawLongBits(array[i]); } this.longs = new AtomicLongArray(longArray); }
/** * Creates a new {@code AtomicDoubleArray} with the same length as, and all elements copied from, * the given array. * * @param array the array to copy elements from * @throws NullPointerException if array is null */ public AtomicDoubleArray(double[] array) { final int len = array.length; long[] longArray = new long[len]; for (int i = 0; i < len; i++) { longArray[i] = doubleToRawLongBits(array[i]); } this.longs = new AtomicLongArray(longArray); }
LockFreeBitArray(long[] data) { checkArgument(data.length > 0, "data length is zero!"); this.data = new AtomicLongArray(data); this.bitCount = LongAddables.create(); long bitCount = 0; for (long value : data) { bitCount += Long.bitCount(value); } this.bitCount.add(bitCount); }
ParallelDispatcher(Subscriber<? super T>[] subscribers, int prefetch) { this.subscribers = subscribers; this.prefetch = prefetch; this.limit = prefetch - (prefetch >> 2); int m = subscribers.length; this.requests = new AtomicLongArray(m + m + 1); this.requests.lazySet(m + m, m); this.emissions = new long[m]; }
/** Reconstitutes the instance from a stream (that is, deserializes it). */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); // Read in array length and allocate array int length = s.readInt(); this.longs = new AtomicLongArray(length); // Read in all elements in the proper order. for (int i = 0; i < length; i++) { set(i, s.readDouble()); } } }
LockFreeBitArray(long[] data) { checkArgument(data.length > 0, "data length is zero!"); this.data = new AtomicLongArray(data); this.bitCount = LongAddables.create(); long bitCount = 0; for (long value : data) { bitCount += Long.bitCount(value); } this.bitCount.add(bitCount); }
/** Reconstitutes the instance from a stream (that is, deserializes it). */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); int length = s.readInt(); ImmutableLongArray.Builder builder = ImmutableLongArray.builder(); for (int i = 0; i < length; i++) { builder.add(doubleToRawLongBits(s.readDouble())); } this.longs = new AtomicLongArray(builder.build().toArray()); } }
LockFreeBitArray(long[] data) { checkArgument(data.length > 0, "data length is zero!"); this.data = new AtomicLongArray(data); this.bitCount = LongAddables.create(); long bitCount = 0; for (long value : data) { bitCount += Long.bitCount(value); } this.bitCount.add(bitCount); }
/** Reconstitutes the instance from a stream (that is, deserializes it). */ private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); int length = s.readInt(); ImmutableLongArray.Builder builder = ImmutableLongArray.builder(); for (int i = 0; i < length; i++) { builder.add(doubleToRawLongBits(s.readDouble())); } this.longs = new AtomicLongArray(builder.build().toArray()); } }
@SuppressWarnings("unchecked") public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) { if (parser.lexer.token() == JSONToken.NULL) { parser.lexer.nextToken(JSONToken.COMMA); return null; } JSONArray array = new JSONArray(); parser.parseArray(array); if (clazz == AtomicIntegerArray.class) { AtomicIntegerArray atomicArray = new AtomicIntegerArray(array.size()); for (int i = 0; i < array.size(); ++i) { atomicArray.set(i, array.getInteger(i)); } return (T) atomicArray; } AtomicLongArray atomicArray = new AtomicLongArray(array.size()); for (int i = 0; i < array.size(); ++i) { atomicArray.set(i, array.getLong(i)); } return (T) atomicArray; }