private void initForPrimitives(ObjectInspector arg0, ObjectInspector arg1) throws UDFArgumentException {
    assert arg0.getCategory() == Category.PRIMITIVE;
    assert arg1.getCategory() == Category.PRIMITIVE;
    final TypeInfo type0 = TypeInfoUtils.getTypeInfoFromObjectInspector(arg0);
    final TypeInfo type1 = TypeInfoUtils.getTypeInfoFromObjectInspector(arg1);
    if (type0.equals(TypeInfoFactory.stringTypeInfo) && type1.equals(TypeInfoFactory.stringTypeInfo)) {
      soi0 = (StringObjectInspector) arg0;
      soi1 = (StringObjectInspector) arg1;
      if (soi0.preferWritable() || soi1.preferWritable()) {
        compareType = CompareType.COMPARE_TEXT;
      } else {
        compareType = CompareType.COMPARE_STRING;
      }
    } else if (type0.equals(TypeInfoFactory.intTypeInfo) && type1.equals(TypeInfoFactory.intTypeInfo)) {
      compareType = CompareType.COMPARE_INT;
      ioi0 = (IntObjectInspector) arg0;
      ioi1 = (IntObjectInspector) arg1;
    } else if (type0.equals(TypeInfoFactory.longTypeInfo) && type1.equals(TypeInfoFactory.longTypeInfo)) {
      compareType = CompareType.COMPARE_LONG;
      loi0 = (LongObjectInspector) arg0;
      loi1 = (LongObjectInspector) arg1;
    } else if (type0.equals(TypeInfoFactory.byteTypeInfo) && type1.equals(TypeInfoFactory.byteTypeInfo)) {
      compareType = CompareType.COMPARE_BYTE;
      byoi0 = (ByteObjectInspector) arg0;
      byoi1 = (ByteObjectInspector) arg1;
    } else if (type0.equals(TypeInfoFactory.booleanTypeInfo) && type1.equals(TypeInfoFactory.booleanTypeInfo)) {
      compareType = CompareType.COMPARE_BOOL;
      boi0 = (BooleanObjectInspector) arg0;
      boi1 = (BooleanObjectInspector) arg1;
    } else {
      if (type0 == type1 || TypeInfoUtils.doPrimitiveCategoriesMatch(type0, type1)) {
        compareType = CompareType.SAME_TYPE;
      } else {
        compareType = CompareType.NEED_CONVERT;
        TypeInfo compareType = FunctionRegistry.getCommonClassForComparison(type0, type1);

        // For now, we always convert to double if we can't find a common type
        compareOI = TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(
            (compareType == null) ? TypeInfoFactory.doubleTypeInfo : compareType);

        converter0 = ObjectInspectorConverters.getConverter(arg0, compareOI);
        converter1 = ObjectInspectorConverters.getConverter(arg1, compareOI);

        checkConversionAllowed(arg0, compareOI);
        checkConversionAllowed(arg1, compareOI);
      }
    }
  }
Returns whether the operator can handle operands with the specified category.
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFBaseCompare.java