Source Code Cross Referenced for B2IFactory.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » store » access » btree » index » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.impl.store.access.btree.index 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.store.access.btree.index.B2IFactory
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.store.access.btree.index;
023:
024:        import java.util.Properties;
025:
026:        import org.apache.derby.iapi.reference.SQLState;
027:
028:        import org.apache.derby.iapi.services.monitor.ModuleControl;
029:        import org.apache.derby.iapi.services.monitor.Monitor;
030:        import org.apache.derby.iapi.services.property.PropertyUtil;
031:        import org.apache.derby.iapi.services.sanity.SanityManager;
032:        import org.apache.derby.iapi.services.io.FormatIdUtil;
033:
034:        import org.apache.derby.catalog.UUID;
035:        import org.apache.derby.iapi.services.uuid.UUIDFactory;
036:        import org.apache.derby.iapi.error.StandardException;
037:        import org.apache.derby.iapi.store.access.conglomerate.Conglomerate;
038:        import org.apache.derby.iapi.store.access.conglomerate.ConglomerateFactory;
039:        import org.apache.derby.iapi.store.access.conglomerate.LogicalUndo;
040:        import org.apache.derby.iapi.store.access.conglomerate.TransactionManager;
041:        import org.apache.derby.iapi.store.access.AccessFactory;
042:        import org.apache.derby.iapi.store.access.ColumnOrdering;
043:        import org.apache.derby.iapi.store.access.ConglomerateController;
044:        import org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo;
045:        import org.apache.derby.iapi.store.access.ScanController;
046:        import org.apache.derby.iapi.store.access.TransactionController;
047:
048:        import org.apache.derby.iapi.store.raw.ContainerKey;
049:        import org.apache.derby.iapi.store.raw.ContainerHandle;
050:        import org.apache.derby.iapi.store.raw.LockingPolicy;
051:        import org.apache.derby.iapi.store.raw.Transaction;
052:
053:        import org.apache.derby.iapi.types.DataValueDescriptor;
054:
055:        import org.apache.derby.impl.store.access.btree.BTree;
056:        import org.apache.derby.impl.store.access.btree.BranchControlRow;
057:        import org.apache.derby.impl.store.access.btree.ControlRow;
058:        import org.apache.derby.impl.store.access.btree.BTreeController;
059:        import org.apache.derby.impl.store.access.btree.LeafControlRow;
060:        import org.apache.derby.impl.store.access.btree.OpenBTree;
061:
062:        /**
063:
064:         The "B2I" (acronym for b-tree secondary index) factory manages b-tree
065:         conglomerates implemented	on the raw store which are used as secondary
066:         indexes.
067:         <p>
068:         Most of this code is generic to all conglomerates.  This class might be
069:         more easily maintained as an abstract class in Raw/Conglomerate/Generic.
070:         The concrete ConglomerateFactories would simply have to supply the 
071:         IMPLEMENTATIONID, FORMATUUIDSTRING, and implement createConglomerate
072:         and defaultProperties.  Conglomerates which support more than one format
073:         would have to override supportsFormat, and conglomerates which support
074:         more than one implementation would have to override supportsImplementation.
075:
076:         **/
077:
078:        public class B2IFactory implements  ConglomerateFactory, ModuleControl {
079:
080:            private static final String IMPLEMENTATIONID = "BTREE";
081:            private static final String FORMATUUIDSTRING = "C6CEEEF0-DAD3-11d0-BB01-0060973F0942";
082:            private UUID formatUUID;
083:
084:            /*
085:             ** Methods of MethodFactory (via ConglomerateFactory)
086:             */
087:
088:            /**
089:            Return the default properties for this kind of conglomerate.
090:            @see org.apache.derby.iapi.store.access.conglomerate.MethodFactory#defaultProperties
091:             **/
092:            public Properties defaultProperties() {
093:                // XXX (nat) Need to return the default b-tree secondary index properties.
094:                return new Properties();
095:            }
096:
097:            /**
098:            Return whether this access method implements the implementation
099:            type given in the argument string.
100:            The btree only has one implementation type, "BTREE".
101:
102:            @see org.apache.derby.iapi.store.access.conglomerate.MethodFactory#supportsImplementation
103:             **/
104:            public boolean supportsImplementation(String implementationId) {
105:                return implementationId.equals(IMPLEMENTATIONID);
106:            }
107:
108:            /**
109:            Return the primary implementation type for this access method.
110:            The btree only has one implementation type, "BTREE".
111:
112:            @see org.apache.derby.iapi.store.access.conglomerate.MethodFactory#primaryImplementationType
113:             **/
114:            public String primaryImplementationType() {
115:                return IMPLEMENTATIONID;
116:            }
117:
118:            /**
119:            Return whether this access method supports the format supplied in
120:            the argument.
121:            The btree currently only supports one format.
122:
123:            @see org.apache.derby.iapi.store.access.conglomerate.MethodFactory#supportsFormat
124:             **/
125:            public boolean supportsFormat(UUID formatid) {
126:                return formatid.equals(formatUUID);
127:            }
128:
129:            /**
130:            Return the primary format that this access method supports.
131:            The btree currently only supports one format.
132:
133:            @see org.apache.derby.iapi.store.access.conglomerate.MethodFactory#primaryFormat
134:             **/
135:            public UUID primaryFormat() {
136:                return formatUUID;
137:            }
138:
139:            /*
140:             ** Methods of ConglomerateFactory
141:             */
142:
143:            /**
144:             * Return the conglomerate factory id.
145:             * <p>
146:             * Return a number in the range of 0-15 which identifies this factory.
147:             * Code which names conglomerates depends on this range currently, but
148:             * could be easily changed to handle larger ranges.   One hex digit seemed
149:             * reasonable for the number of conglomerate types being currently 
150:             * considered (heap, btree, gist, gist btree, gist rtree, hash, others? ).
151:             * <p>
152:             * @see ConglomerateFactory#getConglomerateFactoryId
153:             *
154:             * @return an unique identifier used to the factory into the conglomid.
155:             **/
156:            public int getConglomerateFactoryId() {
157:                return (ConglomerateFactory.BTREE_FACTORY_ID);
158:            }
159:
160:            /**
161:            Create the conglomerate and return a conglomerate object for it.
162:
163:            @see ConglomerateFactory#createConglomerate
164:
165:            @exception StandardException Standard exception policy.
166:             **/
167:            public Conglomerate createConglomerate(TransactionManager xact_mgr,
168:                    int segment, long input_containerid,
169:                    DataValueDescriptor[] template,
170:                    ColumnOrdering[] columnOrder, Properties properties,
171:                    int temporaryFlag) throws StandardException {
172:                B2I btree = new B2I();
173:                btree.create(xact_mgr, segment, input_containerid, template,
174:                        columnOrder, properties, temporaryFlag);
175:
176:                return (btree);
177:            }
178:
179:            /**
180:             * Return Conglomerate object for conglomerate with conglomid.
181:             * <p>
182:             * Return the Conglomerate Object.  This is implementation specific.
183:             * Examples of what will be done is using the id to find the file where
184:             * the conglomerate is located, and then executing implementation specific
185:             * code to instantiate an object from reading a "special" row from a
186:             * known location in the file.  In the btree case the btree conglomerate
187:             * is stored as a column in the control row on the root page.
188:             * <p>
189:             * This operation is costly so it is likely an implementation using this
190:             * will cache the conglomerate row in memory so that subsequent accesses
191:             * need not perform this operation.
192:             * <p>
193:             * The btree object returned by this routine may be installed in a cache
194:             * so the object must not change.
195:             *
196:             * @return An instance of the conglomerate.
197:             *
198:             * @exception  StandardException  Standard exception policy.
199:             **/
200:            public Conglomerate readConglomerate(
201:                    TransactionManager xact_manager, ContainerKey container_key)
202:                    throws StandardException {
203:                Conglomerate btree = null;
204:                ContainerHandle container = null;
205:                ControlRow root = null;
206:
207:                try {
208:                    // open readonly, with no locks.  Dirty read is ok as it is the
209:                    // responsibility of client code to make sure this data is not
210:                    // changing while being read.  The only changes that currently
211:                    // happen to this data is creation and deletion - no updates
212:                    // ever happen to btree conglomerates.
213:                    container = (xact_manager.getRawStoreXact()).openContainer(
214:                            container_key, (LockingPolicy) null,
215:                            ContainerHandle.MODE_READONLY);
216:
217:                    if (container == null) {
218:                        // thrown a "known" error if the conglomerate does not exist 
219:                        // which is checked for explicitly by callers of the store 
220:                        // interface.
221:
222:                        throw StandardException.newException(
223:                                SQLState.STORE_CONGLOMERATE_DOES_NOT_EXIST,
224:                                new Long(container_key.getContainerId()));
225:                    }
226:
227:                    // The conglomerate is located in the control row on the root page.
228:                    root = ControlRow.Get(container, BTree.ROOTPAGEID);
229:
230:                    if (SanityManager.DEBUG)
231:                        SanityManager.ASSERT(root.getPage().isLatched());
232:
233:                    // read the Conglomerate from it's entry in the control row.
234:                    btree = (B2I) root.getConglom(B2I.FORMAT_NUMBER);
235:
236:                    if (SanityManager.DEBUG)
237:                        SanityManager.ASSERT(btree instanceof  B2I);
238:                } finally {
239:
240:                    if (root != null)
241:                        root.release();
242:
243:                    if (container != null)
244:                        container.close();
245:                }
246:
247:                // if any error, just return null - meaning can't access the container.
248:
249:                return (btree);
250:            }
251:
252:            /*
253:             ** Methods of ModuleControl.
254:             */
255:
256:            public boolean canSupport(Properties startParams) {
257:
258:                String impl = startParams
259:                        .getProperty("derby.access.Conglomerate.type");
260:                if (impl == null)
261:                    return false;
262:
263:                return supportsImplementation(impl);
264:            }
265:
266:            public void boot(boolean create, Properties startParams)
267:                    throws StandardException {
268:                // Find the UUID factory.
269:                UUIDFactory uuidFactory = Monitor.getMonitor().getUUIDFactory();
270:
271:                // Make a UUID that identifies this conglomerate's format.
272:                formatUUID = uuidFactory.recreateUUID(FORMATUUIDSTRING);
273:            }
274:
275:            public void stop() {
276:            }
277:        }
w_w___w_.___j__a__v___a2__s___.___c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.