@Override public void aggregate(Aggregator[] aggregators, Tuple result) { long dsize = memoryUsed; for (int i = 0; i < expressions.length; i++) { if (expressions[i].evaluate(result, ptr) && ptr.getLength() != 0) { dsize -= aggregators[i].getSize(); aggregators[i].aggregate(result, ptr); dsize += aggregators[i].getSize(); } expressions[i].reset(); } while(dsize > chunk.getSize()) { logger.info("Request: {}, resizing {} by 1024*1024", dsize, chunk.getSize()); chunk.resize(chunk.getSize() + sizeIncrease); } memoryUsed = dsize; }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { return getAggregator().evaluate(tuple, ptr); }
private static int getMinNullableIndex(List<SingleAggregateFunction> aggFuncs, boolean isUngroupedAggregation) { int minNullableIndex = aggFuncs.size(); for (int i = 0; i < aggFuncs.size(); i++) { SingleAggregateFunction aggFunc = aggFuncs.get(i); if (isUngroupedAggregation ? aggFunc.getAggregator().isNullable() : aggFunc.getAggregatorExpression().isNullable()) { minNullableIndex = i; break; } } return minNullableIndex; }
public Aggregator newServerAggregator(Configuration config, ImmutableBytesWritable ptr) { Aggregator agg = newServerAggregator(config); agg.aggregate(null, ptr); return agg; }
protected static int calculateSize(Aggregator[] aggregators) { int size = SizedUtil.ARRAY_SIZE /*aggregators[]*/ + (SizedUtil.POINTER_SIZE * aggregators.length); for (Aggregator aggregator : aggregators) { size += aggregator.getSize(); } return size; }
public void reset(Aggregator[] aggregators) { for (int i = 0; i < aggregators.length; i++) { aggregators[i].reset(); } }
@Override public int compare(SingleAggregateFunction o1, SingleAggregateFunction o2) { boolean isNullable1 = o1.isNullable(); boolean isNullable2 = o2.isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } isNullable1 = o1.getAggregatorExpression().isNullable(); isNullable2 = o2.getAggregatorExpression().isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } // Ensures COUNT(1) sorts first TODO: unit test for this boolean isConstant1 = o1.isConstantExpression(); boolean isConstant2 = o2.isConstantExpression(); if (isConstant1 != isConstant2) { return isConstant1 ? 1 : -1; } PDataType r1 = o1.getAggregator().getDataType(); PDataType r2 = o2.getAggregator().getDataType(); if (r1.isFixedWidth() != r2.isFixedWidth()) { return r1.isFixedWidth() ? -1 : 1; } return r1.compareTo(r2); } };
if (chunk != null) { for (Aggregator aggregator : aggregators) { if (aggregator.trackSize()) { trackSize = true; break;
@Override public void aggregate(Aggregator[] aggregators, Tuple result) { for (int i = 0; i < expressions.length; i++) { if (expressions[i].evaluate(result, ptr) && ptr.getLength() != 0) { aggregators[i].aggregate(result, ptr); } expressions[i].reset(); } }
protected static int calculateSize(Aggregator[] aggregators) { int size = SizedUtil.ARRAY_SIZE /*aggregators[]*/ + (SizedUtil.POINTER_SIZE * aggregators.length); for (Aggregator aggregator : aggregators) { size += aggregator.getSize(); } return size; }
public void reset(Aggregator[] aggregators) { for (int i = 0; i < aggregators.length; i++) { aggregators[i].reset(); } }
@Override public int compare(SingleAggregateFunction o1, SingleAggregateFunction o2) { boolean isNullable1 = o1.isNullable(); boolean isNullable2 = o2.isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } isNullable1 = o1.getAggregatorExpression().isNullable(); isNullable2 = o2.getAggregatorExpression().isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } // Ensures COUNT(1) sorts first TODO: unit test for this boolean isConstant1 = o1.isConstantExpression(); boolean isConstant2 = o2.isConstantExpression(); if (isConstant1 != isConstant2) { return isConstant1 ? 1 : -1; } PDataType r1 = o1.getAggregator().getDataType(); PDataType r2 = o2.getAggregator().getDataType(); if (r1.isFixedWidth() != r2.isFixedWidth()) { return r1.isFixedWidth() ? -1 : 1; } return r1.compareTo(r2); } };
if (chunk != null) { for (Aggregator aggregator : aggregators) { if (aggregator.trackSize()) { trackSize = true; break;
@Override public void aggregate(Aggregator[] aggregators, Tuple result) { long dsize = memoryUsed; for (int i = 0; i < expressions.length; i++) { if (expressions[i].evaluate(result, ptr) && ptr.getLength() != 0) { dsize -= aggregators[i].getSize(); aggregators[i].aggregate(result, ptr); dsize += aggregators[i].getSize(); } expressions[i].reset(); } while(dsize > chunk.getSize()) { logger.info("Request: {}, resizing {} by 1024*1024", dsize, chunk.getSize()); chunk.resize(chunk.getSize() + sizeIncrease); } memoryUsed = dsize; }
@Override public void aggregate(Aggregator[] aggregators, Tuple result) { TupleUtil.getAggregateValue(result, ptr); tempValueSet.clear(); tempValueSet.or(ptr); int i = 0, maxOffset = ptr.getOffset() + ptr.getLength(); Boolean hasValue; schema.iterator(ptr); while ((hasValue=schema.next(ptr, i, maxOffset, tempValueSet)) != null) { if (hasValue) { aggregators[i].aggregate(result, ptr); } i++; } }
protected static int calculateSize(Aggregator[] aggregators) { int size = SizedUtil.ARRAY_SIZE /*aggregators[]*/ + (SizedUtil.POINTER_SIZE * aggregators.length); for (Aggregator aggregator : aggregators) { size += aggregator.getSize(); } return size; }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { return getAggregator().evaluate(tuple, ptr); }
private static int getMinNullableIndex(List<SingleAggregateFunction> aggFuncs, boolean isUngroupedAggregation) { int minNullableIndex = aggFuncs.size(); for (int i = 0; i < aggFuncs.size(); i++) { SingleAggregateFunction aggFunc = aggFuncs.get(i); if (isUngroupedAggregation ? aggFunc.getAggregator().isNullable() : aggFunc.getAggregatorExpression().isNullable()) { minNullableIndex = i; break; } } return minNullableIndex; }
public void reset(Aggregator[] aggregators) { for (int i = 0; i < aggregators.length; i++) { aggregators[i].reset(); } }
@Override public int compare(SingleAggregateFunction o1, SingleAggregateFunction o2) { boolean isNullable1 = o1.isNullable(); boolean isNullable2 = o2.isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } isNullable1 = o1.getAggregatorExpression().isNullable(); isNullable2 = o2.getAggregatorExpression().isNullable(); if (isNullable1 != isNullable2) { return isNullable1 ? 1 : -1; } // Ensures COUNT(1) sorts first TODO: unit test for this boolean isConstant1 = o1.isConstantExpression(); boolean isConstant2 = o2.isConstantExpression(); if (isConstant1 != isConstant2) { return isConstant1 ? 1 : -1; } PDataType r1 = o1.getAggregator().getDataType(); PDataType r2 = o2.getAggregator().getDataType(); if (r1.isFixedWidth() != r2.isFixedWidth()) { return r1.isFixedWidth() ? -1 : 1; } return r1.compareTo(r2); } };