MCPcopy Create free account
hub / github.com/apache/pig / PigStreamingBase

Class PigStreamingBase

src/org/apache/pig/PigStreamingBase.java:42–95  ·  view source on GitHub ↗

The interface is used for the custom mapping of - a Tuple to a byte array. The byte array is fed to the stdin of the streaming process. - a byte array, received from the stdout of the streaming process, to a Tuple. This interface is designed to provide a common proto

Source from the content-addressed store, hash-verified

40 * @since Pig 0.12
41 */
42@InterfaceAudience.Public
43@InterfaceStability.Stable
44public abstract class PigStreamingBase implements PigToStream, StreamToPig {
45
46 @Override
47 @Deprecated
48 public final byte[] serialize(Tuple t) throws IOException {
49 WritableByteArray data = serializeToBytes(t);
50 if (data.getLength() == data.getData().length) {
51 return data.getData();
52 } else {
53 byte[] buf = new byte[data.getLength()];
54 System.arraycopy(data.getData(), 0, buf, 0, data.getLength());
55 return buf;
56 }
57 }
58
59 /**
60 * Given a tuple, produce an array of bytes to be passed to the streaming
61 * executable.
62 * @param t Tuple to serialize
63 * @return Serialized form of the tuple
64 * @throws IOException
65 */
66 public abstract WritableByteArray serializeToBytes(Tuple t) throws IOException;
67
68 @Override
69 @Deprecated
70 public final Tuple deserialize(byte[] bytes) throws IOException {
71 return deserialize(bytes, 0, bytes.length);
72 }
73
74 /**
75 * Given a byte array from a streaming executable, produce a tuple.
76 * @param bytes bytes to deserialize.
77 * @param offset the offset in the byte array from which to deserialize.
78 * @param length the number of bytes from the offset of the byte array to deserialize.
79 * @return Data as a Pig Tuple.
80 * @throws IOException
81 */
82 public abstract Tuple deserialize(byte[] bytes, int offset, int length) throws IOException;
83
84 /**
85 * This will be called on the front end during planning and not on the back
86 * end during execution.
87 *
88 * @return the {@link LoadCaster} associated with this object, or null if
89 * there is no such LoadCaster.
90 * @throws IOException if there is an exception during LoadCaster
91 */
92 @Override
93 public abstract LoadCaster getLoadCaster() throws IOException;
94
95}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected