protected RexNode register(RexNode expr) { final String key = expr.toString(); final RexNode previous = mapDigestToExpr.put(key, expr); if (!allowDups && (previous != null)) { throw new SubExprExistsException(expr); } return expr; }
/** * Creates a key for {@link RexNode} which is the same as another key of another RexNode only if * the two have both the same type and textual representation. For example, "10" integer and "10" * bigint result in different keys. */ public static String makeKey(RexNode expr) { String type = expr.getType().getFullTypeString(); String separator = ";"; String node = expr.toString(); StringBuilder keyBuilder = new StringBuilder(type.length() + separator.length() + node.length()); keyBuilder.append(type).append(separator).append(node); return keyBuilder.toString(); }
protected RexNode lookup(RexNode expr) { return mapDigestToExpr.get(expr.toString()); }