Package io.deephaven.util.channel
Interface SeekableChannelsProvider
- All Superinterfaces:
AutoCloseable,SafeCloseable
- All Known Implementing Classes:
CachedChannelProvider,LocalFSChannelProvider
-
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamWrapsgetInputStream(SeekableByteChannel)to ensure the channel's position is incremented the exact amount that has been consumed from the resulting input stream.getInputStream(SeekableByteChannel channel) Creates anInputStreamfrom the current position ofchannel; closing the resulting input stream does not close thechannel.default SeekableByteChannelgetReadChannel(@NotNull SeekableChannelContext channelContext, @NotNull String uriStr) getReadChannel(@NotNull SeekableChannelContext channelContext, @NotNull URI uri) default SeekableByteChannelgetWriteChannel(@NotNull String path, boolean append) getWriteChannel(@NotNull Path path, boolean append) booleanisCompatibleWith(@NotNull SeekableChannelContext channelContext) Check if the given context is compatible with this provider.Create a newSeekableChannelContextobject for creating read channels via this provider.default SeekableChannelContextCreate a new "single-use"SeekableChannelContextobject for creating read channels via this provider.Methods inherited from interface io.deephaven.util.SafeCloseable
close
-
Method Details
-
channelPositionInputStream
static InputStream channelPositionInputStream(SeekableChannelsProvider provider, SeekableByteChannel ch) throws IOException WrapsgetInputStream(SeekableByteChannel)to ensure the channel's position is incremented the exact amount that has been consumed from the resulting input stream. To remain valid, the caller must ensure that the resulting input stream isn't re-wrapped by any downstream code in a way that would adversely affect the position (such as re-wrapping the resulting input stream with buffering).Equivalent to
ChannelPositionInputStream.of(ch, provider.getInputStream(ch)).- Parameters:
provider- the providerch- the seekable channel- Returns:
- the position-safe input stream
- Throws:
IOException- if an IO exception occurs- See Also:
-
makeContext
SeekableChannelContext makeContext()Create a newSeekableChannelContextobject for creating read channels via this provider. -
makeSingleUseContext
Create a new "single-use"SeekableChannelContextobject for creating read channels via this provider. This is meant for contexts that have a short lifecycle and expect to read a small amount from a read channel. -
isCompatibleWith
Check if the given context is compatible with this provider. Useful to test if we can use providedcontextobject for creating channels with this provider. -
getReadChannel
default SeekableByteChannel getReadChannel(@NotNull @NotNull SeekableChannelContext channelContext, @NotNull @NotNull String uriStr) throws IOException - Throws:
IOException
-
getReadChannel
SeekableByteChannel getReadChannel(@NotNull @NotNull SeekableChannelContext channelContext, @NotNull @NotNull URI uri) throws IOException - Throws:
IOException
-
getInputStream
Creates anInputStreamfrom the current position ofchannel; closing the resulting input stream does not close thechannel. TheInputStreamwill be buffered; either explicitly in the case where the implementation uses an unbufferedgetReadChannel(SeekableChannelContext, URI), or implicitly when the implementation uses a bufferedgetReadChannel(SeekableChannelContext, URI).channelmust have been created bythisprovider. The caller can't assume the position ofchannelafter consuming theInputStream. For use-cases that require the channel's position to be incremented the exact amount theInputStreamhas been consumed, usechannelPositionInputStream(SeekableChannelsProvider, SeekableByteChannel).- Parameters:
channel- the channel- Returns:
- the input stream
- Throws:
IOException- if an IO exception occurs
-
getWriteChannel
default SeekableByteChannel getWriteChannel(@NotNull @NotNull String path, boolean append) throws IOException - Throws:
IOException
-
getWriteChannel
- Throws:
IOException
-