File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions
unsafe/src/test/java/org/apache/spark/unsafe/string Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ private class StringUnsafeColumnWriter private() extends UnsafeColumnWriter[UTF8
8787 numBytes
8888 )
8989 row.setLong(columnNumber, appendCursor)
90- 8 + (( numBytes / 8 ) + ( if (numBytes % 8 == 0 ) 0 else 1 )) * 8
90+ 8 + ByteArrayMethods .roundNumberOfBytesToNearestWord( numBytes)
9191 }
9292}
9393private object StringUnsafeColumnWriter extends StringUnsafeColumnWriter
Original file line number Diff line number Diff line change 1717
1818package org .apache .spark .unsafe .string ;
1919
20+ import java .io .UnsupportedEncodingException ;
21+ import java .lang .String ;
22+
2023import org .junit .Assert ;
2124import org .junit .Test ;
2225
2326import org .apache .spark .unsafe .memory .MemoryLocation ;
2427import org .apache .spark .unsafe .memory .MemoryBlock ;
25- import java . lang . String ;
28+ import org . apache . spark . unsafe . array . ByteArrayMethods ;
2629
2730public class TestUTF8String {
2831
2932 @ Test
30- public void toStringTest () {
33+ public void toStringTest () throws UnsupportedEncodingException {
3134 final String javaStr = "Hello, World!" ;
3235 final byte [] javaStrBytes = javaStr .getBytes ();
33- final int paddedSizeInWords = javaStrBytes .length / 8 + (javaStrBytes .length % 8 == 0 ? 0 : 1 );
36+ final int paddedSizeInWords =
37+ ByteArrayMethods .roundNumberOfBytesToNearestWord (javaStrBytes .length );
3438 final MemoryLocation memory = MemoryBlock .fromLongArray (new long [paddedSizeInWords ]);
3539 final int bytesWritten = UTF8StringMethods .createFromJavaString (
3640 memory .getBaseObject (),
You can’t perform that action at this time.
0 commit comments