@Override
  public boolean isEqual(final OBinaryField iField1, final OBinaryField iField2) {
    final BytesContainer fieldValue1 = iField1.bytes;
    final int offset1 = fieldValue1.offset;

    final BytesContainer fieldValue2 = iField2.bytes;
    final int offset2 = fieldValue2.offset;

    try {
      switch (iField1.type) {
      case INTEGER: {
        final int value1 = OVarIntSerializer.readAsInteger(fieldValue1);

        switch (iField2.type) {
        case INTEGER: {
          final int value2 = OVarIntSerializer.readAsInteger(fieldValue2);
          return value1 == value2;
        }
        case LONG:
        case DATETIME: {
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2);
          return value1 == value2;
        }
        case DATE: {
          final long value2 = (OVarIntSerializer.readAsLong(fieldValue2) * MILLISEC_PER_DAY);
          return value1 == value2;
        }
        case SHORT: {
          final short value2 = OVarIntSerializer.readAsShort(fieldValue2);
          return value1 == value2;
        }
        case BYTE: {
          final byte value2 = readByte(fieldValue2);
          return value1 == value2;
        }
        case FLOAT: {
          final float value2 = Float.intBitsToFloat(readInteger(fieldValue2));
          return value1 == value2;
        }
        case DOUBLE: {
          final double value2 = Double.longBitsToDouble(readLong(fieldValue2));
          return value1 == value2;
        }
        case STRING: {
          return Integer.parseInt(readString(fieldValue2)) == value1;
        }
        case DECIMAL: {
          final BigDecimal value2 = ODecimalSerializer.INSTANCE.deserialize(fieldValue2.bytes, fieldValue2.offset);
          return value1 == value2.intValue();
        }
        }
        break;
      }

      case LONG: {
        final long value1 = OVarIntSerializer.readAsLong(fieldValue1);

        switch (iField2.type) {
        case INTEGER: {
          final int value2 = OVarIntSerializer.readAsInteger(fieldValue2);
          return value1 == value2;
        }
        case LONG:
        case DATETIME: {
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2);
          return value1 == value2;
        }
        case DATE: {
          final long value2 = (OVarIntSerializer.readAsLong(fieldValue2) * MILLISEC_PER_DAY);
          return value1 == value2;
        }
        case SHORT: {
          final short value2 = OVarIntSerializer.readAsShort(fieldValue2);
          return value1 == value2;
        }
        case BYTE: {
          final byte value2 = readByte(fieldValue2);
          return value1 == value2;
        }
        case FLOAT: {
          final float value2 = Float.intBitsToFloat(readInteger(fieldValue2));
          return value1 == value2;
        }
        case DOUBLE: {
          final double value2 = Double.longBitsToDouble(readLong(fieldValue2));
          return value1 == value2;
        }
        case STRING: {
          return Long.parseLong(readString(fieldValue2)) == value1;
        }
        case DECIMAL: {
          final BigDecimal value2 = ODecimalSerializer.INSTANCE.deserialize(fieldValue2.bytes, fieldValue2.offset);
          return value1 == value2.longValue();
        }
        }
        break;
      }

      case SHORT: {
        final short value1 = OVarIntSerializer.readAsShort(fieldValue1);

        switch (iField2.type) {
        case INTEGER: {
          final int value2 = OVarIntSerializer.readAsInteger(fieldValue2);
          return value1 == value2;
        }
        case LONG:
        case DATETIME: {
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2);
          return value1 == value2;
        }
        case DATE: {
          final long value2 = (OVarIntSerializer.readAsLong(fieldValue2) * MILLISEC_PER_DAY);
          return value1 == value2;
        }
        case SHORT: {
          final short value2 = OVarIntSerializer.readAsShort(fieldValue2);
          return value1 == value2;
        }
        case BYTE: {
          final byte value2 = readByte(fieldValue2);
          return value1 == value2;
        }
        case FLOAT: {
          final float value2 = Float.intBitsToFloat(readInteger(fieldValue2));
          return value1 == value2;
        }
        case DOUBLE: {
          final double value2 = Double.longBitsToDouble(readLong(fieldValue2));
          return value1 == value2;
        }
        case STRING: {
          return Short.parseShort(readString(fieldValue2)) == value1;
        }
        case DECIMAL: {
          final BigDecimal value2 = ODecimalSerializer.INSTANCE.deserialize(fieldValue2.bytes, fieldValue2.offset);
          return value1 == value2.shortValue();
        }
        }
        break;
      }

      case STRING: {
        switch (iField2.type) {
        case INTEGER: {
          final int value2 = OVarIntSerializer.readAsInteger(fieldValue2);
          return Integer.parseInt(readString(fieldValue1)) == value2;
        }
        case LONG:
        case DATETIME: {
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2);
          return Long.parseLong(readString(fieldValue1)) == value2;
        }
        case DATE: {
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2) * MILLISEC_PER_DAY;
          return Long.parseLong(readString(fieldValue1)) == value2;
        }
        case SHORT: {
          final short value2 = OVarIntSerializer.readAsShort(fieldValue2);
          return Short.parseShort(readString(fieldValue1)) == value2;
        }
        case BYTE: {
          final byte value2 = readByte(fieldValue2);
          return Byte.parseByte(readString(fieldValue1)) == value2;
        }
        case FLOAT: {
          final float value2 = Float.intBitsToFloat(readInteger(fieldValue2));
          return Float.parseFloat(readString(fieldValue1)) == value2;
        }
        case DOUBLE: {
          final double value2 = Double.longBitsToDouble(readLong(fieldValue2));
          return Double.parseDouble(readString(fieldValue1)) == value2;
        }
        case STRING: {
          final int len1 = OVarIntSerializer.readAsInteger(fieldValue1);
          final int len2 = OVarIntSerializer.readAsInteger(fieldValue2);

          if (len1 != len2)
            return false;

          final OCollate collate = (iField1.collate != null && !ODefaultCollate.NAME.equals(iField1.collate.getName())) ?
              iField1.collate :
              (iField2.collate != null && !ODefaultCollate.NAME.equals(iField2.collate.getName()) ? iField2.collate : null);

          if (collate != null) {
            final String str1 = (String) collate.transform(stringFromBytes(fieldValue1.bytes, fieldValue1.offset, len1));
            final String str2 = (String) collate.transform(stringFromBytes(fieldValue2.bytes, fieldValue2.offset, len2));

            return str1.equals(str2);

          } else {
            for (int i = 0; i < len1; ++i) {
              if (fieldValue1.bytes[fieldValue1.offset + i] != fieldValue2.bytes[fieldValue2.offset + i])
                return false;
            }
          }
          return true;
        }
        case DECIMAL: {
          final BigDecimal value2 = ODecimalSerializer.INSTANCE.deserialize(fieldValue2.bytes, fieldValue2.offset);
          return new BigDecimal(readString(fieldValue1)).equals(value2);
        }
        case BOOLEAN: {
          final boolean value2 = readByte(fieldValue2) == 1;
          return Boolean.parseBoolean(readString(fieldValue1)) == value2;
        }
        }
        break;
      }

      case DOUBLE: {
        final long value1AsLong = readLong(fieldValue1);

        switch (iField2.type) {
        case INTEGER: {
          final double value1 = Double.longBitsToDouble(value1AsLong);
          final int value2 = OVarIntSerializer.readAsInteger(fieldValue2);
          return value1 == value2;
        }
        case LONG:
        case DATETIME: {
          final double value1 = Double.longBitsToDouble(value1AsLong);
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2);
          return value1 == value2;
        }
        case SHORT: {
          final double value1 = Double.longBitsToDouble(value1AsLong);
          final short value2 = OVarIntSerializer.readAsShort(fieldValue2);
          return value1 == value2;
        }
        case BYTE: {
          final double value1 = Double.longBitsToDouble(value1AsLong);
          final byte value2 = readByte(fieldValue2);
          return value1 == value2;
        }
        case FLOAT: {
          final double value1 = Double.longBitsToDouble(value1AsLong);
          final float value2 = Float.intBitsToFloat(readInteger(fieldValue2));
          return value1 == value2;
        }
        case DOUBLE: {
          final double value2AsLong = readLong(fieldValue2);
          return value1AsLong == value2AsLong;
        }
        case STRING: {
          final double value1 = Double.longBitsToDouble(value1AsLong);
          return Double.parseDouble(readString(fieldValue2)) == value1;
        }
        case DECIMAL: {
          final double value1 = Double.longBitsToDouble(value1AsLong);
          final BigDecimal value2 = ODecimalSerializer.INSTANCE.deserialize(fieldValue2.bytes, fieldValue2.offset);
          return value1 == value2.doubleValue();
        }
        }
        break;
      }

      case FLOAT: {
        final int value1AsInt = readInteger(fieldValue1);

        switch (iField2.type) {
        case INTEGER: {
          final float value1 = Float.intBitsToFloat(value1AsInt);
          final int value2 = OVarIntSerializer.readAsInteger(fieldValue2);
          return value1 == value2;
        }
        case LONG:
        case DATETIME: {
          final float value1 = Float.intBitsToFloat(value1AsInt);
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2);
          return value1 == value2;
        }
        case SHORT: {
          final float value1 = Float.intBitsToFloat(value1AsInt);
          final short value2 = OVarIntSerializer.readAsShort(fieldValue2);
          return value1 == value2;
        }
        case BYTE: {
          final float value1 = Float.intBitsToFloat(value1AsInt);
          final byte value2 = readByte(fieldValue2);
          return value1 == value2;
        }
        case FLOAT: {
          final float value2AsInt = readInteger(fieldValue2);
          return value1AsInt == value2AsInt;
        }
        case DOUBLE: {
          final float value1 = Float.intBitsToFloat(value1AsInt);
          final double value2 = Double.longBitsToDouble(readLong(fieldValue2));
          return value1 == value2;
        }
        case STRING: {
          final float value1 = Float.intBitsToFloat(value1AsInt);
          return Float.parseFloat(readString(fieldValue2)) == value1;
        }
        case DECIMAL: {
          final float value1 = Float.intBitsToFloat(value1AsInt);
          final BigDecimal value2 = ODecimalSerializer.INSTANCE.deserialize(fieldValue2.bytes, fieldValue2.offset);
          return value1 == value2.floatValue();
        }
        }
        break;
      }

      case BYTE: {
        final byte value1 = readByte(fieldValue1);

        switch (iField2.type) {
        case INTEGER: {
          final int value2 = OVarIntSerializer.readAsInteger(fieldValue2);
          return value1 == value2;
        }
        case LONG:
        case DATETIME: {
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2);
          return value1 == value2;
        }
        case SHORT: {
          final short value2 = OVarIntSerializer.readAsShort(fieldValue2);
          return value1 == value2;
        }
        case BYTE: {
          final byte value2 = readByte(fieldValue2);
          return value1 == value2;
        }
        case FLOAT: {
          final float value2 = Float.intBitsToFloat(readInteger(fieldValue2));
          return value1 == value2;
        }
        case DOUBLE: {
          final double value2 = Double.longBitsToDouble(readLong(fieldValue2));
          return value1 == value2;
        }
        case STRING: {
          final byte value2 = Byte.parseByte((readString(fieldValue2)));
          return value1 == value2;
        }
        case DECIMAL: {
          final BigDecimal value2 = ODecimalSerializer.INSTANCE.deserialize(fieldValue2.bytes, fieldValue2.offset);
          return value1 == value2.byteValue();
        }
        }
        break;
      }

      case BOOLEAN: {
        final boolean value1 = readByte(fieldValue1) == 1;

        switch (iField2.type) {
        case BOOLEAN: {
          final boolean value2 = readByte(fieldValue2) == 1;
          return value1 == value2;
        }
        case STRING: {
          final String str = readString(fieldValue2);
          return Boolean.parseBoolean(str) == value1;
        }
        }
        break;
      }

      case DATE: {
        final long value1 = OVarIntSerializer.readAsLong(fieldValue1) * MILLISEC_PER_DAY;

        switch (iField2.type) {
        case INTEGER: {
          final int value2 = OVarIntSerializer.readAsInteger(fieldValue2);
          return value1 == value2;
        }
        case LONG:
        case DATETIME: {
          long value2 = OVarIntSerializer.readAsLong(fieldValue2);
          value2 = convertDayToTimezone(ODateHelper.getDatabaseTimeZone(), TimeZone.getTimeZone("GMT"), value2);
          return value1 == value2;
        }
        case DATE: {
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2) * MILLISEC_PER_DAY;
          return value1 == value2;
        }
        case SHORT: {
          final short value2 = OVarIntSerializer.readAsShort(fieldValue2);
          return value1 == value2;
        }
        case FLOAT: {
          final float value2 = Float.intBitsToFloat(readInteger(fieldValue2));
          return value1 == value2;
        }
        case DOUBLE: {
          final double value2 = Double.longBitsToDouble(readLong(fieldValue2));
          return value1 == value2;
        }
        case STRING: {

        }
        case DECIMAL: {
          final BigDecimal value2 = ODecimalSerializer.INSTANCE.deserialize(fieldValue2.bytes, fieldValue2.offset);
          return value1 == value2.longValue();
        }
        }
        break;
      }

      case DATETIME: {
        final long value1 = OVarIntSerializer.readAsLong(fieldValue1);

        switch (iField2.type) {
        case INTEGER: {
          final int value2 = OVarIntSerializer.readAsInteger(fieldValue2);
          return value1 == value2;
        }
        case LONG:
        case DATETIME: {
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2);
          return value1 == value2;
        }
        case DATE: {
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2) * MILLISEC_PER_DAY;
          return value1 == value2;
        }
        case SHORT: {
          final short value2 = OVarIntSerializer.readAsShort(fieldValue2);
          return value1 == value2;
        }
        case FLOAT: {
          final float value2 = Float.intBitsToFloat(readInteger(fieldValue2));
          return value1 == value2;
        }
        case DOUBLE: {
          final double value2 = Double.longBitsToDouble(readLong(fieldValue2));
          return value1 == value2;
        }
        case STRING: {
          final String value2AsString = readString(fieldValue2);

          if (OIOUtils.isLong(value2AsString)) {
            final long value2 = Long.parseLong(value2AsString);
            return value1 == value2;
          }

          final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined();
          try {
            final SimpleDateFormat dateFormat = db != null ?
                db.getStorage().getConfiguration().getDateTimeFormatInstance() :
                new SimpleDateFormat(OStorageConfiguration.DEFAULT_DATETIME_FORMAT);

            final Date value2AsDate = dateFormat.parse(value2AsString);
            final long value2 = value2AsDate.getTime();
            return value1 == value2;
          } catch (ParseException ignore) {
            try {
              final SimpleDateFormat dateFormat = db != null ?
                  db.getStorage().getConfiguration().getDateFormatInstance() :
                  new SimpleDateFormat(OStorageConfiguration.DEFAULT_DATE_FORMAT);

              final Date value2AsDate = dateFormat.parse(value2AsString);
              final long value2 = value2AsDate.getTime();
              return value1 == value2;
            } catch (ParseException ignored) {
              return new Date(value1).toString().equals(value2AsString);
            }
          }
        }
        case DECIMAL: {
          final BigDecimal value2 = ODecimalSerializer.INSTANCE.deserialize(fieldValue2.bytes, fieldValue2.offset);
          return value1 == value2.longValue();
        }
        }
        break;
      }

      case BINARY: {
        switch (iField2.type) {
        case BINARY: {
          final int length1 = OVarIntSerializer.readAsInteger(fieldValue1);
          final int length2 = OVarIntSerializer.readAsInteger(fieldValue2);
          if (length1 != length2)
            return false;

          for (int i = 0; i < length1; ++i) {
            if (fieldValue1.bytes[fieldValue1.offset + i] != fieldValue2.bytes[fieldValue2.offset + i])
              return false;
          }
          return true;
        }
        }
        break;
      }

      case LINK: {
        switch (iField2.type) {
        case LINK: {
          final int clusterId1 = OVarIntSerializer.readAsInteger(fieldValue1);
          final int clusterId2 = OVarIntSerializer.readAsInteger(fieldValue2);
          if (clusterId1 != clusterId2)
            return false;

          final long clusterPos1 = OVarIntSerializer.readAsLong(fieldValue1);
          final long clusterPos2 = OVarIntSerializer.readAsLong(fieldValue2);
          if (clusterPos1 == clusterPos2)
            return true;
          break;
        }
        case STRING: {
          return readOptimizedLink(fieldValue1, false).toString().equals(readString(fieldValue2));
        }
        }
        break;
      }

      case DECIMAL: {
        final BigDecimal value1 = ODecimalSerializer.INSTANCE.deserialize(fieldValue1.bytes, fieldValue1.offset);

        switch (iField2.type) {
        case INTEGER: {
          final int value2 = OVarIntSerializer.readAsInteger(fieldValue2);
          return value1.equals(new BigDecimal(value2));
        }
        case LONG:
        case DATETIME: {
          final long value2 = OVarIntSerializer.readAsLong(fieldValue2);
          return value1.equals(new BigDecimal(value2));
        }
        case SHORT: {
          final short value2 = OVarIntSerializer.readAsShort(fieldValue2);
          return value1.equals(new BigDecimal(value2));
        }
        case FLOAT: {
          final float value2 = Float.intBitsToFloat(readInteger(fieldValue2));
          return value1.equals(new BigDecimal(value2));
        }
        case DOUBLE: {
          final double value2 = Double.longBitsToDouble(readLong(fieldValue2));
          return value1.equals(new BigDecimal(value2));
        }
        case STRING: {
          return value1.toString().equals(readString(fieldValue2));
        }
        case DECIMAL: {
          final BigDecimal value2 = ODecimalSerializer.INSTANCE.deserialize(fieldValue2.bytes, fieldValue2.offset);
          return value1.equals(value2);
        }
        }
        break;
      }
      }
    } finally {
      fieldValue1.offset = offset1;
      fieldValue2.offset = offset2;
    }

    return false;
  }
@ Override public boolean isEqual ( final OBinaryField iField1 , final OBinaryField iField2 ) { final BytesContainer fieldValue1 = iField1 . bytes ; final int offset1 = fieldValue1 . offset ; final BytesContainer fieldValue2 = iField2 . bytes ; final int offset2 = fieldValue2 . offset ; try { switch ( iField1 . type ) { case INTEGER : { final int value1 = OVarIntSerializer . readAsInteger ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case DATE : { final long value2 = ( OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ) ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { return Integer . parseInt ( readString ( fieldValue2 ) ) == value1 ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . intValue ( ) ; } } break ; } case LONG : { final long value1 = OVarIntSerializer . readAsLong ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case DATE : { final long value2 = ( OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ) ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { return Long . parseLong ( readString ( fieldValue2 ) ) == value1 ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . longValue ( ) ; } } break ; } case SHORT : { final short value1 = OVarIntSerializer . readAsShort ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case DATE : { final long value2 = ( OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ) ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { return Short . parseShort ( readString ( fieldValue2 ) ) == value1 ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . shortValue ( ) ; } } break ; } case STRING : { switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return Integer . parseInt ( readString ( fieldValue1 ) ) == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return Long . parseLong ( readString ( fieldValue1 ) ) == value2 ; } case DATE : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ; return Long . parseLong ( readString ( fieldValue1 ) ) == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return Short . parseShort ( readString ( fieldValue1 ) ) == value2 ; } case BYTE : { final byte value2 = readByte ( fieldValue2 ) ; return Byte . parseByte ( readString ( fieldValue1 ) ) == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return Float . parseFloat ( readString ( fieldValue1 ) ) == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return Double . parseDouble ( readString ( fieldValue1 ) ) == value2 ; } case STRING : { final int len1 = OVarIntSerializer . readAsInteger ( fieldValue1 ) ; final int len2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; if ( len1 != len2 ) return false ; final OCollate collate = ( iField1 . collate != null && ! ODefaultCollate . NAME . equals ( iField1 . collate . getName ( ) ) ) ? iField1 . collate : ( iField2 . collate != null && ! ODefaultCollate . NAME . equals ( iField2 . collate . getName ( ) ) ? iField2 . collate : null ) ; if ( collate != null ) { final String str1 = ( String ) collate . transform ( stringFromBytes ( fieldValue1 . bytes , fieldValue1 . offset , len1 ) ) ; final String str2 = ( String ) collate . transform ( stringFromBytes ( fieldValue2 . bytes , fieldValue2 . offset , len2 ) ) ; return str1 . equals ( str2 ) ; } else { for ( int i = 0 ; i < len1 ; ++ i ) { if ( fieldValue1 . bytes [ fieldValue1 . offset + i ] != fieldValue2 . bytes [ fieldValue2 . offset + i ] ) return false ; } } return true ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return new BigDecimal ( readString ( fieldValue1 ) ) . equals ( value2 ) ; } case BOOLEAN : { final boolean value2 = readByte ( fieldValue2 ) == 1 ; return Boolean . parseBoolean ( readString ( fieldValue1 ) ) == value2 ; } } break ; } case DOUBLE : { final long value1AsLong = readLong ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case SHORT : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2AsLong = readLong ( fieldValue2 ) ; return value1AsLong == value2AsLong ; } case STRING : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; return Double . parseDouble ( readString ( fieldValue2 ) ) == value1 ; } case DECIMAL : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . doubleValue ( ) ; } } break ; } case FLOAT : { final int value1AsInt = readInteger ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case SHORT : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2AsInt = readInteger ( fieldValue2 ) ; return value1AsInt == value2AsInt ; } case DOUBLE : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; return Float . parseFloat ( readString ( fieldValue2 ) ) == value1 ; } case DECIMAL : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . floatValue ( ) ; } } break ; } case BYTE : { final byte value1 = readByte ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { final byte value2 = Byte . parseByte ( ( readString ( fieldValue2 ) ) ) ; return value1 == value2 ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . byteValue ( ) ; } } break ; } case BOOLEAN : { final boolean value1 = readByte ( fieldValue1 ) == 1 ; switch ( iField2 . type ) { case BOOLEAN : { final boolean value2 = readByte ( fieldValue2 ) == 1 ; return value1 == value2 ; } case STRING : { final String str = readString ( fieldValue2 ) ; return Boolean . parseBoolean ( str ) == value1 ; } } break ; } case DATE : { final long value1 = OVarIntSerializer . readAsLong ( fieldValue1 ) * MILLISEC_PER_DAY ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; value2 = convertDayToTimezone ( ODateHelper . getDatabaseTimeZone ( ) , TimeZone . getTimeZone ( "GMT" ) , value2 ) ; return value1 == value2 ; } case DATE : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . longValue ( ) ; } } break ; } case DATETIME : { final long value1 = OVarIntSerializer . readAsLong ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case DATE : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { final String value2AsString = readString ( fieldValue2 ) ; if ( OIOUtils . isLong ( value2AsString ) ) { final long value2 = Long . parseLong ( value2AsString ) ; return value1 == value2 ; } final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal . instance ( ) . getIfDefined ( ) ; try { final SimpleDateFormat dateFormat = db != null ? db . getStorage ( ) . getConfiguration ( ) . getDateTimeFormatInstance ( ) : new SimpleDateFormat ( OStorageConfiguration . DEFAULT_DATETIME_FORMAT ) ; final Date value2AsDate = dateFormat . parse ( value2AsString ) ; final long value2 = value2AsDate . getTime ( ) ; return value1 == value2 ; } catch ( ParseException ignore ) { try { final SimpleDateFormat dateFormat = db != null ? db . getStorage ( ) . getConfiguration ( ) . getDateFormatInstance ( ) : new SimpleDateFormat ( OStorageConfiguration . DEFAULT_DATE_FORMAT ) ; final Date value2AsDate = dateFormat . parse ( value2AsString ) ; final long value2 = value2AsDate . getTime ( ) ; return value1 == value2 ; } catch ( ParseException ignored ) { return new Date ( value1 ) . toString ( ) . equals ( value2AsString ) ; } } } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . longValue ( ) ; } } break ; } case BINARY : { switch ( iField2 . type ) { case BINARY : { final int length1 = OVarIntSerializer . readAsInteger ( fieldValue1 ) ; final int length2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; if ( length1 != length2 ) return false ; for ( int i = 0 ; i < length1 ; ++ i ) { if ( fieldValue1 . bytes [ fieldValue1 . offset + i ] != fieldValue2 . bytes [ fieldValue2 . offset + i ] ) return false ; } return true ; } } break ; } case LINK : { switch ( iField2 . type ) { case LINK : { final int clusterId1 = OVarIntSerializer . readAsInteger ( fieldValue1 ) ; final int clusterId2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; if ( clusterId1 != clusterId2 ) return false ; final long clusterPos1 = OVarIntSerializer . readAsLong ( fieldValue1 ) ; final long clusterPos2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; if ( clusterPos1 == clusterPos2 ) return true ; break ; } case STRING : { return readOptimizedLink ( fieldValue1 , false ) . toString ( ) . equals ( readString ( fieldValue2 ) ) ; } } break ; } case DECIMAL : { final BigDecimal value1 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue1 . bytes , fieldValue1 . offset ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 . equals ( new BigDecimal ( value2 ) ) ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 . equals ( new BigDecimal ( value2 ) ) ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 . equals ( new BigDecimal ( value2 ) ) ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 . equals ( new BigDecimal ( value2 ) ) ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 . equals ( new BigDecimal ( value2 ) ) ; } case STRING : { return value1 . toString ( ) . equals ( readString ( fieldValue2 ) ) ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 . equals ( value2 ) ; } } break ; } } } finally { fieldValue1 . offset = offset1 ; fieldValue2 . offset = offset2 ; } return false ; }
Compares if 2 field values are the same.

@param iField1 First value to compare
@param iField2 Second value to compare

@return true if they match, otherwise false