cascading.tap.local

## Class FileTap

- java.lang.Object
- - cascading.tap.Tap<java.util.Properties,java.io.InputStream,java.io.OutputStream>
  - - cascading.tap.local.FileTap

All Implemented Interfaces:
  FlowElement, ScopedElement, FileType<java.util.Properties>, Traceable, java.io.Serializable

    public class FileTap
    extends Tap<java.util.Properties,java.io.InputStream,java.io.OutputStream>
    implements FileType<java.util.Properties>

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

Constructors
Constructor and Description
`FileTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.lang.String path)` Constructor FileTap creates a new FileTap instance using the given `Scheme` and file `path`.
`FileTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.lang.String path, SinkMode sinkMode)` Constructor FileTap creates a new FileTap instance using the given `Scheme`, file `path`, and `SinkMode`.

### Method Summary

Methods
`boolean` `commitResource(java.util.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(java.util.Properties conf)` Method createResource creates the underlying resource.
`boolean` `deleteResource(java.util.Properties conf)` Method deleteResource deletes the resource represented by this instance.
`java.lang.String[]` `getChildIdentifiers(FlowProcess<? extends java.util.Properties> flowProcess)` Method getChildIdentifiers returns an array of child identifiers if this resource is a directory.
`java.lang.String[]` `getChildIdentifiers(FlowProcess<? extends java.util.Properties> flowProcess, int depth, boolean fullyQualified)`
`java.lang.String[]` `getChildIdentifiers(java.util.Properties conf)` Method getChildIdentifiers returns an array of child identifiers if this resource is a directory.
`java.lang.String[]` `getChildIdentifiers(java.util.Properties conf, int depth, boolean fullyQualified)`
`java.lang.String` `getFullIdentifier(java.util.Properties conf)` Method getFullIdentifier returns a fully qualified resource identifier.
`java.lang.String` `getIdentifier()` Method getIdentifier returns a String representing the resource this Tap instance represents.
`long` `getModifiedTime(java.util.Properties conf)` Method getModifiedTime returns the date this resource was last modified.
`long` `getSize(FlowProcess<? extends java.util.Properties> flowProcess)` Method getSize returns the size of the file referenced by this tap.
`long` `getSize(java.util.Properties conf)` Method getSize returns the size of the file referenced by this tap.
`boolean` `isDirectory(FlowProcess<? extends java.util.Properties> flowProcess)` Method isDirectory returns true if the underlying resource represents a directory or folder instead of an individual file.
`boolean` `isDirectory(java.util.Properties conf)` Method isDirectory returns true if the underlying resource represents a directory or folder instead of an individual file.
`TupleEntryIterator` `openForRead(FlowProcess<? extends java.util.Properties> flowProcess, java.io.InputStream input)` Method openForRead opens the resource represented by this Tap instance for reading.
`TupleEntryCollector` `openForWrite(FlowProcess<? extends java.util.Properties> flowProcess, java.io.OutputStream output)` Method openForWrite opens the resource represented by this Tap instance for writing.
`boolean` `resourceExists(java.util.Properties conf)` Method resourceExists returns true if the path represented by this instance exists.

### Methods inherited from class cascading.tap.Tap

`createResource, deleteResource, equals, flowConfInit, getConfigDef, getFullIdentifier, getModifiedTime, getNodeConfigDef, getScheme, getSinkFields, getSinkMode, getSourceFields, getStepConfigDef, getTrace, hasConfigDef, hashCode, hasNodeConfigDef, hasStepConfigDef, id, isKeep, isReplace, isSink, isSource, isTemporary, isUpdate, openForRead, openForWrite, outgoingScopeFor, prepareResourceForRead, prepareResourceForWrite, presentSinkFields, presentSourceFields, resolveIncomingOperationArgumentFields, resolveIncomingOperationPassThroughFields, resourceExists, retrieveSinkFields, retrieveSourceFields, rollbackResource, setScheme, sinkConfInit, sourceConfInit, taps, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### FileTap

    public FileTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
           java.lang.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<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
           java.lang.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 java.lang.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<java.util.Properties,java.io.InputStream,java.io.OutputStream>`
Returns:
  String

#### getFullIdentifier

    public java.lang.String getFullIdentifier(java.util.Properties conf)

Description copied from class: `Tap`
Method getFullIdentifier returns a fully qualified resource identifier.

Overrides:
  `getFullIdentifier` in class `Tap<java.util.Properties,java.io.InputStream,java.io.OutputStream>`
Parameters:
  `conf` - of type Config
Returns:
  String

#### openForRead

    public TupleEntryIterator openForRead(FlowProcess<? extends java.util.Properties> flowProcess,
                                 java.io.InputStream input)
                                   throws java.io.IOException

Description copied from class: `Tap`
Method openForRead opens the resource represented by this Tap instance for reading.

`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<java.util.Properties,java.io.InputStream,java.io.OutputStream>`
Parameters:
  `flowProcess` - of type FlowProcess
  `input` - of type Input
Returns:
  TupleEntryIterator
Throws:
  `java.io.IOException` - when the resource cannot be opened

#### openForWrite

    public TupleEntryCollector openForWrite(FlowProcess<? extends java.util.Properties> flowProcess,
                                   java.io.OutputStream output)
                                     throws java.io.IOException

Description copied from class: `Tap`
Method openForWrite opens the resource represented by this Tap instance for writing.

This method is used internally and does not honor the `SinkMode` setting. If SinkMode is `SinkMode.REPLACE`, this call may fail. See `Tap.openForWrite(cascading.flow.FlowProcess)`.

`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<java.util.Properties,java.io.InputStream,java.io.OutputStream>`
Parameters:
  `flowProcess` - of type FlowProcess
  `output` - of type Output
Returns:
  TupleEntryCollector
Throws:
  `java.io.IOException` - when the resource cannot be opened

#### createResource

    public boolean createResource(java.util.Properties conf)
                           throws java.io.IOException

Description copied from class: `Tap`
Method createResource creates the underlying resource.

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

#### deleteResource

    public boolean deleteResource(java.util.Properties conf)
                           throws java.io.IOException

Description copied from class: `Tap`
Method deleteResource deletes the resource represented by this instance.

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

#### commitResource

    public boolean commitResource(java.util.Properties conf)
                           throws java.io.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.

Overrides:
  `commitResource` in class `Tap<java.util.Properties,java.io.InputStream,java.io.OutputStream>`
Parameters:
  `conf` - of type Config
Returns:
  returns true if successful
Throws:
  `java.io.IOException`

#### resourceExists

    public boolean resourceExists(java.util.Properties conf)
                           throws java.io.IOException

Description copied from class: `Tap`
Method resourceExists returns true if the path represented by this instance exists.

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

#### getModifiedTime

    public long getModifiedTime(java.util.Properties conf)
                         throws java.io.IOException

Description copied from class: `Tap`
Method getModifiedTime returns the date this resource was last modified.

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

#### isDirectory

    public boolean isDirectory(FlowProcess<? extends java.util.Properties> flowProcess)
                        throws java.io.IOException

Description copied from interface: `FileType`
Method isDirectory returns true if the underlying resource represents a directory or folder instead of an individual file.

Specified by:
  `isDirectory` in interface `FileType<java.util.Properties>`
Returns:
  boolean
Throws:
  `java.io.IOException`

#### isDirectory

    public boolean isDirectory(java.util.Properties conf)
                        throws java.io.IOException

Description copied from interface: `FileType`
Method isDirectory returns true if the underlying resource represents a directory or folder instead of an individual file.

Specified by:
  `isDirectory` in interface `FileType<java.util.Properties>`
Parameters:
  `conf` - of JobConf
Returns:
  boolean
Throws:
  `java.io.IOException`

#### getChildIdentifiers

    public java.lang.String[] getChildIdentifiers(FlowProcess<? extends java.util.Properties> flowProcess)
                                           throws java.io.IOException

Description copied from interface: `FileType`
Method getChildIdentifiers returns an array of child identifiers if this resource is a directory.

This method will skip Hadoop log directories (`_log`).

Specified by:
  `getChildIdentifiers` in interface `FileType<java.util.Properties>`
Returns:
  String[]
Throws:
  `java.io.IOException`

#### getChildIdentifiers

    public java.lang.String[] getChildIdentifiers(java.util.Properties conf)
                                           throws java.io.IOException

Description copied from interface: `FileType`
Method getChildIdentifiers returns an array of child identifiers if this resource is a directory.

This method will skip Hadoop log directories (`_log`).

Specified by:
  `getChildIdentifiers` in interface `FileType<java.util.Properties>`
Parameters:
  `conf` - of JobConf
Returns:
  String[]
Throws:
  `java.io.IOException`

#### getChildIdentifiers

    public java.lang.String[] getChildIdentifiers(FlowProcess<? extends java.util.Properties> flowProcess,
                                         int depth,
                                         boolean fullyQualified)
                                           throws java.io.IOException

Specified by:
  `getChildIdentifiers` in interface `FileType<java.util.Properties>`
Throws:
  `java.io.IOException`

#### getChildIdentifiers

    public java.lang.String[] getChildIdentifiers(java.util.Properties conf,
                                         int depth,
                                         boolean fullyQualified)
                                           throws java.io.IOException

Specified by:
  `getChildIdentifiers` in interface `FileType<java.util.Properties>`
Throws:
  `java.io.IOException`

#### getSize

    public long getSize(FlowProcess<? extends java.util.Properties> flowProcess)
                 throws java.io.IOException

Description copied from interface: `FileType`
Method getSize returns the size of the file referenced by this tap.

Specified by:
  `getSize` in interface `FileType<java.util.Properties>`
Returns:
  The size of the file reference by this tap.
Throws:
  `java.io.IOException`

#### getSize

    public long getSize(java.util.Properties conf)
                 throws java.io.IOException

Description copied from interface: `FileType`
Method getSize returns the size of the file referenced by this tap.

Specified by:
  `getSize` in interface `FileType<java.util.Properties>`
Parameters:
  `conf` - of type Config
Returns:
  The size of the file reference by this tap.
Throws:
  `java.io.IOException`