org.apache.pig
Interface Slice

All Superinterfaces:
Serializable
All Known Implementing Classes:
PigSlice

public interface Slice
extends Serializable

A grouping of data on that can be processed individually by Pig. Instances of this interface are created by Slicer, serialized, and sent to nodes to be processed.

getLocations() is called as part of the configuration process to determine where this Slice should be run for maximal locality with the data to be read. Once the Slice arrives on the processing node, init(DataStorage) is called to give it access to the DataStorage it should use to load Tuples. After init has been called, any of the other methods on this interface may be called as part of Pig's processing.


Method Summary
 void close()
          Closes any streams this Slice has opened as part of its work.
 long getLength()
          Returns the length in bytes of all of the data that will be processed by this Slice.
 String[] getLocations()
          Returns string representations of all the files that will be used as part of processing this Slice.
 long getPos()
          Returns the number of bytes read so far as part of processing this Slice.
 float getProgress()
          Returns the percentage of Slice that is complete from 0.0 to 1.0.
 long getStart()
          Returns the offset from which data in this Slice will be processed.
 void init(DataStorage store)
          Initializes this Slice with the DataStorage it's to use to do its work.
 boolean next(Tuple value)
          Loads the next value from this Slice into value.
 

Method Detail

getLocations

String[] getLocations()
Returns string representations of all the files that will be used as part of processing this Slice.

This is the only method on Slice that is valid to call before init(DataStorage) has been called.


init

void init(DataStorage store)
          throws IOException
Initializes this Slice with the DataStorage it's to use to do its work.

This will always be called before getLength, close, getPos, getProgress and next.

Throws:
IOException

getStart

long getStart()
Returns the offset from which data in this Slice will be processed.


getLength

long getLength()
Returns the length in bytes of all of the data that will be processed by this Slice.

Only valid to call after init(DataStorage) has been called.


close

void close()
           throws IOException
Closes any streams this Slice has opened as part of its work.

Only valid to call after init(DataStorage) has been called.

Throws:
IOException

getPos

long getPos()
            throws IOException
Returns the number of bytes read so far as part of processing this Slice.

Only valid to call after init(DataStorage) has been called.

Throws:
IOException

getProgress

float getProgress()
                  throws IOException
Returns the percentage of Slice that is complete from 0.0 to 1.0.

Only valid to call after init(DataStorage) has been called.

Throws:
IOException

next

boolean next(Tuple value)
             throws IOException
Loads the next value from this Slice into value.

Only valid to call after init(DataStorage) has been called.

Parameters:
value - - the Tuple to be filled with the next value.
Returns:
- true if there are more Tuples to be read.
Throws:
IOException


Copyright © ${year} The Apache Software Foundation