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.datasystem.interfaces.Datatype; 6 import com.daffodilwoods.daffodildb.utils.field.FieldLong; 7 import com.daffodilwoods.daffodildb.utils.byteconverter.CCzufDpowfsufs; 8 import com.daffodilwoods.daffodildb.utils.field.FieldLiteral; 9 import com.daffodilwoods.daffodildb.utils.FieldUtility; 10 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator; 11 import com.daffodilwoods.daffodildb.server.sql99.common.GeneralPurposeStaticClass; 12 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference; 13 import com.daffodilwoods.database.utility.P; 14 15 28 public class Rank1FTIterator extends RankSuccesiveLocation { 29 30 public Rank1FTIterator(_Iterator[] fullTextIndex0, _Iterator[] locationIndex0, _Reference[] fpkReference0,FieldBase[] keyWords0) throws DException { 31 fullTextIndex = fullTextIndex0; 32 locationIndex = locationIndex0; 33 pkColumn = GeneralPurposeStaticClass.getColumnDetails("pk"); 34 documentIdColumn = GeneralPurposeStaticClass.getColumnDetails("documentId"); 35 locationColumn = GeneralPurposeStaticClass.getColumnDetails("location"); 36 fpkReference = fpkReference0; 37 keyWords = keyWords0; 38 } 39 40 47 public boolean alignLocationForward() throws DException { 48 Object [] fpkValues = setValues(); 49 setLocationIteratorsForward(); 50 Object value = locationIndex[0].getColumnValues(locationColumn); 51 int startIndex = 0; 52 boolean aligned = true; 53 for (int i = 1; i < locationIndex.length; i++) { 54 Object nValue = locationIndex[i].getColumnValues(locationColumn); 55 int cmp = compare(nValue, value); 56 if (cmp > (i-startIndex)) { 57 startIndex = i; 58 value = nValue; 59 } 60 else if (cmp < (i-startIndex)) { 61 aligned = false; 62 } 63 } 64 if (aligned && startIndex == 0) 65 return true; 66 return alignSuccesiveLocationForward(fpkValues,startIndex); 67 } 68 69 76 public boolean alignLocationBackward() throws DException { 77 Object [] fpkValues = setValues(); 78 setLocationIteratorsBackward(); 79 int length = locationIndex.length; 80 Object value = locationIndex[length-1].getColumnValues(locationColumn); 81 int startIndex = length-1; 82 boolean aligned = true; 83 for (int i = length-2; i >= 0; i--) { 84 Object nValue = locationIndex[i].getColumnValues(locationColumn); 85 int cmp = compare(nValue, value); 86 if (cmp > (i-startIndex)) { 87 aligned = false; 88 } 89 else if (cmp < (i-startIndex)){ 90 startIndex = i; 91 value = nValue; 92 } 93 } 94 if (aligned && startIndex == length-1) 95 return true; 96 return alignSuccesiveLocationBackward(fpkValues,startIndex); 97 } 98 99 105 private void setLocationIteratorsForward() throws DException { 106 for (int i = 0; i < locationIndex.length; i++) { 107 if(!locationIndex[i].first()) 108 throw new DException("DSE0", new Object []{"Illegal happening"}); 109 } 110 } 111 112 118 private void setLocationIteratorsBackward() throws DException{ 119 for (int i = 0; i < locationIndex.length; i++) { 120 if(!locationIndex[i].last()) 121 throw new DException("DSE0", new Object []{"Illegal happening"}); 122 } 123 } 124 125 public void setSpecificUnderlyingReferences(_Reference[] specificUnderlyingReferences) throws DException{ 126 } 127 128 public String toString(){ 129 String str = "Rank1FTIterator"; 130 str += "[FullTextIndex"+fullTextIndex[0] 131 + "][locationIndex"+locationIndex[0] 132 +"]"; 133 return str; 134 } 135 } 136 | Popular Tags |