Package io.deephaven.util.channel
Class CachedChannelProvider
java.lang.Object
io.deephaven.util.channel.CachedChannelProvider
- All Implemented Interfaces:
SeekableChannelsProvider,SafeCloseable,AutoCloseable
Channel provider that will cache a bounded number of unused channels.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static CachedChannelProvidercreate(@NotNull SeekableChannelsProvider wrappedProvider, int maximumPooledCount) getInputStream(SeekableByteChannel channel, int sizeHint) Creates anInputStreamfrom the current position ofchannelfrom which the caller expects to readsizeHintnumber of bytes.getReadChannel(@NotNull SeekableChannelContext channelContext, @NotNull URI uri) getWriteChannel(@NotNull Path path, boolean append) booleanisCompatibleWith(@NotNull SeekableChannelContext channelContext) Check if the given context is compatible with this provider.Returns a stream of URIs, the elements of which are the entries in the directory.Create a newSeekableChannelContextobject for creating read channels via this provider.Create a new "single-use"SeekableChannelContextobject for creating read channels via this provider.Returns a stream of URIs, the elements of which are all the files in the file tree rooted at the given starting directory.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.deephaven.util.channel.SeekableChannelsProvider
getReadChannel, getWriteChannel
-
Method Details
-
create
public static CachedChannelProvider create(@NotNull @NotNull SeekableChannelsProvider wrappedProvider, int maximumPooledCount) -
makeContext
Description copied from interface:SeekableChannelsProviderCreate a newSeekableChannelContextobject for creating read channels via this provider.- Specified by:
makeContextin interfaceSeekableChannelsProvider
-
makeSingleUseContext
Description copied from interface:SeekableChannelsProviderCreate 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.- Specified by:
makeSingleUseContextin interfaceSeekableChannelsProvider
-
isCompatibleWith
Description copied from interface:SeekableChannelsProviderCheck if the given context is compatible with this provider. Useful to test if we can use providedcontextobject for creating channels with this provider.- Specified by:
isCompatibleWithin interfaceSeekableChannelsProvider
-
getReadChannel
public SeekableByteChannel getReadChannel(@NotNull @NotNull SeekableChannelContext channelContext, @NotNull @NotNull URI uri) throws IOException - Specified by:
getReadChannelin interfaceSeekableChannelsProvider- Throws:
IOException
-
getInputStream
Description copied from interface:SeekableChannelsProviderCreates anInputStreamfrom the current position ofchannelfrom which the caller expects to readsizeHintnumber of bytes. Closing the resulting input stream does not close thechannel. TheInputStreamwill be buffered; either explicitly in the case where the implementation uses an unbufferedSeekableChannelsProvider.getReadChannel(SeekableChannelContext, URI), or implicitly when the implementation uses a bufferedSeekableChannelsProvider.getReadChannel(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, useSeekableChannelsProvider.channelPositionInputStream(SeekableChannelsProvider, SeekableByteChannel, int).- Specified by:
getInputStreamin interfaceSeekableChannelsProvider- Parameters:
channel- the channelsizeHint- the number of bytes the caller expects to read from the input stream- Returns:
- the input stream
- Throws:
IOException- if an IO exception occurs
-
getWriteChannel
public SeekableByteChannel getWriteChannel(@NotNull @NotNull Path path, boolean append) throws IOException - Specified by:
getWriteChannelin interfaceSeekableChannelsProvider- Throws:
IOException
-
list
Description copied from interface:SeekableChannelsProviderReturns a stream of URIs, the elements of which are the entries in the directory. The listing is non-recursive. The URIs supplied by the stream will not have any unnecessary slashes or path separators. Also, the URIs will be file URIs (not ending with "/") irrespective of whether the URI corresponds to a file or a directory. The caller should manage file vs. directory handling in the processor. The caller is also responsible for closing the stream, preferably using a try-with-resources block.- Specified by:
listin interfaceSeekableChannelsProvider- Parameters:
directory- the URI of the directory to list- Returns:
- The
StreamofURIs - Throws:
IOException
-
walk
Description copied from interface:SeekableChannelsProviderReturns a stream of URIs, the elements of which are all the files in the file tree rooted at the given starting directory. The URIs supplied by the stream will not have any unnecessary slashes or path separators. Also, the URIs will be file URIs (not ending with "/") irrespective of whether the URI corresponds to a file or a directory. The caller should manage file vs. directory handling in the processor. The caller is also responsible for closing the stream, preferably using a try-with-resources block.- Specified by:
walkin interfaceSeekableChannelsProvider- Parameters:
directory- the URI of the directory to walk- Returns:
- The
StreamofURIs - Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSafeCloseable
-