Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/6959#discussion_r33198282
--- Diff:
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/UnsafeRow.java
---
@@ -230,27 +237,32 @@ public int size() {
}
@Override
- public StructType schema() {
- return schema;
- }
-
- @Override
public Object get(int i) {
assertIndexIsValid(i);
- assert (schema != null) : "Schema must be defined when calling generic
get() method";
- final DataType dataType = schema.fields()[i].dataType();
- // UnsafeRow is only designed to be invoked by internal code, which
only invokes this generic
- // get() method when trying to access UTF8String-typed columns. If we
refactor the codebase to
- // separate the internal and external row interfaces, then internal
code can fetch strings via
- // a new getUTF8String() method and we'll be able to remove this
method.
if (isNullAt(i)) {
return null;
- } else if (dataType == StringType) {
- return getUTF8String(i);
- } else if (dataType == BinaryType) {
- return getBinary(i);
+ }
+ long v = PlatformDependent.UNSAFE.getLong(baseObject,
getFieldOffset(i));
+ if (v <= 0) {
+ int idx = (int)-v;
+ return pool.get(idx);
} else {
- throw new UnsupportedOperationException();
+ boolean is_string = (v >> (OFFSET_BITS * 2)) > 0;
+ int offset = (int)((v >> OFFSET_BITS) & Integer.MAX_VALUE);
+ int size = (int)(v & Integer.MAX_VALUE);
+ final byte[] bytes = new byte[size];
+ PlatformDependent.copyMemory(
+ baseObject,
--- End diff --
I think these lines are over-indented.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]