KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.daffodilwoods.daffodildb.server.datasystem.indexsystem;
2
3 import java.text.*;
4 import java.util.*;
5 import com.daffodilwoods.daffodildb.server.datadictionarysystem.*;
6 import com.daffodilwoods.daffodildb.server.datasystem.btree.*;
7 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*;
8 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.Utility;
9 import com.daffodilwoods.daffodildb.server.datasystem.persistentsystem.*;
10 import com.daffodilwoods.daffodildb.server.datasystem.utility.*;
11 import com.daffodilwoods.daffodildb.utils.*;
12 import com.daffodilwoods.daffodildb.utils.byteconverter.*;
13 import com.daffodilwoods.daffodildb.utils.comparator.*;
14 import com.daffodilwoods.daffodildb.utils.field.*;
15 import com.daffodilwoods.database.general.*;
16 import com.daffodilwoods.database.resource.*;
17 import com.daffodilwoods.database.utility.*;
18 import com.daffodilwoods.fulltext.common.FullTextFactory;
19 import com.daffodilwoods.fulltext.common._FullTextDML;
20 import com.daffodilwoods.fulltext.common._FullTextAdapter;
21 import com.daffodilwoods.daffodildb.server.sql99.fulltext.dml.DaffodilFullTextAdapter;
22 import com.daffodilwoods.daffodildb.server.sql99.fulltext.dml.DaffodilFullTextIndexInformation;
23 import com.daffodilwoods.daffodildb.server.sql99.fulltext.dml._FullTextIndexInformation;
24 import com.daffodilwoods.daffodildb.server.sql99.fulltext.database.DaffodilFullTextIndexCreator;
25 import com.daffodilwoods.fulltext.common._FullTextGenerator;
26 import com.daffodilwoods.daffodildb.server.sql99.fulltext.dml.DaffodilFullTextGenerator;
27 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator;
28 import com.daffodilwoods.daffodildb.server.datasystem.persistentsystem.versioninfo.VersionHandler;
29
30 /**
31  *
32  * <p>Title: Index Database</p>
33  * <p>Description : Maintains All Table Level opeartions like create table,drop table etc.Except the table level operations it manages
34  * all the operations performed on indexes on a table.It can create a new index,drop an index etc.
35  *
36  * For storing the index informations it has two system tables
37  * 1. DATABASE INDEX INFO
38  * 2. DATABASE INDEX COLUMNS
39  *
40  * Tables mentioned above have all the information regarding the indexes created in a particular database like name of index,columns on
41  * which index is created,order of columns etc.
42  * </p>
43  */

44
45 public class IndexDatabase implements _IndexDatabase {
46
47    /**
48     * Underlying database
49     */

50
51    protected _Database database;
52
53    /**
54     * Maintains list of all tables which are Currently in use having mapping with table name
55     */

56
57    protected HashMap indexTablesMap;
58
59    /**
60     * IndexInfo SystemTable to Maintain all Information of Indexes
61     */

62
63    private _Table indexInfoTable;
64
65    /**
66     * Index Columns SystemTable to maintain all Information of columns
67     * on which index is maintained
68     */

69    private _Table indexColumnsTable;
70
71    /**
72     * Index On Index Info Table.Used for fast seeking.
73     */

74
75    protected _Index indexOnIndexInfo;
76
77    /**
78     * Index On Index Columns Table.Used for fast seeking.
79     */

80
81    protected _Index indexOnIndexColumns;
82
83    /**
84     * System table FULLTEXTINFO.
85     */

86    private _Table fullTextInfoTable;
87
88    /**
89     * Index On FullTextInfoTable .Used for fast seeking.
90     */

91
92    protected _Index indexOnFullTextInfoTable;
93
94    /**
95     * System table FULLTEXTCOLMNINFO.
96     */

97
98    private _Table fullTextColumnInfoTable;
99
100    /**
101     * Index On FullTextColumnInfoTable .Used for fast seeking.
102     */

103
104    protected _Index indexOnFullTextColumnInfoTable;
105
106    /**
107     * Used for comparing two Qualified Identifiers
108     */

109
110    private ByteComparator nameComparator;
111
112    private SuperComparator comperatorForDML;
113    protected VersionHandler versionHandler;
114
115
116    public IndexDatabase(_Database database0, boolean isReadOnlyMode) throws DException {
117       database = database0;
118       indexTablesMap = new HashMap();
119       CTusjohJoTfotjujwfDpnqbsbups stringComparator = new CTusjohJoTfotjujwfDpnqbsbups();
120       nameComparator = new ByteComparator(new boolean[] {true, true, true, true}
121                                           , new SuperComparator[] {stringComparator, stringComparator, stringComparator, stringComparator});
122       versionHandler = ( (PersistentDatabase) database).getVersionHandler();
123       ArrayList list = new ArrayList();
124       list.add(SystemTables.DATABASEINDEXINFO);
125       list.add(SystemTables.DATABASEINDEXCOLUMNS);
126
127       _DatabaseUser user = ( (PersistentDatabase) database).getDatabaseUser(list);
128       try {
129          initialize(user);
130          if (!isReadOnlyMode)
131             user.writeToFile();
132       } catch (Exception JavaDoc ade) {
133          ade.printStackTrace();
134          user.releaseCluster();
135       }
136
137    }
138
139    public synchronized void createTable(QualifiedIdentifier tableName, Object JavaDoc columnInfo) throws DException {
140       database.createTable(tableName, columnInfo);
141    }
142
143    /**
144     * To create a full text index on a single column or multiple column.
145     * In this method we create a new full text dml object and inserts data of the
146     * columns into it.Now update the fullTextDML[] of the table by adding a new entry
147     * into it and also updates the system table i.e. FULLTEXTINFO. and FULLTEXTCOLUMNINFO
148     * in the FULLTEXTINFO table we have information of tableName,indexName,tokenTableName and LocationTableName
149     * in the FULLTEXTCOLUMNINFO table we store information of all the columnNames which are included in the full
150     * text index along with indexName and TableName having multiple entries corresponding to the tableName & indexName
151     * @param tableName on which the full text searching is to be provided.
152     * @param indexName name of the index.
153     * @param columnName name of the columns on which the index is to be created.
154     */

155    public synchronized void createFullTextIndex(QualifiedIdentifier tableName, String JavaDoc indexName, String JavaDoc[] columnName) throws DException {
156       _IndexTableList indexTable = (_IndexTableList) getTable(tableName);
157       ArrayList list = new ArrayList();
158       list.add(tableName);
159       list.add(SystemTables.DATABASEFULLTEXTINFO);
160       list.add(SystemTables.DATABASEFULLTEXTCOLUMNINFO);
161       _DatabaseUser user = null;
162       FullTextFactory fullTextFactory = new FullTextFactory();
163       DaffodilFullTextIndexCreator dftxc = new DaffodilFullTextIndexCreator(this);
164       _FullTextGenerator ftg = new DaffodilFullTextGenerator(dftxc);
165       Object JavaDoc tokenLocationTableName[] = (Object JavaDoc[]) fullTextFactory.getFullTextIndexCreator(ftg).createFullTextIndex(tableName, indexName, columnName);
166       try {
167          DatabaseUserTableIterator fullTextInfoIterator = (
168              DatabaseUserTableIterator) ( (
169              _DataTable) getTable(SystemTables.DATABASEFULLTEXTINFO)).getIterator();
170          DatabaseUserTableIterator fullTextColumnInfoIterator = (
171              DatabaseUserTableIterator) ( (
172              _DataTable) getTable(SystemTables.DATABASEFULLTEXTCOLUMNINFO)).getIterator();
173          BufferRange[] bytes = Utility.getBufferRangeForTableName(tableName);
174          BufferRange[] values = new BufferRange[] {
175              (bytes[0]), (bytes[1]), (bytes[2]),
176              (new BufferRange(indexName.getBytes())),
177              (new BufferRange( ( ( (String JavaDoc) tokenLocationTableName[0])).getBytes())),
178              (new BufferRange( ( (String JavaDoc) tokenLocationTableName[1]).getBytes()))};
179          user = database.getDatabaseUser(list);
180          fullTextInfoIterator.insert(user, values);
181          indexOnFullTextInfoTable.insert(user, new BufferRange[] {values[0], values[1], values[2], values[3]}
182                                          , fullTextInfoIterator.getKey());
183          int length = columnName.length;
184          for (int i = 0; i < length; i++) {
185             values = new BufferRange[] { (bytes[0]), (bytes[1]), (bytes[2]),
186                 (new BufferRange(indexName.getBytes())),
187                 (new BufferRange(columnName[i].getBytes()))};
188             fullTextColumnInfoIterator.insert(user, values);
189             indexOnFullTextColumnInfoTable.insert(user, new BufferRange[] {values[0], values[1], values[2], values[3], values[4]}
190                                                   , fullTextColumnInfoIterator.getKey());
191          }
192          QualifiedIdentifier[] tokenLocatinTableName = new QualifiedIdentifier[2];
193          tokenLocatinTableName[0] = new QualifiedIdentifier(new String JavaDoc(bytes[0].getBytes()),
194              new String JavaDoc(bytes[1].getBytes()),
195              (String JavaDoc) tokenLocationTableName[0]);
196          tokenLocatinTableName[1] = new QualifiedIdentifier(new String JavaDoc(bytes[0].getBytes()),
197              new String JavaDoc(bytes[1].getBytes()),
198              (String JavaDoc) tokenLocationTableName[1]);
199          _DataTable table = (_DataTable) database.getTable(tableName);
200          int indexes[] = new int[length];
201          for (int i = 0; i < length; i++)
202             indexes[i] = table.getTableCharacteristics().getIndexForColumnName(columnName[i]);
203          _FullTextIndexInformation daffodilFullTextIndexInformation =
204              new DaffodilFullTextIndexInformation(tableName, tokenLocatinTableName[0],
205                                                   tokenLocatinTableName[1], indexName, columnName, indexes);
206          _FullTextDML fullTextDML = getFullTextDML(tokenLocatinTableName, fullTextFactory, indexes);
207          insertDataIntoDMLObject(user, indexes, (_IndexTable) indexTable, fullTextDML);
208          setFullTextDMLInIndexTable(fullTextDML, indexTable, daffodilFullTextIndexInformation);
209          user.writeToFile();
210
211       } finally {
212          user.releaseCluster();
213       }
214    }
215
216    /**
217     * Dropping a full text DML object by removing it's entry from
218     * System table FULLTEXTINFO.
219     * firstly we seek into the index name and table name into the
220     * btree created on the system table. If we found any matches
221     * than moves the iterator of the system table on the key geted by the seek
222     * method and than getting the token table name, location table name
223     * dropping the indexes of both tables and than drop the both tables
224     * than removing its entry from the system table.
225     * Also remove the entry from the indexOnFullTextInfo i.e. btree created
226     * on system table FULLTEXTINFO.
227     * and remove the fullTextDML object from the object array
228     * -> special handling for the case if user drop the table than all full text
229     * indexes to be droped so first we check the table in map if exists than drop
230     * the fulltext index if we don't get it from map than we load it and after
231     * dropping the index we unload the table from map.
232     * @param tableName of which fullTextIndex is to be dropped.
233     * @param indexName which is to be deleted.
234     * @throws java.lang.Exception
235     */

236    public synchronized void dropFullTextIndex(QualifiedIdentifier tableName,
237                                               String JavaDoc indexName) throws
238        DException {
239       if (!getVersionHandler().isFullTextSupported())
240          throw new DException("DSE5590", new Object JavaDoc[] {"dropFullTextIndex"});
241       BufferRange[] bytes = Utility.getBufferRangeForTableName(tableName);
242       _TableIterator fullTextInfoTableIterator = ( (_DataTable) fullTextInfoTable).
243           getIterator();
244       ArrayList list = new ArrayList();
245       list.add(SystemTables.DATABASEFULLTEXTINFO);
246       _DatabaseUser user = null;
247       _IndexTable indexTable = (_IndexTable) indexTablesMap.get(tableName);
248       if (indexTable == null) {
249          indexTable = (_IndexTable) getTable(tableName);
250          removeFullTextDMLFromIndexTable( (_IndexTableList) indexTable, indexName);
251          indexTablesMap.remove(tableName);
252          database.removeTable(tableName);
253       } else
254          removeFullTextDMLFromIndexTable( (_IndexTableList) indexTable,
255                                          indexName);
256
257       byte[] bytesOfIndexName = indexName.getBytes();
258       try {
259          seek(indexOnFullTextInfoTable, bytes, indexName.getBytes());
260          throw new DException("DSE482", new Object JavaDoc[] {new String JavaDoc(bytesOfIndexName)});
261       } catch (DException de1) {
262          if (!de1.getDseCode().equalsIgnoreCase("DSE2014"))
263             throw de1;
264          _IndexKey btreeKey = (_IndexKey) de1.getParameters()[0];
265          fullTextInfoTableIterator.move(btreeKey.getValue());
266          BufferRange[] keyToSeek = new BufferRange[] {
267              bytes[0], bytes[1], bytes[2], new BufferRange(bytesOfIndexName)};
268          BufferRange[] columnValues = (BufferRange[]) fullTextInfoTableIterator.
269              getColumnValues(new int[] {0, 1, 2, 3, 4, 5});
270          try {
271             if (nameComparator.compare(new BufferRange[] {
272                                        columnValues[0],
273                                        columnValues[1],
274                                        columnValues[2],
275                                        columnValues[3]}
276                                        , keyToSeek) == 0) {
277                dropLocationAndTokenTableWithIndexes(bytes, columnValues);
278
279                list.add(SystemTables.DATABASEFULLTEXTINFO);
280                user = database.getDatabaseUser(list);
281                Object JavaDoc btreeValue = fullTextInfoTableIterator.getKey();
282                indexOnFullTextInfoTable.delete(user, btreeKey.getKey(),
283                                                btreeValue);
284                ( (DatabaseUserTableIterator) fullTextInfoTableIterator).
285                    delete(user);
286                user.writeToFile();
287                removeInformationFromDATABASEFULLTEXTCOLUMNINFO(tableName, indexName);
288             }
289          } finally {
290             user.releaseCluster();
291          }
292
293       }
294    }
295
296    /**
297     * To get the full text dml object
298     * @param tokenLocationTable
299     * @param fullTextFactory
300     * @param columnIndex
301     * @return
302     */

303
304    public _FullTextDML getFullTextDML(QualifiedIdentifier[] tokenLocationTable, FullTextFactory fullTextFactory, int[] columnIndex) throws DException {
305       _IndexTable tokenIndexTable = (_IndexTable) getTable(tokenLocationTable[0]);
306       tokenIndexTable.setDuplicateKeysAllowedInBtrees();
307       _IndexTable locationIndexTable = (_IndexTable) getTable(tokenLocationTable[1]);
308       locationIndexTable.setDuplicateKeysAllowedInBtrees();
309       _FullTextAdapter fullTextAdapter = new DaffodilFullTextAdapter(
310           tokenIndexTable, locationIndexTable, false, columnIndex);
311       return fullTextFactory.getFullTextDML(fullTextAdapter);
312    }
313
314    /**
315     * It is used to get all the full text DML objects of a table.It is called through
316     * getTable.
317     * In this method firstly we get a comperator fulltextcomperator.
318     * Now seeking the tableName into the index created on the FULLTEXTINFO and
319     * getting the key now moves the iterator on the key which is taken on
320     * FULLTEXTINFO table and getting the row .Now getting the full text dml object
321     * corresponding the row entries and creating a full text index creator object
322     * now setting into the fullTextDML object and adding fullTextDML object into the array list
323     * now when all fullTextDML objects corresponding to the table geted then
324     * check the size of the arraylist and if it is 0 then return null
325     * Otherewise array of the objects.
326     * @param tableName name of the table
327     * @param tab persistent table
328     * @return fulltextDML objects array or null .
329     * @throws DException
330     */

331
332    private _FullTextDML[] getFullTextDml(QualifiedIdentifier tableName, _Table tab) throws DException {
333       if (!versionHandler.isFullTextSupported())
334          return null;
335       fullTextInfoTable = getTable(SystemTables.DATABASEFULLTEXTINFO);
336       _TableIterator fullTextInfoTableIterator = ( (_DataTable) fullTextInfoTable).getIterator();
337       boolean[] orderColumns = new boolean[] {true, true, true};
338       comperatorForDML = getComparatorForDML(orderColumns);
339       QualifiedIdentifier tokenLocationTableName[] = new QualifiedIdentifier[2];
340       _FullTextDML[] fullTextDML = null;
341       BufferRange nameOfTable[] = Utility.getBufferRangeForTableName(tableName);
342       _IndexKey key = (_IndexKey) indexOnFullTextInfoTable.seekFromTopRelative(null, nameOfTable);
343       ArrayList fullTextDMLlist = new ArrayList();
344       orderColumns = new boolean[] {true, true, true};
345       do {
346          int com = -1;
347          if (key == null)
348             break;
349          BufferRange keyBufferRange[] = (BufferRange[]) key.getKey();
350          com = comperatorForDML.compare(new BufferRange[] {keyBufferRange[0], keyBufferRange[1],
351                                         keyBufferRange[2]}
352                                         , nameOfTable);
353          if (com != 0)
354             break;
355          fullTextInfoTableIterator.move(key.getValue());
356          comperatorForDML = getComparatorForDML(orderColumns);
357          BufferRange bytes[] = (BufferRange[]) fullTextInfoTableIterator.getColumnValues(new int[] {0, 1, 2, 3, 4, 5});
358          tokenLocationTableName[0] = new QualifiedIdentifier(new String JavaDoc(bytes[0].getBytes()),
359              new String JavaDoc(bytes[1].getBytes()), new String JavaDoc(bytes[4].getBytes()));
360          tokenLocationTableName[1] = new QualifiedIdentifier(new String JavaDoc(bytes[0].getBytes()),
361              new String JavaDoc(bytes[1].getBytes()), new String JavaDoc(bytes[5].getBytes()));
362          String JavaDoc indexName = new String JavaDoc(bytes[3].getBytes());
363          String JavaDoc[] columnName = getColumnNamesOfFullTextIndex(nameOfTable, indexName);
364          int[] columnIndexes = getColumnIndexes(columnName, tab);
365          _FullTextDML fullTextDMLObject = getFullTextDML(tokenLocationTableName, new FullTextFactory(), columnIndexes);
366          _FullTextIndexInformation daffodilFullTextIndexInformation = new
367              DaffodilFullTextIndexInformation(tableName, tokenLocationTableName[0], tokenLocationTableName[1],
368                                               new String JavaDoc(bytes[3].getBytes()), columnName, columnIndexes);
369          fullTextDMLObject.setFullTextIndexInformation(daffodilFullTextIndexInformation);
370          fullTextDMLlist.add(fullTextDMLObject);
371       } while (indexOnFullTextInfoTable.next(key));
372
373       fullTextDML = fullTextDMLlist.size() == 0 ? null :
374           (_FullTextDML[]) fullTextDMLlist.toArray(new _FullTextDML[0]);
375       return fullTextDML;
376    }
377
378    /**
379     * Returns either ColumnObjectsTable or BlobClobColumnObjectsTable depending on the type of columns.If table has any blob clob
380     * type of column then it will return BlobClobColumnObjectsTable otherwise ColumnObjectsTable.
381     * also getting the full textDML object created on the table and setting them into the Index table
382     * if the table is not geted from index tables map.
383     * Both of the above classes contains an IndexTable which contains all the btrees in the table.
384     */

385
386    public synchronized _Table getTable(QualifiedIdentifier tableName) throws DException {
387       _Table table = (_Table) indexTablesMap.get(tableName);
388       if (table != null)
389          return table;
390       _Table tab = database.getTable(tableName);
391       _Index[] indexes = getPermanantIndexes(tableName, tab.getTableCharacteristics());
392       IndexTable indexTable = new IndexTable(tableName, indexes);
393       indexTable.setFullTextDML(getFullTextDml(tableName, tab));
394       indexTable.setDatabase(this);
395       TableCharacteristics tc = (TableCharacteristics) tab.getTableCharacteristics();
396       boolean isBlobClobTable = (tc.isBlobClobTable() == 0);
397       LobManager lobManager = isBlobClobTable
398           ? null : new LobManager( (PersistentDatabase) database, tc.getStartAddressesOfBlobColumns());
399       _IndexTable columnObjectTable = null;
400       if (!isBlobClobTable)
401          columnObjectTable = new BlobClobColumnObjectsTable( (_DataTable) tab, tableName, lobManager);
402       else
403          columnObjectTable = new ColumnObjectsTable( (_DataTable) tab, tableName, lobManager);
404       ( (_IndexTableList) columnObjectTable).setTable(indexTable);
405       indexTablesMap.put(tableName, columnObjectTable);
406       return columnObjectTable;
407    }
408
409    public synchronized void dropTable(QualifiedIdentifier tableName) throws DException {
410       database.dropTable(tableName);
411       indexTablesMap.remove(tableName);
412
413    }
414
415    /**
416     * Creates a new Index on table with TableName passed.Stores Information of Index in IndexInfo and
417     * IndexColumns System Tables
418     *
419     * @param tableName : Name of Table
420     * @param indexName : Name of Index
421     * @param indexInformationGetter : IndexInformation Of new Index.
422     */

423
424    public void createPermanantIndex(QualifiedIdentifier tableName, String JavaDoc indexName, _IndexInformation indexInformationGetter, _DatabaseUser user) throws DException {
425       createPermanantIndexes(tableName, updateSystemTables(tableName, indexName, indexInformationGetter, user), user);
426    }
427
428    /**
429     * Called from Server System class
430     */

431
432    public void createPermanantIndexForSystemTable(QualifiedIdentifier tableName, String JavaDoc indexName, _IndexInformation indexInformationGetter) throws DException {
433
434
435       if (indexTablesMap.get(tableName) != null)
436          throw new DException("DSE2034", new Object JavaDoc[] {tableName.toString()});
437       BufferRange[] bytes = Utility.getBufferRangeForTableName(tableName);
438       byte[] bytesOfIndexName = indexName.getBytes();
439       ArrayList list = new ArrayList();
440       list.add(SystemTables.DATABASEINDEXINFO);
441       list.add(SystemTables.DATABASEINDEXCOLUMNS);
442       _DatabaseUser user = ( (PersistentDatabase) database).getDatabaseUser(list);
443       try {
444          addIndexInfoInIndexInfoTable(bytes, bytesOfIndexName, indexInformationGetter, user);
445          addIndexInfoInIndexColumnsTable(bytes, bytesOfIndexName, indexInformationGetter.getColumnInformation(), user);
446          user.writeToFile();
447       } catch (DException de) {
448          user.rollback();
449       } finally {
450          user.releaseCluster();
451       }
452    }
453
454    /**
455     * 1. Removes the information stored in both of the System Tables.
456     * 2. Remove the object of btree from IndexTable.
457     *
458     */

459
460    public void dropPeramanantIndex(QualifiedIdentifier tableName, String JavaDoc indexName, _DatabaseUser user) throws DException {
461       BufferRange[] bytes = Utility.getBufferRangeForTableName(tableName);
462       byte[] bb = indexName.getBytes();
463       BufferRange bytesOfIndexName = new BufferRange(bb);
464       BufferRange[] btreeKey = new BufferRange[] {bytes[0], bytes[1], bytes[2], bytesOfIndexName};
465       removeIndexInforamtionFromIndexInfoTabe(user, btreeKey, bytes, bb);
466       removeIndexInformationFromIndexColumnsTable(btreeKey, user, bytes, bb);
467
468       Object JavaDoc ob = indexTablesMap.get(tableName);
469       if (ob != null)
470          removeBtreeFromIndexTable( (_IndexTableList) ob, indexName, user);
471    }
472
473    /**
474     * It requires column indexes of those columns on which index will maintain.
475     */

476
477    public static int[] getAppropriateTypes(int[] indexes, int[] types) {
478       int[] typs = new int[indexes.length];
479       for (int i = 0; i < indexes.length; i++) {
480          typs[i] = types[indexes[i]];
481       }
482       return typs;
483    }
484
485    /**
486     * Returns information of all indexes on table after reading the information from DatabaseIndexInfo and DatabaseIndexColumns System tables
487     *
488     * @param tableName name of table whose indexes are required
489     */

490
491    private _IndexInformation[] getIndexInformations(QualifiedIdentifier tableName, _TableCharacteristics tc) throws DException {
492
493       BufferRange[] bytes = Utility.getBufferRangeForTableName(tableName);
494       _TableIterator indexInfoTableIterator = ( (_DataTable) indexInfoTable).
495           getIterator();
496       ArrayList iinfList = new ArrayList();
497       try {
498          seek(indexOnIndexInfo, bytes, new byte[0]);
499       } catch (DException de) {
500          if (!de.getDseCode().equalsIgnoreCase("DSE2014"))
501             throw de;
502          _IndexKey btreeKey = (_IndexKey) de.getParameters()[0];
503          do {
504             indexInfoTableIterator.move(btreeKey.getValue());
505             BufferRange[] values = (BufferRange[]) indexInfoTableIterator.
506                 getColumnValues();
507             if (CCzufDpowfsufs.getInt(values[4].getBytes()).intValue() == 0)
508                Thread.dumpStack();
509             byte[] bytesOfIndexName = values[3].getBytes();
510             ArrayList columnValueslist = getColumnInformationOfIndexes(bytes,
511                 bytesOfIndexName);
512             Object JavaDoc[][] indexColumnsObject = new Object JavaDoc[columnValueslist.size()][];
513
514             for (int i = 0; i < columnValueslist.size(); i++)
515                indexColumnsObject[i] = (Object JavaDoc[]) columnValueslist.get(i);
516
517             IndexInformations indexInformations = new IndexInformations(tableName,
518                 new String JavaDoc(bytesOfIndexName),
519                 CCzufDpowfsufs.getInt(values[4].getBytes()).hashCode(),
520                 CCzufDpowfsufs.getBoolean(values[5].getBytes()).booleanValue(),
521                 indexColumnsObject, versionHandler);
522             iinfList.add(indexInformations);
523             btreeKey = (_IndexKey) indexOnIndexInfo.seekAbsolute(btreeKey, bytes);
524          } while (btreeKey != null);
525       }
526       return (_IndexInformation[]) iinfList.toArray(new _IndexInformation[0]);
527    }
528
529    protected _Index[] getPermanantIndexes(QualifiedIdentifier tableName, _TableCharacteristics tc) throws DException {
530       _IndexInformation[] indexInformations = getIndexInformations(tableName, tc);
531       int length = indexInformations == null ? 0 : indexInformations.length;
532       if (length == 0) {
533          return null;
534       }
535       _Index[] btrees = new _Index[length];
536       int size = 0;
537       for (int i = 0; i < length; i++) {
538          btrees[i] = getPermanantIndex(tableName, indexInformations[i]);
539          btrees[i].setDuplicateAllowed(false);
540          if (indexInformations[i].isDefault())
541             size = btrees[i].getSize();
542       }
543       for (int i = 0; i < length; i++) {
544          btrees[i].setSize(size);
545       }
546       return btrees;
547    }
548
549    public void dropTemporaryIndex(QualifiedIdentifier tableName, String JavaDoc indexName) throws DException {
550       _IndexTable indexTable = null;
551       try {
552          indexTable = (_IndexTable) getTable(tableName);
553       } catch (DException ex) {
554          return;
555       }
556       removeBtreeFromIndexTable( (_IndexTableList) indexTable, indexName, null);
557    }
558
559
560    public _DatabaseUser getDatabaseUser() throws DException {
561       return new IndexDatabaseUser(database.getDatabaseUser(), this);
562    }
563
564    /**
565     * remove table from tablesMap
566     */

567
568    public void removeTable(QualifiedIdentifier tableName) throws DException {
569       database.removeTable(tableName);
570       indexTablesMap.remove(tableName);
571    }
572
573    public _Table getSystemTable(QualifiedIdentifier parm1) throws com.daffodilwoods.database.resource.DException {
574       /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.interfaces._Database method*/
575       throw new java.lang.UnsupportedOperationException JavaDoc("Method getSystemTable() not yet implemented.");
576    }
577
578    /**
579     * 1. Insert all the records in newly created index.
580     * 2. Add new Btree in IndexTable
581     *
582     */

583
584    private void createPermanantIndexes(QualifiedIdentifier tableName, IndexInformations iinf, _DatabaseUser user) throws DException {
585       _Table sourceTable = database.getTable(tableName);
586       _TableIterator iterator = ( (_DataTable) sourceTable).getIterator();
587       _Index btree = getPermanantIndex(tableName, iinf);
588       btree.setDuplicateAllowed(false);
589       insertRecordsInBTree(iterator, btree, iinf.getColumns(), user);
590       updateBTreesInIndexTable(tableName, btree);
591    }
592
593    public _Table getTableInfo() throws DException {
594       return ( (PersistentDatabase) database).getTableInfo();
595    }
596
597    /**
598     * 1. Create a temporary table with new definition.
599     * 2. Insert all the records in Temporary Table.
600     * 3. Drop the original table.
601     * 4. Rename the temp table by it's ooriginal name.
602     *
603     * @param tableName : Name of Table to be altered
604     * @param columnInfo : New Column Info
605     * @param alterRecord : It converts the old record according to the new definition.
606     * @param defaultValue : default value in case of add new column
607     * @throws DException If Table doesn't exist.
608     */

609
610    public synchronized void alterTableold(QualifiedIdentifier tableName, Object JavaDoc columnInfo, _AlterRecord alterRecord, Object JavaDoc defaultValue, _DatabaseUser user) throws DException {
611       _IndexTableList table = (_IndexTableList) getTable(tableName);
612       DatabaseUserTableIterator iterator = (DatabaseUserTableIterator) ( (_DataTable) database.getTable(tableName)).getIterator();
613       QualifiedIdentifier tempTableName = new QualifiedIdentifier(tableName.catalog, tableName.schema, tableName.name + "temp");
614       createTable(tempTableName, columnInfo);
615       _Index[] indexes = table.getIndexes();
616       _TableCharacteristics newTableCharacteristics = database.getTable(tempTableName).getTableCharacteristics();
617       updateIndexInformations(tempTableName, tableName, newTableCharacteristics, indexes, user);
618       _IndexTable tempTable = (_IndexTable) getTable(tempTableName);
619       IndexTableIterator tempTableIterator = (IndexTableIterator) ( (IteratorWrapper) tempTable.getIterator(0)).getIndexIterator();
620       _TableCharacteristics oldTableCharacteristics = table.getTableCharacteristics();
621       ArrayList list = new ArrayList();
622       list.add(tempTableName);
623       _DatabaseUser tableUser = database.getDatabaseUser(list);
624       try {
625          insertRecordsInAlteredTable(iterator, oldTableCharacteristics,
626                                      tempTableIterator, alterRecord, defaultValue,
627                                      tableUser);
628          tableUser.writeToFile();
629       } catch (DException de) {
630          tableUser.writeToFile();
631       }
632       removeTable(tableName);
633       dropTable(tableName);
634       removeTable(tempTableName);
635       renameTable(tempTableName, tableName, user);
636    }
637
638    public synchronized void alterTable(QualifiedIdentifier tableName, Object JavaDoc columnInfo, _AlterRecord alterRecord, Object JavaDoc defaultValue, _DatabaseUser user) throws DException {
639       _IndexTableList table = (_IndexTableList) getTable(tableName);
640       IndexTableIterator iterator = (IndexTableIterator) ( (IteratorWrapper) ( (_IndexTable) table).getDefaultIterator()).getIndexIterator();
641       QualifiedIdentifier tempTableName = new QualifiedIdentifier(tableName.catalog, tableName.schema, tableName.name + "temp");
642       createTable(tempTableName, columnInfo);
643       _Index[] indexes = table.getIndexes();
644       _TableCharacteristics newTableCharacteristics = database.getTable(tempTableName).getTableCharacteristics();
645       updateIndexInformations(tempTableName, tableName, newTableCharacteristics, indexes, user);
646       _IndexTable tempTable = (_IndexTable) getTable(tempTableName);
647       IndexTableIterator tempTableIterator = (IndexTableIterator) ( (IteratorWrapper) tempTable.getIterator(0)).getIndexIterator();
648       _TableCharacteristics oldTableCharacteristics = table.getTableCharacteristics();
649       ArrayList list = new ArrayList();
650       list.add(tempTableName);
651       _DatabaseUser tableUser = database.getDatabaseUser(list);
652       try {
653          insertRecordsInAlteredTable(iterator, oldTableCharacteristics,
654                                      tempTableIterator, alterRecord, defaultValue,
655                                      tableUser);
656          tableUser.writeToFile();
657       } catch (DException de) {
658          tableUser.writeToFile();
659       }
660       removeTable(tableName);
661       dropTable(tableName);
662       removeTable(tempTableName);
663       renameTable(tempTableName, tableName, user);
664    }
665
666    /**
667     * DATABASEINDEXINFO STRUCTURE
668     * {"table_catalog" (0), "table_schema" (1),"table_name" (2),"IndexName" (3),
669     * "ControlClusterAddress" (4),"FixedVariable" (5)}
670     * DATABASEINDEXCOLUMNS STRUCTURE
671     * {"table_catalog" (0),"table_schema" (1),"table_name" (2),"IndexName" (3),
672     * "column_name" (4),"OrderType" (5),"ColumnIndex" (6),"ordinal_position" (7)}
673     * For all the btrees on the altered table we first seek the old table in the
674     * indexOnIndexInfo btree and if its found we update the record in indexInfoTable
675     * and also update indexOnIndexInfo with new values
676     * Then we update IndexColumnsTable by calling private method updateIndexColumnsTable()
677     * @param tempTableName New table's name
678     * @param tableName Name of Table to be altered
679     * @param newTableCharacteristics Altered table characteristics
680     * @throws DException
681     */

682
683    private void updateIndexInformations(QualifiedIdentifier tempTableName, QualifiedIdentifier tableName, _TableCharacteristics newTableCharacteristics, _Index[] indexes, _DatabaseUser user) throws DException {
684       _TableIterator indexInfoTableIterator = ( (_DataTable) indexInfoTable).getIterator();
685       BufferRange[] bytes = Utility.getBufferRangeForTableName(tableName);
686       for (int i = 0, len = indexes.length; i < len; i++) {
687          _IndexInformation iinf = indexes[i].getIndexInformation();
688          ( (IndexInformations) iinf).updateIndexs(newTableCharacteristics);
689          byte[] bytesOfIndexName = iinf.getIndexName().getBytes();
690          BufferRange[] bytesOfTempTable = Utility.getBufferRangeForTableName(tempTableName);
691          BufferRange[] keyWithOldTable = new BufferRange[] {bytes[0], bytes[1], bytes[2], new BufferRange(bytesOfIndexName)};
692          BufferRange[] keyWithTempTable = new BufferRange[] {bytesOfTempTable[0], bytesOfTempTable[1], bytesOfTempTable[2], new BufferRange(bytesOfIndexName)};
693          try {
694             seek(indexOnIndexInfo, bytes, bytesOfIndexName);
695          } catch (DException de) {
696             if (!de.getDseCode().equalsIgnoreCase("DSE2014"))
697                throw de;
698             _IndexKey btreeKey = (_IndexKey) de.getParameters()[0];
699             indexInfoTableIterator.move(btreeKey.getValue());
700             int controlClusterAddress = ( (_ClusterProvider) database).getControlCluster(user).getStartAddress();
701             ( (_UserTableOperations) indexInfoTableIterator).update(user, new int[] {0, 1, 2, 4}
702                 , new BufferRange[] {bytesOfTempTable[0], bytesOfTempTable[1], bytesOfTempTable[2], new BufferRange(CCzufDpowfsufs.getBytes(controlClusterAddress))});
703             indexOnIndexInfo.update(user, keyWithOldTable, keyWithTempTable, btreeKey.getValue(), indexInfoTableIterator.getKey());
704          }
705          updateIndexColumnsTable(bytes, bytesOfIndexName, keyWithOldTable, user, keyWithTempTable, bytesOfTempTable, true, iinf.getColumnIndexes());
706       }
707    }
708
709    private void evaluateFromBottom(_Index btree, BufferRange[] bytesOfTableName, byte[] indexNameBytes) throws DException {
710       BufferRange[] indexKey = indexNameBytes.length == 0 ? bytesOfTableName
711           : new BufferRange[] {bytesOfTableName[0], bytesOfTableName[1], bytesOfTableName[2], new BufferRange(indexNameBytes)};
712       Object JavaDoc obj = btree.seekFromBottomRelative(null, indexKey);
713       if (obj != null)
714          throw new DException("DSE2014", new Object JavaDoc[] {obj});
715    }
716
717    public synchronized void renameTable(QualifiedIdentifier oldTableName, QualifiedIdentifier newTableName, _DatabaseUser user) throws DException {
718       _TableIterator indexInfoTableIterator = ( (_DataTable) indexInfoTable).
719           getIterator();
720       BufferRange[] bytes = Utility.getBufferRangeForTableName(oldTableName);
721       if (indexInfoTableIterator.first()) {
722          try {
723             seek(indexOnIndexInfo, bytes, new byte[0]);
724          } catch (DException de) {
725             _IndexKey key = (_IndexKey) de.getParameters()[0];
726             do {
727                Object JavaDoc indexInfoTableKey = key.getValue();
728                indexInfoTableIterator.move(indexInfoTableKey);
729                byte[] bytesOfIndexName = ( (BufferRange) indexInfoTableIterator.
730                                           getColumnValues(3)).getBytes();
731                BufferRange[] bytesOfNewTable = Utility.
732                    getBufferRangeForTableName(newTableName);
733                BufferRange[] keyWithOldTable = new BufferRange[] {
734                    bytes[0], bytes[1], bytes[2],
735                    new BufferRange(bytesOfIndexName)};
736                BufferRange[] keyWithNewTable = new BufferRange[] {
737                    bytesOfNewTable[0], bytesOfNewTable[1], bytesOfNewTable[2],
738                    new BufferRange(bytesOfIndexName)};
739                ( (_UserTableOperations) indexInfoTableIterator).update(user,
740                    new int[] {0, 1, 2}
741                    , new BufferRange[] {bytesOfNewTable[0], bytesOfNewTable[1],
742                    bytesOfNewTable[2]});
743                Object JavaDoc newValue = indexInfoTableIterator.getKey();
744                key = (_IndexKey) indexOnIndexInfo.seekAbsolute(key, bytes);
745                indexOnIndexInfo.update(user, keyWithOldTable, keyWithNewTable,
746                                        indexInfoTableKey, newValue);
747                updateIndexColumnsTable(bytes, bytesOfIndexName, keyWithOldTable,
748                                        user, keyWithNewTable, bytesOfNewTable, false, null);
749
750             } while (key != null);
751
752          }
753
754          if (database instanceof PersistentDatabase) // check this method
755
( (PersistentDatabase) database).renameTable(oldTableName,
756                 newTableName);
757       }
758    }
759
760    private int[][] getMapping(int columnCount, int[] indexes) throws DException {
761       int[][] mapping = new int[columnCount][2];
762       for (int j = 0; j < columnCount; j++) {
763          mapping[j][0] = j;
764          mapping[j][1] = -1;
765       }
766       for (int j = 0, len = indexes.length; j < len; j++)
767          mapping[indexes[j]][1] = j;
768       return mapping;
769    }
770
771    protected _Index getPermanantIndex(QualifiedIdentifier tableName, _IndexInformation iinf) throws DException {
772       int[] columnIndexes = iinf.getColumnIndexes();
773       int controlPageAddress = iinf.getControlClusterAddress();
774       if (controlPageAddress == 0)
775          Thread.dumpStack();
776       _TableCharacteristics tableCharacteristics = database.getTable(tableName).getTableCharacteristics();
777       SuperComparator cmp = getComparator(columnIndexes.length == 1, iinf.getOrderOfColumns(), tableCharacteristics.getColumnTypes(columnIndexes), tableCharacteristics.getCollator());
778       _BTreeCharacteristics btreeCharacteristics = getBTreeCharacteristics(tableCharacteristics.getColumnCount(), iinf.getColumns(), columnIndexes, tableCharacteristics);
779       IndexColumnInformation indexColumnInformation = new IndexColumnInformation(tableCharacteristics, iinf.getColumnInformation(), iinf.isVariableColumn());
780       if ( (tableName.getName().indexOf("_token_") != -1) || (tableName.getName().indexOf("_location_") != -1)) {
781          String JavaDoc[] columns = iinf.getColumns();
782          for (int i = 0; i < columns.length; i++) {
783             if (columns[i].equalsIgnoreCase("pk") ||
784                 columns[i].equalsIgnoreCase("documentId") ||
785                 columns[i].equalsIgnoreCase("location")) {
786                ( (IndexInformations) iinf).setIsDefault(true);
787                break;
788             }
789          }
790       }
791       _Index btree = versionHandler.getIndex(cmp, btreeCharacteristics, indexColumnInformation, (_ClusterProvider) database, controlPageAddress, new CUbcmfLfzIboemfs(), iinf.isDefault());
792       btree.setIndexInformation(iinf);
793       return btree;
794    }
795
796    /**
797     * Called at the time of creation of Btree (Every btree needed a comparator).
798     *
799     * @param flag : whether btree is created on single column or not
800     * @param orderColumns : order of index columns
801     * @param types : type of index columns
802     * @param collator
803     * @return : desired comparator
804     */

805    private SuperComparator getComparator(boolean flag, boolean[] orderColumns, int[] types, Collator collator) throws DException {
806       SuperComparator[] comparator = new SuperComparator[types.length];
807       for (int i = 0; i < types.length; i++)
808          comparator[i] = GetByteComparator.getComparatorForDataSystem(types[i], true, collator);
809       return flag ? (SuperComparator)new ByteComparatorSingleColumn(orderColumns[0], comparator[0])
810           : (SuperComparator)new ByteComparator(orderColumns, comparator);
811    }
812
813    private _BTreeCharacteristics getBTreeCharacteristics(int columnCount, String JavaDoc[] indexColumns, int[] columnIndexes, _TableCharacteristics tc) throws DException {
814       return columnIndexes.length == 1 ? (_BTreeCharacteristics)new BTreeCharacteristicsSingleColumn(indexColumns[0], columnIndexes[0], tc)
815           : (_BTreeCharacteristics)new BTreeCharacteristics(getMapping(columnCount, columnIndexes), tc);
816    }
817
818    private void evaluate22(_TableIterator iterator, QualifiedIdentifier tableName, String JavaDoc indexName) throws DException {
819       BufferRange[] bytes = Utility.getBufferRangeForTableName(tableName);
820       BufferRange[] key = new BufferRange[] {bytes[0], bytes[1], bytes[2], new BufferRange(indexName.getBytes())};
821       if (iterator.first()) {
822          BufferRange[] bytesGot;
823          do {
824             bytesGot = (BufferRange[]) iterator.getColumnValues(new int[] {0, 1, 2, 3});
825             if (nameComparator.compare(key, bytesGot) == 0) {
826                throw new DException("DSE1142", new Object JavaDoc[] {null, null, bytesGot});
827             }
828          } while (iterator.next());
829       }
830    }
831
832    private void seek(_Index btree, BufferRange[] bytes, byte[] indexNameBytes) throws DException {
833       BufferRange[] indexKey = indexNameBytes.length == 0 ? bytes
834           : new BufferRange[] {bytes[0], bytes[1], bytes[2], new BufferRange(indexNameBytes)};
835       Object JavaDoc obj = btree.seek(indexKey);
836       if (obj != null)
837          throw new DException("DSE2014", new Object JavaDoc[] {obj});
838
839    }
840
841    protected IndexInformations updateSystemTables(QualifiedIdentifier tableName, String JavaDoc indexName, _IndexInformation indexInformationGetter, _DatabaseUser user) throws DException {
842       BufferRange[] bytes = Utility.getBufferRangeForTableName(tableName);
843       byte[] bytesOfIndexName = indexName.getBytes();
844       addIndexInfoInIndexInfoTable(bytes, bytesOfIndexName, indexInformationGetter, user);
845       Object JavaDoc[][] indexInfo = indexInformationGetter.getColumnInformation();
846       addIndexInfoInIndexColumnsTable(bytes, bytesOfIndexName, indexInfo, user);
847       IndexInformations indexInformations = new IndexInformations(tableName, indexName, indexInformationGetter.getControlClusterAddress(), indexInformationGetter.isVariableColumn(), indexInfo, versionHandler);
848       if (indexInformationGetter.isDefault()) {
849          indexInformations.setIsDefault(true);
850       }
851       return indexInformations;
852    }
853
854    private void addIndexInfoInIndexInfoTable(BufferRange[] bytes, byte[] bytesOfIndexName, _IndexInformation iinf, _DatabaseUser user) throws DException {
855       _TableIterator indexInfoTableIterator = ( (_DataTable) indexInfoTable).getIterator();
856       if (indexInfoTableIterator.first()) {
857          try {
858             seek(indexOnIndexInfo, bytes, bytesOfIndexName);
859          } catch (DException ex) {
860             throw DatabaseConstants.INDEX_ALREDAY_EXISTS;
861          }
862       }
863       int address = ( (_ClusterProvider) database).getControlCluster(user).getStartAddress();
864       iinf.setControlClusterAddress(address);
865       BufferRange[] val = new BufferRange[] {bytes[0], bytes[1], bytes[2], new BufferRange(bytesOfIndexName),
866           new BufferRange(CCzufDpowfsufs.getBytes(address)), new BufferRange(CCzufDpowfsufs.getBytes(Utility.getBooleanValue(iinf.isVariableColumn())))};
867       BufferRange[] btreeKey = new BufferRange[] {bytes[0], bytes[1], bytes[2], new BufferRange(bytesOfIndexName)};
868       ( (_UserTableOperations) indexInfoTableIterator).insert(user, val);
869       indexOnIndexInfo.insert(user, btreeKey, indexInfoTableIterator.getKey());
870    }
871
872    /**
873     * Store the required information in Index Columns Table.
874     *
875     * @param tableName : SourceTableName
876     * @param indexName : IndexName
877     * @param indexInfo : Information of Columns On Which Index Is Maintained
878     * @param user : DatabaseUser
879     * @throws DException
880     */

881
882    private void addIndexInfoInIndexColumnsTable(BufferRange[] bytes, byte[] bytesOfIndexName, Object JavaDoc[][] indexInfo, _DatabaseUser user) throws DException {
883       _TableIterator indexColumnsTableIterator = ( (_DataTable) indexColumnsTable).getIterator();
884       BufferRange[] value, byts;
885       for (int i = 0; i < indexInfo.length; i++) {
886          value = new BufferRange[] {bytes[0], bytes[1], bytes[2], new BufferRange(bytesOfIndexName),
887              new BufferRange( ( (String JavaDoc) indexInfo[i][0]).getBytes()), new BufferRange(CCzufDpowfsufs.getBytes( (Boolean JavaDoc) indexInfo[i][1])),
888              new BufferRange(CCzufDpowfsufs.getBytes( (Integer JavaDoc) indexInfo[i][2])),
889              new BufferRange(CCzufDpowfsufs.getBytes( (Integer JavaDoc) indexInfo[i][3]))};
890
891          ( (_UserTableOperations) indexColumnsTableIterator).insert(user, value);
892          byts = new BufferRange[] {bytes[0], bytes[1], bytes[2], new BufferRange(bytesOfIndexName), new BufferRange(CCzufDpowfsufs.getBytes( (Integer JavaDoc) indexInfo[i][3]))};
893          indexOnIndexColumns.insert(user, byts, indexColumnsTableIterator.getKey());
894       }
895    }
896
897    /**
898     * Initialize The Both System Tables
899     * 1. DatabaseIndexInfo
900     * 2. DatabaseIndexColumns
901     *
902     * @throws DException
903     */

904
905    private void initialize(_DatabaseUser user) throws DException {
906       boolean flag = indexInfoTable == null;
907       indexInfoTable = flag ? database.getTable(SystemTables.DATABASEINDEXINFO) : indexInfoTable;
908       indexColumnsTable = indexColumnsTable == null ? database.getTable(SystemTables.DATABASEINDEXCOLUMNS) : indexColumnsTable;
909       if (flag) {
910          indexTablesMap.put(SystemTables.DATABASEINDEXINFO, indexInfoTable);
911          indexTablesMap.put(SystemTables.DATABASEINDEXCOLUMNS, indexColumnsTable);
912       }
913
914       if (versionHandler.isFullTextSupported()) {
915          fullTextInfoTable = fullTextInfoTable == null ?
916              database.getTable(SystemTables.DATABASEFULLTEXTINFO) :
917              fullTextInfoTable;
918          fullTextColumnInfoTable = fullTextColumnInfoTable == null ?
919              database.getTable(SystemTables.DATABASEFULLTEXTCOLUMNINFO) :
920              fullTextColumnInfoTable;
921          if (flag) {
922             indexTablesMap.put(SystemTables.DATABASEFULLTEXTINFO, fullTextInfoTable);
923             indexTablesMap.put(SystemTables.DATABASEFULLTEXTCOLUMNINFO,
924                                fullTextColumnInfoTable);
925          }
926       }
927       initializeIndexesOnSystemTables(user);
928    }
929
930    private void initializeIndexesOnSystemTables(_DatabaseUser user) throws DException {
931       _TableIterator iter = ( (Table) indexInfoTable).getIterator();
932       boolean flag = false; //iter.first();
933
try {
934          evaluate22(iter, SystemTables.DATABASEINDEXINFO, SystemTables.DATABASEINDEXINFO.name + "TEMP");
935       } catch (DException ex) {
936          flag = true;
937       }
938       indexOnIndexInfo = indexOnIndexInfo == null ? createIndexOnSystemTable(SystemTables.DATABASEINDEXINFO, flag, user) : indexOnIndexInfo;
939       flag = false;
940       try {
941          evaluate22(iter, SystemTables.DATABASEINDEXCOLUMNS, SystemTables.DATABASEINDEXCOLUMNS.name + "TEMP");
942       } catch (DException ex) {
943          flag = true;
944       }
945       indexOnIndexColumns = indexOnIndexColumns == null ? createIndexOnSystemTable(SystemTables.DATABASEINDEXCOLUMNS, flag, user) : indexOnIndexColumns;
946       if (!flag) {
947          insertDataInSystemIndexes(user);
948       }
949
950       if (versionHandler.isFullTextSupported()) {
951
952          flag = false;
953          try {
954             evaluate22(iter, SystemTables.DATABASEFULLTEXTINFO, SystemTables.DATABASEFULLTEXTINFO.name + "TEMP");
955          } catch (DException ex) {
956             flag = true;
957          }
958          indexOnFullTextInfoTable = indexOnFullTextInfoTable == null ? createIndexOnSystemTable(SystemTables.DATABASEFULLTEXTINFO, flag, user) : indexOnFullTextInfoTable;
959          flag = false;
960          try {
961             evaluate22(iter, SystemTables.DATABASEFULLTEXTCOLUMNINFO, SystemTables.DATABASEFULLTEXTCOLUMNINFO.name + "TEMP");
962          } catch (DException ex) {
963             flag = true;
964          }
965          indexOnFullTextColumnInfoTable = indexOnFullTextColumnInfoTable == null ?
966              createIndexOnSystemTable(SystemTables.DATABASEFULLTEXTCOLUMNINFO, flag, user) :
967              indexOnFullTextColumnInfoTable;
968          if (!flag) {
969             insertDataInSystemIndexesOfFullText(user);
970          }
971       }
972    }
973
974    /**
975     * Creates the index on DATABASEINDEXINFO and DATABASEINDEXCOLUMNS
976     */

977    private _Index createIndexOnSystemTable(QualifiedIdentifier tableName, boolean flag, _DatabaseUser user) throws DException {
978       _Table srcTable = getTable(tableName);
979       _TableIterator iterator = ( (_DataTable) indexInfoTable).getIterator();
980       String JavaDoc indexName = tableName.name + "TEMP";
981       BufferRange[] bytes = Utility.getBufferRangeForTableName(tableName);
982       byte[] bytesOfIndexName = indexName.getBytes();
983       if (!flag) {
984          ClusterCharacteristics cluster = ( (_ClusterProvider) database).getControlCluster(user);
985          int clusterAddress = cluster.getStartAddress();
986          BufferRange[] val = new BufferRange[] {bytes[0], bytes[1], bytes[2], new BufferRange(bytesOfIndexName),
987              new BufferRange(CCzufDpowfsufs.getBytes(clusterAddress)),
988              new BufferRange(CCzufDpowfsufs.getBytes(Boolean.TRUE))};
989          ( (_UserTableOperations) iterator).insert(user, val);
990          _TableIterator ite = ( (_DataTable) indexColumnsTable).getIterator();
991          Object JavaDoc[][] indexStructure = getIndexStructure(tableName);
992          for (int i = 0; i < indexStructure.length; i++) {
993             Object JavaDoc[] array = (Object JavaDoc[]) indexStructure[i];
994             BufferRange[] values = new BufferRange[] {bytes[0], bytes[1], bytes[2], new BufferRange(bytesOfIndexName),
995                 new BufferRange( ( (String JavaDoc) array[0]).getBytes()), new BufferRange(CCzufDpowfsufs.getBytes( (Boolean JavaDoc) array[1])),
996                 new BufferRange(CCzufDpowfsufs.getBytes( (Integer JavaDoc) array[2])),
997                 new BufferRange(CCzufDpowfsufs.getBytes(new Integer JavaDoc(i)))};
998             ( (_UserTableOperations) ite).insert(user, values);
999          }
1000
1001      } else {
1002         try {
1003            if (iterator.first()) {
1004               evaluate22(iterator, tableName, indexName);
1005            }
1006            new Exception JavaDoc(" ********** IT'S IMPOSSIBLE ************* ").printStackTrace();
1007         } catch (Exception JavaDoc ex) {
1008         }
1009      }
1010      SuperComparator comparator = null;
1011      if (tableName.equals(SystemTables.DATABASEINDEXCOLUMNS))
1012         comparator = getComparator(false, new boolean[] {true, true, true, true, true}
1013                                    , srcTable.getTableCharacteristics().getColumnTypes(new int[] {0, 1, 2, 3, 7}), null);
1014      else if (tableName.equals(SystemTables.DATABASEFULLTEXTCOLUMNINFO))
1015         comparator = getComparator(false, new boolean[] {true, true, true, true, true}
1016                                    , srcTable.getTableCharacteristics().getColumnTypes(new int[] {0, 1, 2, 3, 4}), null);
1017      else
1018         comparator = getComparator(false, new boolean[] {true, true, true, true}
1019                                    , srcTable.getTableCharacteristics().getColumnTypes(new int[] {0, 1, 2, 3}), null);
1020      _IndexInformation iinf = getIndexInformation(tableName, indexName, iterator);
1021      int controlPageAdress = iinf.getControlClusterAddress();
1022      IndexColumnInformation indexColumnInformation = new IndexColumnInformation(srcTable.getTableCharacteristics(), iinf.getColumnInformation(), iinf.isVariableColumn());
1023      _Index btree = versionHandler.getIndex(comparator, null, indexColumnInformation, (_ClusterProvider) database, controlPageAdress, new CUbcmfLfzIboemfs(), true); //new BTree(comparator,null,new FileNodeManager(indexColumnInformation,(_ClusterProvider)database,controlPageAdress,new CUbcmfLfzIboemfs()));
1024
btree.setIndexInformation(iinf);
1025      btree.setDuplicateAllowed(false);
1026      if (!flag) {
1027         _Index bt = indexOnIndexInfo == null ? btree : indexOnIndexInfo;
1028         int[] cols = bt.getIndexInformation().getColumnIndexes();
1029         BufferRange[] vals = (BufferRange[]) iterator.getColumnValues(cols);
1030         bt.insert(user, vals, iterator.getKey());
1031      }
1032      return btree;
1033   }
1034
1035   private void insertDataInSystemIndexes(_DatabaseUser user) throws DException {
1036      _TableIterator iterator = ( (_DataTable) indexColumnsTable).getIterator();
1037      int[] cols = indexOnIndexColumns.getIndexInformation().getColumnIndexes();
1038      if (iterator.first()) {
1039         BufferRange[] values;
1040         do {
1041            values = (BufferRange[]) iterator.getColumnValues(cols);
1042            indexOnIndexColumns.insert(user, values, iterator.getKey());
1043         } while (iterator.next());
1044      }
1045   }
1046
1047   private void insertDataInSystemIndexesOfFullText(_DatabaseUser user) throws DException {
1048      _TableIterator iterator = ( (_DataTable) fullTextInfoTable).getIterator();
1049      int[] cols = indexOnFullTextColumnInfoTable.getIndexInformation().getColumnIndexes();
1050      if (iterator.first()) {
1051         BufferRange[] values;
1052         do {
1053            values = (BufferRange[]) iterator.getColumnValues(cols);
1054            indexOnFullTextColumnInfoTable.insert(user, values, iterator.getKey());
1055         } while (iterator.next());
1056      }
1057   }
1058
1059   static private Object JavaDoc[][] getIndexStructure(QualifiedIdentifier tableName) {
1060      Object JavaDoc[][] columnInformation = null;
1061      if (tableName.equals(SystemTables.DATABASEINDEXCOLUMNS)) {
1062         columnInformation = new Object JavaDoc[][] { {"CatalogName", Boolean.TRUE, new Integer JavaDoc(0)}
1063             , {"SchemaName", Boolean.TRUE, new Integer JavaDoc(1)}
1064             , {"TableName", Boolean.TRUE, new Integer JavaDoc(2)}
1065             , {"IndexName", Boolean.TRUE, new Integer JavaDoc(3)}
1066             , {"OrdinalPosition", Boolean.TRUE, new Integer JavaDoc(4)}
1067         };
1068      } else if (tableName.equals(SystemTables.DATABASEFULLTEXTCOLUMNINFO)) {
1069         columnInformation = new Object JavaDoc[][] { {"CatalogName", Boolean.TRUE, new Integer JavaDoc(0)}
1070             , {"SchemaName", Boolean.TRUE, new Integer JavaDoc(1)}
1071             , {"TableName", Boolean.TRUE, new Integer JavaDoc(2)}
1072             , {"IndexName", Boolean.TRUE, new Integer JavaDoc(3)}
1073             , {"ColumnName", Boolean.TRUE, new Integer JavaDoc(4)}
1074         };
1075
1076      } else {
1077         columnInformation = new Object JavaDoc[][] { {"CatalogName", Boolean.TRUE, new Integer JavaDoc(0)}
1078             , {"SchemaName", Boolean.TRUE, new Integer JavaDoc(1)}
1079             , {"TableName", Boolean.TRUE, new Integer JavaDoc(2)}
1080             , {"IndexName", Boolean.TRUE, new Integer JavaDoc(3)}
1081         };
1082      }
1083      return columnInformation;
1084   }
1085
1086   private _IndexInformation getIndexInformation(QualifiedIdentifier tableName, String JavaDoc indexName, _TableIterator iterator) throws DException {
1087      Object JavaDoc[][] columnInformation = getIndexStructure(tableName);
1088      BufferRange values = (BufferRange) iterator.getColumnValues(4);
1089      _IndexInformation indexInformation = new IndexInformations(tableName, indexName, CCzufDpowfsufs.getInt(values.getBytes()).hashCode(), true, columnInformation, versionHandler);
1090      return indexInformation;
1091   }
1092
1093
1094
1095   public _TableCharacteristics getTableCharacteristics(QualifiedIdentifier tableName) throws DException {
1096      return database.getTable(tableName).getTableCharacteristics();
1097   }
1098
1099   public _Table getMaterializedTable(QualifiedIdentifier tableName) throws DException {
1100      throw new UnsupportedOperationException JavaDoc(" METHOD NOT IMPLEMENTED ");
1101   }
1102
1103   public _DatabaseUser getTempDatabaseUser() throws DException {
1104      return database.getTempDatabaseUser();
1105   }
1106
1107   public _Database getUnderLyingDatabase() throws DException {
1108      return database;
1109   }
1110
1111   /**
1112    * If create an index on an existing table insert the records in new btree.
1113    */

1114
1115   protected void insertRecordsInBTree(_TableIterator iterator, _Index btree, String JavaDoc[] columns, _DatabaseUser user) throws DException {
1116      _IndexInformation iinf = btree.getIndexInformation();
1117      int[] cols = iinf.getColumnIndexes();
1118      if (iterator.first()) {
1119         Object JavaDoc[] objectValues;
1120         BufferRange[] values;
1121         Object JavaDoc key;
1122         do {
1123            objectValues = (Object JavaDoc[]) iterator.getColumnValues(cols); //record.getObject(columns);
1124
values = convertObjectIntoBufferRange(objectValues);
1125            key = cols.length == 1 ? values[0] : (Object JavaDoc) values;
1126            btree.insert(user, key, iterator.getKey());
1127         } while (iterator.next());
1128      }
1129   }
1130
1131   /**
1132    * add the new btree in existing IndexTable
1133    *
1134    * @param tableName Name Of Index Table
1135    * @param btree Newly created Btree
1136    */

1137
1138   protected void updateBTreesInIndexTable(QualifiedIdentifier tableName, _Index btree) throws DException {
1139      _Table table = (_Table) indexTablesMap.get(tableName);
1140      if (table != null) {
1141         synchronized (table) {
1142            _Index[] oldBtrees = ( (_IndexTableList) table).getIndexes();
1143            int len = oldBtrees.length;
1144            _Index[] newBtrees = new _Index[len + 1];
1145            System.arraycopy(oldBtrees, 0, newBtrees, 0, oldBtrees.length);
1146            btree.setSize(oldBtrees[0].getSize());
1147            newBtrees[len] = btree;
1148            ( (_IndexTableList) table).setIndexes(newBtrees);
1149         }
1150      }
1151
1152   }
1153
1154   /**
1155    * Remove the btree from IndexTable at the time of drop Index.
1156    */

1157
1158   protected void removeBtreeFromIndexTable(_IndexTableList table, String JavaDoc indexName, _DatabaseUser user) throws DException {
1159      synchronized (table) {
1160         _Index[] oldBtrees = table.getIndexes();
1161         int len = oldBtrees.length;
1162         _Index[] newBtrees = new _Index[len - 1];
1163         for (int i = 0, k = 0; i < oldBtrees.length; i++) {
1164            if (oldBtrees[i].getIndexInformation().getIndexName().equalsIgnoreCase(indexName)) {
1165               oldBtrees[i].releaseResource(user, true);
1166               continue;
1167            }
1168            newBtrees[k++] = oldBtrees[i];
1169         }
1170         table.setIndexes(newBtrees);
1171      }
1172   }
1173
1174   /**
1175    * Removes the information stored in DatabaseIndexColumns at the time of Drop Index.
1176    *
1177    */

1178
1179   private void removeIndexInformationFromIndexColumnsTable(BufferRange[] btreeKey, _DatabaseUser user, BufferRange[] bytes, byte[] bytesOfIndexName) throws DException {
1180      _TableIterator indexColumnsTableIterator = ( (_DataTable) indexColumnsTable).getIterator();
1181      if (indexColumnsTableIterator.first()) {
1182         try {
1183            seek(indexOnIndexColumns, bytes, bytesOfIndexName);
1184         } catch (DException ex) {
1185            if (!ex.getDseCode().equalsIgnoreCase("DSE2014"))
1186               throw ex;
1187            _IndexKey btreKey = (_IndexKey) ex.getParameters()[0];
1188            Object JavaDoc btreeValue = btreKey.getValue();
1189            indexColumnsTableIterator.move(btreeValue);
1190            boolean flag = true;
1191            do {
1192               btreeKey = new BufferRange[] {btreeKey[0], btreeKey[1], btreeKey[2], btreeKey[3], (BufferRange) indexColumnsTableIterator.getColumnValues(7)};
1193               indexOnIndexColumns.delete(user, btreeKey, btreeValue);
1194               ( (_UserTableOperations) indexColumnsTableIterator).delete(user);
1195
1196               flag = indexColumnsTableIterator.next();
1197               btreeValue = indexColumnsTableIterator.getKey();
1198
1199               if (flag) {
1200                  BufferRange[] bytesGot = (BufferRange[]) indexColumnsTableIterator.getColumnValues(new int[] {0, 1, 2, 3});
1201                  flag = nameComparator.compare(btreeKey, bytesGot) == 0;
1202               }
1203            } while (flag);
1204         }
1205      }
1206
1207   }
1208
1209   /**
1210    * Removes the information stored in DatabaseIndexInfo table at the time of Drop Index.
1211    *
1212    */

1213
1214   private QualifiedIdentifier removeIndexInforamtionFromIndexInfoTabe(_DatabaseUser user, BufferRange[] btreeKey, BufferRange[] bytes, byte[] bytesOfIndexName) throws DException {
1215      QualifiedIdentifier indexTableName = null;
1216      _TableIterator indexInfoTableIterator = ( (_DataTable) indexInfoTable).getIterator();
1217      if (indexInfoTableIterator.first()) {
1218         try {
1219            seek(indexOnIndexInfo, bytes, bytesOfIndexName);
1220            throw new DException("DSE482", new Object JavaDoc[] {new String JavaDoc(bytesOfIndexName)});
1221         } catch (DException ex) {
1222            if (!ex.getDseCode().equalsIgnoreCase("DSE2014"))
1223               throw ex;
1224            _IndexKey btreKey = (_IndexKey) ex.getParameters()[0];
1225            indexInfoTableIterator.move(btreKey.getValue());
1226            BufferRange[] values = (BufferRange[]) indexInfoTableIterator.getColumnValues(new int[] {0, 1, 4}); // get the column values of required columns only.
1227
indexTableName = new QualifiedIdentifier(new String JavaDoc(values[0].getBytes()), new String JavaDoc(values[1].getBytes()), new String JavaDoc(values[2].getBytes()));
1228            btreeKey = new BufferRange[] {bytes[0], bytes[1], bytes[2], new BufferRange(bytesOfIndexName)};
1229            Object JavaDoc btreeValue = indexInfoTableIterator.getKey();
1230            indexOnIndexInfo.delete(user, btreeKey, btreeValue);
1231            ( (_UserTableOperations) indexInfoTableIterator).delete(user);
1232         }
1233      } else
1234         throw new DException("DSE482", new Object JavaDoc[] {new String JavaDoc(bytesOfIndexName)});
1235      return indexTableName;
1236
1237   }
1238
1239   private void insertRecordsInAlteredTable(DatabaseUserTableIterator iterator, _TableCharacteristics oldTableCharacteristics, IndexTableIterator tempTableIterator, _AlterRecord alterRecord, Object JavaDoc defaultValue, _DatabaseUser user) throws DException {
1240      if (iterator.first()) {
1241         ;//// Removed By Program ** System.out.println(" in first of insert record in latered table");
1242
BufferRange[] vals;
1243         Object JavaDoc[] values;
1244         do {
1245            vals = (BufferRange[]) iterator.getColumnValues();
1246            values = (Object JavaDoc[]) oldTableCharacteristics.getObject(vals);
1247            if (oldTableCharacteristics.isBlobClobTable() != -1) {
1248               int columnCount = oldTableCharacteristics.getColumnCount();
1249               for (int i = 0; i < columnCount; i++) {
1250                  if (! ( (FieldBase) values[i]).getNull()) {
1251                     if (Utility.isBlob(oldTableCharacteristics.getColumnType(i))) {
1252                        _LobUpdatable DBlobUpdatable = new DBlobUpdatable();
1253                        FieldBase fb = (FieldBase) values[i];
1254                        int startAddress = (int) CCzufDpowfsufs.getIntValue( ( (BufferRange) fb.getBufferRange()).getBytes(), 0);
1255                        short recordNumber = CCzufDpowfsufs.getShortValue( ( (BufferRange) fb.getBufferRange()).getBytes(), 4);
1256
1257                        DBlobUpdatable.setStartingClusterAddress(startAddress);
1258                        DBlobUpdatable.setRecordNumber(recordNumber);
1259                        ( (DBlobUpdatable) DBlobUpdatable).setDBLob(true);
1260                        values[i] = DBlobUpdatable;
1261                     } else if (oldTableCharacteristics.isBlobClob(i)) {
1262                        _LobUpdatable DClobUpdatable = new DClobUpdatable();
1263                        FieldBase fb = (FieldBase) values[i];
1264                        int startAddress = (int) CCzufDpowfsufs.getIntValue( ( (BufferRange) fb.getBufferRange()).getBytes(), 0);
1265                        short recordNumber = CCzufDpowfsufs.getShortValue( ( (BufferRange) fb.getBufferRange()).getBytes(), 4);
1266                        DClobUpdatable.setStartingClusterAddress(values[i].hashCode());
1267                        DClobUpdatable.setStartingClusterAddress(startAddress);
1268                        DClobUpdatable.setRecordNumber(recordNumber);
1269                        ( (DBlobUpdatable) DClobUpdatable).setDBLob(true);
1270                        values[i] = DClobUpdatable;
1271                     }
1272                  }
1273
1274               }
1275            }
1276            tempTableIterator.insert(user, alterRecord.getNewRecord(values, oldTableCharacteristics, defaultValue));
1277         } while (iterator.next());
1278      } else {
1279         ;//// Removed By Program ** System.out.println(" first not found");
1280
iterator.show();
1281      }
1282
1283   }
1284
1285   private void insertRecordsInAlteredTable(IndexTableIterator iterator, _TableCharacteristics oldTableCharacteristics, IndexTableIterator tempTableIterator, _AlterRecord alterRecord, Object JavaDoc defaultValue, _DatabaseUser user) throws DException {
1286      if (iterator.first()) {
1287         Object JavaDoc[] values;
1288         do {
1289            values = (Object JavaDoc[]) iterator.getColumnValues();
1290            tempTableIterator.insert(user, alterRecord.getNewRecord(values, oldTableCharacteristics, defaultValue));
1291         } while (iterator.next());
1292      } else {
1293         ;//// Removed By Program ** System.out.println(" first not found");
1294
}
1295
1296   }
1297
1298   /**
1299    * We first search the record in indexOnIndexColumns btree from the bottom and when
1300    * we found that we move to the record in the indexColumnsTable and give call for update
1301    * on this table if columnIndexes are changed i.e if updateIndex is true we
1302    * give call for update of 4 columns i.e 0,1,2,7(for columnIndex) else for 3 columns
1303    * 0,1,2 and also update call is given on indexOnIndexColumns.
1304    *
1305    */

1306
1307   private void updateIndexColumnsTable(BufferRange[] bytes, byte[] bytesOfIndexName, BufferRange[] keyWithOldTable, _DatabaseUser user, BufferRange[] keyWithTempTable, BufferRange[] bytesOfTempTable, boolean updateIndex, int[] columnIndexes) throws DException {
1308      _TableIterator indexColumnsTableIterator = ( (_DataTable) indexColumnsTable).getIterator();
1309      int j = updateIndex ? columnIndexes.length : -1;
1310      try {
1311         evaluateFromBottom(indexOnIndexColumns, bytes, bytesOfIndexName);
1312      } catch (DException de) {
1313         if (!de.getDseCode().equalsIgnoreCase("DSE2014"))
1314            throw de;
1315         _IndexKey btreeKey = (_IndexKey) de.getParameters()[0];
1316         indexColumnsTableIterator.move(btreeKey.getValue());
1317         BufferRange[] columnValues;
1318         do {
1319            columnValues = (BufferRange[]) indexColumnsTableIterator.getColumnValues(new int[] {0, 1, 2, 3});
1320            if (nameComparator.compare(columnValues, keyWithOldTable) == 0) {
1321               BufferRange oldR = new BufferRange( ( (BufferRange) indexColumnsTableIterator.getColumnValues(7)).getBytes());
1322               Object JavaDoc oldValue = indexColumnsTableIterator.getKey();
1323               if (updateIndex)
1324                  ( (_UserTableOperations) indexColumnsTableIterator).update(user, new int[] {0, 1, 2, 6}
1325                      , new BufferRange[] {bytesOfTempTable[0], bytesOfTempTable[1], bytesOfTempTable[2], new BufferRange(CCzufDpowfsufs.getBytes(new Integer JavaDoc(columnIndexes[--j])))});
1326               else
1327                  ( (_UserTableOperations) indexColumnsTableIterator).update(user, new int[] {0, 1, 2}
1328                      , new BufferRange[] {bytesOfTempTable[0], bytesOfTempTable[1], bytesOfTempTable[2]});
1329
1330               BufferRange newR = new BufferRange( ( (BufferRange) indexColumnsTableIterator.getColumnValues(7)).getBytes());
1331
1332               BufferRange[] oldVal = new BufferRange[] {keyWithOldTable[0], keyWithOldTable[1], keyWithOldTable[2], keyWithOldTable[3], oldR};
1333               BufferRange[] newVal = new BufferRange[] {keyWithTempTable[0], keyWithTempTable[1], keyWithTempTable[2], keyWithTempTable[3], newR};
1334
1335               indexOnIndexColumns.update(user, oldVal, newVal, oldValue, indexColumnsTableIterator.getKey());
1336            } else
1337               break;
1338         } while (indexColumnsTableIterator.previous());
1339      }
1340   }
1341
1342   private ArrayList getColumnInformationOfIndexes(BufferRange[] bytes, byte[] bytesOfIndexName) throws DException {
1343      ArrayList columnValueslist = new ArrayList();
1344      _TableIterator indexColumnsTableIterator = ( (_DataTable) indexColumnsTable).getIterator();
1345
1346      try {
1347         seek(indexOnIndexColumns, bytes, bytesOfIndexName);
1348      } catch (DException de1) {
1349         if (!de1.getDseCode().equalsIgnoreCase("DSE2014"))
1350            throw de1;
1351         _IndexKey btreeKey = (_IndexKey) de1.getParameters()[0];
1352         indexColumnsTableIterator.move(btreeKey.getValue());
1353         BufferRange[] keyToSeek = new BufferRange[] {bytes[0], bytes[1], bytes[2], new BufferRange(bytesOfIndexName)};
1354         _TableCharacteristics tc = indexColumnsTable.getTableCharacteristics();
1355         int[] cols = new int[] {4, 5, 6, 7};
1356         BufferRange[] columnValues;
1357         do {
1358            columnValues = (BufferRange[]) indexColumnsTableIterator.getColumnValues(new int[] {0, 1, 2, 3});
1359            if (nameComparator.compare(columnValues, keyToSeek) == 0) {
1360               BufferRange[] byts = (BufferRange[]) indexColumnsTableIterator.getColumnValues(cols);
1361               Object JavaDoc[] array = Utility.convertIntoFieldBase( (Object JavaDoc[]) tc.getObject(cols, byts));
1362               columnValueslist.add(array);
1363            } else
1364               break;
1365         } while (indexColumnsTableIterator.next());
1366      }
1367      return columnValueslist;
1368   }
1369
1370   private BufferRange[] convertObjectIntoBufferRange(Object JavaDoc[] objectValues) {
1371      BufferRange[] values = new BufferRange[objectValues.length];
1372      for (int i = 0; i < objectValues.length; i++) {
1373         values[i] = (BufferRange) objectValues[i];
1374      }
1375      return values;
1376   }
1377
1378   public _DatabaseUser getDatabaseUser(ArrayList tableNames) throws DException {
1379      return new IndexDatabaseUser(database.getDatabaseUser(tableNames), this);
1380   }
1381
1382   protected void insertRecordsInAlteredTable11(com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator iterator, _TableCharacteristics oldTableCharacteristics, IndexTableIterator tempTableIterator, _AlterRecord alterRecord, Object JavaDoc defaultValue) throws DException {
1383      _DatabaseUser user = getDatabaseUser();
1384      try {
1385         if (iterator.first()) {
1386            do {
1387               tempTableIterator.insert(user, alterRecord.getNewRecord( (Object JavaDoc[]) iterator.getColumnValues(), oldTableCharacteristics, defaultValue));
1388            } while (iterator.next());
1389         }
1390         user.writeToFile();
1391      } finally {
1392         user.releaseCluster();
1393      }
1394
1395   }
1396
1397   public void addFreeCluster(_DatabaseUser user, int address) throws DException {
1398      throw new UnsupportedOperationException JavaDoc("addFreeCluster");
1399   }
1400
1401   /**
1402    * This method is used to view the status of the database
1403    * i.e. how many cluster loaded into the memory and for
1404    * every database,table and index .
1405    * For the help in debugging errors like OOM.
1406    * @throws DException
1407    */

1408   public synchronized void getStatus() throws DException {
1409      PersistentDatabase persistentDatabase = (PersistentDatabase) database;
1410      HashMap tablesMap = persistentDatabase.getTablesMap();
1411      int totalTables = tablesMap.size();
1412      Set keySet = tablesMap.keySet();
1413      Iterator iterator = keySet.iterator();
1414      if (iterator.hasNext()) {
1415         do {
1416            QualifiedIdentifier tableName = (QualifiedIdentifier) iterator.next();
1417
1418            Table table = (Table)persistentDatabase.getTable(tableName) ;
1419                int numberOfClusterUsedInTable = ( (PersistentTable) ( (
1420                    ColumnBytesTable) table.getTable()).getTable()).getClusterIterator().
1421                    getNumberOfClustersUsed();
1422
1423            _IndexTable indexTable = null;
1424            boolean isIndexInfoRelatedTable = false;
1425            try {
1426               indexTable = (_IndexTable) getTable(tableName);
1427            } catch (NullPointerException JavaDoc np) {
1428               if (tableName.getName().equalsIgnoreCase("COLUMNINFO"))
1429         ;//// Removed By Program ** System.out.println("\t\t INDEXES CREATED - 0");
1430
} catch (ClassCastException JavaDoc ex1) {
1431               if (tableName.getName().equalsIgnoreCase("DATABASEINDEXINFO")) {
1432         ;//// Removed By Program ** System.out.println("\t\t INDEXES CREATED - 1");
1433

1434               } else if (tableName.getName().equalsIgnoreCase("DATABASEINDEXCOLUMNS")) {
1435         ;//// Removed By Program ** System.out.println("\t\t INDEX_1" + " CLUSTER LOADED - " + indexOnIndexColumns.getTotalNumberOfClusterLoadedInMemory() + " COULMNS - " + P.print(indexOnIndexColumns.getColumnNames()));
1436
} else if (tableName.getName().equalsIgnoreCase("DATABASEFULLTEXTINFO")) {
1437         ;//// Removed By Program ** System.out.println("\t\t INDEX_1" + " CLUSTER LOADED - " + indexOnFullTextInfoTable.getTotalNumberOfClusterLoadedInMemory() + " COULMNS - " + P.print(indexOnFullTextInfoTable.getColumnNames()));
1438
} else if (tableName.getName().equalsIgnoreCase("DATABASEFULLTEXTCOLUMNINFO")) {
1439         ;//// Removed By Program ** System.out.println("\t\t INDEX_1" + " CLUSTER LOADED - " + indexOnFullTextInfoTable.getTotalNumberOfClusterLoadedInMemory() + " COULMNS - " + P.print(indexOnFullTextInfoTable.getColumnNames()));
1440
} else
1441                  throw ex1;
1442               isIndexInfoRelatedTable = true;
1443            }
1444            try {
1445               if (!isIndexInfoRelatedTable) {
1446                  int noOfIndexes = indexTable.getIndexInformations().length;
1447                  for (int i = 0; i < noOfIndexes; i++) {
1448                     _Index btree = ( (IndexTableIterator) ( (IteratorWrapper) (
1449                         indexTable).getIterator(i)).getIndexIterator()).getBtree();
1450                     String JavaDoc columnNames[] = btree.getColumnNames();
1451                     int size = btree.getTotalNumberOfClusterLoadedInMemory();
1452                  }
1453               }
1454            } catch (NullPointerException JavaDoc ex) {
1455            }
1456
1457         } while (iterator.hasNext());
1458
1459      }
1460   }
1461
1462   private SuperComparator getComparatorForDML(boolean[] orderColumns) throws DException {
1463      SuperComparator[] comparator = new SuperComparator[orderColumns.length];
1464      for (int i = 0; i < orderColumns.length; i++)
1465         comparator[i] = new CTusjohJoTfotjujwfDpnqbsbups();
1466      return (SuperComparator)new ByteComparator(orderColumns, comparator);
1467   }
1468
1469   /**
1470    *It is used to remove a fullTextDML object from the array of fullTextDML objects
1471    * when a fullTextDML index is dropped
1472    * @param table IndexTabelList of the table
1473    * @param indexName name of the index dropped
1474    * @throws DException
1475    */

1476   protected void removeFullTextDMLFromIndexTable(_IndexTableList table, String JavaDoc indexName) throws DException {
1477      synchronized (table) {
1478         _FullTextDML[] oldFullTextDML = table.getFullTextDML();
1479         if (oldFullTextDML != null) {
1480            _FullTextDML[] newFullTextDML = new _FullTextDML[oldFullTextDML.length - 1];
1481            for (int i = 0, k = 0; i < oldFullTextDML.length; i++) {
1482               if (oldFullTextDML[i].getFullTextIndexInformation().getIndexName().
1483                   equalsIgnoreCase(indexName))
1484                  continue;
1485               newFullTextDML[k++] = oldFullTextDML[i];
1486            }
1487            table.setFullTextDML(newFullTextDML);
1488         }
1489      }
1490   }
1491
1492   public _Table getIndexInfotable() {
1493      return indexInfoTable;
1494   }
1495
1496   /**
1497    * It is used to get the column names of the table on which the full text
1498    * index created
1499    * 1) we take the system table DATABASEFULLTEXTCOLUMNINFO table and search
1500    * the table name on the index created.
1501    * 2) Now we make a temprary bufferRange of tableName & indexName to compare
1502    * the values got from Btree.
1503    * 3) Now add the columnName in columnName list as a match is found and return.
1504    * @param nameOfTable - table name on which foll text index is created
1505    * @param indexName - name of the full text index
1506    * @return - column names on which the index is created
1507    * @throws DException
1508    */

1509
1510   private String JavaDoc[] getColumnNamesOfFullTextIndex(BufferRange[] nameOfTable, String JavaDoc indexName) throws DException {
1511      fullTextColumnInfoTable = getTable(SystemTables.DATABASEFULLTEXTCOLUMNINFO);
1512      _TableIterator fullTextColumnInfoTableIterator = ( (_DataTable) fullTextColumnInfoTable).getIterator();
1513      BufferRange indexNameBufferRange = new BufferRange(indexName.getBytes());
1514      BufferRange tempBufferRangeForComperator[] = new BufferRange[nameOfTable.length + 1];
1515      tempBufferRangeForComperator[nameOfTable.length] = indexNameBufferRange;
1516      System.arraycopy(nameOfTable, 0, tempBufferRangeForComperator, 0, nameOfTable.length);
1517
1518      _IndexKey key = (_IndexKey) indexOnFullTextColumnInfoTable.seekFromTopRelative(null, tempBufferRangeForComperator);
1519      int com = -1;
1520      ArrayList listOfColumnName = new ArrayList();
1521      boolean[] orderColumns = new boolean[] {
1522          true, true, true, true};
1523      comperatorForDML = getComparatorForDML(orderColumns);
1524      BufferRange[] keyBufferRange, bytes;
1525      do {
1526         com = -1;
1527         if (key == null)
1528            break;
1529         keyBufferRange = (BufferRange[]) key.getKey();
1530         com = comperatorForDML.compare(new BufferRange[] {keyBufferRange[0],
1531                                        keyBufferRange[1], keyBufferRange[2]}
1532                                        , nameOfTable);
1533         if (com != 0)
1534            break;
1535         (fullTextColumnInfoTableIterator).move(key.getValue());
1536
1537         bytes = (BufferRange[]) fullTextColumnInfoTableIterator.
1538             getColumnValues(new int[] {0, 1, 2, 3, 4});
1539         if (comperatorForDML.compare(tempBufferRangeForComperator,
1540                                      new BufferRange[] {bytes[0], bytes[1],
1541                                      bytes[2], bytes[3]}) == 0) {
1542            String JavaDoc tempColumnName = new String JavaDoc(bytes[4].getBytes());
1543            listOfColumnName.add(tempColumnName);
1544         }
1545
1546      } while (indexOnFullTextColumnInfoTable.next(key));
1547      return listOfColumnName.size() == 0 ? null :
1548          (String JavaDoc[]) listOfColumnName.toArray(new String JavaDoc[0]);
1549
1550   }
1551
1552   private int[] getColumnIndexes(String JavaDoc[] columnName, _Table tab) throws DException {
1553      if (columnName != null) {
1554         int[] columnIndexes = new int[columnName.length];
1555         for (int i = 0; i < columnName.length; i++)
1556            columnIndexes[i] = tab.getTableCharacteristics().
1557                getIndexForColumnName(columnName[i]);
1558         return columnIndexes;
1559      }
1560      return null;
1561   }
1562
1563   /**
1564    * It removes the information of a full text index when a fullTextIndex is dropped
1565    * from the DATABASEFULLTEXTCOLUMNINFO table.
1566    * In this method we seek on the index with tableName and indexName and all
1567    * the entry romed from the table and index.
1568    *
1569    * @param tableName - name of the table of which fullTextindex is dropped
1570    * @param indexName - name of the full text index
1571    * @throws DException
1572    */

1573   private void removeInformationFromDATABASEFULLTEXTCOLUMNINFO(QualifiedIdentifier tableName, String JavaDoc indexName) throws DException {
1574      _TableIterator fullTextColumnInfoTableIterator = ( (_DataTable)
1575          fullTextColumnInfoTable).getIterator();
1576      BufferRange[] bytes = Utility.getBufferRangeForTableName(tableName);
1577      ArrayList list = new ArrayList();
1578      _DatabaseUser user = null;
1579      try {
1580         seek(indexOnFullTextColumnInfoTable, bytes, indexName.getBytes());
1581         throw new DException("DSE482", new Object JavaDoc[] {indexName});
1582      } catch (DException de2) {
1583         if (!de2.getDseCode().equalsIgnoreCase("DSE2014"))
1584            throw de2;
1585         _IndexKey btreeKey = (_IndexKey) de2.getParameters()[0];
1586         BufferRange[] keyToSeek = new BufferRange[] {
1587             bytes[0], bytes[1], bytes[2], new BufferRange(indexName.getBytes())};
1588         list.clear();
1589         list.add(SystemTables.DATABASEFULLTEXTCOLUMNINFO);
1590         user = database.getDatabaseUser(list);
1591         BufferRange[] columnValues;
1592         do {
1593            fullTextColumnInfoTableIterator.move(btreeKey.getValue());
1594            columnValues = (BufferRange[]) fullTextColumnInfoTableIterator.getColumnValues(new int[] {0, 1, 2, 3, 4});
1595            if (nameComparator.compare(new BufferRange[] {columnValues[0], columnValues[1],
1596                                       columnValues[2], columnValues[3]}
1597                                       , keyToSeek) != 0)
1598               break;
1599            Object JavaDoc btreeValue = fullTextColumnInfoTableIterator.getKey();
1600            indexOnFullTextColumnInfoTable.delete(user, btreeKey.getKey(), btreeValue);
1601            ( (DatabaseUserTableIterator) fullTextColumnInfoTableIterator).delete(user);
1602
1603         } while (indexOnFullTextColumnInfoTable.next(btreeKey));
1604
1605         user.writeToFile();
1606      }
1607   }
1608
1609   /**
1610    * It is used to drop the Token and Location table with there indexes
1611    * when a full text index is dropped.
1612    * @param bytes - bytes of the tableName of which fullTextIndex is dropped.
1613    * @param columnValues - name of the token and location table.
1614    * @throws DException
1615    */

1616   private void dropLocationAndTokenTableWithIndexes(BufferRange[] bytes, BufferRange[] columnValues) throws DException {
1617      ArrayList list = new ArrayList();
1618      QualifiedIdentifier tokenTable = new
1619          QualifiedIdentifier(new String JavaDoc(
1620          bytes[0].getBytes()), new String JavaDoc(bytes[1].getBytes()),
1621                              new String JavaDoc(columnValues[4].
1622                                         getBytes()));
1623      _IndexTable tokenIndexTable = (_IndexTable) getTable(
1624          tokenTable);
1625      _IndexInformation[] indexInformations = tokenIndexTable.
1626          getIndexInformations();
1627
1628      list.add(tokenTable);
1629      _DatabaseUser user = database.getDatabaseUser(list);
1630      for (int i = 0; i < indexInformations.length; i++) {
1631         dropPeramanantIndex(tokenTable,
1632                             indexInformations[i].getIndexName(),
1633                             user);
1634      }
1635      user.writeToFile();
1636      list.clear();
1637      removeTable(tokenTable);
1638      dropTable(tokenTable);
1639      QualifiedIdentifier locationTable = new
1640          QualifiedIdentifier(new
1641                              String JavaDoc(bytes[0].getBytes()),
1642                              new String JavaDoc(bytes[1].getBytes()),
1643                              new String JavaDoc(columnValues[5].
1644                                         getBytes()));
1645      _IndexTable locationIndexTable = (_IndexTable) getTable(locationTable);
1646      indexInformations = locationIndexTable.getIndexInformations();
1647
1648      list.add(locationTable);
1649      user = database.getDatabaseUser(list);
1650      for (int i = 0; i < indexInformations.length; i++) {
1651         dropPeramanantIndex(locationTable, indexInformations[i].getIndexName(), user);
1652      }
1653      user.writeToFile();
1654      list.clear();
1655      removeTable(locationTable);
1656      dropTable(locationTable);
1657
1658   }
1659
1660   /**
1661    * It is used when we create a full text index and the columns on which
1662    * fullTextIndex is to be made already have some data , so we inserts the
1663    * data in the fullTextDML object corresponding to the full text index.
1664    * @param user
1665    * @param indexes - indexes of the columns on which the full text index created.
1666    * @param indexTable - table on which full text index to be created.
1667    * @param fullTextDML - fullTextDMl object corressponding to the fullTextIndex.
1668    * @throws DException
1669    */

1670   private void insertDataIntoDMLObject(_DatabaseUser user, int[] indexes, _IndexTable indexTable, _FullTextDML fullTextDML) throws DException {
1671      int[] tempIndexes = new int[indexes.length + 1];
1672      tempIndexes[0] = 0;
1673      _Iterator actualTableIterator = ( (_IndexTable) indexTable).getDefaultIterator();
1674      _TableCharacteristics tableCharacteristics = indexTable.getTableCharacteristics();
1675      System.arraycopy(indexes, 0, tempIndexes, 1, indexes.length);
1676      if (actualTableIterator.first()) {
1677         Object JavaDoc[] values, tempValue;
1678         do {
1679            values = (Object JavaDoc[]) actualTableIterator.getColumnValues(tempIndexes);
1680            tempValue = new FieldBase[values.length - 1];
1681            for (int k = 1; k < tempIndexes.length; k++) {
1682               if (tableCharacteristics.isBlobClob(tempIndexes[k])) {
1683                  byte[] clobBytes = ( (DClobUpdatable) values[k]).getBytes();
1684                  BufferRange br = FieldUtility.NULLBUFFERRANGE;
1685                  if (clobBytes != null)
1686                     br = new BufferRange(clobBytes, 0, clobBytes.length);
1687                  FieldString fieldString = new FieldString(br, Datatype.CLOB,
1688                      tableCharacteristics.getCollator());
1689                  tempValue[k - 1] = fieldString;
1690               } else
1691                  tempValue[k - 1] = values[k];
1692            }
1693            fullTextDML.insert(user, tempValue, values[0]);
1694         } while (actualTableIterator.next());
1695      }
1696   }
1697
1698   /**
1699    * It is used to set the full text DML objects in the index table when a
1700    * full text index is created.
1701    * Here we get all the old FullTextDML objects and append the new Object
1702    * and again set them.
1703    * @param fullTextDML - new object corresponding to new fullTextIndex.
1704    * @param indexTable - table on which fullTextIndex is created.
1705    * @param daffodilFullTextIndexInformation
1706    * @throws DException
1707    */

1708   private void setFullTextDMLInIndexTable(_FullTextDML fullTextDML, _IndexTableList indexTable, _FullTextIndexInformation daffodilFullTextIndexInformation) throws DException {
1709      _FullTextDML oldFullTextDML[] = indexTable.getFullTextDML();
1710      fullTextDML.setFullTextIndexInformation(daffodilFullTextIndexInformation);
1711      if (oldFullTextDML == null)
1712         indexTable.setFullTextDML(new _FullTextDML[] {fullTextDML});
1713      else {
1714         _FullTextDML newFullTextDML[] = new _FullTextDML[oldFullTextDML.length +
1715             1];
1716         System.arraycopy(oldFullTextDML, 0, newFullTextDML, 0,
1717                          oldFullTextDML.length);
1718         newFullTextDML[oldFullTextDML.length] = fullTextDML;
1719         indexTable.setFullTextDML(newFullTextDML);
1720
1721      }
1722   }
1723
1724   public void createTemporaryIndex(QualifiedIdentifier parm1, String JavaDoc parm2, _IndexInformation parm3) throws com.daffodilwoods.database.resource.DException {
1725      /**@todo Implement this com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexDatabase method*/
1726      throw new java.lang.UnsupportedOperationException JavaDoc("Method createTemporaryIndex() not yet implemented.");
1727   }
1728
1729   public synchronized _Table getTable(QualifiedIdentifier tableName, _IndexInformation[] info) throws DException {
1730      throw new UnsupportedOperationException JavaDoc();
1731   }
1732
1733   public VersionHandler getVersionHandler() {
1734      return versionHandler;
1735   }
1736
1737   /*
1738        public synchronized void createFullTextIndex1(QualifiedIdentifier tableName,String indexName,String []columnName) throws DException{
1739       _IndexTableList indexTable = (_IndexTableList) getTable(tableName);
1740        ArrayList list = new ArrayList();
1741        list.add(tableName);
1742        list.add(SystemTables.DATABASEFULLTEXTINFO);
1743        list.add(SystemTables.DATABASEFULLTEXTCOLUMNINFO);
1744        _DatabaseUser user =null;
1745        FullTextFactory fullTextFactory = new FullTextFactory();
1746        DaffodilFullTextIndexCreator dftxc = new DaffodilFullTextIndexCreator(this);
1747        _FullTextGenerator ftg = new DaffodilFullTextGenerator(dftxc);
1748        Object tokenLocationTableName[] = (Object[]) fullTextFactory.getFullTextIndexCreator(ftg).createFullTextIndex(tableName, indexName,columnName);
1749        try{
1750     DatabaseUserTableIterator fullTextInfoIterator = (
1751         DatabaseUserTableIterator) ( (
1752         _DataTable) getTable(SystemTables.DATABASEFULLTEXTINFO)).getIterator();
1753     DatabaseUserTableIterator fullTextColumnInfoIterator = (
1754         DatabaseUserTableIterator) ( (
1755         _DataTable) getTable(SystemTables.DATABASEFULLTEXTCOLUMNINFO)).getIterator();
1756     BufferRange[] bytes = Utility.getBufferRangeForTableName(tableName);
1757     BufferRange[] values = new BufferRange[] {
1758          (bytes[0]), (bytes[1]), (bytes[2]),
1759         (new BufferRange(indexName.getBytes())),
1760         (new BufferRange( ( ( (String) tokenLocationTableName[0])).getBytes())),
1761         (new BufferRange( ( (String) tokenLocationTableName[1]).getBytes()))};
1762     user = database.getDatabaseUser(list);
1763     fullTextInfoIterator.insert(user, values);
1764        indexOnFullTextInfoTable.insert(user, new BufferRange[] {values[0],values[1], values[2],values[3]},fullTextInfoIterator.getKey());
1765     int length = columnName.length;
1766       for( int i=0;i<length ;i++){
1767     values = new BufferRange[] {(bytes[0]), (bytes[1]), (bytes[2]),
1768                                (new BufferRange(indexName.getBytes())),
1769                                (new BufferRange(columnName[i].getBytes()))};
1770       fullTextColumnInfoIterator.insert(user,values);
1771       indexOnFullTextColumnInfoTable.insert(user,new BufferRange[] {values[0],values[1], values[2],values[3],values[4]},fullTextColumnInfoIterator.getKey()) ;
1772     }
1773      QualifiedIdentifier[] tokenLocatinTableName = new QualifiedIdentifier[2];
1774     tokenLocatinTableName[0] = new QualifiedIdentifier(new String(bytes[0].getBytes()),
1775                                new String(bytes[1].getBytes()),
1776                                (String) tokenLocationTableName[0]);
1777     tokenLocatinTableName[1] = new QualifiedIdentifier(new String(bytes[0].getBytes()),
1778                                new String(bytes[1].getBytes()),
1779                                (String) tokenLocationTableName[1]);
1780     _DataTable table = (_DataTable) database.getTable(tableName);
1781     int indexes[] = new int [length ];
1782     for(int i=0;i<length ;i++ )
1783       indexes[i] = table.getTableCharacteristics().getIndexForColumnName(columnName[i]);
1784     _FullTextIndexInformation daffodilFullTextIndexInformation =
1785             new DaffodilFullTextIndexInformation(tableName, tokenLocatinTableName[0],
1786                            tokenLocatinTableName[1], indexName,columnName, indexes);
1787     _FullTextDML fullTextDML = getFullTextDML(tokenLocatinTableName,fullTextFactory, indexes);
1788     insertDataIntoDMLObject(user,indexes,(_IndexTable)indexTable,fullTextDML ) ;
1789     setFullTextDMLInIndexTable(fullTextDML ,indexTable, daffodilFullTextIndexInformation);
1790    user.writeToFile();
1791        }catch(Exception ex){
1792        }finally{
1793     user.releaseCluster() ;
1794        }
1795    }
1796       private String[] getColumnNamesOfFullTextIndexOld(BufferRange[] nameOfTable,String indexName) throws DException{
1797     fullTextColumnInfoTable = getTable(SystemTables.DATABASEFULLTEXTCOLUMNINFO);
1798     _TableIterator fullTextColumnInfoTableIterator = ( (_DataTable)fullTextColumnInfoTable).getIterator();
1799     _IndexKey key = (_IndexKey) indexOnFullTextColumnInfoTable.seekFromTopRelative(null, nameOfTable);
1800     int com = -1;
1801       ArrayList listOfColumnName = new ArrayList();
1802       boolean[] orderColumns = new boolean[] {
1803           true, true, true, true};
1804       comperatorForDML = getComparatorForDML(orderColumns);
1805       BufferRange indexNameBufferRange = new BufferRange(indexName.getBytes());
1806       BufferRange tempBufferRangeForComperator[] = new BufferRange[nameOfTable.length + 1];
1807       tempBufferRangeForComperator[nameOfTable.length] = indexNameBufferRange;
1808       System.arraycopy(nameOfTable, 0, tempBufferRangeForComperator, 0,nameOfTable.length);
1809       do {
1810         com = -1;
1811         if (key == null)
1812           break;
1813         BufferRange[] keyBufferRange = (BufferRange[]) key.getKey();
1814         com = comperatorForDML.compare(new BufferRange[] {keyBufferRange[0],
1815                                        keyBufferRange[1], keyBufferRange[2]}
1816                                        , nameOfTable);
1817         if (com != 0)
1818           break;
1819         (fullTextColumnInfoTableIterator).move(key.getValue());
1820         BufferRange[] bytes = (BufferRange[]) fullTextColumnInfoTableIterator.
1821             getColumnValues(new int[] {0, 1, 2, 3, 4});
1822         if (comperatorForDML.compare(tempBufferRangeForComperator,
1823                                      new BufferRange[] {bytes[0], bytes[1],
1824                                      bytes[2], bytes[3]}) == 0) {
1825           String tempColumnName = new String(bytes[4].getBytes());
1826           listOfColumnName.add(tempColumnName);
1827         }
1828       }while (indexOnFullTextColumnInfoTable.next(key));
1829       return listOfColumnName.size() == 0 ? null :
1830           (String[]) listOfColumnName.toArray(new String[0]);
1831        }
1832    */

1833}
1834
Popular Tags