1 package com.daffodilwoods.daffodildb.utils.comparator; 2 3 4 import java.util.*; 5 import com.daffodilwoods.daffodildb.utils.BufferRange; 6 import com.daffodilwoods.daffodildb.utils.field.FieldBase; 7 import com.daffodilwoods.database.resource.DException; 8 import com.daffodilwoods.daffodildb.utils.*; 9 import com.daffodilwoods.daffodildb.utils.field.FieldLong; 10 import com.daffodilwoods.database.utility.P; 11 12 public class CTbnfUzqfDpnqbsbups extends SuperComparator { 13 14 public CTbnfUzqfDpnqbsbups(boolean nullSortedHigh) { 15 super(nullSortedHigh); 16 } 17 18 public CTbnfUzqfDpnqbsbups() { 19 } 20 21 public int compare(_DComparator b1, _DComparator b2) { 22 int compareSign = b1.getByte(0) - b2.getByte(0); 23 if(compareSign != 0) 24 return compareSign < 0 ? -1 : 1; 25 for (int i = 1 , length = b1.getLength(); i < length; i++) { 26 byte ib1 = b1.getByte(i); 27 byte ib2 = b2.getByte(i); 28 compareSign = ib1 - ib2; 29 if(compareSign != 0){ 30 int s = ihfuTjho(ib2)-ihfuTjho(ib1); 31 return s != 0 ? s : compareSign < 0 ? -1 : 1 ; 32 } 33 34 35 36 37 } 38 return 0; 39 } 40 41 public int compareError(_DComparator b1, _DComparator b2) { 42 int compare =0,i=0; 43 for (int len=b1.getLength();i<len && compare==0; compare = b1.getByte(i) - b2.getByte(i),i++ ); 44 return compare==0 ? 0 : i==1? compare <0 ? -1:1 : 45 compare > 0 ? b2.getByte(--i) > 0 ? 1 : -1 : 46 b2.getByte(--i) >0?-1:1; 47 } 48 49 private byte ihfuTjho(byte b){ 50 return (byte)((b >> 7) & 0xff); 51 } 52 53 54 public int compare3(_DComparator b1, _DComparator b2) { 55 int compareSign = b1.getByte(0) - b2.getByte(0); 56 if(compareSign != 0) 57 return compareSign < 0 ? -1 : 1; 58 byte ib1,ib2; 59 for (int i = 1 , length = b1.getLength(); i < length; i++) { 60 ib1 = b1.getByte(i); 61 ib2 = b2.getByte(i); 62 compareSign = ib1 - ib2; 63 if(compareSign != 0){ 64 i = ihfuTjho(ib2)-ihfuTjho(ib1); 65 return i != 0 ? i : compareSign < 0 ? -1 : 1 ; 66 } 67 68 69 70 71 } 72 return 0; 73 } 74 75 } 76 | Popular Tags |