public void serialize(DataOutputStream stream) throws IOException {
    ReadWriteIOUtils.write(measurementList.size(), stream);
    for (String measurement : measurementList) {
      ReadWriteIOUtils.write(measurement, stream);
    }
    for (IMeasurementSchema schema : schemaList) {
      schema.serializeTo(stream);
    }
    for (TSDataType dataType : dataTypes) {
      ReadWriteIOUtils.write(dataType, stream);
    }
    ReadWriteIOUtils.write(scanOrder.ordinal(), stream);
    ReadWriteIOUtils.write(queryAllSensors, stream);

    ReadWriteIOUtils.write(deviceViewOutputNames.size(), stream);
    for (String outputName : deviceViewOutputNames) {
      ReadWriteIOUtils.write(outputName, stream);
    }

    ReadWriteIOUtils.write(deviceToMeasurementIndexes.size(), stream);
    for (int index : deviceToMeasurementIndexes) {
      ReadWriteIOUtils.write(index, stream);
    }

    ReadWriteIOUtils.write(offsetValue, stream);
    ReadWriteIOUtils.write(limitValue, stream);

    if (predicate != null) {
      ReadWriteIOUtils.write((byte) 1, stream);
      Expression.serialize(predicate, stream);
      ReadWriteIOUtils.write(keepNull, stream);
    } else {
      ReadWriteIOUtils.write((byte) 0, stream);
    }

    if (pushDownPredicate != null) {
      ReadWriteIOUtils.write((byte) 1, stream);
      Expression.serialize(pushDownPredicate, stream);
    } else {
      ReadWriteIOUtils.write((byte) 0, stream);
    }

    if (aggregationQuery) {
      ReadWriteIOUtils.write((byte) 1, stream);
      if (groupByTimeParameter != null) {
        ReadWriteIOUtils.write((byte) 1, stream);
        groupByTimeParameter.serialize(stream);
      } else {
        ReadWriteIOUtils.write((byte) 0, stream);
      }

      ReadWriteIOUtils.write(outputEndTime, stream);

      ReadWriteIOUtils.write(ascendingDescriptorList.size(), stream);
      for (AggregationDescriptor descriptor : ascendingDescriptorList) {
        descriptor.serialize(stream);
      }

      ReadWriteIOUtils.write(descendingDescriptorList.size(), stream);
      for (AggregationDescriptor descriptor : descendingDescriptorList) {
        descriptor.serialize(stream);
      }
    } else {
      ReadWriteIOUtils.write((byte) 0, stream);
    }
  }
If in align by device query ,all queried devices are set in one template, we can store the common
variables in TemplatedInfo to avoid repeated creation.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/TemplatedInfo.java