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.database.utility.*; 7 import com.daffodilwoods.daffodildb.utils.field.*; 8 import com.daffodilwoods.daffodildb.utils.*; 9 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*; 10 11 23 24 public abstract class RankSuccesiveLocation extends RankAbstractNavigation { 25 26 34 public boolean alignSuccesiveLocationForward(Object [] fpkValues, int startIndex) throws DException { 35 Object value = locationIndex[startIndex].getColumnValues(locationColumn); 36 int satisfied; 37 do { 38 satisfied = 0; 39 for (int i = 0; i < locationIndex.length; i++) { 40 if (i == startIndex) { 41 satisfied++; 42 continue; 43 } 44 Object cValue = locationIndex[i].getColumnValues(locationColumn); 45 int cmp = compare(cValue, value); 46 if (cmp == i - startIndex) { 47 satisfied++; 48 } 49 else if (cmp > i - startIndex) { 50 startIndex = i; 51 satisfied = 1; 52 value = cValue; 53 break; 54 } 55 else { 56 long longVal = ( (Long ) ( (FieldLong) value).getObject()).longValue() + 57 (i - startIndex); 58 FieldBase val = FieldUtility.getField(Datatype.LONG, new Long (longVal)); 59 if (!locationIndex[i].seekFromTopRelative(new Object [] {fpkValues[i], val})) { 60 return false; 61 } 62 cValue = locationIndex[i].getColumnValues(locationColumn); 63 cmp = compare(cValue, value); 64 if (cmp == i - startIndex) 65 satisfied++; 66 else { 67 startIndex = i; 68 satisfied = 1; 69 value = cValue; 70 break; 71 } 72 } 73 } 74 if(satisfied == locationIndex.length) 75 return true; 76 }while (true); 77 } 78 79 87 public boolean alignSuccesiveLocationBackward(Object [] fpkValues, int startIndex) throws DException { 88 Object value = locationIndex[startIndex].getColumnValues(locationColumn); 89 int satisfied; 90 do { 91 satisfied = 0; 92 for (int i = locationIndex.length-1 ; i >= 0 ; i--) { 93 if (i == startIndex) { 94 satisfied++; 95 continue; 96 } 97 Object cValue = locationIndex[i].getColumnValues(locationColumn); 98 int cmp = compare(cValue, value); 99 if (cmp == i - startIndex) { 100 satisfied++; 101 } 102 else if (cmp < i - startIndex) { 103 startIndex = i; 104 satisfied = 1; 105 value = cValue; 106 break; 107 } 108 else { 109 long longVal = ( (Long ) ( (FieldLong) value).getObject()).longValue() + 110 (i - startIndex); 111 FieldBase val = FieldUtility.getField(Datatype.LONG, new Long (longVal)); 112 if (!locationIndex[i].seekFromBottomRelative(new Object [] {fpkValues[i], val})) { 113 return false; 114 } 115 cValue = locationIndex[i].getColumnValues(locationColumn); 116 cmp = compare(cValue, value); 117 if (cmp == i - startIndex) 118 satisfied++; 119 else { 120 startIndex = i; 121 satisfied = 1; 122 value = cValue; 123 break; 124 } 125 } 126 } 127 if(satisfied == locationIndex.length) 128 return true; 129 }while (true); 130 } 131 } 132 | Popular Tags |