Coverage Report - org.galagosearch.core.parse.KeyValuePairToDocument
 
Classes in this File Line Coverage Branch Coverage Complexity
KeyValuePairToDocument
64%
7/11
N/A
0
 
 1  
 // BSD License (http://www.galagosearch.org/license)
 2  
 
 3  
 package org.galagosearch.core.parse;
 4  
 
 5  
 import java.io.ByteArrayInputStream;
 6  
 import java.io.IOException;
 7  
 import java.io.ObjectInputStream;
 8  
 import org.galagosearch.core.types.KeyValuePair;
 9  
 import org.galagosearch.tupleflow.InputClass;
 10  
 import org.galagosearch.tupleflow.OutputClass;
 11  
 import org.galagosearch.tupleflow.StandardStep;
 12  
 import org.galagosearch.tupleflow.execution.Verified;
 13  
 
 14  
 /**
 15  
  * <p>This is used in conjunction with DocumentToKeyValuePair.  Since Document
 16  
  * is not a real Galago type, it needs to be converted to a KeyValuePair in order
 17  
  * to be passed between stages (or to a Sorter).</p>
 18  
  * 
 19  
  * @author trevor
 20  
  */
 21  
 @Verified
 22  
 @InputClass(className = "org.galagosearch.core.types.KeyValuePair")
 23  
 @OutputClass(className = "org.galagosearch.core.parse.Document")
 24  4
 public class KeyValuePairToDocument extends StandardStep<KeyValuePair, Document> {
 25  
     @Override
 26  
     public void process(KeyValuePair object) throws IOException {
 27  4
         ByteArrayInputStream stream = new ByteArrayInputStream(object.value);
 28  4
         ObjectInputStream input = new ObjectInputStream(stream);
 29  
         Document document;
 30  
         try {
 31  4
             document = (Document) input.readObject();
 32  0
         } catch (ClassNotFoundException ex) {
 33  0
             IOException e = new IOException("Expected to find a serialized document here, " +
 34  
                                             "but found something else instead.");
 35  0
             e.initCause(ex);
 36  0
             throw e;
 37  4
         }
 38  
 
 39  4
         processor.process(document);
 40  4
     }
 41  
 }