|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> store >> [ raw overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.iapi.store.raw
Interface ContainerHandle

- public interface ContainerHandle
A Container contains a contigious address space of pages, the pages start at page number Container.FIRST_PAGE_NUMBER and are numbered sequentially. The page size is set at addContainer() time. RESOLVE: this style of coding is not currently enforced If the caller calls getPage (or one of its variants) more than once on the same page, the caller must call unlatch a corresponding number of times in order to ensure that the page is latched. For example:
Container c;
Page p1 = c.getPage(Container.FIRST_PAGE_NUMBER);
Page p2 = c.getPage(Container.FIRST_PAGE_NUMBER);
p1.unlatch(); -- Page is still latched.
p2.unlatch(); -- Page is now unlatched.
There is no restriction on the order in which latching and unlatching is done. In the example, p1 could have been unlatched after p2 with no ill effects.
Open container modes
ContainerHandle.MODE are used to open or create the container.
Unlike TableProperties, MODEs are not permanantely associated with the
container, it is effective only for the lifetime of the containerHandle
itself.
A container may use any of these mode flags when it is opened.
- MODE_READONLY - Open the container in read only mode.
- MODE_FORUPDATE - Open the container in update mode, if the underlying storage does not allow updates then the container will be opned in read only mode.
- MODE_UNLOGGED - If Unset, any changes to the container are logged. If set, any user changes to the container are unlogged. It is guaranteed at commit time that all changes made during the transaction will have been flushed to disk. Using this mode automatically opens the container in container locking, isolation 3 level. The state of the container following an abort or any type of rollback is unspecified.
- MODE_CREATE_UNLOGGED - If set, not only are user changes to the container are unlogged, page allocations are also unlogged. This MODE is only useful for container is created in the same statement and no change on the container (other than the create) is ever logged. The difference between MODE_UNLOGGED and MODE_CREATE_UNLOGGED is that page allocation is also unlogged and commit of nested transaction will not cause the container to be forced from the cache. Unlike MODE_UNLOGGED, MODE_CREATE_UNLOGGED does not force the cache. It is up to the client of raw store to force the cache at the appropriate time - this allows a statement to create and open the container serveral times for bulk loading without logging or doing any synchronous I/O.
- MODE_LOCK_NOWAIT - if set, then don't wait for the container lock, else wait for the container lock. This flag only dictates whether the lock should be waited for or not. After the container is successfully opened, whether this bit is set or not has no effect on the container handle.
MODE_UNLOGGED must be set for MODE_CREATE_UNLOGGED to be set.
Temporary Containers
If when creating a container the segment used is
ContainerHandle.TEMPORARY_SEGMENT then the container is a temporary
container. Temporary containers are not logged or locked and do not live
across re-boots of the system. In addition any abort or rollback including
rollbacks to savepoints truncate the container if it has been opened for
update since the last commit or abort. Temporary containers are private
to a transaction and must only be used a single thread within the
transaction at any time, these restrictions are not currently enforced.
When opening a temporary container for update access these additional mode
flags may be used
- MODE_TRUNCATE_ON_COMMIT - At commit/abort time container is truncated.
- MODE_DROP_ON_COMMIT - At commit/abort time the container is dropped.
- MODE_TEMP_IS_KEPT - At commit/abort time the container is kept around.
| Field Summary | |
static int |
ADD_PAGE_BULK
|
static int |
ADD_PAGE_DEFAULT
|
static int |
DEFAULT_ASSIGN_ID
|
static int |
DEFAULT_PAGESIZE
Used in add container. |
static int |
DEFAULT_SPARESPACE
|
static long |
FIRST_PAGE_NUMBER
The first valid page number |
static int |
GET_PAGE_UNFILLED
|
static long |
INVALID_PAGE_NUMBER
A page number that is guaranteed to be invalid. |
static int |
MODE_BASEROW_INSERT_LOCKED
|
static int |
MODE_CREATE_UNLOGGED
|
static int |
MODE_DEFAULT
See comments above for these modes. |
static int |
MODE_DROP_ON_COMMIT
|
static int |
MODE_FLUSH_ON_COMMIT
|
static int |
MODE_FORUPDATE
|
static int |
MODE_LOCK_NOWAIT
|
static int |
MODE_NO_ACTIONS_ON_COMMIT
|
static int |
MODE_OPEN_FOR_LOCK_ONLY
|
static int |
MODE_READONLY
|
static int |
MODE_SECONDARY_LOCKED
|
static int |
MODE_TEMP_IS_KEPT
|
static int |
MODE_TRUNCATE_ON_COMMIT
|
static int |
MODE_TRUNCATE_ON_ROLLBACK
|
static int |
MODE_UNLOGGED
|
static int |
MODE_USE_UPDATE_LOCKS
|
static int |
TEMPORARY_SEGMENT
|
| Method Summary | |
Page |
addPage()
Add an empty page to the container and obtain exclusive access to it. |
Page |
addPage(int flag)
Add an empty page to the container and obtain exclusive access to it. |
void |
close()
Close me. |
void |
compactRecord(RecordHandle record)
This record probably has shrunk considerably. |
void |
compressContainer()
Release free space to the OS. |
void |
flushContainer()
Flush all dirty pages of the container to disk. |
void |
getContainerProperties(java.util.Properties prop)
Request the system properties associated with a container. |
long |
getEstimatedPageCount(int flag)
Get the total estimated number of allocated (not freed, not deallocated) user pages in the container, including overflow pages. |
long |
getEstimatedRowCount(int flag)
Get the total estimated number of rows in the container, not including overflow rows. |
Page |
getFirstPage()
Obtain exclusive access to the current first page of the container. |
ContainerKey |
getId()
Return my identifier. |
LockingPolicy |
getLockingPolicy()
Return the locking policy for this open container. |
Page |
getNextPage(long prevNum)
Obtain exclusive access to the next valid page of the given page number in the container. |
Page |
getPage(long pageNumber)
Obtain exclusive access to the page with the given page number. |
Page |
getPageForCompress(int flag,
long pageno)
|
Page |
getPageForInsert(int flag)
Get a page for insert. |
Page |
getPageNoWait(long pageNumber)
Identical to getPage but returns null immediately if the desired page is already latched by another Container. |
org.apache.derby.iapi.store.access.SpaceInfo |
getSpaceInfo()
Get information about space used by the container. |
java.lang.Object |
getUniqueId()
Return my unique identifier, this identifier will be unique to each instance of an open container handle. |
Page |
getUserPageNoWait(long pageNumber)
Obtain exclusive access to the page with the given page number. |
Page |
getUserPageWait(long pageNumber)
Obtain exclusive access to the page with the given page number. |
boolean |
isReadOnly()
Is the container opened for read only or update? |
boolean |
isTemporaryContainer()
Return true if this containerHandle refers to a temporary container. |
RecordHandle |
makeRecordHandle(long pageNumber,
int recordId)
Return a record handle that is initialized to the given segment id, container id, page number and record id. |
void |
preAllocate(int numPage)
Try to preallocate numPage new pages if possible. |
void |
removePage(Page page)
Remove this page from the container and unlatch the page. |
void |
setEstimatedRowCount(long count,
int flag)
Set the total estimated number of rows in the container. |
void |
setLockingPolicy(LockingPolicy newLockingPolicy)
Set the locking policy for this open container |
| Field Detail |
DEFAULT_PAGESIZE
public static final int DEFAULT_PAGESIZE
- Used in add container.
- See Also:
- Constant Field Values
DEFAULT_SPARESPACE
public static final int DEFAULT_SPARESPACE
- See Also:
- Constant Field Values
DEFAULT_ASSIGN_ID
public static final int DEFAULT_ASSIGN_ID
- See Also:
- Constant Field Values
MODE_DEFAULT
public static final int MODE_DEFAULT
- See comments above for these modes.
- See Also:
- Constant Field Values
MODE_UNLOGGED
public static final int MODE_UNLOGGED
- See Also:
- Constant Field Values
MODE_CREATE_UNLOGGED
public static final int MODE_CREATE_UNLOGGED
- See Also:
- Constant Field Values
MODE_FORUPDATE
public static final int MODE_FORUPDATE
- See Also:
- Constant Field Values
MODE_READONLY
public static final int MODE_READONLY
- See Also:
- Constant Field Values
MODE_TRUNCATE_ON_COMMIT
public static final int MODE_TRUNCATE_ON_COMMIT
- See Also:
- Constant Field Values
MODE_DROP_ON_COMMIT
public static final int MODE_DROP_ON_COMMIT
- See Also:
- Constant Field Values
MODE_OPEN_FOR_LOCK_ONLY
public static final int MODE_OPEN_FOR_LOCK_ONLY
- See Also:
- Constant Field Values
MODE_LOCK_NOWAIT
public static final int MODE_LOCK_NOWAIT
- See Also:
- Constant Field Values
MODE_TRUNCATE_ON_ROLLBACK
public static final int MODE_TRUNCATE_ON_ROLLBACK
- See Also:
- Constant Field Values
MODE_FLUSH_ON_COMMIT
public static final int MODE_FLUSH_ON_COMMIT
- See Also:
- Constant Field Values
MODE_NO_ACTIONS_ON_COMMIT
public static final int MODE_NO_ACTIONS_ON_COMMIT
- See Also:
- Constant Field Values
MODE_TEMP_IS_KEPT
public static final int MODE_TEMP_IS_KEPT
- See Also:
- Constant Field Values
MODE_USE_UPDATE_LOCKS
public static final int MODE_USE_UPDATE_LOCKS
- See Also:
- Constant Field Values
MODE_SECONDARY_LOCKED
public static final int MODE_SECONDARY_LOCKED
- See Also:
- Constant Field Values
MODE_BASEROW_INSERT_LOCKED
public static final int MODE_BASEROW_INSERT_LOCKED
- See Also:
- Constant Field Values
TEMPORARY_SEGMENT
public static final int TEMPORARY_SEGMENT
- See Also:
- Constant Field Values
FIRST_PAGE_NUMBER
public static final long FIRST_PAGE_NUMBER
- The first valid page number
- See Also:
- Constant Field Values
INVALID_PAGE_NUMBER
public static final long INVALID_PAGE_NUMBER
- A page number that is guaranteed to be invalid.
- See Also:
- Constant Field Values
ADD_PAGE_DEFAULT
public static final int ADD_PAGE_DEFAULT
- See Also:
- Constant Field Values
ADD_PAGE_BULK
public static final int ADD_PAGE_BULK
- See Also:
- Constant Field Values
GET_PAGE_UNFILLED
public static final int GET_PAGE_UNFILLED
- See Also:
- Constant Field Values
| Method Detail |
getId
public ContainerKey getId()
- Return my identifier.
getUniqueId
public java.lang.Object getUniqueId()
- Return my unique identifier, this identifier will be unique to each
instance of an open container handle. This id is used by the locking
system to group locks to an open container handle.
isReadOnly
public boolean isReadOnly()
- Is the container opened for read only or update?
addPage
public Page addPage() throws org.apache.derby.iapi.error.StandardException
- Add an empty page to the container and obtain exclusive access to it.
Note that the added page may not be the last page in the Container. Once the Page is no longer required the Page's unlatch() method must be called.
compressContainer
public void compressContainer()
throws org.apache.derby.iapi.error.StandardException
- Release free space to the OS.
As is possible release any free space to the operating system. This will usually mean releasing any free pages located at the end of the file using the java truncate() interface.
addPage
public Page addPage(int flag) throws org.apache.derby.iapi.error.StandardException
- Add an empty page to the container and obtain exclusive access to it.
If flag == ADD_PAGE_DEFAULT, this call is identical to addPage().
If flag == ADD_PAGE_BULK, then this call signifies to the container that this addPage is part of a large number of additional pages and it is desirable to do whatever possible to facilitate adding many subsequent pages. The actual container implementation will decide whether or not to heed this hint and what to do about it.
preAllocate
public void preAllocate(int numPage)
- Try to preallocate numPage new pages if possible.
removePage
public void removePage(Page page) throws org.apache.derby.iapi.error.StandardException
- Remove this page from the container and unlatch the page. Caller
should commit or abort this transaction ASAP because failure to do so
will slow down page allocation of this container.
The page to be removed must be latched and gotten (or added) by this ContainerHandle. The page should not be used again after this call as if it has been unlatched. If the call to removePage is successful, this page is invalid should not be gotten again with getPage.
RemovePage will guarantee to unlatch the page even if a StandardException is thrown.Locking Policy
The page will not be freed until the transaction that removed the page commits. A special RecordHandle.DEALLOC_PROTECTION_HANDLE lock will be gotten for the transaction and which is used to prevent the page from being freed. This lock will be held regardless of the default locking policy of the transaction that called removedPage.
getPage
public Page getPage(long pageNumber) throws org.apache.derby.iapi.error.StandardException
- Obtain exclusive access to the page with the given page number.
Once the Page is no longer required the Page's unlatch() method must
be called.
The Page object is guaranteed to remain in-memory and exclusive to the caller until its unlatch() method is called.
getPageNoWait
public Page getPageNoWait(long pageNumber) throws org.apache.derby.iapi.error.StandardException
- Identical to getPage but returns null immediately if the desired page
is already latched by another Container.
getUserPageNoWait
public Page getUserPageNoWait(long pageNumber) throws org.apache.derby.iapi.error.StandardException
- Obtain exclusive access to the page with the given page number.
Will only return a valid, non-overflow user page - so can be used by
routines in post commit to get pages to attempt deleted row space
reclamation. If for some reason a request is made for an overflow
page a null will be returned.
Once the Page is no longer required the Page's unlatch() method must
be called.
The Page object is guaranteed to remain in-memory and exclusive to the caller until its unlatch() method is called.
getUserPageWait
public Page getUserPageWait(long pageNumber) throws org.apache.derby.iapi.error.StandardException
- Obtain exclusive access to the page with the given page number.
Will only return a valid, non-overflow user page - so can be used by
routines in post commit to get pages to attempt deleted row space
reclamation. If for some reason a request is made for an overflow
page a null will be returned.
Once the Page is no longer required the Page's unlatch() method must
be called.
The Page object is guaranteed to remain in-memory and exclusive to the caller until its unlatch() method is called.
getFirstPage
public Page getFirstPage() throws org.apache.derby.iapi.error.StandardException
- Obtain exclusive access to the current first page of the container.
Only a valid, non overflow page will be returned.
Pages in the container are ordered in an internally defined ordering.
Note that once this method returns this page may no longer be the first page of the container. I.e, other threads may allocate pages prior to this page number while this page is latched. It is up to the caller of this routine to synchronize this call with addPage to assure that this is the first page.
As long as the client provide the necessary lock to ensure that no addPage is called, then this page is guaranteed to be the first page of the container in some internally defined ordering of the pages.
getNextPage
public Page getNextPage(long prevNum) throws org.apache.derby.iapi.error.StandardException
- Obtain exclusive access to the next valid page of the given page number
in the container. Only a valid, non overflow page will be returned.
Pages in the container are ordered in an internally defined ordering.
Note that once this method returns this page may no longer be the next page of the container. I.e, other threads may allocate pages prior to this page number while this page is latched. It is up to the caller of this routine to synchronize this call with addPage to assure that this is the first page.
As long as the client provide the necessary lock to ensure that no addPage is called, then this page is guaranteed to be the next page of the container in some internally defined ordering of the pages.
If no pages are added or removed, then an iteration such as:for (Page p = containerHandle.getFirstPage(); p != null; p = containerHandle.getNextPage(p.getPageNumber()))will guarentee to iterate thru and latched all the valid pages in the container
getPageForInsert
public Page getPageForInsert(int flag) throws org.apache.derby.iapi.error.StandardException
- Get a page for insert. If RawStore thinks it knows where a potentially
suitable page is for insert, it will return it. If RawStore doesn't
know where a suitable page for insert is, or if there are no allocated
page, then null is returned. If a page is returned, it will be a
valid, non-overflow page. A potentially suitable page is one which
has enough space for a minium sized record.
getPageForCompress
public Page getPageForCompress(int flag, long pageno) throws org.apache.derby.iapi.error.StandardException
getContainerProperties
public void getContainerProperties(java.util.Properties prop) throws org.apache.derby.iapi.error.StandardException
- Request the system properties associated with a container.
Request the value of properties that are associated with a table. The following properties can be requested: derby.storage.pageSize derby.storage.pageReservedSpace derby.storage.minimumRecordSize
To get the value of a particular property add it to the property list, and on return the value of the property will be set to it's current value. For example: get_prop(ConglomerateController cc) { Properties prop = new Properties(); prop.put("derby.storage.pageSize", ""); cc.getTableProperties(prop); System.out.println( "table's page size = " + prop.getProperty("derby.storage.pageSize"); }
close
public void close()
- Close me. After using this method the caller must throw away the
reference to the Container object, e.g.
ref.close(); ref = null;
The container will be closed automatically at the commit or abort of the transaction if this method is not called explictly.
Any pages that were obtained using me and have not been released using Page's unlatch method are released, and references to them must be thrown away.
getEstimatedRowCount
public long getEstimatedRowCount(int flag)
throws org.apache.derby.iapi.error.StandardException
- Get the total estimated number of rows in the container, not including
overflow rows. This number is a rough estimate and may be grossly off.
setEstimatedRowCount
public void setEstimatedRowCount(long count,
int flag)
throws org.apache.derby.iapi.error.StandardException
- Set the total estimated number of rows in the container. Often, after
a scan, the client of RawStore has a much better estimate of the number
of rows in the container then what RawStore has. Use this better
number for future reference.
It is OK for a ReadOnly ContainerHandle to set the estimated row count.
getEstimatedPageCount
public long getEstimatedPageCount(int flag)
throws org.apache.derby.iapi.error.StandardException
- Get the total estimated number of allocated (not freed, not
deallocated) user pages in the container, including overflow pages.
this number is a rough estimate and may be grossly off.
flushContainer
public void flushContainer()
throws org.apache.derby.iapi.error.StandardException
- Flush all dirty pages of the container to disk. Used mainly for
UNLOGGED or CREATE_UNLOGGED operation.
getLockingPolicy
public LockingPolicy getLockingPolicy()
- Return the locking policy for this open container.
setLockingPolicy
public void setLockingPolicy(LockingPolicy newLockingPolicy)
- Set the locking policy for this open container
makeRecordHandle
public RecordHandle makeRecordHandle(long pageNumber, int recordId) throws org.apache.derby.iapi.error.StandardException
- Return a record handle that is initialized to the given segment id,
container id, page number and record id.
compactRecord
public void compactRecord(RecordHandle record) throws org.apache.derby.iapi.error.StandardException
- This record probably has shrunk considerably. Free its reserved space
or compact it.
isTemporaryContainer
public boolean isTemporaryContainer()
throws org.apache.derby.iapi.error.StandardException
- Return true if this containerHandle refers to a temporary container.
getSpaceInfo
public org.apache.derby.iapi.store.access.SpaceInfo getSpaceInfo() throws org.apache.derby.iapi.error.StandardException
- Get information about space used by the container.
|
|||||||||
| Home >> All >> org >> apache >> derby >> iapi >> store >> [ raw overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC