1 package com.daffodilwoods.daffodildb.server.sql99.dql.plan.table; 2 3 import com.daffodilwoods.daffodildb.server.datasystem.indexsystem.*; 4 import com.daffodilwoods.daffodildb.server.sql99.common.*; 5 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.predicates.*; 6 import com.daffodilwoods.database.resource.*; 7 import com.daffodilwoods.database.sqlinitiator.*; 8 9 20 21 public class TableReferenceMerger implements ExecutionPlanConstants { 22 23 33 public static int checkForOrderColumns(_Order order, _IndexInformation indexInformation) throws DException { 34 if (order == null) { 35 return 0; 36 } 37 String [] indexColumns = indexInformation.getColumns(); 38 ColumnDetails cd[] = order.getColumnDetails(); 39 int length1 = cd.length, length2 = indexColumns.length; 40 if (length1 > length2) { 41 return -1; 42 } 43 boolean[] indexColumnsOrder = indexInformation.getOrderOfColumns(); 44 boolean[] orderColumnsOrder = order.getOrderOfColumns(); 45 int sameOrder = -1; for (int i = 0, j = 0; i < length1 && j < length2; i++, j++) { 47 if (! (cd[i].getColumn().equalsIgnoreCase(indexColumns[j]))) { 48 return -1; 49 } 50 if (orderColumnsOrder[i] == indexColumnsOrder[j]) { 51 if (sameOrder == 1) { 52 return -1; 53 } 54 sameOrder = 0; 55 } else { 56 if (sameOrder == 0) { 57 return -1; 58 } 59 sameOrder = 1; 60 } 61 } 62 return sameOrder; 63 } 64 65 73 74 public static boolean checkForAggregateColumn(ColumnDetails aggColumn, _IndexInformation indexInformation) throws DException { 75 if (aggColumn == null) { 76 return true; 77 } 78 String indexColumnName = indexInformation.getColumns()[0]; 79 boolean indexColumnOrder = indexInformation.getOrderOfColumns()[0]; 80 return!aggColumn.checkNegativeValueFlag() && aggColumn.getColumn().equalsIgnoreCase(indexColumnName) && indexColumnOrder; 81 } 82 83 91 public static boolean checkForQueryColumns(String [] indexColumns, String [] queryColumns) throws DException { 92 if (queryColumns == null || indexColumns == null) { 93 return false; 94 } 95 int length1 = indexColumns.length; 96 outerloop:for (int i = 0, length = queryColumns.length; i < length; ++i) { 97 int j = 0; 98 for (; j < length1; ++j) { 99 if (indexColumns[j].equalsIgnoreCase(queryColumns[i])) { 100 continue outerloop; 101 } 102 } 103 if (j == length1) { 104 return false; 105 } 106 } 107 return true; 108 } 109 110 } 111 | Popular Tags |