When the root spliterator is first split a mapped byte buffer will be created over the file for its size that was observed when the stream was created. Thus a mapped byte buffer is only required for parallel stream execution. Sub-spliterators will share that mapped byte buffer. Splitting will use the mapped byte buffer to find the closest line feed characters(s) to the left or right of the mid-point of covered range of bytes of the file. If a line feed is found then the spliterator is split with returned spliterator containing the identified line feed characters(s) at the end of its covered range of bytes.
Traversing will create a buffered reader, derived from the file channel, for the range of bytes of the file. The lines are then read from that buffered reader. Once traversing commences no further splitting can be performed and the reference to the mapped byte buffer will be set to null.
Modifier and Type | Field and Description |
---|---|
private ByteBuffer | |
private final AtomicInteger | |
private final Charset | |
private final FileChannel | |
private final int | |
private int | |
private BufferedReader | |
pack-priv static final Set |
Access | Constructor and Description |
---|---|
pack-priv | |
private | FileChannelLinesSpliterator(FileChannel fc, Charset cs, int index, int fence, ByteBuffer buffer, AtomicInteger bufRefCount)
|
Modifier and Type | Method and Description |
---|---|
public int | characteristics()
Implements java. Returns a set of characteristics of this Spliterator and its elements. |
pack-priv void | |
public long | estimateSize()
Implements java. Returns an estimate of the number of elements that would be
encountered by a |
public void | forEachRemaining(Consumer<? super String>
The action action)Overrides default java. Performs the given action for each remaining element, sequentially in the current thread, until all elements have been processed or the action throws an exception. |
private BufferedReader | |
public long | getExactSizeIfKnown()
Overrides default java. Convenience method that returns |
private ByteBuffer | |
private String | |
public boolean | tryAdvance(Consumer<? super String>
The action whose operation is performed at-most once action)Implements java. If a remaining element exists: performs the given action on it,
returning |
public Spliterator | trySplit()
Implements java. If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator. |
private void |
buffer | back to summary |
---|---|
private ByteBuffer buffer |
bufRefCount | back to summary |
---|---|
private final AtomicInteger bufRefCount |
cs | back to summary |
---|---|
private final Charset cs |
fc | back to summary |
---|---|
private final FileChannel fc |
fence | back to summary |
---|---|
private final int fence |
index | back to summary |
---|---|
private int index |
reader | back to summary |
---|---|
private BufferedReader reader |
SUPPORTED_CHARSETS | back to summary |
---|---|
pack-priv static final Set<Charset> SUPPORTED_CHARSETS |
FileChannelLinesSpliterator | back to summary |
---|---|
pack-priv FileChannelLinesSpliterator(FileChannel fc, Charset cs, int index, int fence) |
FileChannelLinesSpliterator | back to summary |
---|---|
private FileChannelLinesSpliterator(FileChannel fc, Charset cs, int index, int fence, ByteBuffer buffer, AtomicInteger bufRefCount) |
characteristics | back to summary |
---|---|
public int characteristics() Implements java. Doc from java. Returns a set of characteristics of this Spliterator and its
elements. The result is represented as ORed values from If a Spliterator reports an inconsistent set of characteristics (either those returned from a single invocation or across multiple invocations), no guarantees can be made about any computation using this Spliterator.
|
close | back to summary |
---|---|
pack-priv void close() |
estimateSize | back to summary |
---|---|
public long estimateSize() Implements java. Doc from java. Returns an estimate of the number of elements that would be
encountered by a If this Spliterator is
|
forEachRemaining | back to summary |
---|---|
public void forEachRemaining(Consumer<? super String> action) Overrides default java. Doc from java. Performs the given action for each remaining element, sequentially in
the current thread, until all elements have been processed or the action
throws an exception. If this Spliterator is Subsequent behavior of a spliterator is unspecified if the action throws an exception. |
getBufferedReader | back to summary |
---|---|
private BufferedReader getBufferedReader() |
getExactSizeIfKnown | back to summary |
---|---|
public long getExactSizeIfKnown() Overrides default java. Doc from java. Convenience method that returns
|
getMappedByteBuffer | back to summary |
---|---|
private ByteBuffer getMappedByteBuffer() |
readLine | back to summary |
---|---|
private String readLine() |
tryAdvance | back to summary |
---|---|
public boolean tryAdvance(Consumer<? super String> action) Implements java. Doc from java. If a remaining element exists: performs the given action on it,
returning Subsequent behavior of a spliterator is unspecified if the action throws an exception. |
trySplit | back to summary |
---|---|
public Spliterator Implements java. Doc from java. If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator. If this Spliterator is Unless this Spliterator covers an infinite number of elements,
repeated calls to
This method may return
|
unmap | back to summary |
---|---|
private void unmap() |