Package org.datavec.api.split
Class StringSplit
- java.lang.Object
-
- org.datavec.api.split.StringSplit
-
- All Implemented Interfaces:
InputSplit
public class StringSplit extends Object implements InputSplit
String split used for single line inputs- Author:
- Adam Gibson
-
-
Constructor Summary
Constructors Constructor Description StringSplit(String data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
addNewLocation()
Add a new location with the name generated by this input split/String
addNewLocation(String location)
Add a new location to this input split (this may do anything from updating an in memory location to creating a new file)void
bootStrapForWrite()
Bootstrap this input split for writing.boolean
canWriteToLocation(URI location)
Returns true if the given uri can be written toString
getData()
long
length()
Length of the splitURI[]
locations()
Locations of the splitsIterator<URI>
locationsIterator()
Iterator<String>
locationsPathIterator()
boolean
needsBootstrapForWrite()
Returns true if thisInputSplit
needs bootstrapping for writing.InputStream
openInputStreamFor(String location)
Open anInputStream
for the given location.OutputStream
openOutputStreamFor(String location)
Open anOutputStream
for the given location.void
reset()
Reset the InputSplit without reinitializing it from scratch.boolean
resetSupported()
void
updateSplitLocations(boolean reset)
Refreshes the split locations if needed in memory.
-
-
-
Constructor Detail
-
StringSplit
public StringSplit(String data)
-
-
Method Detail
-
canWriteToLocation
public boolean canWriteToLocation(URI location)
Description copied from interface:InputSplit
Returns true if the given uri can be written to- Specified by:
canWriteToLocation
in interfaceInputSplit
- Parameters:
location
- the location to determine- Returns:
-
addNewLocation
public String addNewLocation()
Description copied from interface:InputSplit
Add a new location with the name generated by this input split/- Specified by:
addNewLocation
in interfaceInputSplit
-
addNewLocation
public String addNewLocation(String location)
Description copied from interface:InputSplit
Add a new location to this input split (this may do anything from updating an in memory location to creating a new file)- Specified by:
addNewLocation
in interfaceInputSplit
- Parameters:
location
- the location to add
-
updateSplitLocations
public void updateSplitLocations(boolean reset)
Description copied from interface:InputSplit
Refreshes the split locations if needed in memory. (Think a few file gets added)- Specified by:
updateSplitLocations
in interfaceInputSplit
-
needsBootstrapForWrite
public boolean needsBootstrapForWrite()
Description copied from interface:InputSplit
Returns true if thisInputSplit
needs bootstrapping for writing. A simple example of needing bootstrapping is forFileSplit
where there is only a directory existing, but no file to write to- Specified by:
needsBootstrapForWrite
in interfaceInputSplit
- Returns:
- true if this input split needs bootstrapping for writing to or not
-
bootStrapForWrite
public void bootStrapForWrite()
Description copied from interface:InputSplit
Bootstrap this input split for writing. This is for use withRecordWriter
- Specified by:
bootStrapForWrite
in interfaceInputSplit
-
openOutputStreamFor
public OutputStream openOutputStreamFor(String location) throws Exception
Description copied from interface:InputSplit
Open anOutputStream
for the given location. Note that the user is responsible for closing the associated output stream.- Specified by:
openOutputStreamFor
in interfaceInputSplit
- Parameters:
location
- the location to open the output stream for- Returns:
- the output input stream
- Throws:
Exception
-
openInputStreamFor
public InputStream openInputStreamFor(String location) throws Exception
Description copied from interface:InputSplit
Open anInputStream
for the given location. Note that the user is responsible for closing the associated input stream.- Specified by:
openInputStreamFor
in interfaceInputSplit
- Parameters:
location
- the location to open the input stream for- Returns:
- the opened input stream
- Throws:
Exception
-
length
public long length()
Description copied from interface:InputSplit
Length of the split- Specified by:
length
in interfaceInputSplit
- Returns:
-
locations
public URI[] locations()
Description copied from interface:InputSplit
Locations of the splits- Specified by:
locations
in interfaceInputSplit
- Returns:
-
locationsIterator
public Iterator<URI> locationsIterator()
- Specified by:
locationsIterator
in interfaceInputSplit
- Returns:
-
locationsPathIterator
public Iterator<String> locationsPathIterator()
- Specified by:
locationsPathIterator
in interfaceInputSplit
- Returns:
-
reset
public void reset()
Description copied from interface:InputSplit
Reset the InputSplit without reinitializing it from scratch. In many cases, this is a no-op. For InputSplits that have randomization: reset should shuffle the order.- Specified by:
reset
in interfaceInputSplit
-
resetSupported
public boolean resetSupported()
- Specified by:
resetSupported
in interfaceInputSplit
- Returns:
- True if the reset() method is supported (or is a no-op), false otherwise. If false is returned, reset() may throw an exception
-
getData
public String getData()
-
-