[
https://issues.apache.org/jira/browse/PHOENIX-1287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14372461#comment-14372461
]
Shuxiong Ye commented on PHOENIX-1287:
--------------------------------------
Hi [~jamestaylor],
I have a question about PVarchar.toObject. When we are trying to put a String
"" into ImmutableBytesWritable, and turn it back to String like the following
code, we get null back. Why not "" back here?
{code:java}
Expression srcExp = LiteralExpression.newConstant("", TYPE);
ImmutableBytesWritable ptr = new ImmutableBytesWritable();
boolean eval = srcExp.evaluate(null, ptr);
String result = (String)srcExp.getDataType().toObject(ptr);
System.out.println(result); // result = null, here
assertTrue("".equals(result));
{code}
In PVarchar.java,
{code:java}
@Override
public Object toObject(byte[] bytes, int offset, int length, PDataType
actualType,
SortOrder sortOrder, Integer maxLength, Integer scale) {
if (!actualType.isCoercibleTo(this)) {
throwConstraintViolationException(actualType, this);
}
if (length == 0) { // <---- here to set it null when length is zero
return null;
}
if (sortOrder == SortOrder.DESC) {
bytes = SortOrder.invert(bytes, offset, length);
offset = 0;
}
return Bytes.toString(bytes, offset, length); // <-- here we call
Bytes.toString from HBase, in which it will return "" when length is zero, and
null when bytes ptr is null.
}
{code}
> Use the joni byte[] regex engine in place of j.u.regex
> ------------------------------------------------------
>
> Key: PHOENIX-1287
> URL: https://issues.apache.org/jira/browse/PHOENIX-1287
> Project: Phoenix
> Issue Type: Bug
> Reporter: James Taylor
> Assignee: Shuxiong Ye
> Labels: gsoc2015
>
> See HBASE-11907. We'd get a 2x perf benefit plus it's driven off of byte[]
> instead of strings.Thanks for the pointer, [~apurtell].
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)