public class DirTap extends FileTap
A DirTap can be used as a sink or a source.
When used as a source, the given pattern and depth are used to identify input files from the filesystem.
When used as a sink, a single file is created in the directory for all the output data. The file is name is
returned by FileTap.getOutputIdentifier(FlowProcess)
and can be overridden (see getOutputFilename(FlowProcess)
and
getOutputFileBasename()
).
When deleting the resource identified by this Tap, the value of FileTap.getOutputIdentifier(FlowProcess)
will
be deleted, if it exists.
DirTap must be used with the LocalFlowConnector
to create
Flow
instances that run in "local" mode.
The given pattern must adhere to the syntax supported by FileSystem.getPathMatcher(String)
.
Or a sub-class may override getPathMatcher()
and return a custom matcher.
The maxDepth parameter is the maximum number of levels of directories to visit. A value of 0 means that only the starting file is visited, unless denied by the security manager.
A value of MAX_VALUE (the default) may be used to indicate that all levels should be visited.
CASCADING_SOURCE_PATH
Constructor and Description |
---|
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.nio.file.Path directory)
Constructor DirTap creates a new DirTap instance using the given
Scheme and file directory . |
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.nio.file.Path directory,
SinkMode sinkMode)
Constructor DirTap creates a new DirTap instance using the given
Scheme and file directory . |
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.nio.file.Path directory,
java.lang.String pattern)
Constructor DirTap creates a new DirTap instance using the given
Scheme , file directory ,
and pattern . |
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.nio.file.Path directory,
java.lang.String pattern,
int maxDepth)
Constructor DirTap creates a new DirTap instance using the given
Scheme , file directory ,
pattern , and maxDepth |
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.nio.file.Path directory,
java.lang.String pattern,
int maxDepth,
SinkMode sinkMode)
Constructor DirTap creates a new DirTap instance using the given
Scheme , file directory ,
pattern , and maxDepth |
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.nio.file.Path directory,
java.lang.String pattern,
SinkMode sinkMode)
Constructor DirTap creates a new DirTap instance using the given
Scheme , file directory ,
and pattern . |
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.lang.String directory)
Constructor DirTap creates a new DirTap instance using the given
Scheme and file directory . |
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.lang.String directory,
SinkMode sinkMode)
Constructor DirTap creates a new DirTap instance using the given
Scheme and file directory . |
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.lang.String directory,
java.lang.String pattern)
Constructor DirTap creates a new DirTap instance using the given
Scheme , file directory ,
and pattern . |
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.lang.String directory,
java.lang.String pattern,
int maxDepth)
Constructor DirTap creates a new DirTap instance using the given
Scheme , file directory ,
pattern , and maxDepth |
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.lang.String directory,
java.lang.String pattern,
int maxDepth,
SinkMode sinkMode)
Constructor DirTap creates a new DirTap instance using the given
Scheme , file directory ,
pattern , and maxDepth |
DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme,
java.lang.String directory,
java.lang.String pattern,
SinkMode sinkMode)
Constructor DirTap creates a new DirTap instance using the given
Scheme , file directory ,
and pattern . |
Modifier and Type | Method and Description |
---|---|
protected static void |
deleteChildren(java.nio.file.Path parentPath,
java.lang.String[] childIdentifiers)
Deletes the child files and their directories.
|
static boolean |
deleteDirTap(DirTap dirTap,
java.util.Properties conf)
Method deleteDirTap will recursively delete all files referenced by the given DirTap.
|
boolean |
deleteResource(java.util.Properties conf) |
int |
getMaxDepth() |
protected java.lang.String |
getOutputFileBasename() |
protected java.lang.String |
getOutputFilename(FlowProcess<? extends java.util.Properties> flowProcess) |
protected java.lang.String |
getOutputIdentifier(FlowProcess<? extends java.util.Properties> flowProcess)
Only used with
FileTap.openForWrite(FlowProcess, OutputStream) calls. |
protected java.nio.file.PathMatcher |
getPathMatcher() |
java.lang.String |
getPattern() |
TupleEntryIterator |
openForRead(FlowProcess<? extends java.util.Properties> flowProcess,
java.io.InputStream input) |
protected void |
verify() |
commitResource, create, createResource, getChildIdentifiers, getChildIdentifiers, getChildIdentifiers, getChildIdentifiers, getFullIdentifier, getIdentifier, getModifiedTime, getPath, getSize, getSize, isDirectory, isDirectory, openForWrite, resourceExists, withChildIdentifier, withScheme, withSinkMode
createResource, deleteResource, entryStream, entryStream, entryStreamCopy, entryStreamCopy, equals, flowConfInit, getConfigDef, getFullIdentifier, getModifiedTime, getNodeConfigDef, getScheme, getSinkFields, getSinkMode, getSourceFields, getStepConfigDef, getTrace, hasConfigDef, hashCode, hasNodeConfigDef, hasStepConfigDef, id, isKeep, isReplace, isSink, isSource, isTemporary, isUpdate, openForRead, openForReadUnchecked, openForWrite, outgoingScopeFor, prepareResourceForRead, prepareResourceForWrite, presentSinkFields, presentSourceFields, resolveIncomingOperationArgumentFields, resolveIncomingOperationPassThroughFields, resourceExists, retrieveSinkFields, retrieveSourceFields, rollbackResource, setScheme, sinkConfInit, sourceConfInit, spliterator, splititerator, taps, toString, tupleStream, tupleStream, tupleStreamCopy, tupleStreamCopy
public DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.lang.String directory)
Scheme
and file directory
.scheme
- of type Schemedirectory
- of type Stringpublic DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.lang.String directory, java.lang.String pattern)
Scheme
, file directory
,
and pattern
.scheme
- of type Schemedirectory
- of type Stringpattern
- of type Stringpublic DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.lang.String directory, java.lang.String pattern, int maxDepth)
Scheme
, file directory
,
pattern
, and maxDepth
scheme
- of type Schemedirectory
- of type Stringpattern
- of type StringmaxDepth
- of type intpublic DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.lang.String directory, SinkMode sinkMode)
Scheme
and file directory
.scheme
- of type Schemedirectory
- of type StringsinkMode
- of type SinkModepublic DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.lang.String directory, java.lang.String pattern, SinkMode sinkMode)
Scheme
, file directory
,
and pattern
.scheme
- of type Schemedirectory
- of type Stringpattern
- of type StringsinkMode
- of type SinkModepublic DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.lang.String directory, java.lang.String pattern, int maxDepth, SinkMode sinkMode)
Scheme
, file directory
,
pattern
, and maxDepth
scheme
- of type Schemedirectory
- of type Stringpattern
- of type StringmaxDepth
- of type intsinkMode
- of type SinkModepublic DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.nio.file.Path directory)
Scheme
and file directory
.scheme
- of type Schemedirectory
- of type Pathpublic DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.nio.file.Path directory, java.lang.String pattern)
Scheme
, file directory
,
and pattern
.scheme
- of type Schemedirectory
- of type Pathpattern
- of type Stringpublic DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.nio.file.Path directory, java.lang.String pattern, int maxDepth)
Scheme
, file directory
,
pattern
, and maxDepth
scheme
- of type Schemedirectory
- of type Pathpattern
- of type StringmaxDepth
- of type intpublic DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.nio.file.Path directory, SinkMode sinkMode)
Scheme
and file directory
.scheme
- of type Schemedirectory
- of type PathsinkMode
- of type SinkModepublic DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.nio.file.Path directory, java.lang.String pattern, SinkMode sinkMode)
Scheme
, file directory
,
and pattern
.scheme
- of type Schemedirectory
- of type Pathpattern
- of type StringsinkMode
- of type SinkModepublic DirTap(Scheme<java.util.Properties,java.io.InputStream,java.io.OutputStream,?,?> scheme, java.nio.file.Path directory, java.lang.String pattern, int maxDepth, SinkMode sinkMode)
Scheme
, file directory
,
pattern
, and maxDepth
scheme
- of type Schemedirectory
- of type Pathpattern
- of type StringmaxDepth
- of type intsinkMode
- of type SinkModeprotected java.lang.String getOutputIdentifier(FlowProcess<? extends java.util.Properties> flowProcess)
FileTap
FileTap.openForWrite(FlowProcess, OutputStream)
calls.getOutputIdentifier
in class FileTap
protected java.lang.String getOutputFilename(FlowProcess<? extends java.util.Properties> flowProcess)
protected java.lang.String getOutputFileBasename()
public java.lang.String getPattern()
public int getMaxDepth()
public boolean deleteResource(java.util.Properties conf) throws java.io.IOException
deleteResource
in class FileTap
java.io.IOException
public TupleEntryIterator openForRead(FlowProcess<? extends java.util.Properties> flowProcess, java.io.InputStream input) throws java.io.IOException
openForRead
in class FileTap
java.io.IOException
protected java.nio.file.PathMatcher getPathMatcher()
getPathMatcher
in class FileTap
public static boolean deleteDirTap(DirTap dirTap, java.util.Properties conf) throws java.io.IOException
dirTap
- the directory to deletejava.io.IOException
protected static void deleteChildren(java.nio.file.Path parentPath, java.lang.String[] childIdentifiers) throws java.io.IOException
parentPath
- childIdentifiers
- java.io.IOException
Copyright © 2007-2017 Cascading Maintainers. All Rights Reserved.