Skip to content

Commit

Permalink
remove ColumnVector.anyNullsSet
Browse files Browse the repository at this point in the history
  • Loading branch information
cloud-fan committed Dec 14, 2017
1 parent 7d8e2ca commit c4d9a41
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public int numNulls() {
return accessor.getNullCount();
}

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

@Override
public void close() {
if (childColumns != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ public abstract class ColumnVector implements AutoCloseable {
*/
public abstract int numNulls();

/**
* Returns true if any of the nulls indicator are set for this column. This can be used
* as an optimization to prevent setting nulls.
*/
public abstract boolean anyNullsSet();

/**
* Returns whether the value at rowId is NULL.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public void putNotNull(int rowId) {
public void putNull(int rowId) {
Platform.putByte(null, nulls + rowId, (byte) 1);
++numNulls;
anyNullsSet = true;
}

@Override
Expand All @@ -119,13 +118,12 @@ public void putNulls(int rowId, int count) {
for (int i = 0; i < count; ++i, ++offset) {
Platform.putByte(null, offset, (byte) 1);
}
anyNullsSet = true;
numNulls += count;
}

@Override
public void putNotNulls(int rowId, int count) {
if (!anyNullsSet) return;
if (numNulls == 0) 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 @@ -107,21 +107,19 @@ public void putNotNull(int rowId) {
public void putNull(int rowId) {
nulls[rowId] = (byte)1;
++numNulls;
anyNullsSet = true;
}

@Override
public void putNulls(int rowId, int count) {
for (int i = 0; i < count; ++i) {
nulls[rowId + i] = (byte)1;
}
anyNullsSet = true;
numNulls += count;
}

@Override
public void putNotNulls(int rowId, int count) {
if (!anyNullsSet) return;
if (numNulls == 0) 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 @@ -54,12 +54,11 @@ public void reset() {
((WritableColumnVector) c).reset();
}
}
numNulls = 0;
elementsAppended = 0;
if (anyNullsSet) {
if (numNulls > 0) {
putNotNulls(0, capacity);
anyNullsSet = false;
}
numNulls = 0;
}

@Override
Expand Down Expand Up @@ -104,9 +103,6 @@ private void throwUnsupportedException(int requiredCapacity, Throwable cause) {
@Override
public int numNulls() { return numNulls; }

@Override
public boolean anyNullsSet() { return anyNullsSet; }

/**
* Returns the dictionary Id for rowId.
*
Expand Down Expand Up @@ -640,12 +636,6 @@ public final int appendStruct(boolean isNull) {
*/
protected int numNulls;

/**
* True if there is at least one NULL byte set. This is an optimization for the writer, to skip
* having to clear NULL bits.
*/
protected boolean anyNullsSet;

/**
* True if this column's values are fixed. This means the column values never change, even
* across resets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class ArrowColumnVectorSuite extends SparkFunSuite {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

idx = column.elementsAppended

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

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

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

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

reference.zipWithIndex.foreach { v =>
Expand Down

0 comments on commit c4d9a41

Please sign in to comment.