private static void addDemotionRule(ATypeTag type1, ATypeTag type2, ITypeConvertComputer demoteStrictComputer, ITypeConvertComputer demoteLenientComputer) { int index = type1.ordinal() * ATypeTag.TYPE_COUNT + type2.ordinal(); typeDemotionHierachyMap.set(index); demoteComputerMap.put(index, Pair.of(demoteStrictComputer, demoteLenientComputer)); }
public static ITypeConvertComputer getTypeDemoteComputer(ATypeTag type1, ATypeTag type2, boolean strict) { if (canDemote(type1, type2)) { Pair<ITypeConvertComputer, ITypeConvertComputer> pair = demoteComputerMap.get(type1.ordinal() * ATypeTag.TYPE_COUNT + type2.ordinal()); return strict ? pair.getLeft() : pair.getRight(); } return null; }
@Override public void writeToFuncArgs(List<Mutable<ILogicalExpression>> funcArgs) { super.writeToFuncArgs(funcArgs); // Write search modifier type. funcArgs.add(new MutableObject<ILogicalExpression>( AccessMethodUtils.createInt32Constant(searchModifierType.ordinal()))); // Write similarity threshold. funcArgs.add(new MutableObject<ILogicalExpression>(new ConstantExpression(similarityThreshold))); // Write search key type. funcArgs.add( new MutableObject<ILogicalExpression>(AccessMethodUtils.createInt32Constant(searchKeyType.ordinal()))); // Write full-text search information. funcArgs.add( new MutableObject<ILogicalExpression>(AccessMethodUtils.createBooleanConstant(isFullTextSearchQuery))); // Write key var list. writeVarList(keyVarList, funcArgs); // Write non-key var list. if (nonKeyVarList != null) { writeVarList(nonKeyVarList, funcArgs); } }
private static void generateTests(List<Object[]> outTests, IAType inType, IAType targetType) { int value = inType.getTypeTag().ordinal(); addTest(outTests, inType, createValue(inType, value), targetType, createValue(targetType, value)); if (ATypeHierarchy.canDemote(inType.getTypeTag(), targetType.getTypeTag())) { IAObject inMax = createValue(inType, getMax(inType)); IAObject inMin = createValue(inType, getMin(inType)); IAObject targetMax = createValue(targetType, getMax(targetType)); IAObject targetMin = createValue(targetType, getMin(targetType)); addTest(outTests, inType, inMax, targetType, targetMax); addTest(outTests, inType, inMin, targetType, targetMin); if (!isInteger(inType) && isInteger(targetType)) { addTest(outTests, inType, createValue(inType, getPositiveInfinity(inType)), targetType, targetMax); addTest(outTests, inType, createValue(inType, getNegativeInfinity(inType)), targetType, targetMin); addTest(outTests, inType, createValue(inType, getNaN(inType)), targetType, createValue(targetType, 0)); } } }