KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > datasystem > indexsystem > IndexInformations


1 package com.daffodilwoods.daffodildb.server.datasystem.indexsystem;
2
3 import com.daffodilwoods.database.resource.*;
4 import com.daffodilwoods.database.general.QualifiedIdentifier;
5 import java.util.ArrayList JavaDoc;
6 import com.daffodilwoods.daffodildb.server.datasystem.interfaces._TableCharacteristics;
7 import com.daffodilwoods.daffodildb.server.datasystem.persistentsystem.versioninfo.VersionHandler;
8 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.Utility;
9
10 /**
11  *
12  * <p>Title: Index Informations</p>
13  * <p>Description: this class is for storing the information of a
14  * particular index </p>
15  */

16
17 public class IndexInformations implements _IndexInformation{
18
19     /**
20      * Table on which Index is Maintained
21      */

22     private QualifiedIdentifier sourceTableName;
23
24     /**
25      * Name Of Index
26      */

27     private String JavaDoc indexName;
28
29     /**
30      * Name of Indextable, It stores BTrees corresponding To Indexes on table
31      */

32     private QualifiedIdentifier indexTableName;
33
34     /**
35      * Columns on which Index is Maintained
36      */

37     private String JavaDoc[] indexColumnNames;
38
39     /**
40      * Indexes of Columns on Table on Which Index is maintained
41      */

42     private int[] indexColumnIndexes;
43
44     /**
45      * Order of Indexes on Columns
46      */

47     private boolean[] orderType;
48
49     /**
50      * Address of Cluster on which root node of btree is stored
51      */

52     public int rootClusterAddress;
53
54     /**
55      * Size of Cluster on Which Btree nodes are stored
56      */

57     private int rootClusterSize;
58
59     /**
60      * RecordNumber of RootCluster on which First Record of root node
61      * is stored
62      */

63
64     /**
65      * Total Number of Records In Btree
66      */

67     private int numberOfRecords;
68
69     /**
70      * Whether Index is on all Fixed Size Columns or not
71      */

72
73     private boolean isVariable;
74     private boolean isDefault;
75
76
77
78
79     public IndexInformations(QualifiedIdentifier sourceTableName0,String JavaDoc indexName0
80                             ,int controlClusterAddress0, boolean isVariable0,Object JavaDoc[] columnInformations0,VersionHandler versionHandler) throws DException{
81         sourceTableName = sourceTableName0;
82         indexName = indexName0;
83         rootClusterAddress = controlClusterAddress0;
84         if(rootClusterAddress == 0)
85             Thread.dumpStack();
86         isVariable = isVariable0;
87         int len = columnInformations0.length;
88         indexColumnNames = new String JavaDoc[len];
89         orderType = new boolean[len];
90         indexColumnIndexes = new int[len];
91         for( int i = 0 ; i < len ; i++ ){
92             Object JavaDoc[] columns = (Object JavaDoc[])columnInformations0[i];
93             indexColumnNames[i] = (String JavaDoc)columns[0];
94             orderType[i] = ((Boolean JavaDoc)columns[1]).booleanValue();
95             indexColumnIndexes[i] = columns[2].hashCode();
96         }
97         isDefault = versionHandler.isDefault(indexColumnNames);//indexColumnNames.length == 1 && indexColumnNames[0].equalsIgnoreCase(SystemFields.systemFields[SystemFields.rowId]);
98
/*indexColumns = "";
99       orderTypeColumn = "";
100       this.indexColumnIndexes = indexColumnIndexes;
101
102       if( indexColumnName != null ){
103          StringBuffer st = new StringBuffer(50);
104          st.append(indexColumnName[0]);
105          for(int i=1;i<indexColumnName.length;i++){
106             st.append(',');st.append(indexColumnName[i]);
107          }
108          indexColumns = st.toString();
109       }
110       if( orderType != null ){
111          StringBuffer st = new StringBuffer(50);
112          st.append(orderType[0]);
113          for (int i = 1; i < orderType.length; i++) {
114             st.append(',');st.append(orderType[i]);
115          }
116          orderTypeColumn = st.toString();
117       }*/

118
119     }
120     public IndexInformations(String JavaDoc[] columnNames,VersionHandler versionHandler) {
121         indexColumnNames = columnNames;
122         isDefault = versionHandler.isDefault(indexColumnNames);//indexColumnNames.length == 1 && indexColumnNames[0].equalsIgnoreCase(SystemFields.systemFields[SystemFields.rowId]);
123
orderType = new boolean[indexColumnNames.length];
124         java.util.Arrays.fill(orderType,true);
125     }
126
127
128     /**
129      * Return Name of Columns on which index is maintained
130      * @return Name of Columns on which index is maintained
131      * @throws DException
132      */

133
134     public String JavaDoc[] getColumns() throws DException {
135         return indexColumnNames;
136     }
137
138     /**
139      * Return Name of Index
140      * @return Name of Index
141      * @throws DException
142      */

143
144     public String JavaDoc getIndexName() throws DException{
145         return indexName;
146     }
147
148     /**
149      * Return Order of Indexes on Columns
150      * @return Order of Indexes on Columns
151      * @throws DException
152      */

153
154     public boolean[] getOrderOfColumns() throws DException {
155         return orderType;
156     }
157
158     /**
159      * Returns whether Index is on all Fixed Size Columns or not
160      * @return whether Index is on all Fixed Size Columns or not
161      * @throws DException
162      */

163
164     public boolean isVariableColumn() throws DException {
165         return isVariable;
166     }
167
168
169     public QualifiedIdentifier getQualifiedIdentifier() throws DException {
170         return new QualifiedIdentifier(null,null,indexName);
171     }
172
173
174     public QualifiedIdentifier getIndexTableName() throws DException {
175         return indexTableName;
176     }
177
178     public int getSize() throws DException {
179         return numberOfRecords;
180     }
181
182
183
184
185     public Object JavaDoc[][] getColumnInformation () throws DException{
186         ArrayList JavaDoc indexStructure = new ArrayList JavaDoc();
187         for(int i =0 ; i < indexColumnNames.length; i++){
188             indexStructure.add(new Object JavaDoc[]{indexColumnNames[i],Utility.getBooleanValue(orderType[i]),new Integer JavaDoc(indexColumnIndexes[i]),new Integer JavaDoc(i)});
189         }
190         return (Object JavaDoc [][])indexStructure.toArray(new Object JavaDoc[0][]);
191     }
192
193     public void setControlClusterAddress(int rootClusterAddress0) throws DException {
194         rootClusterAddress = rootClusterAddress0;
195         if(rootClusterAddress == 0)
196             Thread.dumpStack();
197     }
198
199
200     public int[] getColumnIndexes() throws DException {
201         return indexColumnIndexes;
202     }
203
204     public void refresh() {
205     }
206
207     public boolean isDefault(){
208         return isDefault;
209     }
210
211
212     public String JavaDoc toString() {
213         return "INDEXNAME :: ["+indexName+"] COLUMNS :: "+java.util.Arrays.asList(indexColumnNames)+" isDefault :: ["+isDefault+"]";
214     }
215
216     public void update() throws DException {
217         throw new UnsupportedOperationException JavaDoc("method does not supported ");
218     }
219
220     public void setIndexTableName(QualifiedIdentifier name) {
221         indexTableName = name;
222     }
223
224     public void updateIndexs(_TableCharacteristics tc) throws DException{
225         for(int i =0 ; i < indexColumnNames.length ; i++)
226             indexColumnIndexes[i] = tc.getIndexForColumnName(indexColumnNames[i]);
227         rootClusterAddress = 0;
228         rootClusterSize = 0;
229         numberOfRecords = 0;
230     }
231
232     public int getControlClusterAddress() throws DException{
233         return rootClusterAddress;
234     }
235     public boolean setIsDefault(boolean flag){
236         return isDefault = flag;
237     }
238
239   public boolean isSystemGenerated() {
240     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
241     throw new java.lang.UnsupportedOperationException JavaDoc("Method isSystemGenerated() not yet implemented.");
242   }
243   public boolean isUpdated() {
244     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
245     throw new java.lang.UnsupportedOperationException JavaDoc("Method isUpdated() not yet implemented.");
246   }
247   public void setColumnNames(String JavaDoc[] parm1) throws com.daffodilwoods.database.resource.DException {
248     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
249     throw new java.lang.UnsupportedOperationException JavaDoc("Method setColumnNames() not yet implemented.");
250   }
251   public void setColumnIndexes(int[] parm1) throws com.daffodilwoods.database.resource.DException {
252     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
253     throw new java.lang.UnsupportedOperationException JavaDoc("Method setColumnIndexes() not yet implemented.");
254   }
255   public void setOrderOfColumns(boolean[] parm1) throws com.daffodilwoods.database.resource.DException {
256     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
257     throw new java.lang.UnsupportedOperationException JavaDoc("Method setOrderOfColumns() not yet implemented.");
258   }
259   public void setIsUpdatedFlag(boolean parm1) throws com.daffodilwoods.database.resource.DException {
260     /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.indexsystem._IndexInformation method*/
261     throw new java.lang.UnsupportedOperationException JavaDoc("Method setIsUpdatedFlag() not yet implemented.");
262   }
263
264 }
265
Popular Tags