Source Code Cross Referenced for MergeSortInfo.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » store » access » sort » 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.sort 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.store.access.sort.MergeSortInfo
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.sort;
023:
024:        import org.apache.derby.iapi.store.access.SortInfo;
025:
026:        import org.apache.derby.iapi.error.StandardException;
027:
028:        import org.apache.derby.iapi.reference.SQLState;
029:
030:        import org.apache.derby.iapi.services.i18n.MessageService;
031:
032:        import java.util.Vector;
033:        import java.util.Properties;
034:
035:        /**
036:
037:         This object provides performance information related to a sort.
038:         The information is accumulated during operations on a SortController() and
039:         then copied into this object and returned by a call to
040:         SortController.getSortInfo().
041:
042:         @see org.apache.derby.iapi.store.access.SortController#getSortInfo()
043:
044:         **/
045:        class MergeSortInfo implements  SortInfo {
046:            /**
047:             * Performance counters ...
048:             */
049:
050:            private String stat_sortType;
051:            // private long    stat_estimMemUsed;
052:            private int stat_numRowsInput;
053:            private int stat_numRowsOutput;
054:            private int stat_numMergeRuns;
055:            private Vector stat_mergeRunsSize;
056:
057:            /* Constructors for This class: */
058:            MergeSortInfo(MergeInserter sort) {
059:                // copy perfomance state out of sort, to get a fixed set of stats
060:                stat_sortType = sort.stat_sortType;
061:                // stat_estimMemUsed           = sort.estimatedMemoryUsed;
062:                stat_numRowsInput = sort.stat_numRowsInput;
063:                stat_numRowsOutput = sort.stat_numRowsOutput;
064:                stat_numMergeRuns = sort.stat_numMergeRuns;
065:                stat_mergeRunsSize = sort.stat_mergeRunsSize;
066:            }
067:
068:            /**
069:             * Return all information gathered about the sort.
070:             * <p>
071:             * This routine returns a list of properties which contains all information
072:             * gathered about the sort.  If a Property is passed in, then that property
073:             * list is appended to, otherwise a new property object is created and
074:             * returned.
075:             * <p>
076:             * Not all sorts may support all properties, if the property is not
077:             * supported then it will not be returned.  The following is a list of
078:             * properties that may be returned:
079:             *
080:             *     sortType
081:             *         - type of the sort being performed:
082:             *           internal
083:             *           external
084:             *     numRowsInput
085:             *         - the number of rows input to the sort.  This
086:             *           number includes duplicates.
087:             *     numRowsOutput
088:             *         - the number of rows to be output by the sort.  This number
089:             *           may be different from numRowsInput since duplicates may not
090:             *           be output.
091:             *     numMergeRuns
092:             *         - the number of merge runs for the sort.
093:             *           Applicable to external sorts only.
094:             *           Note: when a SortController is closed, numMergeRuns may increase by 1, to
095:             *           reflect the additional merge run that may be created for
096:             *           any data still in the sort buffer.
097:             *     mergeRunsSize
098:             *         - the size (number of rows) of each merge run for the sort.
099:             *           Applicable to external sorts only.
100:             *           e.g. [3,3,2] indicates 3 merge runs, where the first two runs
101:             *           have 3 rows each, and the last run has 2 rows.
102:             *           Note: when a SortController is closed, this vector may get an
103:             *           additional element, to reflect the additional merge run that
104:             *           may be created for any data still in the sort buffer.
105:             *     NOTE - this list will be expanded as more information about the sort
106:             *            is gathered and returned.
107:             *
108:             * @param prop   Property list to fill in.
109:             *
110:             * @exception  StandardException  Standard exception policy.
111:             **/
112:
113:            public Properties getAllSortInfo(Properties prop)
114:                    throws StandardException {
115:                if (prop == null)
116:                    prop = new Properties();
117:
118:                prop
119:                        .put(
120:                                MessageService
121:                                        .getTextMessage(SQLState.STORE_RTS_SORT_TYPE),
122:                                "external".equals(this .stat_sortType) ? MessageService
123:                                        .getTextMessage(SQLState.STORE_RTS_EXTERNAL)
124:                                        : MessageService
125:                                                .getTextMessage(SQLState.STORE_RTS_INTERNAL));
126:                // prop.put(
127:                //  MessageService.getTextMessage(SQLState.STORE_RTS_ESTIMATED_MEMORY_USED),
128:                //  Long.toString(stat_estimMemUsed));
129:                prop.put(MessageService
130:                        .getTextMessage(SQLState.STORE_RTS_NUM_ROWS_INPUT),
131:                        Integer.toString(stat_numRowsInput));
132:                prop.put(MessageService
133:                        .getTextMessage(SQLState.STORE_RTS_NUM_ROWS_OUTPUT),
134:                        Integer.toString(stat_numRowsOutput));
135:                if (this .stat_sortType == "external") {
136:                    prop.put(MessageService
137:                            .getTextMessage(SQLState.STORE_RTS_NUM_MERGE_RUNS),
138:                            Integer.toString(stat_numMergeRuns));
139:                    prop
140:                            .put(
141:                                    MessageService
142:                                            .getTextMessage(SQLState.STORE_RTS_MERGE_RUNS_SIZE),
143:                                    stat_mergeRunsSize.toString());
144:                }
145:                return (prop);
146:            }
147:        }
148:
149:        /**
150:         *     estimMemUsed IS NOT CURRENTLY SUPPORTED SINCE IT IS UNRELIABLE
151:         *     estimMemUsed
152:         *         - the estimated memory used by the sort.
153:         *
154:         *           This is only measured when the system runs out of sort
155:         *           buffer space, AND when it tries to avoid doing an external sort.
156:         *           It measures this by subtracting the memory usage at initialization
157:         *           from the memory usage at the time we are trying to avoid doing an
158:         *           external sort.  The result could be negative: this probably indicates
159:         *           that there has been some garbage collection in the interim.
160:         *           If the attempt at keeping the sort internal succeeds, the buffer grows
161:         *           but the increased memory usage is not measured.
162:         *
163:         *           The system may never measure the memory usage. This happens if
164:         *           it never runs out of sort buffer space, or if it is set up not
165:         *           to avoid external sorts. In cases that it is not measured, it returns 0.
166:         *
167:         *           In future, this info may improve with an improved JVM API.
168:         */
w__w__w__._j_a___v_a_2__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.