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

cz.seznam.euphoria.inmem.ExecUnit Maven / Gradle / Ivy

Go to download

An all-in-memory executing euphoria executor suitable for executing flows in unit tests.

The newest version!
/**
 * Copyright 2016-2017 Seznam.cz, a.s.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cz.seznam.euphoria.inmem;

import cz.seznam.euphoria.core.client.dataset.Dataset;
import cz.seznam.euphoria.core.client.graph.DAG;
import cz.seznam.euphoria.core.client.graph.Node;
import cz.seznam.euphoria.core.client.operator.Operator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
 * FIXME: this description is WRONG!
 * An {@code ExecUnit} is a series of transformation with no checkpointing.
 * {@code ExecUnit} has several inputs, several outputs and possibly
 * some intermediate datasets. Datasets might be shared across multiple
 * {@code ExecUnit}s.
 */
class ExecUnit {

  /** All inputs to this exec unit. */
  final List> inputs = new ArrayList<>();
  /** All outputs of this exec unit. */
  final List> outputs = new ArrayList<>();
  /** All dag consisting this exec unit. */
  final DAG> operators;

  /**
   * Split Flow into series of execution units.
   *
   * @return the given flow wrapped by a execution unit
   */
  public static List split(DAG> unfoldedFlow) {
    // FIXME: what exactly for is unit?
    return Arrays.asList(new ExecUnit(unfoldedFlow));
  }


  private ExecUnit(DAG> operators) {
    this.operators = operators;
  }


  /** @return leaf operators */
  public Collection>> getLeafs() {
    return operators.getLeafs();
  }


  /** @return the DAG of operators */
  public DAG> getDAG() {
    return operators;
  }


  /** @return all inputs of this unit */
  public Collection> getInputs() {
    return inputs;
  }


  /** @return all outputs of this unit */
  public Collection> getOutputs() {
    return outputs;
  }
  

  /** @return exec paths for this unit */
  public Collection getPaths() {
    Collection>> leafs = operators.getLeafs();
    return leafs.stream()
        .map(l -> ExecPath.of(operators.parentSubGraph(l.get())))
        .collect(Collectors.toList());
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy