/** * Returns the length of the array. * * @return the length of the array */ public final int length() { return longs.length(); }
/** Number of bits */ long bitSize() { return (long) data.length() * Long.SIZE; }
/** * Returns the length of the array. * * @return the length of the array */ public final int length() { return longs.length(); }
/** Number of bits */ long bitSize() { return (long) data.length() * Long.SIZE; }
/** * Returns the length of the array. * * @return the length of the array */ public final int length() { return longs.length(); }
/** * Careful here: if threads are mutating the atomicLongArray while this method is executing, the * final long[] will be a "rolling snapshot" of the state of the bit array. This is usually good * enough, but should be kept in mind. */ public static long[] toPlainArray(AtomicLongArray atomicLongArray) { long[] array = new long[atomicLongArray.length()]; for (int i = 0; i < array.length; ++i) { array[i] = atomicLongArray.get(i); } return array; }
private int numberOfCurrentlyTrackedValues() { return (int) min( valueCursor.get(), values.length() ); }
public long getSum() { long sum = 0; for (int i = 0; i < rangeCounters.length(); ++i) { sum += rangeCounters.get(i); } return sum; }
public void record(long millis) { int index = rangeCounters.length() - 1; for (int i = 0; i < ranges.length; ++i) { if (millis < ranges[i]) { index = i; break; } } rangeCounters.incrementAndGet(index); }
public void reset() { for (int i = 0; i < rangeCounters.length(); i++) { rangeCounters.set(i, 0); } }
public String toString() { StringBuilder buf = new StringBuilder(); buf.append('['); for (int i = 0; i < rangeCounters.length(); ++i) { if (i != 0) { buf.append(','); } buf.append(rangeCounters.get(i)); } buf.append(']'); return buf.toString(); } }
/** * Careful here: if threads are mutating the atomicLongArray while this method is executing, the * final long[] will be a "rolling snapshot" of the state of the bit array. This is usually good * enough, but should be kept in mind. */ public static long[] toPlainArray(AtomicLongArray atomicLongArray) { long[] array = new long[atomicLongArray.length()]; for (int i = 0; i < array.length; ++i) { array[i] = atomicLongArray.get(i); } return array; }
public void reset() { for ( int i = 0; i < values.length(); i++ ) { values.set( i, 0 ); } total.set( 0 ); valueCursor.set( 0 ); } }
public void add( long value ) { long cursor = valueCursor.getAndIncrement(); long prevValue = values.getAndSet( (int) (cursor % values.length()), value ); total.addAndGet( value - prevValue ); }
/** * Careful here: if threads are mutating the atomicLongArray while this method is executing, the * final long[] will be a "rolling snapshot" of the state of the bit array. This is usually good * enough, but should be kept in mind. */ public static long[] toPlainArray(AtomicLongArray atomicLongArray) { long[] array = new long[atomicLongArray.length()]; for (int i = 0; i < array.length; ++i) { array[i] = atomicLongArray.get(i); } return array; }
/** * Writes this {@code BloomFilter} to an output stream, with a custom format (not Java * serialization). This has been measured to save at least 400 bytes compared to regular * serialization. * * <p>Use {@linkplain #readFrom(InputStream, Funnel)} to reconstruct the written BloomFilter. */ public void writeTo(OutputStream out) throws IOException { // Serial form: // 1 signed byte for the strategy // 1 unsigned byte for the number of hash functions // 1 big endian int, the number of longs in our bitset // N big endian longs of our bitset DataOutputStream dout = new DataOutputStream(out); dout.writeByte(SignedBytes.checkedCast(strategy.ordinal())); dout.writeByte(UnsignedBytes.checkedCast(numHashFunctions)); // note: checked at the c'tor dout.writeInt(bits.data.length()); for (int i = 0; i < bits.data.length(); i++) { dout.writeLong(bits.data.get(i)); } }