KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > store > access > sort > MergeScanRowSource


1 /*
2
3    Derby - Class org.apache.derby.impl.store.access.sort.MergeScanRowSource
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.sort;
23
24 import org.apache.derby.iapi.reference.SQLState;
25
26 import org.apache.derby.iapi.services.io.FormatableBitSet;
27 import org.apache.derby.iapi.services.sanity.SanityManager;
28
29 import org.apache.derby.iapi.error.StandardException;
30 import org.apache.derby.iapi.store.access.conglomerate.ScanControllerRowSource;
31 import org.apache.derby.iapi.store.access.conglomerate.TransactionManager;
32 import org.apache.derby.iapi.store.access.SortObserver;
33 import org.apache.derby.iapi.store.access.RowLocationRetRowSource;
34
35 import org.apache.derby.iapi.types.DataValueDescriptor;
36
37 import org.apache.derby.iapi.types.RowLocation;
38
39 import java.util.Vector JavaDoc;
40
41 /**
42     Wrapping the output of a MergeScan in a RowSource for the benefit of the
43     createAndLoadConglomerate and loadConglomerate interface. The output of a
44
45     MergeScan is written to a file when we need more than one level of merge
46     runs.
47
48     MergeScan implements ScanController, this class just implements the
49     RowSource interface.
50 */

51 public class MergeScanRowSource extends MergeScan implements ScanControllerRowSource
52 {
53
54     /* Constructors for This class: */
55     MergeScanRowSource(
56     MergeSort sort,
57     TransactionManager tran,
58     SortBuffer sortBuffer,
59     Vector JavaDoc mergeRuns,
60     SortObserver sortObserver,
61     boolean hold)
62     {
63         super(sort, tran, sortBuffer, mergeRuns, sortObserver, hold);
64     }
65
66     /*
67      * Disable illegal and dangerous scan controller interface call
68      * @exception StandardException This is an illegal operation
69      */

70     public boolean next() throws StandardException
71     {
72         throw StandardException.newException(
73                 SQLState.SORT_IMPROPER_SCAN_METHOD);
74     }
75
76     /* Private/Protected methods of This class: */
77     /* Public Methods of This class: */
78     /* Public Methods of RowSource class: */
79
80
81     public DataValueDescriptor[] getNextRowFromRowSource()
82         throws StandardException
83     {
84         DataValueDescriptor[] row = sortBuffer.removeFirst();
85
86         if (row != null)
87         {
88             mergeARow(sortBuffer.getLastAux());
89         }
90
91         return row;
92     }
93
94     /**
95      * @see RowLocationRetRowSource#needsRowLocation
96      */

97     public boolean needsRowLocation()
98     {
99         return false;
100     }
101
102     /**
103      * @see org.apache.derby.iapi.store.access.RowSource#needsToClone
104      */

105     public boolean needsToClone()
106     {
107         return false;
108     }
109
110
111     /**
112      * @see RowLocationRetRowSource#rowLocation
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 row source - implemented by MergeScan already
131      */

132     public void closeRowSource()
133     {
134         close();
135     }
136
137 }
138
139
Popular Tags