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


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.sql.execute.rts.RealBasicNoPutResultSetStatistics
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.sql.execute.rts;
023:
024:        import org.apache.derby.iapi.services.io.StoredFormatIds;
025:        import org.apache.derby.iapi.services.io.Formatable;
026:
027:        import org.apache.derby.iapi.services.i18n.MessageService;
028:        import org.apache.derby.iapi.reference.SQLState;
029:
030:        import org.apache.derby.iapi.services.io.FormatableHashtable;
031:
032:        import java.util.Vector;
033:
034:        import java.io.ObjectOutput;
035:        import java.io.ObjectInput;
036:        import java.io.IOException;
037:
038:        import java.text.DecimalFormat;
039:
040:        /**
041:         ResultSetStatistics implemenation for BasicNoPutResultSetImpl.
042:
043:         @author jerry
044:
045:         */
046:        abstract class RealBasicNoPutResultSetStatistics implements 
047:                ResultSetStatistics {
048:
049:            /* Leave these fields public for object inspectors */
050:            public int numOpens;
051:            public int rowsSeen;
052:            public int rowsFiltered;
053:            public long constructorTime;
054:            public long openTime;
055:            public long nextTime;
056:            public long closeTime;
057:            public long inspectOverall;
058:            public long inspectNum;
059:            public String inspectDesc;
060:            public double optimizerEstimatedRowCount;
061:            public double optimizerEstimatedCost;
062:
063:            // CONSTRUCTORS
064:
065:            /**
066:             *
067:             *
068:             */
069:            public RealBasicNoPutResultSetStatistics(int numOpens,
070:                    int rowsSeen, int rowsFiltered, long constructorTime,
071:                    long openTime, long nextTime, long closeTime,
072:                    double optimizerEstimatedRowCount,
073:                    double optimizerEstimatedCost) {
074:                this .numOpens = numOpens;
075:                this .rowsSeen = rowsSeen;
076:                this .rowsFiltered = rowsFiltered;
077:                this .constructorTime = constructorTime;
078:                this .openTime = openTime;
079:                this .nextTime = nextTime;
080:                this .closeTime = closeTime;
081:                this .optimizerEstimatedRowCount = optimizerEstimatedRowCount;
082:                this .optimizerEstimatedCost = optimizerEstimatedCost;
083:            }
084:
085:            // Class implementation
086:            /**
087:             * Dump out the time information for run time stats.
088:             *
089:             * @return Nothing.
090:             */
091:            protected final String dumpTimeStats(String indent, String subIndent) {
092:                return
093:                /*
094:                 indent + "time spent in this ResultSet = " +
095:                 getTimeSpent(ResultSet.CURRENT_RESULTSET_ONLY) + "\n" +
096:                 indent + "time spent in this ResultSet and below = " +
097:                 getTimeSpent(NoPutResultSet.ENTIRE_RESULTSET_TREE) + "\n" +
098:                 indent + "total time breakdown: " + "\n" +
099:                 */
100:                subIndent
101:                        + MessageService
102:                                .getTextMessage(SQLState.LANG_CONSTRUCTOR_TIME)
103:                        + " "
104:                        + constructorTime
105:                        + "\n"
106:                        + subIndent
107:                        + MessageService
108:                                .getTextMessage(SQLState.LANG_OPEN_TIME)
109:                        + " "
110:                        + openTime
111:                        + "\n"
112:                        + subIndent
113:                        + MessageService
114:                                .getTextMessage(SQLState.LANG_NEXT_TIME)
115:                        + " "
116:                        + nextTime
117:                        + "\n"
118:                        + subIndent
119:                        + MessageService
120:                                .getTextMessage(SQLState.LANG_CLOSE_TIME) + " "
121:                        + closeTime;
122:            }
123:
124:            /**
125:             * Dump out the estimated cost information
126:             *
127:             * @return Nothing.
128:             */
129:            protected final String dumpEstimatedCosts(String subIndent) {
130:                return subIndent
131:                        + MessageService
132:                                .getTextMessage(SQLState.RTS_OPT_EST_RC)
133:                        + ": "
134:                        + formatDouble(optimizerEstimatedRowCount)
135:                        + "\n"
136:                        + subIndent
137:                        + MessageService
138:                                .getTextMessage(SQLState.RTS_OPT_EST_COST)
139:                        + ": " + formatDouble(optimizerEstimatedCost) + "\n";
140:            }
141:
142:            /**
143:             * Format a double as a String with leading spaces and two digits
144:             * after the decimal.
145:             */
146:            private static DecimalFormat df = null;
147:
148:            private String formatDouble(double toFormat) {
149:                if (df == null) {
150:                    // RESOLVE: This really should use the database locale to
151:                    // format the number.
152:                    df = new DecimalFormat("###########0.00");
153:                    df.setMinimumIntegerDigits(1);
154:                }
155:
156:                String retval = df.format(toFormat);
157:
158:                if (retval.length() < 15) {
159:                    retval = "               ".substring(0, 15 - retval
160:                            .length())
161:                            + retval;
162:                }
163:
164:                return retval;
165:            }
166:
167:            /**
168:             * Get the objects to be displayed when this tree object is expanded.
169:             * <P>
170:             * The objects returned can be of any type, including addtional Inspectables.
171:             *
172:             * @return java.util.Vector	A vector of objects.
173:             */
174:            public Vector getChildren() {
175:                return new Vector();
176:            }
177:
178:            /**
179:             * Return the time for all operations performed by this node, and the children
180:             * of this node.  The times included open, next, and close.
181:             *
182:             */
183:            public long getTotalTime() {
184:                //The method below is the original calculation.  However, the constructor
185:                //time was found to be inaccurate, and was therefore removed from the calculation.
186:                //return constructorTime + openTime + nextTime + closeTime;
187:                return openTime + nextTime + closeTime;
188:            }
189:
190:            /**
191:             * Return the time for all operations performed by the children of this node.
192:             *
193:             */
194:            public long getChildrenTime() {
195:                long childrenTime = 0;
196:                java.util.Enumeration e = getChildren().elements();
197:                while (e.hasMoreElements()) {
198:                    childrenTime = childrenTime
199:                            + ((RealBasicNoPutResultSetStatistics) e
200:                                    .nextElement()).getTotalTime();
201:                }
202:                return childrenTime;
203:            }
204:
205:            /**
206:             * Return the time for all operations performed by this node, but not the
207:             * time for the children of this node.
208:             *
209:             */
210:            public long getNodeTime() {
211:                return getTotalTime() - getChildrenTime();
212:            }
213:
214:            /**
215:             * Format for display, a name for this node.
216:             *
217:             */
218:            public abstract String getNodeName();
219:
220:            /**
221:             * If this node is on a database item (like a table or an index), then provide a
222:             * string that describes the on item.
223:             *
224:             */
225:            public String getNodeOn() {
226:                return "";
227:            }
228:
229:            /**
230:             * Get the estimated row count for the number of rows returned
231:             * by the associated query or statement.
232:             *
233:             * @return	The estimated number of rows returned by the associated
234:             * query or statement.
235:             */
236:            public double getEstimatedRowCount() {
237:                return optimizerEstimatedRowCount;
238:            }
239:        }
w__ww___.ja__v__a__2s_.___co__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.