commonlib/src/main/java/com/streamsets/pipeline/lib/parser/udp/collectd/CollectdParser.java
private int parseValues(int startOffset, ByteBuf buf) throws OnRecordErrorException {
    int offset = startOffset;
    // N Values
    // For each Value:
    // 1 byte data type code
    int numValues = buf.getUnsignedShort(offset); // 4-5
    offset += 2;

    List<Byte> types = new ArrayList<>(numValues);

    while (numValues-- > 0) {
      types.add(buf.getByte(offset));
      offset += 1;
    }

    for (int i = 0; i < types.size(); i++) {
      Byte type = types.get(i);
      String label = getValueLabel(i, type);
      switch (type) {
        case COUNTER:
          fields.put(label, Field.create(buf.getUnsignedInt(offset)));
          offset += 8;
          break;
        case GAUGE:
          fields.put(
              label,
              Field.create(buf.order(ByteOrder.LITTLE_ENDIAN).getDouble(offset))
          );
          offset += 8;
          break;
        case DERIVE:
          fields.put(label, Field.create(buf.getLong(offset)));
          offset += 8;
          break;
        case ABSOLUTE:
          fields.put(label, Field.create(buf.getUnsignedInt(offset)));
          offset += 8;
          break;
        default:
          // error
          throw new OnRecordErrorException(Errors.COLLECTD_01, type);
      }
    }
    return offset;
  }
private int parseValues(int startOffset, ByteBuf buf) throws OnRecordErrorException {
    int offset = startOffset;
    // N Values
    // For each Value:
    // 1 byte data type code
    int numValues = buf.getUnsignedShort(offset); // 4-5
    offset += 2;

    List<Byte> types = new ArrayList<>(numValues);

    while (numValues-- > 0) {
      types.add(buf.getByte(offset));
      offset += 1;
    }

    for (int i = 0; i < types.size(); i++) {
      Byte type = types.get(i);
      String label = getValueLabel(i, type);
      switch (type) {
        case COUNTER:
          fields.put(label, Field.create(buf.getUnsignedInt(offset)));
          offset += 8;
          break;
        case GAUGE:
          fields.put(
              label,
              Field.create(buf.order(ByteOrder.LITTLE_ENDIAN).getDouble(offset))
          );
          offset += 8;
          break;
        case DERIVE:
          fields.put(label, Field.create(buf.getLong(offset)));
          offset += 8;
          break;
        case ABSOLUTE:
          fields.put(label, Field.create(buf.getUnsignedInt(offset)));
          offset += 8;
          break;
        default:
          // error
          throw new OnRecordErrorException(Errors.COLLECTD_01, type);
      }
    }
    return offset;
  }
private int parseValues ( int startOffset , ByteBuf buf ) throws OnRecordErrorException { int offset = startOffset ; // N Values // For each Value: // 1 byte data type code int numValues = buf . getUnsignedShort ( offset ) ; // 4-5 offset += 2 ; List < Byte > types = new ArrayList <> ( numValues ) ; while ( numValues -- > 0 ) { types . add ( buf . getByte ( offset ) ) ; offset += 1 ; } for ( int i = 0 ; i < types . size ( ) ; i ++ ) { Byte type = types . get ( i ) ; String label = getValueLabel ( i , type ) ; switch ( type ) { case COUNTER : fields . put ( label , Field . create ( buf . getUnsignedInt ( offset ) ) ) ; offset += 8 ; break ; case GAUGE : fields . put ( label , Field . create ( buf . order ( ByteOrder . LITTLE_ENDIAN ) . getDouble ( offset ) ) ) ; offset += 8 ; break ; case DERIVE : fields . put ( label , Field . create ( buf . getLong ( offset ) ) ) ; offset += 8 ; break ; case ABSOLUTE : fields . put ( label , Field . create ( buf . getUnsignedInt ( offset ) ) ) ; offset += 8 ; break ; default : // error throw new OnRecordErrorException ( Errors . COLLECTD_01 , type ) ; } } return offset ; }
Parses the value part of the packet where metrics are located

@param startOffset beginning offset for this part
@param buf         buffered packet
@return offset after consuming part
Parses the value part of the packet where metrics are located