KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > store > raw > RecordHandle


1 /*
2
3    Derby - Class org.apache.derby.iapi.store.raw.RecordHandle
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.store.raw;
23
24 import org.apache.derby.iapi.services.locks.Lockable;
25
26 /**
27     A handle to a record within a container. This interface does not provide
28     an information about the data of the record, it is only used to perform
29     updates, deletes and allow ordered record manipulation.
30
31     MT - immutable
32
33     @see Page
34 */

35
36 public interface RecordHandle extends Lockable {
37
38     /*****************************************************************
39      * Special record Identifiers.
40      *
41      * Reserved identifiers that does not represent a row but rather have their
42      * own special meaning. No real rows will ever have these record
43      * identifiers.
44      *****************************************************************/

45
46     /** An invalid record handle */
47     public static final int INVALID_RECORD_HANDLE = 0;
48  
49     /**
50         A lock with this recordHandle protects all the recordIds in the page.
51         No recordId can disappear while this lock is held.
52         New recordIds may appear while this lock is held.
53     */

54     public static final int RECORD_ID_PROTECTION_HANDLE = 1;
55
56     /**
57         A lock with this recordHandle protects this deallocated page from
58         being freed and reallocated. This lock is released when the
59         transaction that deallocated the page terminates, at which point
60         the page can be freed if the transaction committed.
61     */

62     public static final int DEALLOCATE_PROTECTION_HANDLE = 2;
63
64     /**
65         A lock with this recordHandle is used to lock the range of keys
66         between the first key in a btree and keys previous to it.
67     */

68     public static final int PREVIOUS_KEY_HANDLE = 3;
69
70     /**
71         Reserve for future use - name it and define it when you have a need to
72         use one
73     */

74     public static final int RESERVED4_RECORD_HANDLE = 4;
75     public static final int RESERVED5_RECORD_HANDLE = 5;
76     
77     /**
78         First recordId that is used to identify a record.
79     */

80     public static final int FIRST_RECORD_ID = 6;
81
82     /**
83         Obtain the page-unique identifier for this record.
84         This id combined with a page number is guaranteed to be unique
85         within a container.
86     */

87     public int getId();
88
89     /**
90         Obtain the page number this record lives on.
91     */

92     public long getPageNumber();
93
94     /**
95      * What slot number might the record be at?
96      * <p>
97      * The raw store guarantees that the record handle of a record will not
98      * change, but it's slot number may. An implementation of a record handle
99      * may provide a hint of the slot number, which may help routines like
100      * Page.getSlotNumber() perform better.
101      * <p>
102      * If an implementation does not track slot numbers at all the
103      * implementation should just always return Page.FIRST_SLOT_NUMBER.
104      *
105      * @return The slot number the record handle may be at.
106      **/

107     public int getSlotNumberHint();
108
109     /**
110         Return the identity of my container.
111     */

112     public ContainerKey getContainerId();
113
114     /**
115         Return the identity of my Page.
116     */

117     public Object JavaDoc getPageId();
118
119 }
120
Popular Tags