Skip to content

Commit

Permalink
Move reserveDictionaryIds logic into the parent class.
Browse files Browse the repository at this point in the history
  • Loading branch information
ueshin committed Aug 17, 2017
1 parent d2dda9c commit 2769b39
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,17 @@ public void setDictionary(Dictionary dictionary) {
/**
* Reserve a integer column for ids of dictionary.
*/
public abstract MutableColumnVector reserveDictionaryIds(int capacity);
public MutableColumnVector reserveDictionaryIds(int capacity) {
MutableColumnVector dictionaryIds = (MutableColumnVector) this.dictionaryIds;
if (dictionaryIds == null) {
dictionaryIds = reserveNewColumn(capacity, DataTypes.IntegerType);
this.dictionaryIds = dictionaryIds;
} else {
dictionaryIds.reset();
dictionaryIds.reserve(capacity);
}
return dictionaryIds;
}

/**
* Returns the underlying integer column for ids of dictionary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,22 +492,6 @@ public void loadBytes(ColumnVector.Array array) {
array.byteArrayOffset = 0;
}

/**
* Reserve a integer column for ids of dictionary.
*/
@Override
public OffHeapColumnVector reserveDictionaryIds(int capacity) {
OffHeapColumnVector dictionaryIds = (OffHeapColumnVector) this.dictionaryIds;
if (dictionaryIds == null) {
dictionaryIds = new OffHeapColumnVector(capacity, DataTypes.IntegerType);
this.dictionaryIds = dictionaryIds;
} else {
dictionaryIds.reset();
dictionaryIds.reserve(capacity);
}
return dictionaryIds;
}

// Split out the slow path.
@Override
protected void reserveInternal(int newCapacity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,22 +461,6 @@ public int putByteArray(int rowId, byte[] value, int offset, int length) {
return result;
}

/**
* Reserve a integer column for ids of dictionary.
*/
@Override
public OnHeapColumnVector reserveDictionaryIds(int capacity) {
OnHeapColumnVector dictionaryIds = (OnHeapColumnVector) this.dictionaryIds;
if (dictionaryIds == null) {
dictionaryIds = new OnHeapColumnVector(capacity, DataTypes.IntegerType);
this.dictionaryIds = dictionaryIds;
} else {
dictionaryIds.reset();
dictionaryIds.reserve(capacity);
}
return dictionaryIds;
}

// Spilt this function out since it is the slow path.
@Override
protected void reserveInternal(int newCapacity) {
Expand Down

0 comments on commit 2769b39

Please sign in to comment.