/** * Return the key at <code>0 <= index <= capacity()</code>. The result is undefined if the slot is unused. */ public long get(long id) { return keys.get(id); }
public boolean get(int index) { int wordNum = index >> 6; long bitmask = 1L << index; return (bits.get(wordNum) & bitmask) != 0; }
/** * Get the id associated with key at <code>0 <= index <= capacity()</code> or -1 if this slot is unused. */ public long id(long index) { return ids.get(index) - 1; }
@Override int compareCurrent(int slot) { return Long.compare(currentValue, values.get(slot)) * reverseMul; }
/** * Return the key at <code>0 <= index <= capacity()</code>. The result is undefined if the slot is unused. * <p>Beware that the content of the {@link BytesRef} may become invalid as soon as {@link #close()} is called</p> */ public BytesRef get(long id, BytesRef dest) { final long startOffset = startOffsets.get(id); final int length = (int) (startOffsets.get(id + 1) - startOffset); bytes.get(startOffset, length, dest); return dest; }
@Override Long toComparable(int slot) { if (missingBucket && bits.get(slot) == false) { return null; } return values.get(slot); }
@Override BytesRef toComparable(int slot) throws IOException { long globalOrd = values.get(slot); if (missingBucket && globalOrd == -1) { return null; } else if (globalOrd == lastLookupOrd) { return lastLookupValue; } else { lastLookupOrd = globalOrd; lastLookupValue = BytesRef.deepCopyOf(lookup.lookupOrd(values.get(slot))); return lastLookupValue; } }
private double variance(long owningBucketOrd) { double sum = sums.get(owningBucketOrd); long count = counts.get(owningBucketOrd); return (sumOfSqrs.get(owningBucketOrd) - ((sum * sum) / count)) / count; }
@Override protected void removeAndAdd(long index) { final long key = keys.get(index); final T value = values.set(index, null); --size; final T removed = set(key, value); assert removed == null; }
@Override public double metric(long owningBucketOrd) { if (valuesSource == null || owningBucketOrd >= sums.size()) { return Double.NaN; } return sums.get(owningBucketOrd) / counts.get(owningBucketOrd); }
@Override int compareCurrent(int slot) { if (missingBucket) { if (missingCurrentValue) { return bits.get(slot) ? -1 * reverseMul : 0; } else if (bits.get(slot) == false) { return reverseMul; } } return compareValues(currentValue, values.get(slot)); }
/** * Get the id associated with <code>key</code> or -1 if the key is not contained in the hash. */ public long find(long key) { final long slot = slot(hash(key), mask); for (long index = slot; ; index = nextSlot(index, mask)) { final long id = id(index); if (id == -1 || keys.get(id) == key) { return id; } } }
@Override public InternalAggregation buildAggregation(long bucket) { if (valuesSource == null || bucket >= counts.size()) { return buildEmptyAggregation(); } return new InternalValueCount(name, counts.get(bucket), pipelineAggregators(), metaData()); }
@Override public InternalAggregation buildAggregation(long bucket) { if (valuesSource == null || bucket >= sums.size()) { return buildEmptyAggregation(); } return new InternalAvg(name, sums.get(bucket), counts.get(bucket), format, pipelineAggregators(), metaData()); }
private void append(long id, BytesRef key, int code) { assert size == id; final long startOffset = startOffsets.get(size); bytes = bigArrays.grow(bytes, startOffset + key.length); bytes.set(startOffset, key.bytes, key.offset, key.length); startOffsets = bigArrays.grow(startOffsets, size + 2); startOffsets.set(size + 1, startOffset + key.length); hashes = bigArrays.grow(hashes, id + 1); hashes.set(id, code); }
@Override public InternalAggregation buildAggregation(long bucket) { if (valuesSource == null || bucket >= sums.size()) { return buildEmptyAggregation(); } return new InternalStats(name, counts.get(bucket), sums.get(bucket), mins.get(bucket), maxes.get(bucket), format, pipelineAggregators(), metaData()); }
@Override public InternalAggregation buildAggregation(long bucket) { if (valuesSource == null || bucket >= counts.size()) { return buildEmptyAggregation(); } return new InternalExtendedStats(name, counts.get(bucket), sums.get(bucket), mins.get(bucket), maxes.get(bucket), sumOfSqrs.get(bucket), sigma, format, pipelineAggregators(), metaData()); }