Package com.github.ambry.store
Interface MessageReadSet
-
public interface MessageReadSet
This represents a list of messages from a given store.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
count()
void
doPrefetch(int index, long relativeOffset, long size)
Do data prefetch from store.StoreKey
getKeyAt(int index)
Returns the key of the ith messageio.netty.buffer.ByteBuf
getPrefetchedData(int index)
Return prefetched data at givenindex
.long
sizeInBytes(int index)
Returns the size of the ith messagelong
writeTo(int index, java.nio.channels.WritableByteChannel channel, long relativeOffset, long maxSize)
Write the message referred by the index in this set to the given channel from the given relative offset up to maxSize.void
writeTo(AsyncWritableChannel channel, Callback<java.lang.Long> callback)
This method is intend to write prefetched data fromMessageReadSet
toAsyncWritableChannel
.
-
-
-
Method Detail
-
writeTo
long writeTo(int index, java.nio.channels.WritableByteChannel channel, long relativeOffset, long maxSize) throws java.io.IOException
Write the message referred by the index in this set to the given channel from the given relative offset up to maxSize. Less than the complete amount may be written, but no more than maxSize can be. The number of bytes written is returned- Parameters:
index
- the index of the message in the set that needs to be writtenchannel
- the channel into which the data needs to be written torelativeOffset
- The relative offset into the message from which the write needs to startmaxSize
- The max size that needs to be written from the given message- Returns:
- The total bytes that was written into the channel
- Throws:
java.io.IOException
-
writeTo
void writeTo(AsyncWritableChannel channel, Callback<java.lang.Long> callback)
This method is intend to write prefetched data fromMessageReadSet
toAsyncWritableChannel
. Data should be ready in memory(no blocking call) before write toAsyncWritableChannel
asynchronously. Callback is called when the entire batch of writes succeeds or fails.- Parameters:
channel
- the channel into which the data needs to be written tocallback
- The callback when data is fully wrote to the channel.
-
count
int count()
- Returns:
- The total number of messages in this set
-
sizeInBytes
long sizeInBytes(int index)
Returns the size of the ith message- Parameters:
index
- The index into the message set- Returns:
- The size in bytes of the message represented by the index
-
getKeyAt
StoreKey getKeyAt(int index)
Returns the key of the ith message- Parameters:
index
- The index into the message set- Returns:
- The key of the message represented by the index
-
doPrefetch
void doPrefetch(int index, long relativeOffset, long size) throws java.io.IOException
Do data prefetch from store.- Parameters:
index
- The index into the message setrelativeOffset
- The relativeOffset to start withsize
- The size requested to doPrefetch.- Throws:
java.io.IOException
-
getPrefetchedData
io.netty.buffer.ByteBuf getPrefetchedData(int index)
Return prefetched data at givenindex
.- Parameters:
index
- The index into the message set.- Returns:
- The prefetched data.
-
-