1 package com.daffodilwoods.daffodildb.server.sql99.fulltext.dql.condition; 2 3 import com.daffodilwoods.database.resource.DException; 4 import com.daffodilwoods.daffodildb.server.sql99.dql.plan.condition._AllColumnPredicates; 5 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator; 6 import com.daffodilwoods.daffodildb.server.sql99.fulltext.dml._FullTextIndexInformation; 7 import com.daffodilwoods.database.sqlinitiator._Order; 8 import com.daffodilwoods.daffodildb.server.datasystem.interfaces._IndexTable; 9 import com.daffodilwoods.daffodildb.server.datadictionarysystem.information._IndexInformation; 10 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.set.ExceptAllIterator; 11 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator.set.ExceptDistinctIterator; 12 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference; 13 import com.daffodilwoods.daffodildb.server.sql99.common.ColumnDetails; 14 import com.daffodilwoods.daffodildb.server.sql99.common.Datatypes; 15 import com.daffodilwoods.daffodildb.server.datasystem.indexsystem.ByteComparator; 16 import com.daffodilwoods.daffodildb.utils.GetByteComparator; 17 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator; 18 import com.daffodilwoods.daffodildb.server.sql99.common.GeneralPurposeStaticClass; 19 import com.daffodilwoods.daffodildb.utils.comparator.CKpjoDpnqbsbups; 20 21 32 33 public class NotFullTextPredicate 34 implements _FullTextPredicate { 35 36 _FullTextPredicate fullTextPredicate; 37 String columnName; 38 private _Order order; 39 40 public NotFullTextPredicate(_FullTextPredicate fullTextPredicate0) { 41 fullTextPredicate = fullTextPredicate0; 42 } 43 44 50 public int getType() throws DException { 51 return PredicateConstant.notFullTextPredicate; 52 } 53 54 60 public String getColumn() throws DException { 61 return columnName; 62 } 63 64 70 public void setColumn(String colName) throws DException { 71 fullTextPredicate.setColumn(colName); 72 columnName = colName; 73 } 74 75 83 public _Iterator execute(Object session) throws DException { 84 _FullTextIndexInformation[] fullTextIndexInfo = ( (_IndexTable) session). 85 getFullTextIndexInformation(); 86 _Iterator iter = fullTextPredicate.executeForSortedResult(session); for (int i = 0; i < fullTextIndexInfo.length; i++) { 88 String [] columnNames = fullTextIndexInfo[i].getColumnName(); 89 if ((columnName.equalsIgnoreCase(fullTextIndexInfo[i].getIndexName())) 90 || (columnNames.length ==1 && 91 (columnName.equalsIgnoreCase(columnNames[0])))){ 92 _Iterator tokenIterator = getTokenIterator(fullTextIndexInfo[i], 93 session); 94 return getExceptIterator(tokenIterator, iter); 95 } 96 } 97 throw new DException("DSE0", new Object [] {"Invalid ColumnName - " + columnName}); 98 } 99 100 108 private _Iterator getExceptIterator(_Iterator tokenIterator, 109 _Iterator underlyingIterator) throws 110 DException { 111 _Reference[] leftReferences = new _Reference[] { 112 GeneralPurposeStaticClass.getColumnDetails("documentId")}; 113 _Reference[] rightReferences = new _Reference[] { 114 GeneralPurposeStaticClass.getColumnDetails("documentId")}; 115 SuperComparator comparator = GetByteComparator.getComparator(Datatypes.LONG, true, null); 116 CKpjoDpnqbsbups joincomparator = new CKpjoDpnqbsbups(new SuperComparator[] { 117 comparator}); 118 _Reference[] orderLeftColumnDetails = new _Reference[] { 119 GeneralPurposeStaticClass.getColumnDetails("documentId")}; 120 _Reference[] orderRightColumnDetails = new _Reference[] { 121 GeneralPurposeStaticClass.getColumnDetails("documentId")}; 122 return new ExceptDistinctIterator(tokenIterator, underlyingIterator, 123 leftReferences, rightReferences, 124 joincomparator, orderLeftColumnDetails, 125 orderRightColumnDetails, joincomparator, 126 joincomparator); 127 } 128 129 136 private _Iterator getTokenIterator(_FullTextIndexInformation fullTextIndexInfo, 137 Object session) throws DException { 138 _IndexTable token = (_IndexTable) ( (_IndexTable) session).getDatabase(). 139 getTable(fullTextIndexInfo.getTokenTableName()); 140 com.daffodilwoods.daffodildb.server.datasystem.indexsystem. 141 _IndexInformation[] indexInfo = token.getIndexInformations(); 142 for (int i = 0; i < indexInfo.length; i++) { 143 String [] cName = indexInfo[i].getColumns(); 144 if (cName[0].equalsIgnoreCase("documentId")) { return token.getIterator(i); 146 } 147 } 148 throw new DException("DSE0", 149 new Object [] {"Invalid FullTextIndex - " + fullTextIndexInfo}); 150 } 151 152 public double getCost() throws DException { 153 return 0.0; 154 } 155 156 public double getCost(Object session) throws DException { 157 return 0.0; 158 } 159 160 public double getEstimatedRow() throws DException { 161 return 1; 162 } 163 164 public void setOrder(_Order order) throws DException { 165 this.order = order; 166 } 167 168 public _Order getOrder() throws DException { 169 return order; 170 } 171 172 180 public _Iterator getWordIterator(Object session) throws DException { 181 return fullTextPredicate.execute(session); 182 } 183 184 191 public _Iterator executeForSortedResult(Object indexTable) throws DException { 192 return execute(indexTable); 193 } 194 195 } 196 | Popular Tags |