/** * Sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value */ public final void set(int i, double newValue) { long next = doubleToRawLongBits(newValue); longs.set(i, next); }
/** * Sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value */ public final void set(int i, double newValue) { long next = doubleToRawLongBits(newValue); longs.set(i, next); }
/** * Sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value */ public final void set(int i, double newValue) { long next = doubleToRawLongBits(newValue); longs.set(i, next); }
/** * Sets the element at position {@code i} to the given value. * * @param i the index * @param newValue the new value */ public final void set(int i, double newValue) { long next = doubleToRawLongBits(newValue); longs.set(i, next); }
public void reset() { for (int i = 0; i < rangeCounters.length(); i++) { rangeCounters.set(i, 0); } }
public void reset() { for ( int i = 0; i < values.length(); i++ ) { values.set( i, 0 ); } total.set( 0 ); valueCursor.set( 0 ); } }
private void initializeArray(AtomicLongArray arr) { for (int i = 0; i < arr.length(); i++) { arr.set(i, Long.valueOf(0)); } } }
/** * Creates a new {@link UniformReservoir}. * * @param size the number of samples to keep in the sampling reservoir */ public UniformReservoir(int size) { this.values = new AtomicLongArray(size); for (int i = 0; i < values.length(); i++) { values.set(i, 0); } count.set(0); }
/** * Creates a new {@code UniformTimeReservoir} instance. * * @param size the number of samples to keep in the sampling reservoir * @param startTime The start time * @param startTimeUnit The start time unit */ public UniformTimeReservoir(int size, final long startTime, final TimeUnit startTimeUnit) { this.startTime = startTime; this.startTimeUnit = startTimeUnit; this.values = new AtomicLongArray(size); for (int i = 0; i < values.length(); i++) { values.set(i, 0); } count.set(0); }
/** * Called if the thread no longer exists. The totals are cumulative so we copy the last * previously captured value. */ private void updateNoValue() { final int currentPos = toIndex(nextPos.get() - 1); totals.set(toIndex(nextPos.getAndIncrement()), totals.get(currentPos)); } }
@Override public void restoreState(List<Tuple2<Long, Integer>> list) throws Exception { if (list.isEmpty() || list.size() > 1) { throw new RuntimeException("Test failed due to unexpected recovered state size " + list.size()); } Tuple2<Long, Integer> state = list.get(0); LOG.debug("Restoring state {}", state); // This is necessary to make sure that something is recovered at all. Otherwise it // might happen that the job is restarted from the beginning. recoveredStates.set(getRuntimeContext().getIndexOfThisSubtask(), 1); sync.countDown(); current = state._1; repeat = state._2; }
@Override public void run() { if ( run ) { return; } long highest = 0; for ( int i = 0; i < 10; i++ ) { long nextLong = random.nextLong( 100 ); highestId.offer( nextLong ); highest = max( highest, nextLong ); } highestIds.set( cc, highest ); latch.countDown(); run = true; } } );
/** * Mark multiple hits. * * @param hits Number of hits. */ public void onHits(long hits) { long curTs = U.currentTimeMillis(); int curPos = position(curTs); clearIfObsolete(curTs, curPos); lastHitTimes.set(curPos, curTs); // Order is important. Hit won't be cleared by concurrent #clearIfObsolete. taggedCounters.addAndGet(curPos, hits); }
public void setCounter(LlapIOCounters counter, long value) { fixedCounters.set(counter.ordinal(), value); if (tezCounters != null) { tezCounters.findCounter(LlapIOCounters.values()[counter.ordinal()]).setValue(value); } }
/** * @param curTs Current timestamp. * @param i Index. */ private void clearIfObsolete(long curTs, int i) { long cur = taggedCounters.get(i); byte curTag = getTag(cur); long lastTs = lastHitTimes.get(i); if (isObsolete(curTs, lastTs)) { if (taggedCounters.compareAndSet(i, cur, taggedLongZero(++curTag))) // ABA problem prevention. lastHitTimes.set(i, curTs); // If CAS failed, counter is reset by another thread. } }
@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; }