@Override
 public SignificanceHeuristic readResult(StreamInput in) throws IOException {
   return new ScriptHeuristic(
       null,
       in.readOptionalString(),
       in.readString(),
       ScriptService.ScriptType.readFrom(in),
       in.readMap());
 }
 /** Read from a stream. */
 public ScriptedMetricAggregationBuilder(StreamInput in) throws IOException {
   super(in, TYPE);
   initScript = in.readOptionalWriteable(Script::new);
   mapScript = in.readOptionalWriteable(Script::new);
   combineScript = in.readOptionalWriteable(Script::new);
   reduceScript = in.readOptionalWriteable(Script::new);
   if (in.readBoolean()) {
     params = in.readMap();
   }
 }
 @Override
 public void readFrom(StreamInput in) throws IOException {
   name = in.readOptionalString();
   type = in.readOptionalString();
   started = new Date(in.readLong());
   timestamp = new Date(in.readLong());
   enabled = in.readBoolean();
   active = in.readBoolean();
   counter = in.readLong();
   custom = in.readMap();
 }
 @Override
 public final void readFrom(StreamInput in) throws IOException {
   try {
     getWriteableName(); // Throws UnsupportedOperationException if this aggregation should be read
                         // using old style Streams
     assert false : "Used reading constructor instead";
   } catch (UnsupportedOperationException e) {
     // OK
   }
   name = in.readString();
   bucketsPaths = in.readStringArray();
   metaData = in.readMap();
   doReadFrom(in);
 }
 /** Read from a stream. */
 protected PipelineAggregator(StreamInput in) throws IOException {
   name = in.readString();
   bucketsPaths = in.readStringArray();
   metaData = in.readMap();
 }