kadirozde commented on a change in pull request #1021:
URL: https://github.com/apache/phoenix/pull/1021#discussion_r545359432
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
##########
@@ -694,16 +696,22 @@ private Void addDataColInfo(final PTable dataTable,
Expression expression) {
output.write(ptr.get(), ptr.getOffset(),
ptr.getLength());
}
}
+
if (!indexColumnType.isFixedWidth()) {
-
output.writeByte(SchemaUtil.getSeparatorByte(rowKeyOrderOptimizable,
ptr.getLength() == 0, isIndexColumnDesc ? SortOrder.DESC : SortOrder.ASC));
+ byte sepByte =
SchemaUtil.getSeparatorByte(rowKeyOrderOptimizable, ptr.getLength() == 0,
isIndexColumnDesc ? SortOrder.DESC : SortOrder.ASC);
+ output.writeByte(sepByte);
+ trailingVariableWitdthColumnNum++;
+ } else {
+ trailingVariableWitdthColumnNum = 0;
}
}
- int length = stream.size();
- int minLength = length - maxTrailingNulls;
byte[] indexRowKey = stream.getBuffer();
// Remove trailing nulls
- while (length > minLength && indexRowKey[length-1] ==
QueryConstants.SEPARATOR_BYTE) {
+ int length = stream.size();
+ int minLength = length - maxTrailingNulls;
+ while (trailingVariableWitdthColumnNum > 0 && length > minLength
&& indexRowKey[length-1] == QueryConstants.SEPARATOR_BYTE) {
Review comment:
The existing code does not eliminate the separator if the data type is
not nullable. It not clear why. The actual bug is in the calculation of
maxTrailingNulls with view indexes. So, in order not to impact some other
cases, we should keep it here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]