Package org.h2.mvstore.cache
Class FilePathCache.FileCache
- java.lang.Object
-
- java.nio.channels.spi.AbstractInterruptibleChannel
-
- java.nio.channels.FileChannel
-
- org.h2.store.fs.FileBase
-
- org.h2.mvstore.cache.FilePathCache.FileCache
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.ByteChannel,java.nio.channels.Channel,java.nio.channels.GatheringByteChannel,java.nio.channels.InterruptibleChannel,java.nio.channels.ReadableByteChannel,java.nio.channels.ScatteringByteChannel,java.nio.channels.SeekableByteChannel,java.nio.channels.WritableByteChannel
- Enclosing class:
- FilePathCache
public static class FilePathCache.FileCache extends FileBase
A file with a read cache.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.channels.FileChannelbaseprivate CacheLongKeyLIRS<java.nio.ByteBuffer>cacheprivate static intCACHE_BLOCK_SIZE
-
Constructor Summary
Constructors Constructor Description FileCache(java.nio.channels.FileChannel base)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidclearCache(java.nio.ByteBuffer src, long position)voidforce(boolean metaData)private static longgetCachePos(long pos)protected voidimplCloseChannel()longposition()java.nio.channels.FileChannelposition(long newPosition)intread(java.nio.ByteBuffer dst)intread(java.nio.ByteBuffer dst, long position)longsize()java.lang.StringtoString()java.nio.channels.FileChanneltruncate(long newSize)java.nio.channels.FileLocktryLock(long position, long size, boolean shared)intwrite(java.nio.ByteBuffer src)intwrite(java.nio.ByteBuffer src, long position)-
Methods inherited from class org.h2.store.fs.FileBase
lock, map, read, transferFrom, transferTo, write
-
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
-
-
-
Field Detail
-
CACHE_BLOCK_SIZE
private static final int CACHE_BLOCK_SIZE
- See Also:
- Constant Field Values
-
base
private final java.nio.channels.FileChannel base
-
cache
private final CacheLongKeyLIRS<java.nio.ByteBuffer> cache
-
-
Method Detail
-
implCloseChannel
protected void implCloseChannel() throws java.io.IOException- Overrides:
implCloseChannelin classFileBase- Throws:
java.io.IOException
-
position
public java.nio.channels.FileChannel position(long newPosition) throws java.io.IOException- Specified by:
positionin interfacejava.nio.channels.SeekableByteChannel- Specified by:
positionin classjava.nio.channels.FileChannel- Throws:
java.io.IOException
-
position
public long position() throws java.io.IOException- Specified by:
positionin interfacejava.nio.channels.SeekableByteChannel- Specified by:
positionin classjava.nio.channels.FileChannel- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException- Specified by:
readin interfacejava.nio.channels.ReadableByteChannel- Specified by:
readin interfacejava.nio.channels.SeekableByteChannel- Specified by:
readin classjava.nio.channels.FileChannel- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst, long position) throws java.io.IOException
-
getCachePos
private static long getCachePos(long pos)
-
size
public long size() throws java.io.IOException- Specified by:
sizein interfacejava.nio.channels.SeekableByteChannel- Specified by:
sizein classjava.nio.channels.FileChannel- Throws:
java.io.IOException
-
truncate
public java.nio.channels.FileChannel truncate(long newSize) throws java.io.IOException- Specified by:
truncatein interfacejava.nio.channels.SeekableByteChannel- Specified by:
truncatein classjava.nio.channels.FileChannel- Throws:
java.io.IOException
-
write
public int write(java.nio.ByteBuffer src, long position) throws java.io.IOException
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException- Specified by:
writein interfacejava.nio.channels.SeekableByteChannel- Specified by:
writein interfacejava.nio.channels.WritableByteChannel- Specified by:
writein classjava.nio.channels.FileChannel- Throws:
java.io.IOException
-
clearCache
private void clearCache(java.nio.ByteBuffer src, long position)
-
force
public void force(boolean metaData) throws java.io.IOException
-
tryLock
public java.nio.channels.FileLock tryLock(long position, long size, boolean shared) throws java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-