Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
address review comments
  • Loading branch information
kiszk committed Aug 7, 2017
commit dc331f138ee22f3567bfc8a6f5b1e39e7102affd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* A column backed by data compressed thru ColumnAccessor
* this is a wrapper to read compressed data for table cache
*/
public final class CachedBatchColumnVector extends ColumnVector {
public final class CachedBatchColumnVector extends ReadOnlyColumnVector {

// accessor for a column
private ColumnAccessor columnAccessor;
Expand All @@ -49,7 +49,7 @@ public final class CachedBatchColumnVector extends ColumnVector {


public CachedBatchColumnVector(byte[] buffer, int numRows, DataType type) {
super(numRows, DataTypes.NullType, MemoryMode.ON_HEAP);
super(numRows, type, MemoryMode.ON_HEAP);
initialize(buffer, type);
reserveInternal(numRows);
reset();
Expand Down Expand Up @@ -89,26 +89,6 @@ private void prepareAccess(int rowId) {
// APIs dealing with nulls
//

@Override
public void putNotNull(int rowId) {
throw new UnsupportedOperationException();
}

@Override
public void putNull(int rowId) {
throw new UnsupportedOperationException();
}

@Override
public void putNulls(int rowId, int count) {
throw new UnsupportedOperationException();
}

@Override
public void putNotNulls(int rowId, int count) {
throw new UnsupportedOperationException();
}

@Override
public boolean isNullAt(int rowId) {
prepareAccess(rowId);
Expand All @@ -119,16 +99,6 @@ public boolean isNullAt(int rowId) {
// APIs dealing with Booleans
//

@Override
public void putBoolean(int rowId, boolean value) {
throw new UnsupportedOperationException();
}

@Override
public void putBooleans(int rowId, int count, boolean value) {
throw new UnsupportedOperationException();
}

@Override
public boolean getBoolean(int rowId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we support reading values in a random order? e.g. getBoolean(2), getBoolean(1), getBoolean(2)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not support reading values in a random order. This is because implementation of CompressionScheme (e.g. IntDelta) supports only sequential access.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we should throw exception for this case instead of returning wrong result.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I will add code to track access order for each getter.

prepareAccess(rowId);
Expand All @@ -146,21 +116,6 @@ public boolean[] getBooleans(int rowId, int count) {
// APIs dealing with Bytes
//

@Override
public void putByte(int rowId, byte value) {
throw new UnsupportedOperationException();
}

@Override
public void putBytes(int rowId, int count, byte value) {
throw new UnsupportedOperationException();
}

@Override
public void putBytes(int rowId, int count, byte[] src, int srcIndex) {
throw new UnsupportedOperationException();
}

@Override
public byte getByte(int rowId) {
prepareAccess(rowId);
Expand All @@ -176,21 +131,6 @@ public byte[] getBytes(int rowId, int count) {
// APIs dealing with Shorts
//

@Override
public void putShort(int rowId, short value) {
throw new UnsupportedOperationException();
}

@Override
public void putShorts(int rowId, int count, short value) {
throw new UnsupportedOperationException();
}

@Override
public void putShorts(int rowId, int count, short[] src, int srcIndex) {
throw new UnsupportedOperationException();
}

@Override
public short getShort(int rowId) {
prepareAccess(rowId);
Expand All @@ -206,26 +146,6 @@ public short[] getShorts(int rowId, int count) {
// APIs dealing with Ints
//

@Override
public void putInt(int rowId, int value) {
throw new UnsupportedOperationException();
}

@Override
public void putInts(int rowId, int count, int value) {
throw new UnsupportedOperationException();
}

@Override
public void putInts(int rowId, int count, int[] src, int srcIndex) {
throw new UnsupportedOperationException();
}

@Override
public void putIntsLittleEndian(int rowId, int count, byte[] src, int srcIndex) {
throw new UnsupportedOperationException();
}

@Override
public int getInt(int rowId) {
prepareAccess(rowId);
Expand All @@ -245,26 +165,6 @@ public int getDictId(int rowId) {
// APIs dealing with Longs
//

@Override
public void putLong(int rowId, long value) {
throw new UnsupportedOperationException();
}

@Override
public void putLongs(int rowId, int count, long value) {
throw new UnsupportedOperationException();
}

@Override
public void putLongs(int rowId, int count, long[] src, int srcIndex) {
throw new UnsupportedOperationException();
}

@Override
public void putLongsLittleEndian(int rowId, int count, byte[] src, int srcIndex) {
throw new UnsupportedOperationException();
}

@Override
public long getLong(int rowId) {
prepareAccess(rowId);
Expand All @@ -280,26 +180,6 @@ public long[] getLongs(int rowId, int count) {
// APIs dealing with floats
//

@Override
public void putFloat(int rowId, float value) {
throw new UnsupportedOperationException();
}

@Override
public void putFloats(int rowId, int count, float value) {
throw new UnsupportedOperationException();
}

@Override
public void putFloats(int rowId, int count, float[] src, int srcIndex) {
throw new UnsupportedOperationException();
}

@Override
public void putFloats(int rowId, int count, byte[] src, int srcIndex) {
throw new UnsupportedOperationException();
}

@Override
public float getFloat(int rowId) {
prepareAccess(rowId);
Expand All @@ -315,26 +195,6 @@ public float[] getFloats(int rowId, int count) {
// APIs dealing with doubles
//

@Override
public void putDouble(int rowId, double value) {
throw new UnsupportedOperationException();
}

@Override
public void putDoubles(int rowId, int count, double value) {
throw new UnsupportedOperationException();
}

@Override
public void putDoubles(int rowId, int count, double[] src, int srcIndex) {
throw new UnsupportedOperationException();
}

@Override
public void putDoubles(int rowId, int count, byte[] src, int srcIndex) {
throw new UnsupportedOperationException();
}

@Override
public double getDouble(int rowId) {
prepareAccess(rowId);
Expand All @@ -359,11 +219,6 @@ public int getArrayOffset(int rowId) {
throw new UnsupportedOperationException();
}

@Override
public void putArray(int rowId, int offset, int length) {
throw new UnsupportedOperationException();
}

@Override
public void loadBytes(ColumnVector.Array array) {
throw new UnsupportedOperationException();
Expand All @@ -373,24 +228,12 @@ public void loadBytes(ColumnVector.Array array) {
// APIs dealing with Byte Arrays
//

@Override
public int putByteArray(int rowId, byte[] value, int offset, int length) {
throw new UnsupportedOperationException();
}

public final UTF8String getUTF8String(int rowId) {
prepareAccess(rowId);
return unsafeRow.getUTF8String(ORDINAL);
}

@Override
protected void reserveInternal(int newCapacity) {
capacity = newCapacity;
}

private void initialize(byte[] buffer, DataType type) {
this.type = type;

if (columnAccessor == null) {
ByteBuffer byteBuffer = ByteBuffer.wrap(buffer);
columnAccessor = ColumnAccessor$.MODULE$.apply(type, byteBuffer);
Expand Down
Loading