cascading.tap.local
Class FileTap

java.lang.Object
  extended by cascading.tap.Tap<Properties,InputStream,OutputStream>
      extended by cascading.tap.local.FileTap
All Implemented Interfaces:
FlowElement, Serializable

public class FileTap
extends Tap<Properties,InputStream,OutputStream>

Class FileTap is a Tap sub-class that allows for direct local file access.

FileTap must be used with the LocalFlowConnector to create Flow instances that run in "local" mode.

See Also:
Serialized Form

Constructor Summary
FileTap(Scheme<Properties,InputStream,OutputStream,?,?> scheme, String path)
          Constructor FileTap creates a new FileTap instance using the given Scheme and file path.
FileTap(Scheme<Properties,InputStream,OutputStream,?,?> scheme, String path, SinkMode sinkMode)
          Constructor FileTap creates a new FileTap instance using the given Scheme, file path, and SinkMode.
 
Method Summary
 boolean commitResource(Properties conf)
          Method commitResource allows the underlying resource to be notified when all write processing is successful so that any additional cleanup or processing may be completed.
 boolean createResource(Properties conf)
          Method createResource creates the underlying resource.
 boolean deleteResource(Properties conf)
          Method deleteResource deletes the resource represented by this instance.
 String getIdentifier()
          Method getIdentifier returns a String representing the resource this Tap instance represents.
 long getModifiedTime(Properties conf)
          Method getModifiedTime returns the date this resource was last modified.
 long getSize(Properties conf)
          Method getSize returns the size of the file referenced by this tap.
 TupleEntryIterator openForRead(FlowProcess<Properties> flowProcess, InputStream input)
          Method openForRead opens the resource represented by this Tap instance.
 TupleEntryCollector openForWrite(FlowProcess<Properties> flowProcess, OutputStream output)
          Method openForWrite opens the resource represented by this Tap instance.
 boolean resourceExists(Properties conf)
          Method resourceExists returns true if the path represented by this instance exists.
 String toString()
           
 
Methods inherited from class cascading.tap.Tap
equals, flowConfInit, getConfigDef, getFullIdentifier, getScheme, getSinkFields, getSinkMode, getSourceFields, getStepConfigDef, getTrace, hasConfigDef, hashCode, hasStepConfigDef, id, isEquivalentTo, isKeep, isReplace, isSink, isSource, isTemporary, isUpdate, openForRead, openForWrite, outgoingScopeFor, presentSinkFields, presentSourceFields, resolveFields, resolveIncomingOperationFields, retrieveSinkFields, retrieveSourceFields, rollbackResource, setScheme, sinkConfInit, sourceConfInit, taps
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileTap

public FileTap(Scheme<Properties,InputStream,OutputStream,?,?> scheme,
               String path)
Constructor FileTap creates a new FileTap instance using the given Scheme and file path.

Parameters:
scheme - of type LocalScheme
path - of type String

FileTap

public FileTap(Scheme<Properties,InputStream,OutputStream,?,?> scheme,
               String path,
               SinkMode sinkMode)
Constructor FileTap creates a new FileTap instance using the given Scheme, file path, and SinkMode.

Parameters:
scheme - of type LocalScheme
path - of type String
sinkMode - of type SinkMode
Method Detail

getIdentifier

public String getIdentifier()
Description copied from class: Tap
Method getIdentifier returns a String representing the resource this Tap instance represents.

Often, if the tap accesses a filesystem, the identifier is nothing more than the path to the file or directory. In other cases it may be a an URL or URI representing a connection string or remote resource.

Any two Tap instances having the same value for the identifier are considered equal.

Specified by:
getIdentifier in class Tap<Properties,InputStream,OutputStream>
Returns:
String

openForRead

public TupleEntryIterator openForRead(FlowProcess<Properties> flowProcess,
                                      InputStream input)
                               throws IOException
Description copied from class: Tap
Method openForRead opens the resource represented by this Tap instance.

input value may be null, if so, sub-classes must inquire with the underlying Scheme via Scheme.sourceConfInit(cascading.flow.FlowProcess, Tap, Object) to get the proper input type and instantiate it before calling super.openForRead().

Note the returned iterator will return the same instance of TupleEntry on every call, thus a copy must be made of either the TupleEntry or the underlying Tuple instance if they are to be stored in a Collection.

Specified by:
openForRead in class Tap<Properties,InputStream,OutputStream>
Returns:
TupleEntryIterator @throws java.io.IOException when the resource cannot be opened
Throws:
IOException

openForWrite

public TupleEntryCollector openForWrite(FlowProcess<Properties> flowProcess,
                                        OutputStream output)
                                 throws IOException
Description copied from class: Tap
Method openForWrite opens the resource represented by this Tap instance.

output value may be null, if so, sub-classes must inquire with the underlying Scheme via Scheme.sinkConfInit(cascading.flow.FlowProcess, Tap, Object) to get the proper output type and instantiate it before calling super.openForWrite().

Specified by:
openForWrite in class Tap<Properties,InputStream,OutputStream>
Returns:
TupleEntryCollector
Throws:
IOException - when

getSize

public long getSize(Properties conf)
             throws IOException
Method getSize returns the size of the file referenced by this tap.

Parameters:
conf - of type Properties
Returns:
The size of the file reference by this tap.
Throws:
IOException

createResource

public boolean createResource(Properties conf)
                       throws IOException
Description copied from class: Tap
Method createResource creates the underlying resource.

Specified by:
createResource in class Tap<Properties,InputStream,OutputStream>
Parameters:
conf - of type JobConf
Returns:
boolean
Throws:
IOException - when there is an error making directories

deleteResource

public boolean deleteResource(Properties conf)
                       throws IOException
Description copied from class: Tap
Method deleteResource deletes the resource represented by this instance.

Specified by:
deleteResource in class Tap<Properties,InputStream,OutputStream>
Parameters:
conf - of type JobConf
Returns:
boolean
Throws:
IOException - when the resource cannot be deleted

commitResource

public boolean commitResource(Properties conf)
                       throws IOException
Description copied from class: Tap
Method commitResource allows the underlying resource to be notified when all write processing is successful so that any additional cleanup or processing may be completed.

See Tap.rollbackResource(Object) to handle cleanup in the face of failures.

This method is invoked once "client side" and not in the cluster, if any.

If other sink Tap instance in a given Flow fail on commitResource after called on this instance, rollbackResource will not be called.

This is an experimental API and subject to refinement!!

Overrides:
commitResource in class Tap<Properties,InputStream,OutputStream>
Returns:
returns true if successful
Throws:
IOException

resourceExists

public boolean resourceExists(Properties conf)
                       throws IOException
Description copied from class: Tap
Method resourceExists returns true if the path represented by this instance exists.

Specified by:
resourceExists in class Tap<Properties,InputStream,OutputStream>
Parameters:
conf - of type JobConf
Returns:
true if the underlying resource already exists
Throws:
IOException - when the status cannot be determined

getModifiedTime

public long getModifiedTime(Properties conf)
                     throws IOException
Description copied from class: Tap
Method getModifiedTime returns the date this resource was last modified.

Specified by:
getModifiedTime in class Tap<Properties,InputStream,OutputStream>
Parameters:
conf - of type Config
Returns:
The date this resource was last modified.
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Tap<Properties,InputStream,OutputStream>


Copyright © 2007-2012 Concurrent, Inc. All Rights Reserved.