|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.magnos.data.store.AbstractStore
org.magnos.data.store.MappedStore
public class MappedStore
A store which has a memory-mapped file as its persisted medium. All reads and writes are not done immediately, only when the disk is idle or when flush or load are called explicitly. If this store has exclusive or read-write access to the mapped file load does not need to be called before reads.
Constructor Summary | |
---|---|
MappedStore(java.io.File file)
Instantiantes a new MappedStore. |
|
MappedStore(java.io.File file,
StoreAccess access,
int capacity)
Instantiates a new MappedStore while opening it with the given access and setting it the given capacity. |
|
MappedStore(java.lang.String filename)
Instantiantes a new MappedStore. |
|
MappedStore(java.lang.String filename,
StoreAccess access,
int capacity)
Instantiates a new MappedStore while opening it with the given access and setting it the given capacity. |
Method Summary | |
---|---|
java.nio.MappedByteBuffer |
getBuffer()
Returns the memory mapped buffer of the files data. |
java.nio.channels.FileChannel |
getChannel()
Returns the channel used to perform operations on the file. |
java.io.File |
getFile()
Returns the file the store is persisted to. |
java.io.RandomAccessFile |
getStream()
The stream used to perform operations on the file. |
protected void |
storeClose()
Should close the store. |
protected void |
storeDelete()
Deletes the medium to which the store has been persisting to. |
protected boolean |
storeExists()
Returns whether the store exists in its probable medium. |
protected void |
storeFlush()
Should flush the contents of the store from memory to a persisted medium if the implementation supports it. |
protected void |
storeGet(int location,
byte[] bytes,
int offset,
int length)
Gets data at the given location and stores it in the given byte array. |
protected void |
storeGet(int location,
java.nio.ByteBuffer b)
Gets data at the given location and stores it in the given ByteBuffer. |
protected void |
storeLoad()
Should load contents of the store into memory from a persisted medium if the implementation supports it. |
protected int |
storeOpen(StoreAccess access)
Should open the store and return the capacity. |
protected void |
storePut(int location,
byte[] bytes,
int offset,
int length)
Puts data at the given location from the given byte array. |
protected void |
storePut(int location,
java.nio.ByteBuffer b)
Puts data at the given location from the given ByteBuffer. |
protected int |
storeResize(int capacity)
Resizes the store to the given capacity. |
Methods inherited from class org.magnos.data.store.AbstractStore |
---|
capacity, capacity, close, create, delete, equals, exists, flush, get, get, get, get, getAccess, getName, hashCode, isAutoFlush, isAutoLoad, isAutoOpen, isClosed, isOpen, load, open, put, put, put, setAccess, setAutoFlush, setAutoLoad, setAutoOpen, toString, validate |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MappedStore(java.io.File file, StoreAccess access, int capacity)
file
- The file to persist data to. If this file doesn't exist it will be
created when the store is opened, sized, or written to.access
- The requested access to the store.capacity
- The requested capacity of the store.public MappedStore(java.lang.String filename, StoreAccess access, int capacity)
filename
- The file to persist data to. If this file doesn't exist it will be
created when the store is opened, sized, or written to.access
- The requested access to the store.capacity
- The requested capacity of the store.public MappedStore(java.io.File file)
file
- The file to persist data to. If this file doesn't exist it will be
created when the store is opened, sized, or written to.public MappedStore(java.lang.String filename)
filename
- The file to persist data to. If this file doesn't exist it will be
created when the store is opened, sized, or written to.Method Detail |
---|
public java.nio.channels.FileChannel getChannel()
public java.io.File getFile()
public java.io.RandomAccessFile getStream()
public java.nio.MappedByteBuffer getBuffer()
protected int storeOpen(StoreAccess access) throws java.io.IOException
storeOpen
in class AbstractStore
java.io.IOException
- An error occurred opening the store with the given access.protected void storeLoad() throws java.io.IOException
storeLoad
in class AbstractStore
java.io.IOException
- An error occurred loading the store.protected void storeFlush() throws java.io.IOException
storeFlush
in class AbstractStore
java.io.IOException
- An error occurred flushing the store.protected void storeClose() throws java.io.IOException
storeClose
in class AbstractStore
java.io.IOException
- An error occurred closing the store.protected void storeDelete()
storeDelete
in class AbstractStore
protected boolean storeExists()
storeExists
in class AbstractStore
protected int storeResize(int capacity) throws java.io.IOException
storeResize
in class AbstractStore
capacity
- The new capacity of the store.
java.io.IOException
- An error occured resizing the store.protected void storeGet(int location, byte[] bytes, int offset, int length) throws java.io.IOException
storeGet
in class AbstractStore
location
- The offset to get the data, in bytes, from the beginning of the store.bytes
- The array of bytes to place the data in.offset
- The offset in the byte array to place the data.length
- The number of bytes to copy from the store and place in the array.
java.io.IOException
- An error occurred reading from the store.protected void storePut(int location, byte[] bytes, int offset, int length) throws java.io.IOException
storePut
in class AbstractStore
location
- The offset to put the data, in bytes, from the beginning of the store.bytes
- The array of bytes to take data from.offset
- The offset in the byte array to take the data.length
- The number of bytes to copy from the array and place in the store.
java.io.IOException
- An error occurred writing to the store.protected void storeGet(int location, java.nio.ByteBuffer b) throws java.io.IOException
storeGet
in class AbstractStore
location
- The offset to get the data, in bytes, from the beginning of the store.b
- The buffer to place the data in. The buffer will be filled with data
to its limit (so it has no remaining bytes).
java.io.IOException
- An error occurred reading from the store.protected void storePut(int location, java.nio.ByteBuffer b) throws java.io.IOException
storePut
in class AbstractStore
location
- The offset to put the data, in bytes, from the beginning of the store.b
- The buffer to take the data from. The buffer will be emptied of data
to its limit (so it has no remaining bytes).
java.io.IOException
- An error occurred writing to the store.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |