public class BatchAttributeGenerator extends java.lang.Object implements Commandable, Options
Note: Order of entries is not guaranteed to be preserved for parallel evaluation.
How to Use This Class
There are two major use cases for this class
Usage: <batch size> <output method>
[<output options...>]
batch size: Number of entries to compute at once
output method: Name of BaseDatasetOutput
method used for output
output options: Any options for the output method
Modifier and Type | Field and Description |
---|---|
protected Dataset |
AttributeComputer
Dataset used to generate attributes
|
protected int |
BatchSize
Number of entries to evaluate at a single time
|
protected BaseDatasetOutput |
Outputter
Tool used to output data
|
Constructor and Description |
---|
BatchAttributeGenerator()
Create an batch writer using the default settings: comma-delimited file,
batch size of 10000 entries
|
BatchAttributeGenerator(BaseDatasetOutput outputter,
int batchSize)
Create a batch evaluator with a specified output method and batch size
|
Modifier and Type | Method and Description |
---|---|
protected java.util.List<BaseEntry> |
getBatch()
Get a batch of entries.
|
void |
output(Dataset data,
java.io.File file)
Compute attributes and write entries to a file
|
void |
output(Dataset template,
java.util.Iterator<BaseEntry> iterator,
java.io.OutputStream out)
Compute attributes and write entries to an output stream in batches
|
void |
output(Dataset data,
java.io.OutputStream out)
Compute attributes and write entries to an output stream in batches
|
java.lang.String |
printUsage()
Print out required format for options.
|
java.lang.Object |
runCommand(java.util.List<java.lang.Object> Command)
Process some command described by a list of Objects.
|
void |
setBatchSize(int size)
Define maximum number of entries to compute at a single time
|
protected void |
setEntryIterator(java.util.Iterator<BaseEntry> iterator)
Set the iterator over entries being processed
|
void |
setOptions(java.util.List<java.lang.Object> Options)
Set any options for this object.
|
void |
setOutputter(BaseDatasetOutput output)
Define tool used to output data
|
protected void |
writeEntries(Dataset toWrite,
java.io.OutputStream output)
Write entries to output stream
|
protected BaseDatasetOutput Outputter
protected int BatchSize
protected Dataset AttributeComputer
public BatchAttributeGenerator()
public BatchAttributeGenerator(BaseDatasetOutput outputter, int batchSize)
outputter
- Output method (default: DelimitedOutput)batchSize
- Batch size (default: 10000)public void setOptions(java.util.List<java.lang.Object> Options) throws java.lang.Exception
Options
setOptions
in interface Options
Options
- Array of options as Objects - can be null
java.lang.Exception
- if problem with inputspublic java.lang.String printUsage()
Options
printUsage
in interface Options
public void setOutputter(BaseDatasetOutput output)
output
- Output methodpublic void setBatchSize(int size)
size
- Desired batch sizeprotected void setEntryIterator(java.util.Iterator<BaseEntry> iterator)
iterator
- Iteratorpublic void output(Dataset data, java.io.File file) throws java.io.IOException
data
- Dataset to be writtenfile
- Path to output filejava.io.IOException
public void output(Dataset data, java.io.OutputStream out)
data
- Dataset to be writtenout
- Output stream for datapublic void output(Dataset template, java.util.Iterator<BaseEntry> iterator, java.io.OutputStream out)
template
- Dataset used to generate attributesiterator
- Iterator over entries to be printedout
- Output stream for dataprotected java.util.List<BaseEntry> getBatch()
protected void writeEntries(Dataset toWrite, java.io.OutputStream output)
toWrite
- Entries to be writtenoutput
- Desired output streampublic java.lang.Object runCommand(java.util.List<java.lang.Object> Command) throws java.lang.Exception
Commandable
runCommand
in interface Commandable
Command
- Command as a list of objectsjava.lang.Exception
- If something goes wrong