Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public void close() {

}

@Override
public boolean hasNull() {
return !baseData.noNulls;
}

@Override
public int numNulls() {
if (baseData.isRepeating) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void putNulls(int rowId, int count) {

@Override
public void putNotNulls(int rowId, int count) {
if (numNulls == 0) return;
if (!hasNull()) return;
long offset = nulls + rowId;
for (int i = 0; i < count; ++i, ++offset) {
Platform.putByte(null, offset, (byte) 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void putNulls(int rowId, int count) {

@Override
public void putNotNulls(int rowId, int count) {
if (numNulls == 0) return;
if (!hasNull()) return;
for (int i = 0; i < count; ++i) {
nulls[rowId + i] = (byte)0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public void reset() {
elementsAppended = 0;
if (numNulls > 0) {
putNotNulls(0, capacity);
numNulls = 0;
}
numNulls = 0;
}

@Override
Expand Down Expand Up @@ -102,6 +102,11 @@ private void throwUnsupportedException(int requiredCapacity, Throwable cause) {
throw new RuntimeException(message, cause);
}

@Override
public boolean hasNull() {
return numNulls > 0;
}

@Override
public int numNulls() { return numNulls; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public final class ArrowColumnVector extends ColumnVector {
private final ArrowVectorAccessor accessor;
private ArrowColumnVector[] childColumns;

@Override
public boolean hasNull() {
return accessor.getNullCount() > 0;
}

@Override
public int numNulls() {
return accessor.getNullCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public abstract class ColumnVector implements AutoCloseable {
@Override
public abstract void close();

/**
* Returns true if this column vector contains any null values.
*/
public abstract boolean hasNull();

/**
* Returns the number of nulls in this column vector.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === BooleanType)
assert(columnVector.hasNull)
assert(columnVector.numNulls === 1)

(0 until 10).foreach { i =>
Expand Down Expand Up @@ -69,6 +70,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === ByteType)
assert(columnVector.hasNull)
assert(columnVector.numNulls === 1)

(0 until 10).foreach { i =>
Expand Down Expand Up @@ -96,6 +98,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === ShortType)
assert(columnVector.hasNull)
assert(columnVector.numNulls === 1)

(0 until 10).foreach { i =>
Expand Down Expand Up @@ -123,6 +126,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === IntegerType)
assert(columnVector.hasNull)
assert(columnVector.numNulls === 1)

(0 until 10).foreach { i =>
Expand Down Expand Up @@ -150,6 +154,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === LongType)
assert(columnVector.hasNull)
assert(columnVector.numNulls === 1)

(0 until 10).foreach { i =>
Expand Down Expand Up @@ -177,6 +182,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === FloatType)
assert(columnVector.hasNull)
assert(columnVector.numNulls === 1)

(0 until 10).foreach { i =>
Expand Down Expand Up @@ -204,6 +210,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === DoubleType)
assert(columnVector.hasNull)
assert(columnVector.numNulls === 1)

(0 until 10).foreach { i =>
Expand Down Expand Up @@ -232,6 +239,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === StringType)
assert(columnVector.hasNull)
assert(columnVector.numNulls === 1)

(0 until 10).foreach { i =>
Expand All @@ -258,6 +266,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === BinaryType)
assert(columnVector.hasNull)
assert(columnVector.numNulls === 1)

(0 until 10).foreach { i =>
Expand Down Expand Up @@ -300,6 +309,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === ArrayType(IntegerType))
assert(columnVector.hasNull)
assert(columnVector.numNulls === 1)

val array0 = columnVector.getArray(0)
Expand Down Expand Up @@ -344,6 +354,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === schema)
assert(!columnVector.hasNull)
assert(columnVector.numNulls === 0)

val row0 = columnVector.getStruct(0)
Expand Down Expand Up @@ -396,6 +407,7 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

val columnVector = new ArrowColumnVector(vector)
assert(columnVector.dataType === schema)
assert(columnVector.hasNull)
assert(columnVector.numNulls === 1)

val row0 = columnVector.getStruct(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,41 +66,49 @@ class ColumnarBatchSuite extends SparkFunSuite {
column =>
val reference = mutable.ArrayBuffer.empty[Boolean]
var idx = 0
assert(!column.hasNull)
assert(column.numNulls() == 0)

column.appendNotNull()
reference += false
assert(!column.hasNull)
assert(column.numNulls() == 0)

column.appendNotNulls(3)
(1 to 3).foreach(_ => reference += false)
assert(!column.hasNull)
assert(column.numNulls() == 0)

column.appendNull()
reference += true
assert(column.hasNull)
assert(column.numNulls() == 1)

column.appendNulls(3)
(1 to 3).foreach(_ => reference += true)
assert(column.hasNull)
assert(column.numNulls() == 4)

idx = column.elementsAppended

column.putNotNull(idx)
reference += false
idx += 1
assert(column.hasNull)
assert(column.numNulls() == 4)

column.putNull(idx)
reference += true
idx += 1
assert(column.hasNull)
assert(column.numNulls() == 5)

column.putNulls(idx, 3)
reference += true
reference += true
reference += true
idx += 3
assert(column.hasNull)
assert(column.numNulls() == 8)

column.putNotNulls(idx, 4)
Expand All @@ -109,6 +117,7 @@ class ColumnarBatchSuite extends SparkFunSuite {
reference += false
reference += false
idx += 4
assert(column.hasNull)
assert(column.numNulls() == 8)

reference.zipWithIndex.foreach { v =>
Expand Down