public class StreamInputSplit extends Object implements InputSplit
Function<URI,InputStream>
that opens an InputStream for the given URI.StreamInputSplit(List, Function, Random)
by providing a Random
instance. If no Random instance is provided, the order will always be according to the
order in the provided list of URIs.Modifier and Type | Field and Description |
---|---|
protected int[] |
order |
protected Random |
rng |
protected Function<URI,InputStream> |
streamCreatorFn |
protected List<URI> |
uris |
Constructor and Description |
---|
StreamInputSplit(List<URI> uris,
Function<URI,InputStream> streamCreatorFn)
Create a StreamInputSplit with no randomization
|
StreamInputSplit(List<URI> uris,
Function<URI,InputStream> streamCreatorFn,
Random rng)
Create a StreamInputSplit with optional randomization
|
Modifier and Type | Method and 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 to
|
long |
length()
Length of the split
|
URI[] |
locations()
Locations of the splits
|
Iterator<URI> |
locationsIterator() |
Iterator<String> |
locationsPathIterator() |
boolean |
needsBootstrapForWrite()
Returns true if this
InputSplit
needs bootstrapping for writing. |
InputStream |
openInputStreamFor(String location)
Open an
InputStream
for the given location. |
OutputStream |
openOutputStreamFor(String location)
Open an
OutputStream
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.
|
protected Function<URI,InputStream> streamCreatorFn
protected Random rng
protected int[] order
public StreamInputSplit(@NonNull List<URI> uris, @NonNull Function<URI,InputStream> streamCreatorFn)
uris
- The list of URIs to loadstreamCreatorFn
- The function to be used to create InputStream objects for a given URI.public StreamInputSplit(@NonNull List<URI> uris, @NonNull Function<URI,InputStream> streamCreatorFn, Random rng)
uris
- The list of URIs to loadstreamCreatorFn
- The function to be used to create InputStream objects for a given URIrng
- Random number generator instance. If non-null: streams will be iterated over in a random
order. If null: no randomization (iteration order is according to the URIs list)public boolean canWriteToLocation(URI location)
InputSplit
canWriteToLocation
in interface InputSplit
location
- the location to determinepublic String addNewLocation()
InputSplit
addNewLocation
in interface InputSplit
public String addNewLocation(String location)
InputSplit
addNewLocation
in interface InputSplit
location
- the location to addpublic void updateSplitLocations(boolean reset)
InputSplit
updateSplitLocations
in interface InputSplit
public boolean needsBootstrapForWrite()
InputSplit
InputSplit
needs bootstrapping for writing.
A simple example of needing bootstrapping is for
FileSplit
where there is only a directory
existing, but no file to write toneedsBootstrapForWrite
in interface InputSplit
public void bootStrapForWrite()
InputSplit
RecordWriter
bootStrapForWrite
in interface InputSplit
public OutputStream openOutputStreamFor(String location) throws Exception
InputSplit
OutputStream
for the given location.
Note that the user is responsible for closing
the associated output stream.openOutputStreamFor
in interface InputSplit
location
- the location to open the output stream forException
public InputStream openInputStreamFor(String location) throws Exception
InputSplit
InputStream
for the given location.
Note that the user is responsible for closing
the associated input stream.openInputStreamFor
in interface InputSplit
location
- the location to open the input stream forException
public long length()
InputSplit
length
in interface InputSplit
public URI[] locations()
InputSplit
locations
in interface InputSplit
public Iterator<URI> locationsIterator()
locationsIterator
in interface InputSplit
public Iterator<String> locationsPathIterator()
locationsPathIterator
in interface InputSplit
public void reset()
InputSplit
reset
in interface InputSplit
public boolean resetSupported()
resetSupported
in interface InputSplit
Copyright © 2019. All rights reserved.