public interface IRawStore extends IAddressManager, ICounterSetAccess, IStreamStore
A low-level interface for reading and writing data. This interface is not isolated and operations do not possess ACID semantics. Implementations may or may not be durable. All operations are expressed in terms of long integers that are often called "addresses" but which should be understood as opaque identifiers.
The AbstractJournal
is the principal implementation of this interface
and provides both transient and durable options and the facilities for atomic
commit. BTree
provides a higher level interface for operations on an
IRawStore
and uses a copy-on-write policy designed to support
transactional semantics by making it possible to read from a consistent
historical state. The AbstractJournal
provides the necessary
mechanisms to support transactions based on the copy-on-write semantics of
the BTree
.
The IRawStore
supports write and read back on immutable addresses and
does NOT directly support update of data for an immutable address once that
data has been written. Applications seeking Create, Read, Update, Delete
(CRUD) semantics should use a BTree
to store their application data.
Unlike this interface, the BTree
can correctly support update and
delete of application data using a persistent identifier (the key).
AbstractJournal
,
FIXME This should be restated in terms of {@link IByteArrayBuffer}. The
use of the {@link ByteBuffer} in this API has become limiting. It would
be nicer to specify a byte[] with optional offset and length parameters.
This would make it easier to wrap the byte[] in different ways for
reading and writing. The {@link ByteBuffer} has an advantage when
reading since it allows us to return a read-only view of the record, but
in practice that is only effective for an in-memory store (with or
without a backing file). The byte[] is more flexible. The caller is free
to reuse the byte[] and the store always copies the data. In practice,
we tend to work around this by copying to an array backed
{@link ByteBuffer} or to a byte[] wrapped as an {@link IByteArrayBuffer}
.
NULL
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the store immediately.
|
void |
delete(long addr)
Delete the data (unisolated).
|
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.
|
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).
|
getByteCount, getOffset, getPhysicalAddress, toAddr, toString
getCounters
getInputStream, getOutputStream
long write(ByteBuffer data)
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
.IllegalArgumentException
- if data is null
.IllegalArgumentException
- if data has zero bytes Buffer.remaining()
.IllegalStateException
- if the store is not open.IllegalStateException
- if the store does not allow writes.void delete(long addr)
After this operation subsequent reads on the address MAY fail and the caller MUST NOT depend on the ability to read at that address.
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.IllegalArgumentException
- If the address is known to be invalid (never written or
deleted). Note that the address 0L is always invalid.
It is only applicable in the
context of a garbage collection strategy. With an append only
store and with eviction of btrees into index segments there
is no reason to delete anything on the store - and nothing to
keep track of the delete.
However, with a Read-Write store it is a requirement, and a void
implementation is provided for other stores.ByteBuffer read(long addr)
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)
.IllegalArgumentException
- If the address is known to be invalid (never written or
deleted). Note that the address 0L is always invalid.IllegalStateException
- if the store is not open.boolean isOpen()
true
iff the store is open.true
iff the store is open.boolean isReadOnly()
true
iff the store does not allow writes.IllegalStateException
- if the store is not open.void close()
IllegalStateException
- if the store is not open.void deleteResources()
IllegalStateException
- if the store is open.RuntimeException
- if the backing file exists and could not be deleted.void destroy()
IllegalStateException
if the store
is already closed, but still deletes the backing resources.deleteResources()
File getFile()
null
if there is no backing file
for the store.UUID getUUID()
IResourceMetadata getResourceMetadata()
boolean isStable()
IllegalStateException
- if the store is not open.boolean isFullyBuffered()
Note: This does not guarantee that the OS will not swap the buffer onto disk.
IllegalStateException
- if the store is not open.void force(boolean metadata)
metadata
- If true, then force both the file contents and the file
metadata to disk.IllegalStateException
- if the store is not open.long size()
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.