private static void dumpRespTypeNum(OMMMsg msg, PrintStream ps) {
   if (msg.getMsgType() == OMMMsg.MsgType.REFRESH_RESP) {
     ps.println(" (" + OMMMsg.RespType.toString(msg.getRespTypeNum()) + ")");
   } else
   // msg.getMsgType() == OMMMsg.OMMMsg.MsgType.UPDATE_RESP
   {
     if ((msg.getMsgModelType() >= RDMMsgTypes.MARKET_PRICE)
         && (msg.getMsgModelType() <= RDMMsgTypes.HISTORY)) {
       ps.println(" (" + RDMInstrument.Update.toString(msg.getRespTypeNum()) + ")");
     }
   }
 }
 /* BID            : REAL      8 : 21.42 <18>		// TSS_HINT_DECIMAL_2
  * ASK            : REAL      8 : 21.43 <18>
  * BIDSIZE        : REAL      8 : 7.0 <0>		// TSS_HINT_DENOM_NONE
  * ASKSIZE        : REAL      8 : 7.0 <0>
  * PRC_QL_CD      : STRING    1 : "0" <261>		// TSS_HINT_MFEED_ENUMERATED
  * BID_MMID1      : STRING    4 : "NAS "
  * ASK_MMID1      : STRING    4 : "NAS "
  * GV1_TEXT       : STRING    6 : "A     "
  * QUOTIM         : STRING    8 : "14:33:44" <260>	// TSS_HINT_MFEED_TIME_SECONDS
  * PRC_QL3        : STRING    1 : "0" <261>
  * QUOTIM_MS      : REAL      8 : 5.2424789E7 <0>
  *
  * <!-- rwfMajorVer="14" rwfMinorVer="0" -->
  * <updateMsg domainType="RSSL_DMT_MARKET_PRICE" streamId="5" containerType="RSSL_DT_FIELD_LIST" flags="0x10 (RSSL_UPMF_HAS_SEQ_NUM)" updateType="1" seqNum="3632" dataSize="70">
  *     <dataBody>
  *         <fieldList flags="0x8 (RSSL_FLF_HAS_STANDARD_DATA)">
  *             <fieldEntry fieldId="22" dataType="RSSL_DT_REAL" data="21.42"/>
  *             <fieldEntry fieldId="25" dataType="RSSL_DT_REAL" data="21.43"/>
  *             <fieldEntry fieldId="30" dataType="RSSL_DT_REAL" data="7"/>
  *             <fieldEntry fieldId="31" dataType="RSSL_DT_REAL" data="7"/>
  *             <fieldEntry fieldId="118" dataType="RSSL_DT_ENUM" data="0"/>
  *             <fieldEntry fieldId="293" dataType="RSSL_DT_RMTES_STRING" data="NAS"/>
  *             <fieldEntry fieldId="296" dataType="RSSL_DT_RMTES_STRING" data="NAS"/>
  *             <fieldEntry fieldId="1000" dataType="RSSL_DT_RMTES_STRING" data="A"/>
  *             <fieldEntry fieldId="1025" dataType="RSSL_DT_TIME" data=" 14:33:44:000"/>
  *             <fieldEntry fieldId="3264" dataType="RSSL_DT_ENUM" data="0"/>
  *             <fieldEntry fieldId="3855" dataType="RSSL_DT_UINT" data="52424789"/>
  *         </fieldList>
  *     </dataBody>
  * </updateMsg>
  */
 @SuppressWarnings("unchecked")
 @BeforeExperiment
 void setUp() {
   pool =
       OMMPool.create(
           "RWF", 14, /* RWF major version */ 0, /* RWF minor version */ OMMPool.SINGLE_THREADED);
   OMMEncoder encoder = pool.acquireEncoder();
   encoder.initialize(OMMTypes.MSG, 500);
   msg = pool.acquireMsg();
   msg.setMsgType(OMMMsg.MsgType.UPDATE_RESP);
   msg.setMsgModelType(RDMMsgTypes.MARKET_PRICE);
   msg.setSeqNum(3632);
   msg.setRespTypeNum(RDMInstrument.Update.QUOTE);
   encoder.encodeMsgInit(msg, OMMTypes.NO_DATA, OMMTypes.FIELD_LIST);
   encoder.encodeFieldListInit(
       OMMFieldList.HAS_STANDARD_DATA,
       (short) 1, /* dictionaryId */
       (short) 78, /* fieldListNumber */
       (short) 0); /* dataDefId */
   final ImmutableMap<String, FidDef> dict = ImmutableMap.copyOf(dictionary.toNameMap());
   encoder.encodeFieldEntryInit(dict.get("BID").getFieldId(), OMMTypes.REAL);
   encoder.encodeReal((long) (21.42 * 100), OMMNumeric.EXPONENT_NEG2);
   encoder.encodeFieldEntryInit(dict.get("ASK").getFieldId(), OMMTypes.REAL);
   encoder.encodeReal((long) (21.43 * 100), OMMNumeric.EXPONENT_NEG2);
   encoder.encodeFieldEntryInit(dict.get("BIDSIZE").getFieldId(), OMMTypes.REAL);
   encoder.encodeReal(7L, OMMNumeric.EXPONENT_0);
   encoder.encodeFieldEntryInit(dict.get("ASKSIZE").getFieldId(), OMMTypes.REAL);
   encoder.encodeReal(7L, OMMNumeric.EXPONENT_0);
   encoder.encodeFieldEntryInit(dict.get("PRC_QL_CD").getFieldId(), OMMTypes.ENUM);
   encoder.encodeEnum(0);
   encoder.encodeFieldEntryInit(dict.get("BID_MMID1").getFieldId(), OMMTypes.RMTES_STRING);
   encoder.encodeString("NAS", OMMTypes.RMTES_STRING);
   encoder.encodeFieldEntryInit(dict.get("ASK_MMID1").getFieldId(), OMMTypes.RMTES_STRING);
   encoder.encodeString("NAS", OMMTypes.RMTES_STRING);
   encoder.encodeFieldEntryInit(dict.get("GV1_TEXT").getFieldId(), OMMTypes.RMTES_STRING);
   encoder.encodeString("A", OMMTypes.RMTES_STRING);
   encoder.encodeFieldEntryInit(dict.get("QUOTIM").getFieldId(), OMMTypes.TIME);
   encoder.encodeTime(14, 33, 44, 0);
   encoder.encodeFieldEntryInit(dict.get("PRC_QL3").getFieldId(), OMMTypes.ENUM);
   encoder.encodeEnum(0);
   encoder.encodeFieldEntryInit(dict.get("QUOTIM_MS").getFieldId(), OMMTypes.UINT);
   encoder.encodeUInt(52424789L);
   encoder.encodeAggregateComplete();
   msg = (OMMMsg) encoder.getEncodedObject();
 }
 @Benchmark
 long OmmFind(int reps) {
   long dummy = 0;
   for (int i = 0; i < reps; ++i) {
     final OMMFieldList fieldlist = (OMMFieldList) msg.getPayload();
     dummy |=
         fieldlist.find(biddef.getFieldId()).getData(biddef.getOMMType()).toString().hashCode();
     dummy |=
         fieldlist.find(askdef.getFieldId()).getData(askdef.getOMMType()).toString().hashCode();
   }
   return dummy;
 }
 @Benchmark
 long OmmIterate(int reps) {
   long dummy = 0;
   String bid, ask;
   for (int i = 0; i < reps; ++i) {
     bid = ask = null;
     for (Iterator<?> it = ((OMMIterable) msg.getPayload()).iterator(); it.hasNext(); ) {
       final OMMFieldEntry field = (OMMFieldEntry) it.next();
       if (biddef.getFieldId() == field.getFieldId())
         bid = field.getData(biddef.getOMMType()).toString();
       else if (askdef.getFieldId() == field.getFieldId())
         ask = field.getData(askdef.getOMMType()).toString();
       if (null != bid && null != ask) break;
     }
     dummy |= bid.hashCode();
     dummy |= ask.hashCode();
   }
   return dummy;
 }
  static final void parseMsg(OMMMsg msg, PrintStream ps, int tabLevel) {
    msg.getMsgType();
    dumpIndent(ps, tabLevel);
    ps.println("MESSAGE");
    dumpIndent(ps, tabLevel + 1);
    ps.println("Msg Type: " + OMMMsg.MsgType.toString(msg.getMsgType()));
    dumpIndent(ps, tabLevel + 1);
    ps.println("Msg Model Type: " + RDMMsgTypes.toString(msg.getMsgModelType()));
    dumpIndent(ps, tabLevel + 1);
    ps.println("Indication Flags: " + OMMMsg.Indication.indicationString(msg));

    dumpIndent(ps, tabLevel + 1);
    ps.println("Hint Flags: " + hintString(msg));

    if ((msg.getDataType() == OMMTypes.ANSI_PAGE) && msg.isSet(OMMMsg.Indication.CLEAR_CACHE)) {
      CURRENT_PAGE = null;
    }

    if (msg.has(OMMMsg.HAS_STATE)) {
      dumpIndent(ps, tabLevel + 1);
      ps.println("State: " + msg.getState());
    }
    if (msg.has(OMMMsg.HAS_PRIORITY)) {
      dumpIndent(ps, tabLevel + 1);
      OMMPriority p = msg.getPriority();
      if (p != null) ps.println("Priority: " + p.getPriorityClass() + "," + p.getCount());
      else ps.println("Priority: Error flag recieved but there is not priority present");
    }
    if (msg.has(OMMMsg.HAS_QOS)) {
      dumpIndent(ps, tabLevel + 1);
      ps.println("Qos: " + msg.getQos());
    }
    if (msg.has(OMMMsg.HAS_QOS_REQ)) {
      dumpIndent(ps, tabLevel + 1);
      ps.println("QosReq: " + msg.getQosReq());
    }
    if (msg.has(OMMMsg.HAS_ITEM_GROUP)) {
      dumpIndent(ps, tabLevel + 1);
      ps.println("Group: " + msg.getItemGroup());
    }
    if (msg.has(OMMMsg.HAS_PERMISSION_DATA)) {
      byte[] permdata = msg.getPermissionData();

      dumpIndent(ps, tabLevel + 1);
      ps.print("PermissionData: " + HexDump.toHexString(permdata, false));
      ps.println(" ( " + HexDump.formatHexString(permdata) + " ) ");
    }
    if (msg.has(OMMMsg.HAS_SEQ_NUM)) {
      dumpIndent(ps, tabLevel + 1);
      ps.println("SeqNum: " + msg.getSeqNum());
    }

    if (msg.has(OMMMsg.HAS_CONFLATION_INFO)) {
      dumpIndent(ps, tabLevel + 1);
      ps.println("Conflation Count: " + msg.getConflationCount());
      dumpIndent(ps, tabLevel + 1);
      ps.println("Conflation Time: " + msg.getConflationTime());
    }

    if (msg.has(OMMMsg.HAS_RESP_TYPE_NUM)) {
      dumpIndent(ps, tabLevel + 1);
      ps.print("RespTypeNum: " + msg.getRespTypeNum());
      dumpRespTypeNum(msg, ps);
    }

    if (msg.has(OMMMsg.HAS_ID)) {
      dumpIndent(ps, tabLevel + 1);
      ps.println("Id: " + msg.getId());
    }

    if ((msg.has(OMMMsg.HAS_PUBLISHER_INFO)) || (msg.getMsgType() == OMMMsg.MsgType.POST)) {
      PublisherPrincipalIdentity pi = (PublisherPrincipalIdentity) msg.getPrincipalIdentity();
      if (pi != null) {
        dumpIndent(ps, tabLevel + 1);
        ps.println("Publisher Address: 0x" + Long.toHexString(pi.getPublisherAddress()));
        dumpIndent(ps, tabLevel + 1);
        ps.println("Publisher Id: " + pi.getPublisherId());
      }
    }

    if (msg.has(OMMMsg.HAS_USER_RIGHTS)) {
      dumpIndent(ps, tabLevel + 1);
      ps.println(
          "User Rights Mask: " + OMMMsg.UserRights.userRightsString(msg.getUserRightsMask()));
    }

    if (msg.has(OMMMsg.HAS_ATTRIB_INFO)) {
      dumpIndent(ps, tabLevel + 1);
      ps.println("AttribInfo");
      OMMAttribInfo ai = msg.getAttribInfo();
      if (ai.has(OMMAttribInfo.HAS_SERVICE_NAME)) {
        dumpIndent(ps, tabLevel + 2);
        ps.println("ServiceName: " + ai.getServiceName());
      }
      if (ai.has(OMMAttribInfo.HAS_SERVICE_ID)) {
        dumpIndent(ps, tabLevel + 2);
        ps.println("ServiceId: " + ai.getServiceID());
      }
      if (ai.has(OMMAttribInfo.HAS_NAME)) {
        dumpIndent(ps, tabLevel + 2);
        ps.println("Name: " + ai.getName());
      }
      if (ai.has(OMMAttribInfo.HAS_NAME_TYPE)) {
        dumpIndent(ps, tabLevel + 2);
        ps.print("NameType: " + ai.getNameType());
        if (msg.getMsgModelType() == RDMMsgTypes.LOGIN) {
          ps.println(" (" + RDMUser.NameType.toString(ai.getNameType()) + ")");
        } else if (RDMInstrument.isInstrumentMsgModelType(msg.getMsgModelType())) {

          ps.println(" (" + RDMInstrument.NameType.toString(ai.getNameType()) + ")");
        } else {
          ps.println();
        }
      }
      if (ai.has(OMMAttribInfo.HAS_FILTER)) {
        dumpIndent(ps, tabLevel + 2);
        ps.print("Filter: " + ai.getFilter());
        if (msg.getMsgModelType() == RDMMsgTypes.DIRECTORY) {
          ps.println(" (" + RDMService.Filter.toString(ai.getFilter()) + ")");
        } else if (msg.getMsgModelType() == RDMMsgTypes.DICTIONARY) {
          ps.println(" (" + RDMDictionary.Filter.toString(ai.getFilter()) + ")");
        } else {
          ps.println();
        }
      }
      if (ai.has(OMMAttribInfo.HAS_ID)) {
        dumpIndent(ps, tabLevel + 2);
        ps.println("ID: " + ai.getId());
      }
      if (ai.has(OMMAttribInfo.HAS_ATTRIB)) {
        dumpIndent(ps, tabLevel + 2);
        ps.println("Attrib");
        parseData(ai.getAttrib(), ps, tabLevel + 2);
      }
    }

    dumpIndent(ps, tabLevel + 1);
    ps.print("Payload: ");
    if (msg.getDataType() != OMMTypes.NO_DATA) {
      ps.println(msg.getPayload().getEncodedLength() + " bytes");
      parseData(msg.getPayload(), ps, tabLevel + 1);
    } else {
      ps.println("None");
    }
  }
  private static final String hintString(OMMMsg msg) {
    StringBuilder buf = new StringBuilder(60);

    boolean bAppend = true;

    if (msg.has(OMMMsg.HAS_ATTRIB_INFO)) {
      bAppend = append(buf, "HAS_ATTRIB_INFO", bAppend);
    }
    if (msg.has(OMMMsg.HAS_CONFLATION_INFO)) {
      bAppend = append(buf, "HAS_CONFLATION_INFO", bAppend);
    }
    if (msg.has(OMMMsg.HAS_HEADER)) {
      bAppend = append(buf, "HAS_HEADER", bAppend);
    }
    if (msg.has(OMMMsg.HAS_ITEM_GROUP)) {
      bAppend = append(buf, "HAS_ITEM_GROUP", bAppend);
    }
    if (msg.has(OMMMsg.HAS_PERMISSION_DATA)) {
      bAppend = append(buf, "HAS_PERMISSION_DATA", bAppend);
    }
    if (msg.has(OMMMsg.HAS_PRIORITY)) {
      bAppend = append(buf, "HAS_PRIORITY", bAppend);
    }
    if (msg.has(OMMMsg.HAS_QOS)) {
      bAppend = append(buf, "HAS_QOS", bAppend);
    }
    if (msg.has(OMMMsg.HAS_QOS_REQ)) {
      bAppend = append(buf, "HAS_QOS_REQ", bAppend);
    }
    if (msg.has(OMMMsg.HAS_RESP_TYPE_NUM)) {
      bAppend = append(buf, "HAS_RESP_TYPE_NUM", bAppend);
    }
    if (msg.has(OMMMsg.HAS_SEQ_NUM)) {
      bAppend = append(buf, "HAS_SEQ_NUM", bAppend);
    }
    if (msg.has(OMMMsg.HAS_ID)) {
      bAppend = append(buf, "HAS_ID", bAppend);
    }
    if (msg.has(OMMMsg.HAS_PUBLISHER_INFO)) {
      bAppend = append(buf, "HAS_PUBLISHER_INFO", bAppend);
    }
    if (msg.has(OMMMsg.HAS_STATE)) {
      bAppend = append(buf, "HAS_STATE", bAppend);
    }
    if (msg.has(OMMMsg.HAS_USER_RIGHTS)) {
      bAppend = append(buf, "HAS_USER_RIGHTS", bAppend);
    }

    return buf.toString();
  }