Coverage Report - org.galagosearch.tupleflow.execution.Connection
 
Classes in this File Line Coverage Branch Coverage Complexity
Connection
47%
15/32
30%
3/10
0
 
 1  
 // BSD License (http://galagosearch.org)
 2  
 
 3  
 package org.galagosearch.tupleflow.execution;
 4  
 
 5  
 import java.util.ArrayList;
 6  
 
 7  
 /**
 8  
  * Represents a data connection between two stages in a TupleFlow job.
 9  
  * 
 10  
  * @see org.galagosearch.tupleflow.execution.Job
 11  
  * @author trevor
 12  
  */
 13  2
 public class Connection extends Locatable implements Cloneable {
 14  
     String className;
 15  
     String connectionName;
 16  
     String[] order;
 17  
     String[] hash;
 18  
     int hashCount;
 19  2
     public ArrayList<ConnectionEndPoint> inputs = new ArrayList<ConnectionEndPoint>();
 20  2
     public ArrayList<ConnectionEndPoint> outputs = new ArrayList<ConnectionEndPoint>();
 21  
 
 22  
     public Connection(FileLocation location, String connectionName, String className, String[] order, String[] hash, int hashCount) {
 23  2
         super(location);
 24  2
         this.connectionName = connectionName;
 25  2
         this.className = className;
 26  2
         this.order = order;
 27  2
         this.hash = hash;
 28  2
         this.hashCount = hashCount;
 29  2
     }
 30  
 
 31  
     public Connection(FileLocation location, String className, String[] order, String[] hash, int hashCount) {
 32  2
         this(location, null, className, order, hash, hashCount);
 33  2
     }
 34  
 
 35  
     public String getName() {
 36  2
         if (connectionName == null) {
 37  2
             assert inputs.size() > 0;
 38  2
             return inputs.get(0).getStageName() + "-" + inputs.get(0).getPointName();
 39  
         } else {
 40  0
             return connectionName;
 41  
         }
 42  
     }
 43  
 
 44  
     String getClassName() {
 45  0
         return className;
 46  
     }
 47  
 
 48  
     String[] getOrder() {
 49  0
         return order;
 50  
     }
 51  
 
 52  
     String[] getHash() {
 53  0
         return hash;
 54  
     }
 55  
 
 56  
     int getHashCount() {
 57  0
         return hashCount;
 58  
     }
 59  
 
 60  
     @Override
 61  
     public Connection clone() {
 62  
         try {
 63  0
             Connection copy = (Connection) super.clone();
 64  0
             ArrayList<ConnectionEndPoint> inputCopy = new ArrayList<ConnectionEndPoint>();
 65  
 
 66  0
             for (ConnectionEndPoint point : inputs) {
 67  0
                 inputCopy.add(point.clone());
 68  
             }
 69  
 
 70  0
             ArrayList<ConnectionEndPoint> outputCopy = new ArrayList<ConnectionEndPoint>();
 71  
 
 72  0
             for (ConnectionEndPoint point : outputs) {
 73  0
                 outputCopy.add(point.clone());
 74  
             }
 75  
 
 76  0
             copy.inputs = inputCopy;
 77  0
             copy.outputs = outputCopy;
 78  0
             return copy;
 79  0
         } catch (CloneNotSupportedException ex) {
 80  0
             throw new RuntimeException("Expected cloning to be supported in superclass", ex);
 81  
         }
 82  
     }
 83  
 }