1 package com.daffodilwoods.daffodildb.server.sql99.fulltext.dql.iterator; 2 3 import com.daffodilwoods.database.resource.DException; 4 import com.daffodilwoods.daffodildb.utils.field.FieldBase; 5 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference; 6 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator; 7 import com.daffodilwoods.daffodildb.server.sql99.common.GeneralPurposeStaticClass; 8 import com.daffodilwoods.database.utility.*; 9 import com.daffodilwoods.daffodildb.utils.GetByteComparator; 10 import java.util.Arrays ; 11 12 23 public abstract class AnyWordsAbstractIterator extends FTException { 24 25 29 protected boolean direction; 30 33 protected int iterIndex = -1; 34 37 protected int state = -1; 38 39 public Object getColumnValues() throws DException { 40 return fullTextIndex[iterIndex].getColumnValues(); 41 } 42 43 public Object getColumnValues(int[] columns) throws DException { 44 return fullTextIndex[iterIndex].getColumnValues(columns); 45 } 46 47 public Object getColumnValues(_Reference[] references) throws DException { 48 Object [] fbsToRet = new Object [references.length]; 49 for (int i = 0; i < references.length; i++) { 50 fbsToRet[i] = getColumnValues(references[i]); 51 } 52 return fbsToRet; 53 } 54 55 public Object getColumnValues(_Reference reference) throws DException { 56 return fullTextIndex[iterIndex].getColumnValues(reference); 57 } 58 59 public FieldBase field(_Reference reference) throws com.daffodilwoods.database.resource.DException { 60 return fullTextIndex[iterIndex].field(reference); 61 } 62 63 public FieldBase[] fields(_Reference[] references) throws com.daffodilwoods.database.resource.DException { 64 FieldBase[] fbsToRet = new FieldBase[references.length]; 65 for (int i = 0; i < references.length; i++) { 66 fbsToRet[i] = field(references[i]); 67 } 68 return fbsToRet; 69 } 70 71 public FieldBase[] fields(int[] columns) throws com.daffodilwoods.database.resource.DException { 72 return (FieldBase[]) getColumnValues(columns); 73 } 74 75 81 public int compare(Object ob1, Object ob2 ) throws DException{ 82 return GetByteComparator.sameComparator.compare(ob1,ob2); 83 } 84 85 91 92 protected boolean allFalse() throws DException{ 93 for (int i = 0; i < fullTextIndex.length; i++) { 94 try { 95 fullTextIndex[i].getColumnValues(documentIdColumn); 96 } 97 catch (DException ex) { 98 continue; 99 } 100 return false; 101 } 102 return true; 103 } 104 105 113 protected boolean allSameWithSmallest() throws DException { 114 Object min = null; 115 boolean allSame = true; 116 for (int i = 0; i < fullTextIndex.length; i++) { 117 Object nValue = null; 118 try { 119 nValue = fullTextIndex[i].getColumnValues(documentIdColumn); 120 } 121 catch (DException ex) { 122 allSame = false; 123 continue; 124 } 125 if (min == null) { 126 min = nValue; 127 iterIndex = i; 128 continue; 129 } 130 int cmp = compare(nValue, min); 131 if(cmp < 0) { 132 iterIndex = i; 133 min = nValue; 134 allSame = false; 135 } 136 else if( cmp > 0) { 137 allSame = false; 138 } 139 } 140 if(allSame){ 141 } 142 else{ 143 } 144 return allSame; 145 } 146 147 148 156 protected boolean allSameWithLargest() throws DException { 157 Object max = null; 158 boolean allSame = true; 159 for (int i = 0; i < fullTextIndex.length; i++) { 160 Object nValue = null; 161 try { 162 nValue = fullTextIndex[i].getColumnValues(documentIdColumn); 163 } 164 catch (DException ex) { 165 allSame = false; 166 continue; 167 } 168 if (max == null) { 169 max = nValue; 170 iterIndex = i; 171 continue; 172 } 173 int cmp = compare(nValue, max); 174 if(cmp > 0) { 175 iterIndex = i; 176 max = nValue; 177 allSame = false; 178 } 179 else if( cmp < 0) { 180 allSame = false; 181 } 182 } 183 if(allSame){ 184 } 185 else{ 186 } 187 return allSame; 188 } 189 190 197 protected boolean[] getSmallest() throws DException { 198 Object minValue = null; 199 int len = fullTextIndex.length; 200 boolean[] isMinimum = new boolean[len]; 201 for (int i = 0; i < fullTextIndex.length; i++) { 202 Object nValue = null; 203 try { 204 nValue = fullTextIndex[i].getColumnValues(documentIdColumn); 205 } 206 catch (Exception ex) { 207 continue; 208 } 209 if (minValue == null) { 210 minValue = nValue; 211 isMinimum[i] = true; 212 continue; 213 } 214 int cmp = compare(nValue, minValue); 215 if(cmp < 0){ 216 java.util.Arrays.fill(isMinimum, false); 217 minValue = nValue; 218 isMinimum[i] = true; 219 } 220 else if(cmp == 0){ 221 isMinimum[i] = true; 222 } 223 } 224 return isMinimum; 225 } 226 227 234 protected boolean[] getLargest() throws DException { 235 Object maxValue = null; 236 int len = fullTextIndex.length; 237 boolean[] isMaximum = new boolean[len]; 238 for (int i = 0; i < fullTextIndex.length; i++) { 239 Object nValue = null; 240 try { 241 nValue = fullTextIndex[i].getColumnValues(documentIdColumn); 242 } 243 catch (Exception ex) { 244 continue; 245 } 246 if (maxValue == null) { 247 maxValue = nValue; 248 isMaximum[i] = true; 249 continue; 250 } 251 int cmp = compare(nValue, maxValue); 252 if(cmp > 0){ 253 java.util.Arrays.fill(isMaximum, false); 254 maxValue = nValue; 255 isMaximum[i] = true; 256 } 257 else if(cmp == 0){ 258 isMaximum[i] = true; 259 } 260 } 261 return isMaximum; 262 } 263 } 264 | Popular Tags |