static byte[] encode(
      Map<String, String> commonTags,
      List<Measurement> measurements) throws IOException {

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    JsonGenerator gen = FACTORY.createGenerator(baos);
    gen.writeStartArray();
    Map<String, Integer> strings = buildStringTable(gen, commonTags, measurements);
    for (Measurement m : measurements) {
      appendMeasurement(gen, strings, commonTags, m.id(), m.value());
    }
    gen.writeEndArray();
    gen.close();
    return baos.toByteArray();
  }
static byte [ ] encode ( Map < String , String > commonTags , List < Measurement > measurements ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; JsonGenerator gen = FACTORY . createGenerator ( baos ) ; gen . writeStartArray ( ) ; Map < String , Integer > strings = buildStringTable ( gen , commonTags , measurements ) ; for ( Measurement m : measurements ) { appendMeasurement ( gen , strings , commonTags , m . id ( ) , m . value ( ) ) ; } gen . writeEndArray ( ) ; gen . close ( ) ; return baos . toByteArray ( ) ; }
Encode the measurements to a JSON payload that can be sent to the aggregator.