Github user kiszk commented on a diff in the pull request: https://github.com/apache/spark/pull/19222#discussion_r172393439 --- Diff: common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java --- @@ -119,24 +121,33 @@ public static UTF8String blankString(int length) { return fromBytes(spaces); } - protected UTF8String(Object base, long offset, int numBytes) { + protected UTF8String(byte[] bytes, long offset, int numBytes) { + this(new ByteArrayMemoryBlock(bytes, offset, numBytes)); + } + + protected UTF8String(MemoryBlock base) { this.base = base; - this.offset = offset; - this.numBytes = numBytes; + if (base != null) { + if ((long) Integer.MAX_VALUE < base.size()) { + throw new ArrayIndexOutOfBoundsException( + "MemoryBlock.size " + base.size() + " should be less than " + Integer.MAX_VALUE); + } + this.numBytes = (int) base.size(); + } } // for serialization public UTF8String() { - this(null, 0, 0); + this(null); } /** * Writes the content of this string into a memory address, identified by an object and an offset. * The target memory address must already been allocated, and have enough space to hold all the * bytes in this string. */ - public void writeToMemory(Object target, long targetOffset) { - Platform.copyMemory(base, offset, target, targetOffset, numBytes); + public void writeToMemory(byte[] target, long targetOffset) { --- End diff -- I see for now. We expect that the type of this parameter would be `MemoryBlock` in near future.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org