@@ -88,21 +88,100 @@ public ByteBuffer decodeKeyValues(DataInputStream source,
88
88
// Having this as static is fine but if META is having DBE then we should
89
89
// change this.
90
90
public static int compareCommonRowPrefix (Cell left , Cell right , int rowCommonPrefix ) {
91
- return Bytes .compareTo (left .getRowArray (), left .getRowOffset () + rowCommonPrefix ,
92
- left .getRowLength () - rowCommonPrefix , right .getRowArray (),
93
- right .getRowOffset () + rowCommonPrefix , right .getRowLength () - rowCommonPrefix );
91
+ if (left instanceof ByteBufferExtendedCell ) {
92
+ ByteBufferExtendedCell bbLeft = (ByteBufferExtendedCell ) left ;
93
+ if (right instanceof ByteBufferExtendedCell ) {
94
+ ByteBufferExtendedCell bbRight = (ByteBufferExtendedCell ) right ;
95
+ return ByteBufferUtils .compareTo (bbLeft .getRowByteBuffer (),
96
+ bbLeft .getRowPosition () + rowCommonPrefix , left .getRowLength () - rowCommonPrefix ,
97
+ bbRight .getRowByteBuffer (), bbRight .getRowPosition () + rowCommonPrefix ,
98
+ right .getRowLength () - rowCommonPrefix );
99
+ } else {
100
+ return ByteBufferUtils .compareTo (bbLeft .getRowByteBuffer (),
101
+ bbLeft .getRowPosition () + rowCommonPrefix , left .getRowLength () - rowCommonPrefix ,
102
+ right .getRowArray (), right .getRowOffset () + rowCommonPrefix ,
103
+ right .getRowLength () - rowCommonPrefix );
104
+ }
105
+ } else {
106
+ if (right instanceof ByteBufferExtendedCell ) {
107
+ ByteBufferExtendedCell bbRight = (ByteBufferExtendedCell ) right ;
108
+ return ByteBufferUtils .compareTo (left .getRowArray (), left .getRowOffset () + rowCommonPrefix ,
109
+ left .getRowLength () - rowCommonPrefix , bbRight .getRowByteBuffer (),
110
+ bbRight .getRowPosition () + rowCommonPrefix , right .getRowLength () - rowCommonPrefix );
111
+ } else {
112
+ return Bytes .compareTo (left .getRowArray (), left .getRowOffset () + rowCommonPrefix ,
113
+ left .getRowLength () - rowCommonPrefix , right .getRowArray (),
114
+ right .getRowOffset () + rowCommonPrefix , right .getRowLength () - rowCommonPrefix );
115
+ }
116
+ }
94
117
}
95
118
96
119
public static int compareCommonFamilyPrefix (Cell left , Cell right , int familyCommonPrefix ) {
97
- return Bytes .compareTo (left .getFamilyArray (), left .getFamilyOffset () + familyCommonPrefix ,
98
- left .getFamilyLength () - familyCommonPrefix , right .getFamilyArray (),
99
- right .getFamilyOffset () + familyCommonPrefix , right .getFamilyLength () - familyCommonPrefix );
120
+ if (left instanceof ByteBufferExtendedCell ) {
121
+ ByteBufferExtendedCell bbLeft = (ByteBufferExtendedCell ) left ;
122
+ if (right instanceof ByteBufferExtendedCell ) {
123
+ ByteBufferExtendedCell bbRight = (ByteBufferExtendedCell ) right ;
124
+ return ByteBufferUtils .compareTo (bbLeft .getFamilyByteBuffer (),
125
+ bbLeft .getFamilyPosition () + familyCommonPrefix ,
126
+ left .getFamilyLength () - familyCommonPrefix , bbRight .getFamilyByteBuffer (),
127
+ bbRight .getFamilyPosition () + familyCommonPrefix ,
128
+ right .getFamilyLength () - familyCommonPrefix );
129
+ } else {
130
+ return ByteBufferUtils .compareTo (bbLeft .getFamilyByteBuffer (),
131
+ bbLeft .getFamilyPosition () + familyCommonPrefix ,
132
+ left .getFamilyLength () - familyCommonPrefix , right .getFamilyArray (),
133
+ right .getFamilyOffset () + familyCommonPrefix ,
134
+ right .getFamilyLength () - familyCommonPrefix );
135
+ }
136
+ } else {
137
+ if (right instanceof ByteBufferExtendedCell ) {
138
+ ByteBufferExtendedCell bbRight = (ByteBufferExtendedCell ) right ;
139
+ return ByteBufferUtils .compareTo (left .getFamilyArray (),
140
+ left .getFamilyOffset () + familyCommonPrefix , left .getFamilyLength () - familyCommonPrefix ,
141
+ bbRight .getFamilyByteBuffer (), bbRight .getFamilyPosition () + familyCommonPrefix ,
142
+ right .getFamilyLength () - familyCommonPrefix );
143
+ } else {
144
+ return Bytes .compareTo (left .getFamilyArray (), left .getFamilyOffset () + familyCommonPrefix ,
145
+ left .getFamilyLength () - familyCommonPrefix , right .getFamilyArray (),
146
+ right .getFamilyOffset () + familyCommonPrefix ,
147
+ right .getFamilyLength () - familyCommonPrefix );
148
+ }
149
+ }
100
150
}
101
151
102
152
public static int compareCommonQualifierPrefix (Cell left , Cell right , int qualCommonPrefix ) {
103
- return Bytes .compareTo (left .getQualifierArray (), left .getQualifierOffset () + qualCommonPrefix ,
104
- left .getQualifierLength () - qualCommonPrefix , right .getQualifierArray (),
105
- right .getQualifierOffset () + qualCommonPrefix , right .getQualifierLength () - qualCommonPrefix );
153
+ if (left instanceof ByteBufferExtendedCell ) {
154
+ ByteBufferExtendedCell bbLeft = (ByteBufferExtendedCell ) left ;
155
+ if (right instanceof ByteBufferExtendedCell ) {
156
+ ByteBufferExtendedCell bbRight = (ByteBufferExtendedCell ) right ;
157
+ return ByteBufferUtils .compareTo (bbLeft .getQualifierByteBuffer (),
158
+ bbLeft .getQualifierPosition () + qualCommonPrefix ,
159
+ left .getQualifierLength () - qualCommonPrefix , bbRight .getQualifierByteBuffer (),
160
+ bbRight .getQualifierPosition () + qualCommonPrefix ,
161
+ right .getQualifierLength () - qualCommonPrefix );
162
+ } else {
163
+ return ByteBufferUtils .compareTo (bbLeft .getQualifierByteBuffer (),
164
+ bbLeft .getQualifierPosition () + qualCommonPrefix ,
165
+ left .getQualifierLength () - qualCommonPrefix , right .getQualifierArray (),
166
+ right .getQualifierOffset () + qualCommonPrefix ,
167
+ right .getQualifierLength () - qualCommonPrefix );
168
+ }
169
+ } else {
170
+ if (right instanceof ByteBufferExtendedCell ) {
171
+ ByteBufferExtendedCell bbRight = (ByteBufferExtendedCell ) right ;
172
+ return ByteBufferUtils .compareTo (left .getQualifierArray (),
173
+ left .getQualifierOffset () + qualCommonPrefix ,
174
+ left .getQualifierLength () - qualCommonPrefix , bbRight .getQualifierByteBuffer (),
175
+ bbRight .getQualifierPosition () + qualCommonPrefix ,
176
+ right .getQualifierLength () - qualCommonPrefix );
177
+ } else {
178
+ return Bytes .compareTo (left .getQualifierArray (),
179
+ left .getQualifierOffset () + qualCommonPrefix ,
180
+ left .getQualifierLength () - qualCommonPrefix , right .getQualifierArray (),
181
+ right .getQualifierOffset () + qualCommonPrefix ,
182
+ right .getQualifierLength () - qualCommonPrefix );
183
+ }
184
+ }
106
185
}
107
186
108
187
protected static class SeekerState {
@@ -951,25 +1030,57 @@ private int compareTypeBytes(Cell key, Cell right) {
951
1030
return 0 ;
952
1031
}
953
1032
954
- private static int findCommonPrefixInRowPart (Cell left , Cell right , int rowCommonPrefix ) {
955
- return Bytes .findCommonPrefix (left .getRowArray (), right .getRowArray (),
956
- left .getRowLength () - rowCommonPrefix , right .getRowLength () - rowCommonPrefix ,
957
- left .getRowOffset () + rowCommonPrefix , right .getRowOffset () + rowCommonPrefix );
1033
+ // These findCommonPrefix* methods rely on the fact that keyOnlyKv is the "right" cell argument
1034
+ // and always on-heap
1035
+
1036
+ private static int findCommonPrefixInRowPart (Cell left , KeyValue .KeyOnlyKeyValue right ,
1037
+ int rowCommonPrefix ) {
1038
+ if (left instanceof ByteBufferExtendedCell ) {
1039
+ ByteBufferExtendedCell bbLeft = (ByteBufferExtendedCell ) left ;
1040
+ return ByteBufferUtils .findCommonPrefix (bbLeft .getRowByteBuffer (),
1041
+ bbLeft .getRowPosition () + rowCommonPrefix , left .getRowLength () - rowCommonPrefix ,
1042
+ right .getRowArray (), right .getRowOffset () + rowCommonPrefix ,
1043
+ right .getRowLength () - rowCommonPrefix );
1044
+ } else {
1045
+ return Bytes .findCommonPrefix (left .getRowArray (), right .getRowArray (),
1046
+ left .getRowLength () - rowCommonPrefix , right .getRowLength () - rowCommonPrefix ,
1047
+ left .getRowOffset () + rowCommonPrefix , right .getRowOffset () + rowCommonPrefix );
1048
+ }
958
1049
}
959
1050
960
- private static int findCommonPrefixInFamilyPart (Cell left , Cell right , int familyCommonPrefix ) {
961
- return Bytes .findCommonPrefix (left .getFamilyArray (), right .getFamilyArray (),
962
- left .getFamilyLength () - familyCommonPrefix , right .getFamilyLength () - familyCommonPrefix ,
963
- left .getFamilyOffset () + familyCommonPrefix , right .getFamilyOffset () + familyCommonPrefix );
1051
+ private static int findCommonPrefixInFamilyPart (Cell left , KeyValue .KeyOnlyKeyValue right ,
1052
+ int familyCommonPrefix ) {
1053
+ if (left instanceof ByteBufferExtendedCell ) {
1054
+ ByteBufferExtendedCell bbLeft = (ByteBufferExtendedCell ) left ;
1055
+ return ByteBufferUtils .findCommonPrefix (bbLeft .getFamilyByteBuffer (),
1056
+ bbLeft .getFamilyPosition () + familyCommonPrefix ,
1057
+ left .getFamilyLength () - familyCommonPrefix , right .getFamilyArray (),
1058
+ right .getFamilyOffset () + familyCommonPrefix ,
1059
+ right .getFamilyLength () - familyCommonPrefix );
1060
+ } else {
1061
+ return Bytes .findCommonPrefix (left .getFamilyArray (), right .getFamilyArray (),
1062
+ left .getFamilyLength () - familyCommonPrefix , right .getFamilyLength () - familyCommonPrefix ,
1063
+ left .getFamilyOffset () + familyCommonPrefix ,
1064
+ right .getFamilyOffset () + familyCommonPrefix );
1065
+ }
964
1066
}
965
1067
966
- private static int findCommonPrefixInQualifierPart (Cell left , Cell right ,
1068
+ private static int findCommonPrefixInQualifierPart (Cell left , KeyValue . KeyOnlyKeyValue right ,
967
1069
int qualifierCommonPrefix ) {
968
- return Bytes .findCommonPrefix (left .getQualifierArray (), right .getQualifierArray (),
969
- left .getQualifierLength () - qualifierCommonPrefix ,
970
- right .getQualifierLength () - qualifierCommonPrefix ,
971
- left .getQualifierOffset () + qualifierCommonPrefix ,
972
- right .getQualifierOffset () + qualifierCommonPrefix );
1070
+ if (left instanceof ByteBufferExtendedCell ) {
1071
+ ByteBufferExtendedCell bbLeft = (ByteBufferExtendedCell ) left ;
1072
+ return ByteBufferUtils .findCommonPrefix (bbLeft .getQualifierByteBuffer (),
1073
+ bbLeft .getQualifierPosition () + qualifierCommonPrefix ,
1074
+ left .getQualifierLength () - qualifierCommonPrefix , right .getQualifierArray (),
1075
+ right .getQualifierOffset () + qualifierCommonPrefix ,
1076
+ right .getQualifierLength () - qualifierCommonPrefix );
1077
+ } else {
1078
+ return Bytes .findCommonPrefix (left .getQualifierArray (), right .getQualifierArray (),
1079
+ left .getQualifierLength () - qualifierCommonPrefix ,
1080
+ right .getQualifierLength () - qualifierCommonPrefix ,
1081
+ left .getQualifierOffset () + qualifierCommonPrefix ,
1082
+ right .getQualifierOffset () + qualifierCommonPrefix );
1083
+ }
973
1084
}
974
1085
975
1086
private void moveToPrevious () {
0 commit comments