public class SimpleMemoryRawStore extends AbstractRawWormStore
ArrayList
.
Note: it is safe to NOT call close()
on this implementation. The
implementation does not contain things like ExecutorService
s that
would hang around unless explicitly shutdown.
TemporaryRawStore}, which provides a more scalable solution for
temporary data.
Modifier and Type | Field and Description |
---|---|
protected int |
nextOffset
The #of bytes written so far.
|
protected ArrayList<byte[]> |
records
The buffered records in the order written.
|
am
NULL
Constructor and Description |
---|
SimpleMemoryRawStore()
Uses an initial capacity of 1000 records.
|
SimpleMemoryRawStore(int capacity) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the store immediately.
|
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)
Force the data to stable storage.
|
CounterSet |
getCounters()
Return performance counters.
|
File |
getFile()
The backing file -or-
null if there is no backing file
for the store. |
IResourceMetadata |
getResourceMetadata()
A description of this store in support of the scale-out architecture.
|
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 |
write(ByteBuffer data)
Write the data (unisolated).
|
getAddressManager, getByteCount, getOffset, getOffsetBits, getPhysicalAddress, toAddr, toString
delete, getInputStream, getOutputStream
protected int nextOffset
write(ByteBuffer)
. This is necessary in order for
this implementation to assign addresses in the same manner as they would
be assigned by an implementation using an append only byte[] or file.protected final ArrayList<byte[]> records
public SimpleMemoryRawStore()
public SimpleMemoryRawStore(int capacity)
capacity
- The #of records that you expect to store (non-negative). If
the capacity is exceeded then the internal ArrayList
will be grown as necessary.public boolean isOpen()
IRawStore
true
iff the store is open.true
iff the store is open.public boolean isReadOnly()
IRawStore
true
iff the store does not allow writes.public boolean isStable()
IRawStore
public boolean isFullyBuffered()
IRawStore
Note: This does not guarantee that the OS will not swap the buffer onto disk.
public IResourceMetadata getResourceMetadata()
IRawStore
public File getFile()
null
if there is no backing file
for the store.
This always returns null
.
public void close()
IRawStore
public void deleteResources()
IRawStore
public void destroy()
IRawStore
IllegalStateException
if the store
is already closed, but still deletes the backing resources.IRawStore.deleteResources()
public ByteBuffer read(long addr)
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
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 void force(boolean metadata)
IRawStore
metadata
- If true, then force both the file contents and the file
metadata to disk.public long size()
IRawStore
public CounterSet getCounters()
ICounterSetAccess
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.