/** * Determines whether or not a function may be used to form * the start/stop key of a scan * When OrderPreserving is YES, in order to make order-by optimization * valid, it should return 0. (refer to {@link RoundDateExpression}) * @return the zero-based position of the argument to traverse * into to look for a primary key column reference, or * {@value #NO_TRAVERSAL} if the function cannot be used to * form the scan key. */ public int getKeyFormationTraversalIndex() { return preservesOrder() == OrderPreserving.NO ? NO_TRAVERSAL : 0; }
@Override public OrderPreserving preservesOrder() { return udfFunction.preservesOrder(); }
@Override public Iterator<Expression> visitEnter(ScalarFunction node) { return node.preservesOrder() == OrderPreserving.NO ? Collections.<Expression> emptyIterator() : Iterators .singletonIterator(node.getChildren().get(node.getKeyFormationTraversalIndex())); }
@Override public Info visitLeave(ScalarFunction node, List<Info> l) { if (l.isEmpty()) { return null; } Info info = l.get(0); // Keep the minimum value between this function and the current value, // so that we never increase OrderPreserving from NO or YES_IF_LAST. OrderPreserving orderPreserving = OrderPreserving.values()[Math.min(node.preservesOrder().ordinal(), info.orderPreserving.ordinal())]; if (orderPreserving == info.orderPreserving) { return info; } return new Info(info, orderPreserving); }
private KeySlots newScalarFunctionKeyPart(KeySlot slot, ScalarFunction node) { if (isDegenerate(slot.getKeyRanges())) { return EMPTY_KEY_SLOTS; } KeyPart part = node.newKeyPart(slot.getKeyPart()); if (part == null) { return null; } // Scalar function always returns primitive and never a row value constructor, so span is always 1 return new SingleKeySlot(part, slot.getPKPosition(), slot.getKeyRanges(), node.preservesOrder()); }
/** * Determines whether or not a function may be used to form * the start/stop key of a scan * When OrderPreserving is YES, in order to make order-by optimization * valid, it should return 0. (refer to {@link RoundDateExpression}) * @return the zero-based position of the argument to traverse * into to look for a primary key column reference, or * {@value #NO_TRAVERSAL} if the function cannot be used to * form the scan key. */ public int getKeyFormationTraversalIndex() { return preservesOrder() == OrderPreserving.NO ? NO_TRAVERSAL : 0; }
@Override public OrderPreserving preservesOrder() { return udfFunction.preservesOrder(); }
/** * Determines whether or not a function may be used to form * the start/stop key of a scan * When OrderPreserving is YES, in order to make order-by optimization * valid, it should return 0. (refer to {@link RoundDateExpression}) * @return the zero-based position of the argument to traverse * into to look for a primary key column reference, or * {@value #NO_TRAVERSAL} if the function cannot be used to * form the scan key. */ public int getKeyFormationTraversalIndex() { return preservesOrder() == OrderPreserving.NO ? NO_TRAVERSAL : 0; }
@Override public OrderPreserving preservesOrder() { return udfFunction.preservesOrder(); }
@Override public Iterator<Expression> visitEnter(ScalarFunction node) { return node.preservesOrder() == OrderPreserving.NO ? Collections.<Expression> emptyIterator() : Iterators .singletonIterator(node.getChildren().get(node.getKeyFormationTraversalIndex())); }
@Override public Iterator<Expression> visitEnter(ScalarFunction node) { return node.preservesOrder() == OrderPreserving.NO ? Collections.<Expression> emptyIterator() : Iterators .singletonIterator(node.getChildren().get(node.getKeyFormationTraversalIndex())); }
@Override public Info visitLeave(ScalarFunction node, List<Info> l) { if (l.isEmpty()) { return null; } Info info = l.get(0); // Keep the minimum value between this function and the current value, // so that we never increase OrderPreserving from NO or YES_IF_LAST. OrderPreserving orderPreserving = OrderPreserving.values()[Math.min(node.preservesOrder().ordinal(), info.orderPreserving.ordinal())]; if (orderPreserving == info.orderPreserving) { return info; } return new Info(info, orderPreserving); }
@Override public Info visitLeave(ScalarFunction node, List<Info> l) { if (l.isEmpty()) { return null; } Info info = l.get(0); // Keep the minimum value between this function and the current value, // so that we never increase OrderPreserving from NO or YES_IF_LAST. OrderPreserving orderPreserving = OrderPreserving.values()[Math.min(node.preservesOrder().ordinal(), info.orderPreserving.ordinal())]; if (orderPreserving == info.orderPreserving) { return info; } return new Info(info, orderPreserving); }
private KeySlots newScalarFunctionKeyPart(KeySlot slot, ScalarFunction node) { if (isDegenerate(slot.getKeyRanges())) { return EMPTY_KEY_SLOTS; } KeyPart part = node.newKeyPart(slot.getKeyPart()); if (part == null) { return null; } // Scalar function always returns primitive and never a row value constructor, so span is always 1 return new SingleKeySlot(part, slot.getPKPosition(), slot.getKeyRanges(), node.preservesOrder()); }
private KeySlots newScalarFunctionKeyPart(KeySlot slot, ScalarFunction node) { if (isDegenerate(slot.getKeyRanges())) { return EMPTY_KEY_SLOTS; } KeyPart part = node.newKeyPart(slot.getKeyPart()); if (part == null) { return null; } // Scalar function always returns primitive and never a row value constructor, so span is always 1 return new SingleKeySlot(part, slot.getPKPosition(), slot.getKeyRanges(), node.preservesOrder()); }