Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/20850#discussion_r178025468
--- Diff:
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/codegen/UnsafeWriter.java
---
@@ -17,17 +17,86 @@
package org.apache.spark.sql.catalyst.expressions.codegen;
import org.apache.spark.sql.types.Decimal;
+import org.apache.spark.unsafe.Platform;
+import org.apache.spark.unsafe.array.ByteArrayMethods;
import org.apache.spark.unsafe.types.CalendarInterval;
import org.apache.spark.unsafe.types.UTF8String;
/**
* Base class for writing Unsafe* structures.
*/
public abstract class UnsafeWriter {
+ // Keep internal buffer holder
+ protected final BufferHolder holder;
+
+ // The offset of the global buffer where we start to write this
structure.
+ protected int startingOffset;
+
+ protected UnsafeWriter(BufferHolder holder) {
+ this.holder = holder;
+ }
+
+ /**
+ * Accessor methods are delegated from BufferHolder class
+ */
+ public final BufferHolder getBufferHolder() {
+ return holder;
+ }
+
+ public final byte[] buffer() {
+ return holder.buffer();
+ }
+
+ public final void reset() {
+ holder.reset();
+ }
+
+ public final int totalSize() {
+ return holder.totalSize();
+ }
+
+ public final void grow(int neededSize) {
+ holder.grow(neededSize);
+ }
+
+ public final int cursor() {
+ return holder.getCursor();
+ }
+
+ public final void incrementCursor(int val) {
+ holder.incrementCursor(val);
+ }
+
+ public abstract void setOffsetAndSizeFromMark(int ordinal, int mark);
--- End diff --
I don't actually. I think this should be the responsibility of the writer,
and we are doing the same thing in three different places.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]