org.apache.sysds.hops.cost

## Class HopRel

- java.lang.Object
- - org.apache.sysds.hops.cost.HopRel

    public class HopRel
    extends Object

HopRel provides a representation of the relation between a hop, the cost of setting a given FederatedOutput value, and the input dependency with the given FederatedOutput value. The HopRel class is used when building and selecting an optimal federated execution plan in IPAPassRewriteFederatedPlan. The input dependency is needed to hold the valid and optimal FederatedOutput values for the inputs.

### Constructor Summary

Constructors
Constructor and Description
`HopRel(Hop associatedHop, FEDInstruction.FederatedOutput fedOut, Map<Long,List<HopRel>> hopRelMemo)` Constructs a HopRel with input dependency and cost estimate based on entries in hopRelMemo.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addCostPointer(long hopID)` Adds hopID to set of hops pointing to this HopRel.
`boolean` `existingCostPointer(long currentHopID)` Checks if another Hop is refering to this HopRel in memo table.
`double` `getCost()` Get total cost as double
`FederatedCost` `getCostObject()` Get cost object
`FEDInstruction.FederatedOutput` `getFederatedOutput()`
`Hop` `getHopRef()`
`List<HopRel>` `getInputDependency()`
`boolean` `hasFederatedOutput()`
`boolean` `hasLocalOutput()`
`String` `toString()`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### HopRel

    public HopRel(Hop associatedHop,
                  FEDInstruction.FederatedOutput fedOut,
                  Map<Long,List<HopRel>> hopRelMemo)

Constructs a HopRel with input dependency and cost estimate based on entries in hopRelMemo.

Parameters:
  `associatedHop` - hop associated with this HopRel
  `fedOut` - FederatedOutput value assigned to this HopRel
  `hopRelMemo` - memo table storing other HopRels including the inputs of associatedHop

### Method Detail

#### addCostPointer

    public void addCostPointer(long hopID)

Adds hopID to set of hops pointing to this HopRel. By storing the hopID it can later be determined if the cost stored in this HopRel is already used as input cost in another HopRel.

Parameters:
  `hopID` - added to set of stored cost pointers

#### existingCostPointer

    public boolean existingCostPointer(long currentHopID)

Checks if another Hop is refering to this HopRel in memo table. A reference from a HopRel with same Hop ID is allowed, so this ID is ignored when checking references.

Parameters:
  `currentHopID` - to ignore when checking references
Returns:
  true if another Hop refers to this HopRel in memo table

#### hasLocalOutput

    public boolean hasLocalOutput()

#### hasFederatedOutput

    public boolean hasFederatedOutput()

#### getFederatedOutput

    public FEDInstruction.FederatedOutput getFederatedOutput()

#### getInputDependency

    public List<HopRel> getInputDependency()

#### getHopRef

    public Hop getHopRef()

#### getCost

    public double getCost()

Get total cost as double

Returns:
  cost as double

#### getCostObject

    public FederatedCost getCostObject()

Get cost object

Returns:
  cost object

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`