Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
  * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package org.apache.pig;
The interface is used for the custom mapping of - a 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 This interface is designed to provide a common protocol for data exchange between Pig runtime and streaming executables. Typically, a user implements this interface for a particular type of stream command and specifies the implementation class in the Pig DEFINE statement.

Pig 0.12
public abstract class PigStreamingBase implements PigToStreamStreamToPig {
    public final byte[] serialize(Tuple tthrows IOException {
        WritableByteArray data = serializeToBytes(t);
        if (data.getLength() == data.getData().length) {
            return data.getData();
        } else {
            byte[] buf = new byte[data.getLength()];
            System.arraycopy(data.getData(), 0, buf, 0, data.getLength());
            return buf;

Given a tuple, produce an array of bytes to be passed to the streaming executable.

t Tuple to serialize
Serialized form of the tuple
    public abstract WritableByteArray serializeToBytes(Tuple tthrows IOException;
    public final Tuple deserialize(byte[] bytesthrows IOException {
        return deserialize(bytes, 0, bytes.length);

Given a byte array from a streaming executable, produce a tuple.

bytes bytes to deserialize.
offset the offset in the byte array from which to deserialize.
length the number of bytes from the offset of the byte array to deserialize.
Data as a Pig Tuple.
    public abstract Tuple deserialize(byte[] bytesint offsetint lengththrows IOException;

This will be called on the front end during planning and not on the back end during execution.

the LoadCaster associated with this object, or null if there is no such LoadCaster.
Throws: if there is an exception during LoadCaster
    public abstract LoadCaster getLoadCaster() throws IOException;
New to GrepCode? Check out our FAQ X