@Override public boolean isStateless() { return delegate.isStateless(); }
public static boolean isConstant(Expression expression) { return (expression.isStateless() && isContantForStatement(expression)); }
@Override public Iterator<Expression> visitEnter(ComparisonExpression node) { Expression rhs = node.getChildren().get(1); if (!rhs.isStateless() || node.getFilterOp() == CompareOp.NOT_EQUAL) { return Collections.emptyIterator(); } return Iterators.singletonIterator(node.getChildren().get(0)); }
@Override public Iterator<Expression> visitEnter(ComparisonExpression node) { if (node.getFilterOp() == CompareOp.EQUAL && node.getChildren().get(1).isStateless() && node.getChildren().get(1).getDeterminism() == Determinism.ALWAYS ) { return Iterators.singletonIterator(node.getChildren().get(0)); } return super.visitEnter(node); }
private void init() { Expression offsetExpr = children.get(1); ImmutableBytesWritable ptr = new ImmutableBytesWritable(); if (offsetExpr.isStateless() && offsetExpr.getDeterminism() == Determinism.ALWAYS && offsetExpr.evaluate(null, ptr)) { offsetPreCompute = (Integer) PInteger.INSTANCE.toObject(ptr, offsetExpr.getSortOrder()); } else offsetPreCompute = null; }
private void init(List<Expression> children) { this.children = ImmutableList.copyOf(children); boolean isStateless = true; boolean isNullable = false; boolean requiresFinalEvaluation = false; boolean cloneExpression = false; this.determinism = Determinism.ALWAYS; for (int i = 0; i < children.size(); i++) { Expression child = children.get(i); isNullable |= child.isNullable(); isStateless &= child.isStateless(); this.determinism = this.determinism.combine(child.getDeterminism()); requiresFinalEvaluation |= child.requiresFinalEvaluation(); cloneExpression |= child.isCloneExpression(); } this.isStateless = isStateless; this.isNullable = isNullable; this.requiresFinalEvaluation = requiresFinalEvaluation; this.cloneExpression = cloneExpression; }
private void init() { Expression offsetExpr = children.get(1); ImmutableBytesWritable ptr = new ImmutableBytesWritable(); if (offsetExpr.isStateless() && offsetExpr.getDeterminism() == Determinism.ALWAYS && offsetExpr.evaluate(null, ptr)) { offsetPreCompute = (Integer) PInteger.INSTANCE.toObject(ptr, offsetExpr.getSortOrder()); } else offsetPreCompute = null; }
public static Expression create (List<Expression> children, boolean isNegate, ImmutableBytesWritable ptr, boolean rowKeyOrderOptimizable) throws SQLException { Expression firstChild = children.get(0); if (firstChild.isStateless() && (!firstChild.evaluate(null, ptr) || ptr.getLength() == 0)) { return LiteralExpression.newConstant(null, PBoolean.INSTANCE, firstChild.getDeterminism());
return coercedNodes.equals(rhs.getChildren()) ? rhs : new RowValueConstructorExpression(coercedNodes, rhs.isStateless()); } else if (lhs instanceof RowValueConstructorExpression) { List<Expression> coercedNodes = Lists.newArrayListWithExpectedSize(Math.max(rhs.getChildren().size(), lhs.getChildren().size())); return coercedNodes.equals(rhs.getChildren()) ? rhs : new RowValueConstructorExpression(coercedNodes, rhs.isStateless()); } else if (rhs instanceof RowValueConstructorExpression) { List<Expression> coercedNodes = Lists.newArrayListWithExpectedSize(Math.max(rhs.getChildren().size(), lhs.getChildren().size())); return coercedNodes.equals(rhs.getChildren()) ? rhs : new RowValueConstructorExpression(coercedNodes, rhs.isStateless()); } else if (lhs == null) { return rhs;
private void init() { List<Expression> children = getChildren(); if (children.size() <= LIKE_TYPE_INDEX) { this.likeType = LikeType.CASE_SENSITIVE; } else { LiteralExpression likeTypeExpression = (LiteralExpression)children.get(LIKE_TYPE_INDEX); this.likeType = LikeType.valueOf((String)likeTypeExpression.getValue()); } ImmutableBytesWritable ptr = new ImmutableBytesWritable(); Expression e = getPatternExpression(); if (e.isStateless() && e.getDeterminism() == Determinism.ALWAYS && e.evaluate(null, ptr)) { String value = (String) PVarchar.INSTANCE.toObject(ptr, e.getDataType(), e.getSortOrder()); pattern = compilePattern(value); } }
private void init() { ImmutableBytesWritable ptr = new ImmutableBytesWritable(); Expression e = getPatternStrExpression(); if (e.isStateless() && e.getDeterminism() == Determinism.ALWAYS && e.evaluate(null, ptr)) { String pattern = (String) TYPE.toObject(ptr, TYPE, e.getSortOrder()); if (pattern != null) { initializedSplitter = compilePatternSpec(pattern); } } }
rhs= new RowValueConstructorExpression(rhs.getChildren().subList(0, Math.min(rvc.getChildren().size(), rhs.getChildren().size())), rhs.isStateless());
ParseNode node = groupByNodes.get(i); Expression expression = node.accept(compiler); if (!expression.isStateless()) { if (compiler.isAggregate()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.AGGREGATE_IN_GROUP_BY)
private void init() { ImmutableBytesWritable tmpPtr = new ImmutableBytesWritable(); Expression e = getPatternStrExpression(); if (e.isStateless() && e.getDeterminism() == Determinism.ALWAYS && e.evaluate(null, tmpPtr)) { String patternStr = (String) TYPE.toObject(tmpPtr, e.getDataType(), e.getSortOrder()); if (patternStr != null) pattern = compilePatternSpec(patternStr); } e = getReplaceStrExpression(); if (e.isStateless() && e.getDeterminism() == Determinism.ALWAYS && e.evaluate(null, tmpPtr)) { TYPE.coerceBytes(tmpPtr, TYPE, e.getSortOrder(), SortOrder.ASC); rStrBytes = tmpPtr.get(); rStrOffset = tmpPtr.getOffset(); rStrLen = tmpPtr.getLength(); } else { rStrBytes = null; } }
if (overlapViewColumns.contains(targetColumn)) { Expression source = projector.getColumnProjector(i).getExpression(); if (source.isStateless()) { source.evaluate(null, ptr); if (Bytes.compareTo(ptr.get(), ptr.getOffset(), ptr.getLength(), targetColumn.getViewConstant(), 0, targetColumn.getViewConstant().length-1) == 0) {
public static Expression create(Expression child, ImmutableBytesWritable ptr) throws SQLException { if (child.getDataType() != PBoolean.INSTANCE) { throw TypeMismatchException.newException(child.getDataType(), PBoolean.INSTANCE, "NOT"); } if (child.isStateless()) { if (!child.evaluate(null, ptr) || ptr.getLength() == 0) { return LiteralExpression.newConstant(null, PBoolean.INSTANCE, child.getDeterminism()); } return LiteralExpression.newConstant(!(Boolean) PBoolean.INSTANCE.toObject(ptr), PBoolean.INSTANCE, child.getDeterminism()); } return new NotExpression(child); }
private void init() { ImmutableBytesWritable ptr = new ImmutableBytesWritable(); Expression patternExpr = getPatternExpression(); if (patternExpr.isStateless() && patternExpr.getDeterminism() == Determinism.ALWAYS && patternExpr.evaluate(null, ptr)) { String patternStr = (String) patternExpr.getDataType().toObject(ptr, patternExpr.getSortOrder()); if (patternStr != null) { pattern = compilePatternSpec(patternStr); } } // If the source string has a fixed width, then the max length would be the length // of the source string minus the offset, or the absolute value of the offset if // it's negative. Offset number is a required argument. However, if the source string // is not fixed width, the maxLength would be null. Expression offsetExpr = getOffsetExpression(); if (offsetExpr.isStateless() && offsetExpr.getDeterminism() == Determinism.ALWAYS && offsetExpr.evaluate(null, ptr)) { offset = (Integer)PInteger.INSTANCE.toObject(ptr, offsetExpr.getDataType(), offsetExpr.getSortOrder()); if (offset != null) { PDataType type = getSourceStrExpression().getDataType(); if (type.isFixedWidth()) { if (offset >= 0) { Integer maxLength = getSourceStrExpression().getMaxLength(); this.maxLength = maxLength - offset - (offset == 0 ? 0 : 1); } else { this.maxLength = -offset; } } } } }
expression = node.getNode().accept(compiler); if (!expression.isStateless() && !compiler.isAggregate()) { if (statement.isAggregate() || statement.isDistinct()) { if (!expression.isStateless()) { boolean isAscending = node.isAscending(); boolean isNullsLast = node.isNullsLast();
lhsExpr = new RowValueConstructorExpression(Collections.singletonList(lhsExpr), lhsExpr.isStateless());
throw new SQLExceptionInfo.Builder(SQLExceptionCode.NON_DETERMINISTIC_EXPRESSION_NOT_ALLOWED_IN_INDEX).build().buildException(); if (expression.isStateless()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.STATELESS_EXPRESSION_NOT_ALLOWED_IN_INDEX).build().buildException();