Modifier and Type | Class and Description |
---|---|
static interface |
Transaction.CallableClosure<R,T extends Throwable>
This closure interface is intended for the end user implement callbacks for the Transaction.exectue() method.
|
static interface |
Transaction.Closure<T extends Throwable>
This closure interface is intended for the end user implement callbacks for the Transaction.exectue() method.
|
class |
Transaction.InvalidPageIOException
The InvalidPageIOException is thrown if try to load/store a a page
with an invalid page id.
|
class |
Transaction.PageOverflowIOException
The PageOverflowIOException occurs when a page write is requested
and it's data is larger than what would fit into a single page.
|
Modifier and Type | Method and Description |
---|---|
<T> Page<T> |
allocate()
Allocates a free page that you can write data to.
|
<T> Page<T> |
allocate(int count)
Allocates a block of free pages that you can write data to.
|
void |
commit()
Commits the transaction to the PageFile as a single 'Unit of Work'.
|
<R,T extends Throwable> |
execute(Transaction.CallableClosure<R,T> closure)
Executes a closure and if it does not throw any exceptions, then it commits the transaction.
|
<T extends Throwable> |
execute(Transaction.Closure<T> closure)
Executes a closure and if it does not throw any exceptions, then it commits the transaction.
|
void |
free(long pageId)
Frees up a previously allocated page so that it can be re-allocated again.
|
void |
free(long pageId,
int count)
Frees up a previously allocated sequence of pages so that it can be re-allocated again.
|
<T> void |
free(Page<T> page)
Frees up a previously allocated page so that it can be re-allocated again.
|
<T> void |
free(Page<T> page,
int count)
Frees up a previously allocated sequence of pages so that it can be re-allocated again.
|
PageFile |
getPageFile() |
protected File |
getTempFile() |
boolean |
isReadOnly() |
Iterator<Page> |
iterator()
Allows you to iterate through all active Pages in this object.
|
Iterator<Page> |
iterator(boolean includeFreePages)
Allows you to iterate through all active Pages in this object.
|
<T> Page<T> |
load(long pageId,
Marshaller<T> marshaller)
Loads a page from disk.
|
<T> void |
load(Page<T> page,
Marshaller<T> marshaller)
Loads a page from disk.
|
InputStream |
openInputStream(Page p) |
OutputStream |
openOutputStream(Page page,
boolean overflow) |
void |
rollback()
Rolls back the transaction.
|
<T> void |
store(Page<T> page,
Marshaller<T> marshaller,
boolean overflow) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public PageFile getPageFile()
public <T> Page<T> allocate() throws IOException
IOException
- If an disk error occurred.IllegalStateException
- if the PageFile is not loadedpublic <T> Page<T> allocate(int count) throws IOException
count
- the number of sequential pages to allocateIOException
- If an disk error occurred.IllegalStateException
- if the PageFile is not loadedpublic void free(long pageId) throws IOException
pageId
- the page to free upIOException
- If an disk error occurred.IllegalStateException
- if the PageFile is not loadedpublic void free(long pageId, int count) throws IOException
pageId
- the initial page of the sequence that will be getting freedcount
- the number of pages in the sequenceIOException
- If an disk error occurred.IllegalStateException
- if the PageFile is not loadedpublic <T> void free(Page<T> page, int count) throws IOException
page
- the initial page of the sequence that will be getting freedcount
- the number of pages in the sequenceIOException
- If an disk error occurred.IllegalStateException
- if the PageFile is not loadedpublic <T> void free(Page<T> page) throws IOException
page
- the page to free upIOException
- If an disk error occurred.IllegalStateException
- if the PageFile is not loadedpublic <T> void store(Page<T> page, Marshaller<T> marshaller, boolean overflow) throws IOException
page
- the page to write. The Page object must be fully populated with a valid pageId, type, and data.marshaller
- the marshaler to use to load the data portion of the Page, may be null if you do not wish to write the data.overflow
- If true, then if the page data marshalls to a bigger size than can fit in one page, then additional
overflow pages are automatically allocated and chained to this page to store all the data. If false,
and the overflow condition would occur, then the PageOverflowIOException is thrown.IOException
- If an disk error occurred.Transaction.PageOverflowIOException
- If the page data marshalls to size larger than maximum page size and overflow was false.IllegalStateException
- if the PageFile is not loadedpublic OutputStream openOutputStream(Page page, boolean overflow) throws IOException
IOException
public <T> Page<T> load(long pageId, Marshaller<T> marshaller) throws IOException
pageId
- the id of the page to loadmarshaller
- the marshaler to use to load the data portion of the Page, may be null if you do not wish to load the data.IOException
- If an disk error occurred.IllegalStateException
- if the PageFile is not loadedpublic <T> void load(Page<T> page, Marshaller<T> marshaller) throws IOException
page
- - The pageId field must be properly setmarshaller
- the marshaler to use to load the data portion of the Page, may be null if you do not wish to load the data.IOException
- If an disk error occurred.Transaction.InvalidPageIOException
- If the page is is not valid.IllegalStateException
- if the PageFile is not loadedpublic InputStream openInputStream(Page p) throws IOException
public Iterator<Page> iterator()
iterator
in interface Iterable<Page>
IllegalStateException
- if the PageFile is not loadedpublic Iterator<Page> iterator(boolean includeFreePages)
includeFreePages
- - if true, free pages are included in the iterationIllegalStateException
- if the PageFile is not loadedpublic void commit() throws IOException
IOException
public void rollback() throws IOException
IOException
protected File getTempFile()
public boolean isReadOnly()
public <T extends Throwable> void execute(Transaction.Closure<T> closure) throws T extends Throwable, IOException
T
- closure
- - the work to get exectued.T
- if the closure throws itIOException
- If the commit fails.T extends Throwable
public <R,T extends Throwable> R execute(Transaction.CallableClosure<R,T> closure) throws T extends Throwable, IOException
T
- closure
- - the work to get exectued.T
- if the closure throws itIOException
- If the commit fails.T extends Throwable
Copyright © 2005–2019 The Apache Software Foundation. All rights reserved.