Coverage Report - org.galagosearch.tupleflow.execution.DataPipe
 
Classes in this File Line Coverage Branch Coverage Complexity
DataPipe
0%
0/56
0%
0/18
0
 
 1  
 // BSD License (http://www.galagosearch.org/license)
 2  
 package org.galagosearch.tupleflow.execution;
 3  
 
 4  
 import java.io.File;
 5  
 import java.io.Serializable;
 6  
 
 7  
 /**
 8  
  * A data pipe carries tuples from m sources/outputs to
 9  
  * n sinks/outputs.
 10  
  *
 11  
  * @author trevor
 12  
  */
 13  
 ;
 14  
 
 15  
 public class DataPipe implements Serializable {
 16  0
     public DataPipe(String root, String pipeName, String className, String[] order, String[] hash, int inputCount, int outputCount) {
 17  0
         this.root = root;
 18  0
         this.pipeName = pipeName;
 19  0
         this.className = className;
 20  0
         this.order = order;
 21  0
         this.hash = hash;
 22  0
         this.setInputCount(inputCount);
 23  0
         this.setOutputCount(outputCount);
 24  0
     }
 25  
 
 26  
     public String getPipeName() {
 27  0
         return pipeName;
 28  
     }
 29  
 
 30  
     private String getFileNamesString(String[] fileNames) {
 31  0
         StringBuilder builder = new StringBuilder();
 32  0
         for (String fileName : fileNames) {
 33  0
             if (builder.length() != 0) {
 34  0
                 builder.append(':');
 35  
             }
 36  0
             builder.append(fileName);
 37  
         }
 38  0
         return builder.toString();
 39  
     }
 40  
 
 41  
     @Override
 42  
     public String toString() {
 43  0
         String out = String.format("className: %s\n", className);
 44  0
         out += "Pipe path: " + root + "\n";
 45  0
         out += getInputCount() + "\n";
 46  0
         out += getOutputCount() + "\n";
 47  
 
 48  0
         out += "order: [" + order.length + "]/";
 49  
 
 50  0
         for (String o : order) {
 51  0
             out += o + "/";
 52  
         }
 53  0
         out += "\n";
 54  
 
 55  0
         out += "hash: [" + hash.length + "]/";
 56  0
         for (String h : hash) {
 57  0
             out += h + "/";
 58  
         }
 59  0
         out += "\n";
 60  0
         return out;
 61  
     }
 62  
 
 63  
     public String[] getInputFileNames(int index) {
 64  0
         String[] inputNames = null;
 65  
 
 66  0
         if (hash != null) {
 67  0
             inputNames = new String[getOutputCount()];
 68  
 
 69  0
             for (int i = 0; i < getOutputCount(); i++) {
 70  0
                 inputNames[i] = getFileName(index, i);
 71  
             }
 72  
         } else {
 73  0
             inputNames = new String[]{getFileName(index, index)};
 74  
         }
 75  
 
 76  0
         return inputNames;
 77  
     }
 78  
 
 79  
     public String[] getOutputFileNames(int index) {
 80  0
         String[] outputNames = null;
 81  
 
 82  0
         if (hash != null) {
 83  0
             outputNames = new String[getInputCount()];
 84  
 
 85  0
             for (int i = 0; i < getInputCount(); i++) {
 86  0
                 outputNames[i] = getFileName(i, index);
 87  
             }
 88  
         } else {
 89  0
             outputNames = new String[]{getFileName(index, index)};
 90  
         }
 91  
 
 92  0
         return outputNames;
 93  
     }
 94  
 
 95  
     public String getFileName(int inputIndex, int outputIndex) {
 96  0
         return root + File.separator + inputIndex + File.separator + outputIndex;
 97  
     }
 98  
 
 99  
     public void makeDirectories() {
 100  0
         for (int i = 0; i < getInputCount(); i++) {
 101  0
             new File(root + File.separator + i).mkdirs();
 102  
         }
 103  0
     }
 104  
 
 105  
     public int getInputCount() {
 106  0
         return inputCount;
 107  
     }
 108  
 
 109  
     public void setInputCount(int inputCount) {
 110  0
         this.inputCount = inputCount;
 111  0
     }
 112  
 
 113  
     public int getOutputCount() {
 114  0
         return outputCount;
 115  
     }
 116  
 
 117  
     public void setOutputCount(int outputCount) {
 118  0
         this.outputCount = outputCount;
 119  0
     }
 120  
 
 121  
     public String[] getHash() {
 122  0
         return hash;
 123  
     }
 124  
 
 125  
     public String getClassName() {
 126  0
         return className;
 127  
     }
 128  
 
 129  
     public String[] getOrder() {
 130  0
         return order;
 131  
     }
 132  
 
 133  
     public String root;
 134  
     public String pipeName;
 135  
     private int inputCount;
 136  
     private int outputCount;
 137  
     public String className;
 138  
     public String[] order;
 139  
     public String[] hash;
 140  
 }