Class FileProcessor<T extends Event>
- java.lang.Object
-
- org.openstreetmap.atlas.checks.event.FileProcessor<T>
-
- Type Parameters:
T- type that is going to be processed
- All Implemented Interfaces:
Processor<T>
- Direct Known Subclasses:
CheckFlagFileProcessor,CheckFlagTippecanoeProcessor,MetricFileGenerator
public abstract class FileProcessor<T extends Event> extends java.lang.Object implements Processor<T>
A useful base class to handle common functionality for file processors.
-
-
Field Summary
Fields Modifier and Type Field Description static intBATCH_SIZE
-
Constructor Summary
Constructors Constructor Description FileProcessor(org.openstreetmap.atlas.generator.tools.spark.utilities.SparkFileHelper fileHelper, java.lang.String directory)Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandoesCompressOutput()intgetBatchSize()intgetCount()protected java.lang.StringgetFilename()voidprocess(java.lang.String event)Processes given String and writes batched events into a file if neededvoidsetBatchSize(int batchSize)Sets batch size to given valueFileProcessor<T>withCompression(boolean compress)Sets whether or not output files are compressedprotected voidwrite()Writes a new file with the cached in String buffer
-
-
-
Field Detail
-
BATCH_SIZE
public static final int BATCH_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileProcessor
public FileProcessor(org.openstreetmap.atlas.generator.tools.spark.utilities.SparkFileHelper fileHelper, java.lang.String directory)Default constructor- Parameters:
fileHelper-SparkFileHelperinstance for I/O operationsdirectory- directory path to write files to
-
-
Method Detail
-
doesCompressOutput
public boolean doesCompressOutput()
-
getBatchSize
public int getBatchSize()
- Returns:
- the maximum number of events to be batched in a file
-
getCount
public final int getCount()
- Returns:
- the number of events processed in the current batch
-
process
public void process(java.lang.String event)
Processes given String and writes batched events into a file if needed- Parameters:
event- a character set to process
-
setBatchSize
public void setBatchSize(int batchSize)
Sets batch size to given value- Parameters:
batchSize- New batch size
-
withCompression
public FileProcessor<T> withCompression(boolean compress)
Sets whether or not output files are compressed- Parameters:
compress- value to set- Returns:
- the
FileProcessor
-
getFilename
protected java.lang.String getFilename()
- Returns:
- the name of the file to be used in
#write()method to write files
-
write
protected void write()
Writes a new file with the cached in String buffer
-
-