| 1 | |
|
| 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 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 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 | |
} |