private static Pair<String, byte[]> generatePageViewEvent(int index) {
    PageViewEvent event = new PageViewEvent();
    String name = randValueGenerator.getNextString(10, 20);
    event.id = randValueGenerator.getNextInt();
    event.Name = name;
    event.ViewerName = randValueGenerator.getNextString(10, 20);
    event.ProfileViewTimestamp = System.currentTimeMillis();
    byte[] value;
    try {
      value = encodeAvroSpecificRecord(PageViewEvent.class, event);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    return new ImmutablePair<>(name, value);
  }
Encode an Avro record into byte array

@param clazz The class type of the avro record
@param record the instance of the avro record
@param <T> The type of the avro record.
@return encoded bytes
@throws IOException on I/O errors encoding the avro record
samza-tools/src/main/java/org/apache/samza/tools/GenerateKafkaEvents.java