[ 
https://issues.apache.org/jira/browse/PHOENIX-1863?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14501498#comment-14501498
 ] 

James Taylor commented on PHOENIX-1863:
---------------------------------------

[~Dumindux] - the test would confirm the correct order (based on the byte[] 
produced after calling pad()) of a list of inputs and confirm that the order is 
reversed when the inputs are SortOrder.DESC.
{code}
String[] inputs = {"foo","foo!","fooA","foo~"};
Collections.sort(inputs);
List<byte[] ascOrderedInputs = Lists.newListWithExpectedSize(inputs.length);
SortOrder sortOrder = SortOrder.ASC;
for (String input : inputs) {
    LiteralExpression expr = LiteralExpression.newConstant(value, dataType, 
sortOrder);
    ImmutableBytesPtr ptr = new ImmutableBytesPtr(expr.getBytes());
    dataType.pad(ptr, length, sortOrder);
    ascOrderedInputs.add(ptr.copyBytes());
}
Collections.sort(ascOrderedInputs, Bytes.BYTES_COMPARATOR);
// Confirm ascOrderedInputs are in the same order as the inputs

List<byte[] descOrderedInputs = Lists.newListWithExpectedSize(inputs.length);
SortOrder sortOrder = SortOrder.DESC;
for (String input : inputs) {
    LiteralExpression expr = LiteralExpression.newConstant(value, dataType, 
sortOrder);
    ImmutableBytesPtr ptr = new ImmutableBytesPtr(expr.getBytes());
    dataType.pad(ptr, length, sortOrder);
    descOrderedInputs.add(ptr.copyBytes());
}
// Confirm descOrderedInputs are in the reverse order of the inputs
{code}



> Create unit test for inverting the pad character
> ------------------------------------------------
>
>                 Key: PHOENIX-1863
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1863
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: James Taylor
>            Assignee: Dumindu Buddhika
>             Fix For: 5.0.0, 4.4.0
>
>         Attachments: PHOENIX-1863.patch
>
>
> It'd be good to have unit tests that test the necessity of inverting the pad 
> character (the parent JIRA).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to