code: public tsfile_data data(TimeSeriesCollection ts_data) {
          final dictionary_delta dict_delta = new dictionary_delta();
          dict_delta.gdd = new path_dictionary_delta[0];
          dict_delta.mdd = new path_dictionary_delta[0];
          dict_delta.sdd = new strval_dictionary_delta[0];
          dict_delta.tdd = new tag_dictionary_delta[0];
  
          final List<tsfile_record> records = new ArrayList<>();
          final Iterator<TimeSeriesValue> tsv_iter = ts_data.getTSValues().stream().iterator();
          while (tsv_iter.hasNext()) {
              final TimeSeriesValue tsv = tsv_iter.next();
              tsfile_record record = new tsfile_record();
  
              record.group_ref = simpleGroupPath_index(dict_delta, tsv.getGroup().getPath());
              record.tag_ref = tags_index(dict_delta, tsv.getGroup().getTags());
              record.metrics = tsv.getMetrics().entrySet().stream()
                      .map(entry -> {
                          tsfile_record_entry tre = new tsfile_record_entry();
                          tre.metric_ref = metricName_index(dict_delta, entry.getKey());
                          tre.v = metric_value_(dict_delta, entry.getValue());
                          return tre;
                      })
                      .toArray(tsfile_record_entry[]::new);
              records.add(record);
          }
  
          tsfile_data result = new tsfile_data();
          result.records = records.stream().toArray(tsfile_record[]::new);
          result.ts = timestamp(ts_data.getTimestamp());
          if (dict_delta.gdd.length > 0 || dict_delta.mdd.length > 0 || dict_delta.sdd.length > 0 || dict_delta.tdd.length > 0)
              result.dd = dict_delta;
          return result;
      }
docs: Transform a TimeSeriesCollection into the XDR serialized form.