Table of contents


A Presence Map (or "PMap" as it is commonly called) occurs at the beginning of each FAST message and sometimes within a FAST message. It has bits representing each field in the message (that is not 'required', defined later) to indicate whether or not that field is present in the message body. If our FAST message includes a repeating sequence where any field requires a PMap bit, then a PMap will be present before each group of the sequence.
General structure of full FAST message is shown on the Picture 3.4

FAST message structure

Picture 3.4 - "FAST message structure"

A presence map is represented as a stop bit encoded entity. It is a sequence of bits with each bit representing a template field according to sequence. PresenceMap indicates which fields in the template have data present and which fields have data implied. Fields with data present have the PMap bit set to ‘1’. Fields with data implied have the PMap bit set to ‘0’ (does not present in the stream). So if PMap bit set to ‘1’ we should decode value for appropriate bit, like:

if (presenceMap.isNextPMapBitSet()) {
     offset = dataTypeDecoder.decode(encodedData, offset, templateField);

Logically a PresenceMap has an infinite suffix of zeroes. This makes it possible to truncate a PresenceMap that ends in a sequence where the bits are all zero. This concept is shown below.

Picture 3.5 - "PMap infinite suffix of zeroes"

The decoder's implementation should be able to determine if a PMap has a particular value. For example:

 * Returns boolean representation of the presence map bit in the next position
 * (true - "1", false - "0") 
 * @return true if bit in the next position of the presence map is set to "1"  
public boolean isNextPMapBitSet() {     
    //Check if our PresenceMap object is empty (not initialized) or just has
    //no more data in the input stream (that is has infinitive suffix of zeros).
    //So it will always return false (that means PMap bit “0” or “not set PMap bit”)
    //for the template fields which call this method.
    if (isEmptyPMap) {
         return false;
    //Check if input stream does not contain bytes that related to the PresenceMap.
    //If so, we set value isEmptyPMap to “true” and return “false”
    //as value from previous condition.
    if (offset > lastPMapBytePosition) {
        isEmptyPMap = true;
        return false;
     //Define actual PMap stop bit value for field that calls this method.
     boolean bitOnPosition = isBitOnPositionSet(currentByte, currentBitPosition);
     //Increment our index of bit in the byte that will be used as PMap stop bit
     //for the next field which will call this method.
     //Check if our bit index (currentBitPosition) is 8 (1 byte has 8 bits.
     //If we count it from 0, the last should be 7 so the eighth is not
     //correct value as index). In such case we set bit index to 1 (0 index is
     //stop bit in the byte and is not used) and use next byte from the input stream.
     if (currentBitPosition == NUMBER_BITS_IN_BYTE) {
         currentBitPosition = 1;
         currentByte = data[offset];
     //return stop bit value in the boolean representation
     return bitOnPosition;


In our own implementation of a PresenceMap class, we do not extract the PMap bits and copy them to a new location, but instead use them in-place in the encoded message.   

Checking if a bit for a specific position is set can be easily defined as follows:

public static boolean isBitOnPositionSet(byte byteToCheck, int bitPosition) {
    if (bitPosition > 0) {
        byteToCheck = (byte) (byteToCheck << bitPosition);
    if (byteToCheck < 0) {
        return true;
    return false;

In the sample above we are shifting byte to have required bit on the first position and if first bit in the shifted byte is 1 we return true.

For example we have the FAST message which contains only templateID field: 0xC0 0xA9
Here its bits representation: 11000000 10101001.
Using stop bit definition we define amount of bytes which encode the FAST message PMap by the following steps:
  1. Gets bytes one by one.
    The first is 0xC0 and has 1100 0000 bits representation.
  2. Check the stop bit value of current byte. If it is equals to "1", our PMap completed by this byte.
    In our case the 0xC0 has first bit equals to "1", so our PMap is 1100 0000.
    In case of current byte does not have first bit equals to "1" we increment length of our PMap by 1 and repeat our process from the step 1 using next byte.