phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (PHOENIX-4237) Allow sorting on (Java) collation keys for non-English locales
Date Tue, 17 Oct 2017 19:33:01 GMT


ASF GitHub Bot commented on PHOENIX-4237:

Github user JamesRTaylor commented on a diff in the pull request:
    --- Diff: phoenix-core/src/test/java/org/apache/phoenix/expression/function/
    @@ -96,33 +96,35 @@ private static boolean testExpression(String inputStr, String localeIsoCode,
     		strengthLiteral = LiteralExpression.newConstant(null, PInteger.INSTANCE, sortOrder);
     		decompositionLiteral = LiteralExpression.newConstant(null, PInteger.INSTANCE, sortOrder);
     		boolean ret = testExpression(inputStrLiteral, localeIsoCodeLiteral, upperCaseBooleanLiteral,
    -				decompositionLiteral, new PhoenixArray(PInteger.INSTANCE, expectedCollationKeyBytes));
    +				decompositionLiteral, expectedCollationKeyBytesHex);
     		return ret;
     	private static boolean testExpression(LiteralExpression inputStrLiteral, LiteralExpression
     			LiteralExpression upperCaseBooleanLiteral, LiteralExpression strengthLiteral,
    -			LiteralExpression decompositionLiteral, PhoenixArray expectedCollationKeyByteArray)
throws SQLException {
    +			LiteralExpression decompositionLiteral, String expectedCollationKeyBytesHex) throws
Exception {
     		List<Expression> expressions = Lists.newArrayList((Expression) inputStrLiteral,
     				(Expression) localeIsoCodeLiteral, (Expression) upperCaseBooleanLiteral, (Expression)
     				(Expression) decompositionLiteral);
     		Expression collationKeyFunction = new CollationKeyFunction(expressions);
     		ImmutableBytesWritable ptr = new ImmutableBytesWritable();
     		boolean ret = collationKeyFunction.evaluate(null, ptr);
     		if (ret) {
    -			PhoenixArray result = (PhoenixArray) collationKeyFunction.getDataType().toObject(ptr,
    +			byte[] result = (byte[]) collationKeyFunction.getDataType().toObject(ptr,
    +			byte[] expectedCollationKeyByteArray = Hex.decodeHex(expectedCollationKeyBytesHex.toCharArray());
    --- End diff --
    Why not use assertArrayEquals here instead?

> Allow sorting on (Java) collation keys for non-English locales
> --------------------------------------------------------------
>                 Key: PHOENIX-4237
>                 URL:
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Shehzaad Nakhoda
>             Fix For: 4.12.0
> Strings stored via Phoenix can be composed from a subset of the entire set of Unicode
characters. The natural sort order for strings for different languages often differs from
the order dictated by the binary representation of the characters of these strings. Java provides
the idea of a Collator which given an input string and a (language) locale can generate a
Collation Key which can then be used to compare strings in that natural order.
> Salesforce has recently open-sourced grammaticus. IBM has open-sourced ICU4J some time
ago. These technologies can be combined to provide a robust new Phoenix function that can
be used in an ORDER BY clause to sort strings according to the user's locale.

This message was sent by Atlassian JIRA

View raw message