public static int getByteSizeForValue(long id) {
    final int length;

    // compare threadId to find its range
    if (id <= Byte.MAX_VALUE) {
      length = 1;
    } else if (id <= Short.MAX_VALUE) {
      length = 2;
    } else if (id <= Integer.MAX_VALUE) {
      length = 4;
    } else {
      length = 8;
    }

    return length;
  }
Returns the number of bytes needed to store the given value. This calculation is needed to
create the optimized byte-array for an eventId, which will be sent across the network

@param id - the long value ( threadId or sequenceId in this context)
@return - the number of byte taken by this value
geode-core/src/main/java/org/apache/geode/internal/cache/EventID.java