private static void serializeStruct(RandomAccessOutput byteStream, Object[] fieldData,
      List<ObjectInspector> fieldOis, BooleanRef warnedOnceNullMapKey)
          throws SerDeException {

    int lasti = 0;
    byte nullByte = 0;
    int size = fieldData.length;

    for (int i = 0; i < size; i++) {
      // set bit to 1 if a field is not null
      if (null != fieldData[i]) {
        nullByte |= 1 << (i % 8);
      }
      // write the null byte every eight elements or
      // if this is the last element and serialize the
      // corresponding 8 struct fields at the same time
      if (7 == i % 8 || i == size - 1) {
        byteStream.write(nullByte);
        for (int j = lasti; j <= i; j++) {
          serialize(byteStream, fieldData[j], fieldOis.get(j), false, warnedOnceNullMapKey);
        }
        lasti = i + 1;
        nullByte = 0;
      }
    }
  }
Serialize a struct object without writing the byte size. This function is
shared by both row serialization and struct serialization.

@param byteStream
         the byte stream storing the serialization data
@param fieldData
         the struct object to serialize
@param fieldOis
         the struct object inspector
@param warnedOnceNullMapKey a boolean indicating whether a warning
         has been issued once already when encountering null map keys
serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinarySerDe.java