@Override public OrderPreserving preservesOrder() { if (isOffsetConstant) { LiteralExpression literal = (LiteralExpression) getOffsetExpression(); Number offsetNumber = (Number) literal.getValue(); if (offsetNumber != null) { int offset = offsetNumber.intValue(); if ((offset == 0 || offset == 1) && (!hasLengthExpression || isLengthConstant)) { return OrderPreserving.YES_IF_LAST; } } } return OrderPreserving.NO; }
@Override public String toString() { StringBuilder buf = new StringBuilder(getName() + "("); if (children.size()==0) return buf.append(")").toString(); if (hasLengthExpression) { buf.append(getStrExpression()); buf.append(", "); buf.append(getOffsetExpression()); buf.append(", "); buf.append(getLengthExpression()); } else { buf.append(getStrExpression()); buf.append(", "); buf.append(getOffsetExpression()); } buf.append(")"); return buf.toString(); }
@Override public boolean isNullable() { return getStrExpression().isNullable() || !isFixedWidth || getOffsetExpression().isNullable(); }
private void init() { isOffsetConstant = getOffsetExpression() instanceof LiteralExpression; isLengthConstant = getLengthExpression() instanceof LiteralExpression; hasLengthExpression = !isLengthConstant || ((LiteralExpression)getLengthExpression()).getValue() != null; isFixedWidth = getStrExpression().getDataType().isFixedWidth() && ((hasLengthExpression && isLengthConstant) || (!hasLengthExpression && isOffsetConstant)); if (hasLengthExpression && isLengthConstant) { Integer maxLength = ((Number)((LiteralExpression)getLengthExpression()).getValue()).intValue(); this.maxLength = maxLength >= 0 ? maxLength : 0; } else if (isOffsetConstant) { Number offsetNumber = (Number)((LiteralExpression)getOffsetExpression()).getValue(); if (offsetNumber != null) { int offset = offsetNumber.intValue(); PDataType type = getStrExpression().getDataType(); if (type.isFixedWidth()) { if (offset >= 0) { Integer maxLength = getStrExpression().getMaxLength(); this.maxLength = maxLength - offset + (offset == 0 ? 0 : 1); } else { this.maxLength = -offset; } } } } }
@Override public OrderPreserving preservesOrder() { if (isOffsetConstant) { LiteralExpression literal = (LiteralExpression) getOffsetExpression(); Number offsetNumber = (Number) literal.getValue(); if (offsetNumber != null) { int offset = offsetNumber.intValue(); if ((offset == 0 || offset == 1) && (!hasLengthExpression || isLengthConstant)) { return OrderPreserving.YES_IF_LAST; } } } return OrderPreserving.NO; }
@Override public OrderPreserving preservesOrder() { if (isOffsetConstant) { LiteralExpression literal = (LiteralExpression) getOffsetExpression(); Number offsetNumber = (Number) literal.getValue(); if (offsetNumber != null) { int offset = offsetNumber.intValue(); if ((offset == 0 || offset == 1) && (!hasLengthExpression || isLengthConstant)) { return OrderPreserving.YES_IF_LAST; } } } return OrderPreserving.NO; }
@Override public String toString() { StringBuilder buf = new StringBuilder(getName() + "("); if (children.size()==0) return buf.append(")").toString(); if (hasLengthExpression) { buf.append(getStrExpression()); buf.append(", "); buf.append(getOffsetExpression()); buf.append(", "); buf.append(getLengthExpression()); } else { buf.append(getStrExpression()); buf.append(", "); buf.append(getOffsetExpression()); } buf.append(")"); return buf.toString(); }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { Expression offsetExpression = getOffsetExpression(); if (!offsetExpression.evaluate(tuple, ptr)) { return false;
@Override public boolean isNullable() { return getStrExpression().isNullable() || !isFixedWidth || getOffsetExpression().isNullable(); }
@Override public boolean isNullable() { return getStrExpression().isNullable() || !isFixedWidth || getOffsetExpression().isNullable(); }
private void init() { isOffsetConstant = getOffsetExpression() instanceof LiteralExpression; isLengthConstant = getLengthExpression() instanceof LiteralExpression; hasLengthExpression = !isLengthConstant || ((LiteralExpression)getLengthExpression()).getValue() != null; isFixedWidth = getStrExpression().getDataType().isFixedWidth() && ((hasLengthExpression && isLengthConstant) || (!hasLengthExpression && isOffsetConstant)); if (hasLengthExpression && isLengthConstant) { Integer maxLength = ((Number)((LiteralExpression)getLengthExpression()).getValue()).intValue(); this.maxLength = maxLength >= 0 ? maxLength : 0; } else if (isOffsetConstant) { Number offsetNumber = (Number)((LiteralExpression)getOffsetExpression()).getValue(); if (offsetNumber != null) { int offset = offsetNumber.intValue(); PDataType type = getStrExpression().getDataType(); if (type.isFixedWidth()) { if (offset >= 0) { Integer maxLength = getStrExpression().getMaxLength(); this.maxLength = maxLength - offset + (offset == 0 ? 0 : 1); } else { this.maxLength = -offset; } } } } }
private void init() { isOffsetConstant = getOffsetExpression() instanceof LiteralExpression; isLengthConstant = getLengthExpression() instanceof LiteralExpression; hasLengthExpression = !isLengthConstant || ((LiteralExpression)getLengthExpression()).getValue() != null; isFixedWidth = getStrExpression().getDataType().isFixedWidth() && ((hasLengthExpression && isLengthConstant) || (!hasLengthExpression && isOffsetConstant)); if (hasLengthExpression && isLengthConstant) { Integer maxLength = ((Number)((LiteralExpression)getLengthExpression()).getValue()).intValue(); this.maxLength = maxLength >= 0 ? maxLength : 0; } else if (isOffsetConstant) { Number offsetNumber = (Number)((LiteralExpression)getOffsetExpression()).getValue(); if (offsetNumber != null) { int offset = offsetNumber.intValue(); PDataType type = getStrExpression().getDataType(); if (type.isFixedWidth()) { if (offset >= 0) { Integer maxLength = getStrExpression().getMaxLength(); this.maxLength = maxLength - offset + (offset == 0 ? 0 : 1); } else { this.maxLength = -offset; } } } } }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { Expression offsetExpression = getOffsetExpression(); if (!offsetExpression.evaluate(tuple, ptr)) { return false;
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { Expression offsetExpression = getOffsetExpression(); if (!offsetExpression.evaluate(tuple, ptr)) { return false;