public class MemStore extends AbstractRawStore implements IAllocationManagerStore
IRawStore
backed by an IMemoryManager
.NULL
Constructor and Description |
---|
MemStore(DirectBufferPool pool)
Create a new instance.
|
MemStore(DirectBufferPool pool,
int bufferCapacity)
Create a new instance.
|
MemStore(IMemoryManager mmgr)
Wrap an existing
IMemoryManager . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the store immediately.
|
MemStore |
createAllocationContext()
Return a new view of the
MemStore backed by a child
IMemoryManager . |
void |
delete(long addr)
The default implementation is a NOP.
|
void |
delete(long addr,
IAllocationContext context)
Delete the data associated with the address within the allocation
context.
|
void |
deleteResources()
Deletes the backing file(s) (if any).
|
void |
destroy()
Closes the store immediately (if open) and deletes its persistent
resources.
|
void |
force(boolean metadata)
NOP since the
MemStore is not backed by stable media. |
IAddressManager |
getAddressManager()
Return the delegate object that provides the
IAddressManager
implementation for this IRawStore . |
int |
getByteCount(long addr)
The length of the datum in bytes.
|
CounterSet |
getCounters()
Return performance counters.
|
File |
getFile()
This method always returns
null since there is no backing
file. |
InputStream |
getInputStream(long addr)
Return an input stream from which a previously written stream may be read
back.
|
IMemoryManager |
getMemoryManager()
Return the backing
IMemoryManager . |
long |
getOffset(long addr)
The offset on the store at which the datum is stored.
|
IPSOutputStream |
getOutputStream()
Return an output stream which can be used to write on the backing store.
|
IPSOutputStream |
getOutputStream(IAllocationContext context)
Return an output stream which can be used to write on the backing store
within the given allocation context.
|
long |
getPhysicalAddress(long addr)
Determine the unencoded physical address
|
IResourceMetadata |
getResourceMetadata()
A description of this store in support of the scale-out architecture.
|
MemStrategy |
getStrategy() |
UUID |
getUUID()
|
boolean |
isFullyBuffered()
True iff the store is fully buffered (all reads are against memory).
|
boolean |
isOpen()
true iff the store is open. |
boolean |
isReadOnly()
true iff the store does not allow writes. |
boolean |
isStable()
True iff backed by stable storage.
|
ByteBuffer |
read(long addr)
Read the data (unisolated).
|
long |
size()
The #of application data bytes written on the store (does not count any
headers or root blocks that may exist for the store).
|
long |
toAddr(int nbytes,
long offset)
Converts a byte count and offset into a long integer.
|
String |
toString(long addr)
A human readable representation of the address.
|
long |
write(ByteBuffer data)
Write the data (unisolated).
|
long |
write(ByteBuffer data,
IAllocationContext context)
Write the data within the allocation context.
|
public MemStore(DirectBufferPool pool)
pool
- The pool from which the backing direct ByteBuffer
s
will be allocated.public MemStore(DirectBufferPool pool, int bufferCapacity)
pool
- The pool from which the backing direct ByteBuffer
s
will be allocated.bufferCapacity
- The maximum #of buffers which may be allocated by this
MemStore
from that pool. This may be
Integer.MAX_VALUE
for an effectively unlimited
capacity.public MemStore(IMemoryManager mmgr)
IMemoryManager
.mmgr
- The IMemoryManager
.public MemStrategy getStrategy()
public IMemoryManager getMemoryManager()
IMemoryManager
.public MemStore createAllocationContext()
public ByteBuffer read(long addr)
IRawStore
read
in interface IRawStore
addr
- A long integer that encodes both the offset from which the
data will be read and the #of bytes to be read. See
IAddressManager.toAddr(int, long)
.public long write(ByteBuffer data)
IRawStore
write
in interface IRawStore
data
- The data. The bytes from the current
Buffer.position()
to the
Buffer.limit()
will be written and the
Buffer.position()
will be advanced to the
Buffer.limit()
. The caller may subsequently
modify the contents of the buffer without changing the state
of the store (i.e., the data are copied into the store).IAddressManager
.public long write(ByteBuffer data, IAllocationContext context)
IAllocationManagerStore
write
in interface IAllocationManagerStore
data
- The data.context
- The allocation context.public void delete(long addr)
AbstractRawStore
delete
in interface IRawStore
delete
in class AbstractRawStore
addr
- A long integer formed using Addr
that encodes both the
offset at which the data was written and the #of bytes that
were written.public void delete(long addr, IAllocationContext context)
IAllocationManagerStore
delete
in interface IAllocationManagerStore
addr
- The address whose allocation is to be deleted.context
- The allocation context.public CounterSet getCounters()
ICounterSetAccess
getCounters
in interface ICounterSetAccess
public boolean isOpen()
IRawStore
true
iff the store is open.public void close()
IRawStore
public void deleteResources()
IRawStore
deleteResources
in interface IRawStore
public void destroy()
IRawStore
IllegalStateException
if the store
is already closed, but still deletes the backing resources.destroy
in interface IRawStore
IRawStore.deleteResources()
public void force(boolean metadata)
MemStore
is not backed by stable media.
Force the data to stable storage. While this is NOT sufficient to guarantee an atomic commit, the data must be forced to disk as part of an atomic commit protocol.
public File getFile()
null
since there is no backing
file.
The backing file -or- null
if there is no backing file
for the store.
public IResourceMetadata getResourceMetadata()
IRawStore
getResourceMetadata
in interface IRawStore
public boolean isFullyBuffered()
IRawStore
Note: This does not guarantee that the OS will not swap the buffer onto disk.
isFullyBuffered
in interface IRawStore
public boolean isReadOnly()
IRawStore
true
iff the store does not allow writes.isReadOnly
in interface IRawStore
public boolean isStable()
IRawStore
public long size()
Overridden to return the #of bytes in the allocation slots rather than
the user bytes. This is because the MemoryManager
, like the
RWStore
, does not know the #of bytes of user data in each
allocation slot. Therefore it is not able to keep accurate track of the
user bytes as allocation slots are cycled.
public IAddressManager getAddressManager()
AbstractRawStore
IAddressManager
implementation for this IRawStore
.
Note: LRUNexus
depends on the delegation model to retain
references to the IAddressManager
without causing the
IRawStore
to be retained. It uses the IAddressManager
to
decode the address in order to track the bytesOnDisk for the buffered
records.
getAddressManager
in class AbstractRawStore
public int getByteCount(long addr)
IAddressManager
IRawStore
.getByteCount
in interface IAddressManager
addr
- The opaque identifier that is the within store locator for
some datum.public long getOffset(long addr)
IAddressManager
getOffset
in interface IAddressManager
addr
- The opaque identifier that is the within store locator for
some datum.public long getPhysicalAddress(long addr)
IAddressManager
getPhysicalAddress
in interface IAddressManager
addr
- The encoded addresspublic long toAddr(int nbytes, long offset)
IAddressManager
toAddr
in interface IAddressManager
nbytes
- The byte count.offset
- The byte offset.public String toString(long addr)
IAddressManager
toString
in interface IAddressManager
addr
- The opaque identifier that is the within store locator for
some datum.public IPSOutputStream getOutputStream()
IStreamStore
IPSOutputStream
.getOutputStream
in interface IStreamStore
getOutputStream
in class AbstractRawStore
public IPSOutputStream getOutputStream(IAllocationContext context)
IPSOutputStream
.getOutputStream
in interface IAllocationManagerStore
context
- The context within which any allocations are made by the
returned IPSOutputStream
.public InputStream getInputStream(long addr)
getInputStream
in interface IStreamStore
getInputStream
in class AbstractRawStore
addr
- The address at which the stream was written.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.