EMMA Coverage Report (generated Wed Jun 28 22:15:27 PDT 2006)
[all classes][org.apache.derby.impl.store.access.sort]

COVERAGE SUMMARY FOR SOURCE FILE [SortBufferRowSource.java]

nameclass, %method, %block, %line, %
SortBufferRowSource.java100% (1/1)42%  (5/12)72%  (63/88)67%  (22/33)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SortBufferRowSource100% (1/1)42%  (5/12)72%  (63/88)67%  (22/33)
SortBufferRowSource (SortBuffer, TransactionManager, SortObserver, boolean, i... 100% (1/1)100% (24/24)100% (9/9)
close (): void 100% (1/1)100% (14/14)100% (5/5)
closeForEndTransaction (boolean): boolean 0%   (0/1)0%   (0/7)0%   (0/3)
closeRowSource (): void 100% (1/1)100% (3/3)100% (2/2)
fetch (DataValueDescriptor []): void 0%   (0/1)0%   (0/3)0%   (0/1)
fetchNext (DataValueDescriptor []): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
getNextRowFromRowSource (): DataValueDescriptor [] 100% (1/1)91%  (20/22)83%  (5/6)
getValidColumns (): FormatableBitSet 100% (1/1)100% (2/2)100% (1/1)
needsRowLocation (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
needsToClone (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
next (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
rowLocation (RowLocation): void 0%   (0/1)0%   (0/3)0%   (0/2)

1/*
2 
3   Derby - Class org.apache.derby.impl.store.access.sort.SortBufferRowSource
4 
5   Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable.
6 
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10 
11      http://www.apache.org/licenses/LICENSE-2.0
12 
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18 
19 */
20 
21package org.apache.derby.impl.store.access.sort;
22 
23import org.apache.derby.iapi.reference.SQLState;
24 
25import org.apache.derby.iapi.services.sanity.SanityManager;
26import org.apache.derby.iapi.error.StandardException;
27import org.apache.derby.iapi.store.access.RowSource;
28import org.apache.derby.iapi.store.access.SortObserver;
29import org.apache.derby.iapi.types.RowLocation;
30import org.apache.derby.iapi.store.access.conglomerate.ScanControllerRowSource;
31import org.apache.derby.iapi.store.access.conglomerate.TransactionManager;
32import org.apache.derby.iapi.store.access.ScanController;
33 
34import org.apache.derby.iapi.types.DataValueDescriptor;
35 
36import org.apache.derby.iapi.services.io.FormatableBitSet;
37 
38/**
39        Wrapping the output of a SortBuffer in a RowSource for the benefit of the
40        createAndLoadConglomerate and loadConglomerate interface.
41 
42        Scan implements ScanController, this class just implements the
43        RowSource interface. 
44 
45*/
46public class SortBufferRowSource extends Scan
47                implements ScanControllerRowSource
48{
49        /**
50        The Sort buffer where rows come from
51        **/
52        SortBuffer sortBuffer = null;
53 
54        /**
55        The TransactionManager that opened this scan.
56        **/
57        protected TransactionManager tran = null;
58 
59        private int                         maxFreeListSize;
60        private boolean                 writingToDisk;
61        private SortObserver sortObserver;
62 
63        /*
64         * Constructors.
65         */
66 
67        SortBufferRowSource(
68    SortBuffer          sortBuffer, 
69    TransactionManager  tran, 
70    SortObserver        sortObserver,
71    boolean             writingToDisk, 
72    int                 maxFreeListSize)
73        {
74                super();
75                this.sortBuffer = sortBuffer;
76                this.tran = tran;
77                this.sortObserver = sortObserver;
78                this.writingToDisk = writingToDisk;
79                this.maxFreeListSize = maxFreeListSize;
80        }
81 
82        /* Private/Protected methods of This class: */
83    /* Public Methods of This class: */
84    /* Public Methods of RowSource class: */
85 
86    public DataValueDescriptor[] getNextRowFromRowSource()
87    {
88                if (sortBuffer == null)        // has been closed
89                        return null;
90 
91                DataValueDescriptor[] retval = sortBuffer.removeFirst();
92 
93                // Return the removed object to the free DataValueDescriptor[]
94                if (retval != null && writingToDisk)
95                {
96                        sortObserver.addToFreeList(retval, maxFreeListSize);
97                }
98                return retval;
99          }
100 
101        public boolean needsRowLocation()
102        {
103                return false;
104        }
105 
106        /**
107         * @see RowSource#needsToClone
108         */
109        public boolean needsToClone()
110        {
111                return false;
112        }
113 
114        public void rowLocation(RowLocation rl)
115        {
116                if (SanityManager.DEBUG)
117                        SanityManager.THROWASSERT("unexpected call to RowSource.rowLocation");
118        }
119 
120 
121        /**
122                All columns are always set from a sorter
123        */
124        public FormatableBitSet getValidColumns()
125        {
126                return null;
127        }
128 
129        /**
130                Close the scan
131         */
132        public void close()
133        {
134                if (sortBuffer != null)
135                {
136                        sortBuffer.close();
137                        sortBuffer = null;
138                }
139                tran.closeMe(this);
140        }
141 
142        /**
143                Close the scan
144         */
145        public boolean closeForEndTransaction(boolean closeHeldScan)
146        {
147        if (SanityManager.DEBUG)
148            SanityManager.ASSERT(
149                closeHeldScan, 
150                "Sort scan should not be held open across commit.");
151 
152        close();
153        return(true);
154    }
155 
156        /**
157                Close the rowSource
158         */
159        public void closeRowSource()
160        {
161                close();
162        }
163 
164        /*
165         * Disable illegal and dangerous scan controller interface call
166         */
167        public boolean next() throws StandardException
168        {
169        throw StandardException.newException(
170                SQLState.SORT_IMPROPER_SCAN_METHOD);
171        }
172 
173    /**
174     * Fetch the row at the current position of the Scan and does not apply the
175     * qualifiers.
176     *
177     * This method will always throw an exception. 
178     * (SQLState.SORT_IMPROPER_SCAN_METHOD)
179     *
180     * @see ScanController#fetchWithoutQualify
181     **/
182    public void fetchWithoutQualify(DataValueDescriptor[] result) 
183        throws StandardException
184    {
185        throw StandardException.newException(
186                SQLState.SORT_IMPROPER_SCAN_METHOD);
187    }
188 
189    /**
190     * Fetch the row at the current position of the Scan.
191     *
192     * @see ScanController#fetch
193     **/
194    public void fetch(DataValueDescriptor[] result) throws StandardException
195        {
196        throw StandardException.newException(
197                SQLState.SORT_IMPROPER_SCAN_METHOD);
198        }
199 
200    public final boolean fetchNext(DataValueDescriptor[] row) 
201        throws StandardException
202        {
203        throw StandardException.newException(
204                SQLState.SORT_IMPROPER_SCAN_METHOD);
205        }
206 
207}

[all classes][org.apache.derby.impl.store.access.sort]
EMMA 2.0.5312 (C) Vladimir Roubtsov