@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { boolean wasEvaluated = super.evaluate(tuple, ptr); if (!wasEvaluated) { return false; } if (isConstantExpression()) { getAggregatorExpression().evaluate(tuple, ptr); } return true; }
@Override public PDataType getDataType() { if (super.getDataType() == PDecimal.INSTANCE) { return PDecimal.INSTANCE; } else if (PDataType.equalsAny(super.getDataType(), PUnsignedFloat.INSTANCE, PUnsignedDouble.INSTANCE, PFloat.INSTANCE, PDouble.INSTANCE)) { return PDouble.INSTANCE; } else { return PLong.INSTANCE; } }
@Override public int hashCode() { return isConstantExpression() ? 0 : super.hashCode(); }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { // TODO: optimize query plan of this to run scan serially for a limit of one row if (!super.evaluate(tuple, ptr)) { ptr.set(ZERO); // If evaluate returns false, then no rows were found, so result is 0 } else if (isConstantExpression()) { ptr.set(ONE); // Otherwise, we found one or more rows, so a distinct on a constant is 1 } return true; // Always evaluates to a LONG value }
@Override public PDataType getDataType() { if (super.getDataType() == PDecimal.INSTANCE) { return PDecimal.INSTANCE; } else if (PDataType.equalsAny(super.getDataType(), PUnsignedFloat.INSTANCE, PUnsignedDouble.INSTANCE, PFloat.INSTANCE, PDouble.INSTANCE)) { return PDouble.INSTANCE; } else { return PLong.INSTANCE; } }
@Override public int hashCode() { return isConstantExpression() ? 0 : super.hashCode(); }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { boolean wasEvaluated = super.evaluate(tuple, ptr); if (!wasEvaluated) { return false; } if (isConstantExpression()) { getAggregatorExpression().evaluate(tuple, ptr); } return true; }
@Override public PDataType getDataType() { if (super.getDataType() == PDecimal.INSTANCE) { return PDecimal.INSTANCE; } else if (PDataType.equalsAny(super.getDataType(), PUnsignedFloat.INSTANCE, PUnsignedDouble.INSTANCE, PFloat.INSTANCE, PDouble.INSTANCE)) { return PDouble.INSTANCE; } else { return PLong.INSTANCE; } }
@Override public int hashCode() { return isConstantExpression() ? 0 : super.hashCode(); }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { if (!super.evaluate(tuple, ptr)) { return false; } if (isConstantExpression()) { PDataType type = getDataType(); Object constantValue = ((LiteralExpression)children.get(0)).getValue(); if (type == PDecimal.INSTANCE) { BigDecimal value = ((BigDecimal)constantValue).multiply((BigDecimal) PDecimal.INSTANCE.toObject(ptr, PLong.INSTANCE)); ptr.set(PDecimal.INSTANCE.toBytes(value)); } else { long constantLongValue = ((Number)constantValue).longValue(); long value = constantLongValue * type.getCodec().decodeLong(ptr, SortOrder.getDefault()); byte[] resultPtr = new byte[type.getByteSize()]; type.getCodec().encodeLong(value, resultPtr, 0); ptr.set(resultPtr); } } return true; }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { boolean wasEvaluated = super.evaluate(tuple, ptr); if (!wasEvaluated) { return false; } if (isConstantExpression()) { getAggregatorExpression().evaluate(tuple, ptr); } return true; }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { boolean wasEvaluated = super.evaluate(tuple, ptr); if (!wasEvaluated) { return false; } if (isConstantExpression()) { getAggregatorExpression().evaluate(tuple, ptr); } return true; }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { boolean wasEvaluated = super.evaluate(tuple, ptr); if (!wasEvaluated) { return false; } if (isConstantExpression()) { getAggregatorExpression().evaluate(tuple, ptr); } return true; }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { // TODO: optimize query plan of this to run scan serially for a limit of one row if (!super.evaluate(tuple, ptr)) { ptr.set(ZERO); // If evaluate returns false, then no rows were found, so result is 0 } else if (isConstantExpression()) { ptr.set(ONE); // Otherwise, we found one or more rows, so a distinct on a constant is 1 } return true; // Always evaluates to a LONG value }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { // TODO: optimize query plan of this to run scan serially for a limit of one row if (!super.evaluate(tuple, ptr)) { ptr.set(ZERO); // If evaluate returns false, then no rows were found, so result is 0 } else if (isConstantExpression()) { ptr.set(ONE); // Otherwise, we found one or more rows, so a distinct on a constant is 1 } return true; // Always evaluates to a LONG value }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { boolean wasEvaluated = super.evaluate(tuple, ptr); if (!wasEvaluated) { return false; } if (isConstantExpression()) { getAggregatorExpression().evaluate(tuple, ptr); } return true; }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { if (!super.evaluate(tuple, ptr)) { return false; } if (isConstantExpression()) { PDataType type = getDataType(); Object constantValue = ((LiteralExpression)children.get(0)).getValue(); if (type == PDecimal.INSTANCE) { BigDecimal value = ((BigDecimal)constantValue).multiply((BigDecimal) PDecimal.INSTANCE.toObject(ptr, PLong.INSTANCE)); ptr.set(PDecimal.INSTANCE.toBytes(value)); } else { long constantLongValue = ((Number)constantValue).longValue(); long value = constantLongValue * type.getCodec().decodeLong(ptr, SortOrder.getDefault()); byte[] resultPtr = new byte[type.getByteSize()]; type.getCodec().encodeLong(value, resultPtr, 0); ptr.set(resultPtr); } } return true; }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { if (!super.evaluate(tuple, ptr)) { return false; } if (isConstantExpression()) { PDataType type = getDataType(); Object constantValue = ((LiteralExpression)children.get(0)).getValue(); if (type == PDecimal.INSTANCE) { BigDecimal value = ((BigDecimal)constantValue).multiply((BigDecimal) PDecimal.INSTANCE.toObject(ptr, PLong.INSTANCE)); ptr.set(PDecimal.INSTANCE.toBytes(value)); } else { long constantLongValue = ((Number)constantValue).longValue(); long value = constantLongValue * type.getCodec().decodeLong(ptr, SortOrder.getDefault()); byte[] resultPtr = new byte[type.getByteSize()]; type.getCodec().encodeLong(value, resultPtr, 0); ptr.set(resultPtr); } } return true; }