org.fusesource.hawtdb.api
Interface Paged

All Known Subinterfaces:
PageFile, Transaction

public interface Paged

Implemented by objects which provides block io access to pages on file.

Author:
Hiram Chirino

Nested Class Summary
static class Paged.SliceType
           
 
Method Summary
 int alloc()
          does the same as allocator().alloc(1)
 Allocator allocator()
           
<T> void
clear(PagedAccessor<T> pagedAccessor, int page)
          Frees any pages associated with the value stored at the given page if any.
 void flush()
           
 void free(int page)
          does the same as allocator().free(page, 1)
<T> T
get(PagedAccessor<T> pagedAccessor, int page)
          Gets an object previously put at the given page.
 int getPageSize()
           
 int pages(int length)
           
<T> void
put(PagedAccessor<T> pagedAccessor, int page, T value)
          Put an object at a given page.
 void read(int pageId, org.fusesource.hawtbuf.Buffer buffer)
          Copies the contents of a page into the buffer space.
 java.nio.ByteBuffer slice(Paged.SliceType mode, int pageId, int count)
          Provides direct access to the memory associated with a page.
 void unslice(java.nio.ByteBuffer buffer)
           
 void write(int pageId, org.fusesource.hawtbuf.Buffer buffer)
          Copies the buffer into the page.
 

Method Detail

allocator

Allocator allocator()
Returns:
An object which provides access to allocate/deallocate pages.

alloc

int alloc()
does the same as allocator().alloc(1)

Returns:
a newly allocated page location.

free

void free(int page)
does the same as allocator().free(page, 1)


slice

java.nio.ByteBuffer slice(Paged.SliceType mode,
                          int pageId,
                          int count)
                          throws IOPagingException
Provides direct access to the memory associated with a page. Specifying the correct mode argument is especially critical and the Paged resources is being accessed in a transaction context so that the transaction can maintain snapshot isolation.

Parameters:
mode - how will the buffer be used.
pageId - the starting page of the buffer
count - the number of pages to include in the buffer.
Returns:
Throws:
IOPagingException

unslice

void unslice(java.nio.ByteBuffer buffer)

read

void read(int pageId,
          org.fusesource.hawtbuf.Buffer buffer)
Copies the contents of a page into the buffer space. The buffer offset will be updated to reflect the amount of data copied into the buffer.

Parameters:
pageId -
buffer -

write

void write(int pageId,
           org.fusesource.hawtbuf.Buffer buffer)
Copies the buffer into the page. The buffer offset will be updated to reflect the amount of data copied to the page.

Parameters:
pageId -
buffer -

getPageSize

int getPageSize()
Returns:
the maximum number of bytes that be read or written to a page.

pages

int pages(int length)
Returns:
the number of pages that would be required to store the specified number of bytes

flush

void flush()

get

<T> T get(PagedAccessor<T> pagedAccessor,
          int page)
Gets an object previously put at the given page. The returned object SHOULD NEVER be mutated.

Parameters:
page -
Returns:

put

<T> void put(PagedAccessor<T> pagedAccessor,
             int page,
             T value)
Put an object at a given page. The supplied object SHOULD NEVER be mutated once it has been stored.

Parameters:
page -
value -

clear

<T> void clear(PagedAccessor<T> pagedAccessor,
               int page)
Frees any pages associated with the value stored at the given page if any. Does not free the page supplied.

Parameters:
page -


Copyright © 2009-2011 FuseSource, Corp.. All Rights Reserved.