1 21 22 package org.apache.derby.impl.sql.compile; 23 24 import org.apache.derby.iapi.store.access.ColumnOrdering; 25 26 import org.apache.derby.impl.sql.execute.IndexColumnOrder; 27 28 import java.util.Hashtable ; 29 30 35 public abstract class OrderedColumnList extends QueryTreeNodeVector 36 { 37 40 public IndexColumnOrder[] getColumnOrdering() 41 { 42 IndexColumnOrder[] ordering; 43 int numCols = size(); 44 int actualCols; 45 46 ordering = new IndexColumnOrder[numCols]; 47 48 56 Hashtable hashColumns = new Hashtable (); 57 58 actualCols = 0; 59 60 for (int i = 0; i < numCols; i++) 61 { 62 OrderedColumn oc = (OrderedColumn) elementAt(i); 63 64 int position = oc.getColumnPosition() - 1; 67 68 Integer posInt = new Integer (position); 69 70 if (! hashColumns.containsKey(posInt)) 71 { 72 ordering[i] = new IndexColumnOrder(position, 73 oc.isAscending()); 74 actualCols++; 75 hashColumns.put(posInt, posInt); 76 } 77 } 78 79 83 if (actualCols < numCols) 84 { 85 IndexColumnOrder[] newOrdering = new IndexColumnOrder[actualCols]; 86 System.arraycopy(ordering, 0, newOrdering, 0, actualCols); 87 ordering = newOrdering; 88 } 89 90 return ordering; 91 } 92 } 93 | Popular Tags |