All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.linkedin.dagli.dag.AbstractDAGResult2 Maven / Gradle / Ivy

Go to download

DAG-oriented machine learning framework for bug-resistant, readable, efficient, maintainable and trivially deployable models in Java and other JVM languages

There is a newer version: 15.0.0-beta9
Show newest version
// AUTOGENERATED CODE.  DO NOT MODIFY DIRECTLY!  Instead, please modify the dag/AbstractDAGResultX.ftl file.
// See the README in the module's src/template directory for details.
package com.linkedin.dagli.dag;

import com.linkedin.dagli.objectio.ObjectReader;
import com.linkedin.dagli.objectio.WrappedObjectReader;
import java.util.Objects;
import com.linkedin.dagli.tuple.Tuple2;
import com.linkedin.dagli.objectio.tuple.TupleReader;


/**
 * Base class for an object encapsulating the results of executing a DAG.
 *
 * @param  the type of result #1 of the DAG
 * @param  the type of result #2 of the DAG
 */
abstract class AbstractDAGResult2 extends WrappedObjectReader> implements DAGResult2,
    AutoCloseable {
  private final ObjectReader _result1;
  private final ObjectReader _result2;

  @Override
  public ObjectReader getResult1() {
    return _result1;
  }

  @Override
  public ObjectReader getResult2() {
    return _result2;
  }

  /**
   * Create a new DAG result instance from the provided array of {@link ObjectReader}s.
   *
   * @param results an array of length 2 providing an {@link ObjectReader} for each of the DAG's outputs.
   */
  @SuppressWarnings("unchecked")
  AbstractDAGResult2(ObjectReader[] results) {
    this((ObjectReader) results[0], (ObjectReader) results[1]);
    assert results.length == 2;
  }

  /**
   * Create a new DAG result instance from the provided {@link ObjectReader}s.
   *
   * @param results1 an {@link ObjectReader} for the DAG's first output.
   * @param results2 an {@link ObjectReader} for the DAG's second output.
   */
  AbstractDAGResult2(ObjectReader results1, ObjectReader results2) {
    super(new TupleReader<>(results1, results2));

    _result1 = Objects.requireNonNull(results1);
    _result2 = Objects.requireNonNull(results2);
  }

  @Override
  public void close() {
    _result1.close();
    _result2.close();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy