1 package com.daffodilwoods.daffodildb.server.sql99.fulltext.dql.iterator; 2 3 import com.daffodilwoods.database.resource.DException; 4 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator; 5 import com.daffodilwoods.daffodildb.server.sql99.common.GeneralPurposeStaticClass; 6 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference; 7 import com.daffodilwoods.database.utility.*; 8 import com.daffodilwoods.daffodildb.utils.field.FieldBase; 9 10 23 24 public class Rank3FTIterator extends RankAbstractNavigation { 25 26 public Rank3FTIterator(_Iterator[] fullTextIndex0, _Iterator[] locationIndex0,_Reference[] fpkReference0,FieldBase[] keyWords0) throws DException { 27 fullTextIndex = fullTextIndex0; 28 locationIndex = locationIndex0; 29 pkColumn = GeneralPurposeStaticClass.getColumnDetails("pk"); 30 documentIdColumn = GeneralPurposeStaticClass.getColumnDetails("documentId"); 31 locationColumn = GeneralPurposeStaticClass.getColumnDetails("location"); 32 fpkReference = fpkReference0; 33 keyWords = keyWords0; 34 } 35 36 43 public boolean alignLocationForward() throws DException { 44 Object [] fpkValues = setValues(); 45 setLocationIteratorsForward(); 46 Object value = locationIndex[0].getColumnValues(locationColumn); 47 for (int ii = 1; ii < locationIndex.length; ii++) { 48 if(!locationIndex[ii].seekFromTopRelative(new Object [] {fpkValues[ii], value})) 49 return true; 50 value = locationIndex[ii].getColumnValues(locationColumn); 51 } 52 return false; 53 } 54 61 public boolean alignLocationBackward() throws DException { 62 Object [] fpkValues = setValues(); 63 setLocationIteratorsBackward(); 64 int length = locationIndex.length; 65 Object value = locationIndex[length - 1].getColumnValues(locationColumn); 66 for (int ii = length - 2; ii >= 0 ; ii--) { 67 if(!locationIndex[ii].seekFromBottomRelative(new Object [] {fpkValues[ii], value})) 68 return true; 69 value = locationIndex[ii].getColumnValues(locationColumn); 70 } 71 return false; 72 } 73 74 81 private void setLocationIteratorsForward() throws DException { 82 if(!locationIndex[0].first()) 83 throw new DException("DSE0", new Object []{"Illegal happening"}); 84 for (int i = 1; i < locationIndex.length; i++) { if(locationIndex[i].first()) 86 locationIndex[i].previous(); 87 } 88 } 89 90 97 private void setLocationIteratorsBackward() throws DException{ 98 int length = locationIndex.length; 99 if(!locationIndex[length-1].last()) 100 throw new DException("DSE0", new Object []{"Illegal happening"}); 101 for (int i = length - 2 ; i >= 0; i--) { if(locationIndex[i].last()) 103 locationIndex[i].next(); 104 } 105 } 106 107 public void setSpecificUnderlyingReferences(_Reference[] specificUnderlyingReferences) throws DException{ 108 } 109 110 public String toString(){ 111 String str = "Rank3FTIterator"; 112 str += "[FullTextIndex"+fullTextIndex[0] 113 + "][locationIndex"+locationIndex[0] 114 +"]"; 115 return str; 116 } 117 } 118 | Popular Tags |