public class TextLine extends Scheme<Properties,InputStream,OutputStream,LineNumberReader,PrintWriter>
Scheme
for plain text files. Files are broken into
lines. Either line-feed or carriage-return are used to signal end of line.
By default, this scheme returns a Tuple
with two fields, "num" and "line". Where "num"
is the line number for "line".
Many of the constructors take both "sourceFields" and "sinkFields". sourceFields denote the field names
to be used instead of the names "num" and "line". sinkFields is a selector and is by default Fields.ALL
.
Any available field names can be given if only a subset of the incoming fields should be used.
If a Fields
instance is passed on the constructor as sourceFields having only one field, the return tuples
will simply be the "line" value using the given field name.
Note that TextLine will concatenate all the Tuple values for the selected fields with a TAB delimiter before
writing out the line.
By default, all text is encoded/decoded as UTF-8. This can be changed via the charsetName
constructor
argument.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_CHARSET |
static Fields |
DEFAULT_SOURCE_FIELDS |
Constructor and Description |
---|
TextLine()
Creates a new TextLine instance that sources "num" and "line" fields, and sinks all incoming fields, where
"num" is the line number of the line in the input file.
|
TextLine(Fields sourceFields)
Creates a new TextLine instance.
|
TextLine(Fields sourceFields,
Fields sinkFields)
Creates a new TextLine instance.
|
TextLine(Fields sourceFields,
Fields sinkFields,
String charsetName)
Creates a new TextLine instance.
|
TextLine(Fields sourceFields,
String charsetName)
Creates a new TextLine instance.
|
equals, getNumSinkParts, getSinkFields, getSourceFields, getTrace, hashCode, isSink, isSource, isSymmetrical, presentSinkFieldsInternal, presentSourceFieldsInternal, retrieveSinkFields, retrieveSourceFields, setNumSinkParts, setSinkFields, setSourceFields, toString
public static final String DEFAULT_CHARSET
public static final Fields DEFAULT_SOURCE_FIELDS
public TextLine()
@ConstructorProperties(value="sourceFields") public TextLine(Fields sourceFields)
sourceFields
- of Fields@ConstructorProperties(value={"sourceFields","charsetName"}) public TextLine(Fields sourceFields, String charsetName)
sourceFields
- of FieldscharsetName
- of type String@ConstructorProperties(value={"sourceFields","sinkFields"}) public TextLine(Fields sourceFields, Fields sinkFields)
sourceFields
- of FieldssinkFields
- of Fields@ConstructorProperties(value={"sourceFields","sinkFields","charsetName"}) public TextLine(Fields sourceFields, Fields sinkFields, String charsetName)
sourceFields
- of FieldssinkFields
- of FieldscharsetName
- of type Stringpublic String getCharsetName()
public LineNumberReader createInput(InputStream inputStream)
public PrintWriter createOutput(OutputStream outputStream)
public void presentSourceFields(FlowProcess<? extends Properties> process, Tap tap, Fields fields)
presentSourceFields
in class Scheme<Properties,InputStream,OutputStream,LineNumberReader,PrintWriter>
public void presentSinkFields(FlowProcess<? extends Properties> process, Tap tap, Fields fields)
presentSinkFields
in class Scheme<Properties,InputStream,OutputStream,LineNumberReader,PrintWriter>
public void sourceConfInit(FlowProcess<? extends Properties> flowProcess, Tap<Properties,InputStream,OutputStream> tap, Properties conf)
sourceConfInit
in class Scheme<Properties,InputStream,OutputStream,LineNumberReader,PrintWriter>
public void sinkConfInit(FlowProcess<? extends Properties> flowProcess, Tap<Properties,InputStream,OutputStream> tap, Properties conf)
sinkConfInit
in class Scheme<Properties,InputStream,OutputStream,LineNumberReader,PrintWriter>
public void sourcePrepare(FlowProcess<? extends Properties> flowProcess, SourceCall<LineNumberReader,InputStream> sourceCall) throws IOException
sourcePrepare
in class Scheme<Properties,InputStream,OutputStream,LineNumberReader,PrintWriter>
IOException
public boolean source(FlowProcess<? extends Properties> flowProcess, SourceCall<LineNumberReader,InputStream> sourceCall) throws IOException
source
in class Scheme<Properties,InputStream,OutputStream,LineNumberReader,PrintWriter>
IOException
public void sourceCleanup(FlowProcess<? extends Properties> flowProcess, SourceCall<LineNumberReader,InputStream> sourceCall) throws IOException
sourceCleanup
in class Scheme<Properties,InputStream,OutputStream,LineNumberReader,PrintWriter>
IOException
public void sinkPrepare(FlowProcess<? extends Properties> flowProcess, SinkCall<PrintWriter,OutputStream> sinkCall) throws IOException
sinkPrepare
in class Scheme<Properties,InputStream,OutputStream,LineNumberReader,PrintWriter>
IOException
public void sink(FlowProcess<? extends Properties> flowProcess, SinkCall<PrintWriter,OutputStream> sinkCall) throws IOException
sink
in class Scheme<Properties,InputStream,OutputStream,LineNumberReader,PrintWriter>
IOException
public void sinkCleanup(FlowProcess<? extends Properties> flowProcess, SinkCall<PrintWriter,OutputStream> sinkCall) throws IOException
sinkCleanup
in class Scheme<Properties,InputStream,OutputStream,LineNumberReader,PrintWriter>
IOException
Copyright © 2007-2015 Concurrent, Inc. All Rights Reserved.