KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > store > access > heap > HeapScanInfo


1 /*
2
3    Derby - Class org.apache.derby.impl.store.access.heap.HeapScanInfo
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.impl.store.access.heap;
23
24 import org.apache.derby.iapi.store.access.ScanInfo;
25
26 import org.apache.derby.iapi.error.StandardException;
27
28 import org.apache.derby.iapi.reference.SQLState;
29
30 import org.apache.derby.iapi.services.io.FormatableBitSet;
31 import org.apache.derby.iapi.services.i18n.MessageService;
32 import java.util.Properties JavaDoc;
33
34 /**
35
36   This object provides performance information related to an open scan.
37   The information is accumulated during operations on a ScanController() and
38   then copied into this object and returned by a call to
39   ScanController.getStatistic().
40
41   @see org.apache.derby.iapi.store.access.ScanController#getScanInfo()
42
43 **/

44 class HeapScanInfo implements ScanInfo
45 {
46     /**
47      * Performance counters ...
48      */

49     private int stat_numpages_visited = 0;
50     private int stat_numrows_visited = 0;
51     private int stat_numrows_qualified = 0;
52     private int stat_numColumnsFetched = 0;
53     private FormatableBitSet stat_validColumns = null;
54
55     /* Constructors for This class: */
56     HeapScanInfo(HeapScan scan)
57     {
58         // copy perfomance state out of scan, to get a fixed set of stats
59
stat_numpages_visited = scan.getNumPagesVisited();
60         stat_numrows_visited = scan.getNumRowsVisited();
61         stat_numrows_qualified = scan.getNumRowsQualified();
62
63         stat_validColumns =
64             (scan.getScanColumnList() == null ?
65                 null : ((FormatableBitSet) scan.getScanColumnList().clone()));
66
67         if (stat_validColumns == null)
68         {
69             stat_numColumnsFetched = ((Heap) scan.getOpenConglom().getConglomerate()).format_ids.length;
70         }
71         else
72         {
73             for (int i = 0; i < stat_validColumns.size(); i++)
74             {
75                 if (stat_validColumns.get(i))
76                     stat_numColumnsFetched++;
77             }
78         }
79
80     }
81
82     /**
83      * Return all information gathered about the scan.
84      * <p>
85      * This routine returns a list of properties which contains all information
86      * gathered about the scan. If a Property is passed in, then that property
87      * list is appeneded to, otherwise a new property object is created and
88      * returned.
89      * <p>
90      * Not all scans may support all properties, if the property is not
91      * supported then it will not be returned. The following is a list of
92      * properties that may be returned:
93      *
94      * numPagesVisited
95      * - the number of pages visited during the scan. For btree scans
96      * this number only includes the leaf pages visited.
97      * numRowsVisited
98      * - the number of rows visited during the scan. This number
99      * includes all rows, including: those marked deleted, those
100      * that don't meet qualification, ...
101      * numRowsQualified
102      * - the number of undeleted rows, which met the qualification.
103      * treeHeight (btree's only)
104      * - for btree's the height of the tree. A tree with one page
105      * has a height of 1. Total number of pages visited in a btree
106      * scan is (treeHeight - 1 + numPagesVisited).
107      * NOTE - this list will be expanded as more information about the scan
108      * is gathered and returned.
109      *
110      * @param prop Property list to fill in.
111      *
112      * @exception StandardException Standard exception policy.
113      **/

114     public Properties JavaDoc getAllScanInfo(Properties JavaDoc prop)
115         throws StandardException
116     {
117         if (prop == null)
118             prop = new Properties JavaDoc();
119
120         prop.put(
121             MessageService.getTextMessage(SQLState.STORE_RTS_SCAN_TYPE),
122             MessageService.getTextMessage(SQLState.STORE_RTS_HEAP));
123         prop.put(
124             MessageService.getTextMessage(SQLState.STORE_RTS_NUM_PAGES_VISITED),
125             Integer.toString(stat_numpages_visited));
126         prop.put(
127             MessageService.getTextMessage(SQLState.STORE_RTS_NUM_ROWS_VISITED),
128             Integer.toString(stat_numrows_visited));
129         prop.put(
130           MessageService.getTextMessage(SQLState.STORE_RTS_NUM_ROWS_QUALIFIED),
131           Integer.toString(stat_numrows_qualified));
132         prop.put(
133           MessageService.getTextMessage(SQLState.STORE_RTS_NUM_COLUMNS_FETCHED),
134           Integer.toString(stat_numColumnsFetched));
135         prop.put(
136       MessageService.getTextMessage(SQLState.STORE_RTS_COLUMNS_FETCHED_BIT_SET),
137             (stat_validColumns == null ?
138                 MessageService.getTextMessage(SQLState.STORE_RTS_ALL) :
139                 stat_validColumns.toString()));
140
141         return(prop);
142     }
143 }
144
Popular Tags