Skip to content

Commit

Permalink
Polymorphic numeric getters for ColumnValueSelector (apache#4623)
Browse files Browse the repository at this point in the history
* Add methods getFloat(), getDouble() and getLong() to ColumnValueSelector

* Fix copy-paste mistake in docs

* Spelling
  • Loading branch information
leventov authored and gianm committed Aug 9, 2017
1 parent d5606bc commit 7454fd8
Show file tree
Hide file tree
Showing 83 changed files with 356 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ public void init(final ByteBuffer buf, final int position)
@Override
public void aggregate(final ByteBuffer buf, final int position)
{
final float x = xSelector.get();
final double n = x > 0 ? x + 1 : ySelector.get() + 1;
final float x = xSelector.getFloat();
final double n = x > 0 ? x + 1 : ySelector.getFloat() + 1;
buf.putDouble(0, buf.getDouble(position) + n);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public List<Long> apply(Cursor input)
List<Long> longvals = new ArrayList<Long>();
LongColumnSelector selector = input.makeLongColumnSelector("sumLongSequential");
while (!input.isDone()) {
long rowval = selector.get();
long rowval = selector.getLong();
blackhole.consume(rowval);
input.advance();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ApproximateHistogramAggregator(
@Override
public void aggregate()
{
histogram.offer(selector.get());
histogram.offer(selector.getFloat());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void aggregate(ByteBuffer buf, int position)
mutationBuffer.position(position);

ApproximateHistogram h0 = ApproximateHistogram.fromBytesDense(mutationBuffer);
h0.offer(selector.get());
h0.offer(selector.getFloat());

mutationBuffer.position(position);
h0.toBytesDense(mutationBuffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public FloatVarianceAggregator(FloatColumnSelector selector)
@Override
public void aggregate()
{
holder.add(selector.get());
holder.add(selector.getFloat());
}
}

Expand All @@ -99,7 +99,7 @@ public LongVarianceAggregator(LongColumnSelector selector)
@Override
public void aggregate()
{
holder.add(selector.get());
holder.add(selector.getLong());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public FloatVarianceAggregator(String name, FloatColumnSelector selector)
@Override
public void aggregate(ByteBuffer buf, int position)
{
float v = selector.get();
float v = selector.getFloat();
long count = buf.getLong(position + COUNT_OFFSET) + 1;
double sum = buf.getDouble(position + SUM_OFFSET) + v;
buf.putLong(position, count);
Expand Down Expand Up @@ -130,7 +130,7 @@ public LongVarianceAggregator(String name, LongColumnSelector selector)
@Override
public void aggregate(ByteBuffer buf, int position)
{
long v = selector.get();
long v = selector.getLong();
long count = buf.getLong(position + COUNT_OFFSET) + 1;
double sum = buf.getDouble(position + SUM_OFFSET) + v;
buf.putLong(position, count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private static class FloatHandOver extends TestFloatColumnSelector
float v;

@Override
public float get()
public float getFloat()
{
return v;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public DoubleMaxAggregator(DoubleColumnSelector selector)
@Override
public void aggregate()
{
max = Math.max(max, selector.get());
max = Math.max(max, selector.getDouble());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public DoubleMinAggregator(DoubleColumnSelector selector)
@Override
public void aggregate()
{
min = Math.min(min, (double) selector.get());
min = Math.min(min, selector.getDouble());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public DoubleSumAggregator(DoubleColumnSelector selector)
@Override
public void aggregate()
{
sum += selector.get();
sum += selector.getDouble();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public FloatMaxAggregator(FloatColumnSelector selector)
@Override
public void aggregate()
{
max = Math.max(max, selector.get());
max = Math.max(max, selector.getFloat());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public FloatMinAggregator(FloatColumnSelector selector)
@Override
public void aggregate()
{
min = Math.min(min, selector.get());
min = Math.min(min, selector.getFloat());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public FloatSumAggregator(FloatColumnSelector selector)
@Override
public void aggregate()
{
sum += selector.get();
sum += selector.getFloat();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public HistogramAggregator(FloatColumnSelector selector, float[] breaks)
@Override
public void aggregate()
{
histogram.offer(selector.get());
histogram.offer(selector.getFloat());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void init(ByteBuffer buf, int position)
@Override
public void aggregate(ByteBuffer buf, int position)
{
final float value = selector.get();
final float value = selector.getFloat();
final int minPos = position + minOffset;
final int maxPos = position + maxOffset;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public LongMaxAggregator(LongColumnSelector selector)
@Override
public void aggregate()
{
max = Math.max(max, selector.get());
max = Math.max(max, selector.getLong());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public void init(ByteBuffer buf, int position)
@Override
public void aggregate(ByteBuffer buf, int position)
{
buf.putLong(position, Math.max(buf.getLong(position), selector.get()));
buf.putLong(position, Math.max(buf.getLong(position), selector.getLong()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public LongMinAggregator(LongColumnSelector selector)
@Override
public void aggregate()
{
min = Math.min(min, selector.get());
min = Math.min(min, selector.getLong());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public void init(ByteBuffer buf, int position)
@Override
public void aggregate(ByteBuffer buf, int position)
{
buf.putLong(position, Math.min(buf.getLong(position), selector.get()));
buf.putLong(position, Math.min(buf.getLong(position), selector.getLong()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public LongSumAggregator(LongColumnSelector selector)
@Override
public void aggregate()
{
sum += selector.get();
sum += selector.getLong();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ public void init(ByteBuffer buf, int position)
@Override
public void aggregate(ByteBuffer buf, int position)
{
buf.putLong(position, buf.getLong(position) + selector.get());
buf.putLong(position, buf.getLong(position) + selector.getLong());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public DoubleColumnSelector getSelector()
@Override
public final void aggregate(ByteBuffer buf, int position)
{
aggregate(buf, position, selector.get());
aggregate(buf, position, selector.getDouble());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public FloatColumnSelector getSelector()
@Override
public final void aggregate(ByteBuffer buf, int position)
{
aggregate(buf, position, selector.get());
aggregate(buf, position, selector.getFloat());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public class DoubleCardinalityAggregatorColumnSelectorStrategy implements Cardin
@Override
public void hashRow(DoubleColumnSelector dimSelector, Hasher hasher)
{
hasher.putDouble(dimSelector.get());
hasher.putDouble(dimSelector.getDouble());
}

@Override
public void hashValues(DoubleColumnSelector dimSelector, HyperLogLogCollector collector)
{
collector.add(CardinalityAggregator.hashFn.hashLong(Double.doubleToLongBits(dimSelector.get())).asBytes());
collector.add(CardinalityAggregator.hashFn.hashLong(Double.doubleToLongBits(dimSelector.getDouble())).asBytes());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public class FloatCardinalityAggregatorColumnSelectorStrategy
@Override
public void hashRow(FloatColumnSelector dimSelector, Hasher hasher)
{
hasher.putFloat(dimSelector.get());
hasher.putFloat(dimSelector.getFloat());
}

@Override
public void hashValues(FloatColumnSelector dimSelector, HyperLogLogCollector collector)
{
collector.add(CardinalityAggregator.hashFn.hashInt(Float.floatToIntBits(dimSelector.get())).asBytes());
collector.add(CardinalityAggregator.hashFn.hashInt(Float.floatToIntBits(dimSelector.getFloat())).asBytes());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public class LongCardinalityAggregatorColumnSelectorStrategy
@Override
public void hashRow(LongColumnSelector dimSelector, Hasher hasher)
{
hasher.putLong(dimSelector.get());
hasher.putLong(dimSelector.getLong());
}

@Override
public void hashValues(LongColumnSelector dimSelector, HyperLogLogCollector collector)
{
collector.add(CardinalityAggregator.hashFn.hashLong(dimSelector.get()).asBytes());
collector.add(CardinalityAggregator.hashFn.hashLong(dimSelector.getLong()).asBytes());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public DoubleFirstAggregator(
@Override
public void aggregate()
{
long time = timeSelector.get();
long time = timeSelector.getLong();
if (time < firstTime) {
firstTime = time;
firstValue = valueSelector.get();
firstValue = valueSelector.getDouble();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public void init(ByteBuffer buf, int position)
@Override
public void aggregate(ByteBuffer buf, int position)
{
long time = timeSelector.get();
long time = timeSelector.getLong();
long firstTime = buf.getLong(position);
if (time < firstTime) {
buf.putLong(position, time);
buf.putDouble(position + Long.BYTES, valueSelector.get());
buf.putDouble(position + Long.BYTES, valueSelector.getDouble());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public FloatFirstAggregator(
@Override
public void aggregate()
{
long time = timeSelector.get();
long time = timeSelector.getLong();
if (time < firstTime) {
firstTime = time;
firstValue = valueSelector.get();
firstValue = valueSelector.getFloat();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public void init(ByteBuffer buf, int position)
@Override
public void aggregate(ByteBuffer buf, int position)
{
long time = timeSelector.get();
long time = timeSelector.getLong();
long firstTime = buf.getLong(position);
if (time < firstTime) {
buf.putLong(position, time);
buf.putFloat(position + Long.BYTES, valueSelector.get());
buf.putFloat(position + Long.BYTES, valueSelector.getFloat());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public LongFirstAggregator(
@Override
public void aggregate()
{
long time = timeSelector.get();
long time = timeSelector.getLong();
if (time < firstTime) {
firstTime = time;
firstValue = valueSelector.get();
firstValue = valueSelector.getLong();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public void init(ByteBuffer buf, int position)
@Override
public void aggregate(ByteBuffer buf, int position)
{
long time = timeSelector.get();
long time = timeSelector.getLong();
long firstTime = buf.getLong(position);
if (time < firstTime) {
buf.putLong(position, time);
buf.putLong(position + Longs.BYTES, valueSelector.get());
buf.putLong(position + Longs.BYTES, valueSelector.getLong());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public DoubleLastAggregator(
@Override
public void aggregate()
{
long time = timeSelector.get();
long time = timeSelector.getLong();
if (time >= lastTime) {
lastTime = timeSelector.get();
lastValue = valueSelector.get();
lastTime = time;
lastValue = valueSelector.getDouble();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public void init(ByteBuffer buf, int position)
@Override
public void aggregate(ByteBuffer buf, int position)
{
long time = timeSelector.get();
long time = timeSelector.getLong();
long lastTime = buf.getLong(position);
if (time >= lastTime) {
buf.putLong(position, time);
buf.putDouble(position + Long.BYTES, valueSelector.get());
buf.putDouble(position + Long.BYTES, valueSelector.getDouble());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public FloatLastAggregator(
@Override
public void aggregate()
{
long time = timeSelector.get();
long time = timeSelector.getLong();
if (time >= lastTime) {
lastTime = timeSelector.get();
lastValue = valueSelector.get();
lastTime = time;
lastValue = valueSelector.getFloat();
}
}

Expand Down
Loading

0 comments on commit 7454fd8

Please sign in to comment.