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
  *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * 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 org.apache.pig.data.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 org.apache.pig.data.Tuple. 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.

Since:
Pig 0.12
public abstract class PigStreamingBase implements PigToStreamStreamToPig {
    @Override
    @Deprecated
    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.

Parameters:
t Tuple to serialize
Returns:
Serialized form of the tuple
Throws:
java.io.IOException
    public abstract WritableByteArray serializeToBytes(Tuple tthrows IOException;
    @Override
    @Deprecated
    public final Tuple deserialize(byte[] bytesthrows IOException {
        return deserialize(bytes, 0, bytes.length);
    }

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

Parameters:
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.
Returns:
Data as a Pig Tuple.
Throws:
java.io.IOException
    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.

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