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