@Test public void testNullValuesNotCounted() { ExpressionResult actual1 = testSubject.apply(expressionContext, mapValue("value", stringValue("string"))); ExpressionResult actual2 = testSubject.apply(expressionContext, mapValue("value", nullValue())); ExpressionResult actual3 = testSubject.apply(expressionContext, mapValue("value", numericValue(1L))); assertEquals(1, actual1.getNumericValue().longValue()); assertEquals(1, actual2.getNumericValue().longValue()); assertEquals(2, actual3.getNumericValue().longValue()); }
@Override public ExpressionResult apply(ExpressionContext context, ExpressionResult input) { ExpressionContext scoped = context.scoped(this); AtomicLong counter = scoped.computeIfAbsent(alias, AtomicLong::new); ExpressionResult expressionResult = expression == null ? input : expression.apply(context, input); if( expressionResult == null) { return new NumericExpressionResult(counter.get()); } return new NumericExpressionResult(counter.addAndGet(expressionResult.count())); }
CountExpression extends AbstractAggregationFunction { @Override public ExpressionResult apply(ExpressionContext context, ExpressionResult input) { ExpressionContext scoped = context.scoped(this); AtomicLong counter = scoped.computeIfAbsent(alias, AtomicLong::new); ExpressionResult expressionResult = expression == null ? input : expression.apply(context, input); if( expressionResult == null) { return new NumericExpressionResult(counter.get()); } return new NumericExpressionResult(counter.addAndGet(expressionResult.count())); } }
CountExpression extends AbstractAggregationFunction { @Override public ExpressionResult apply(ExpressionContext context, ExpressionResult input) { ExpressionContext scoped = context.scoped(this); AtomicLong counter = scoped.computeIfAbsent(alias, AtomicLong::new); ExpressionResult expressionResult = expression == null ? input : expression.apply(context, input); if( expressionResult == null) { return new NumericExpressionResult(counter.get()); } return new NumericExpressionResult(counter.addAndGet(expressionResult.count())); } CountExpression(String alias, Expression expression); }
CountExpression extends AbstractAggregationFunction { @Override public ExpressionResult apply(ExpressionContext context, ExpressionResult input) { ExpressionContext scoped = context.scoped(this); AtomicLong counter = scoped.computeIfAbsent(alias, AtomicLong::new); ExpressionResult expressionResult = expression == null ? input : expression.apply(context, input); if( expressionResult == null) { return new NumericExpressionResult(counter.get()); } return new NumericExpressionResult(counter.addAndGet(expressionResult.count())); } CountExpression(String alias, Expression expression); @Override ExpressionResult apply(ExpressionContext context, ExpressionResult input); }
CountExpression extends AbstractAggregationFunction { @Override public ExpressionResult apply(ExpressionContext context, ExpressionResult input) { ExpressionContext scoped = context.scoped(this); AtomicLong counter = scoped.computeIfAbsent(alias, AtomicLong::new); ExpressionResult expressionResult = expression == null ? input : expression.apply(context, input); if( expressionResult == null) { return new NumericExpressionResult(counter.get()); } return new NumericExpressionResult(counter.addAndGet(expressionResult.count())); } CountExpression(String alias, Expression expression); @Override ExpressionResult apply(ExpressionContext context, ExpressionResult input);  }