You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by gvramana <gi...@git.apache.org> on 2018/07/02 12:34:52 UTC

[GitHub] carbondata pull request #2417: [WIP][Complex Column Enhancements]Primitive D...

Github user gvramana commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/2417#discussion_r199481192
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/datastore/chunk/store/ColumnPageWrapper.java ---
    @@ -30,32 +40,72 @@ public ColumnPageWrapper(ColumnPage columnPage) {
         this.columnPage = columnPage;
       }
     
    +  public ColumnPage getColumnPage() {
    +    return columnPage;
    +  }
    +
       @Override
       public int fillRawData(int rowId, int offset, byte[] data, KeyStructureInfo restructuringInfo) {
    -    throw new UnsupportedOperationException("internal error");
    +    throw new UnsupportedOperationException(
    +        "internal error: should be called for only dictionary columns");
       }
     
       @Override
       public int fillSurrogateKey(int rowId, int chunkIndex, int[] outputSurrogateKey,
           KeyStructureInfo restructuringInfo) {
    -    throw new UnsupportedOperationException("internal error");
    +    throw new UnsupportedOperationException(
    +        "internal error: should be called for only dictionary columns");
       }
     
       @Override
       public int fillVector(ColumnVectorInfo[] vectorInfo, int chunkIndex,
           KeyStructureInfo restructuringInfo) {
    -    throw new UnsupportedOperationException("internal error");
    +    // fill the vector with data in column page
    +    ColumnVectorInfo columnVectorInfo = vectorInfo[chunkIndex];
    +    CarbonColumnVector vector = columnVectorInfo.vector;
    +    fillData(null, columnVectorInfo, vector);
    +    return chunkIndex + 1;
       }
     
    +
       @Override
       public int fillVector(int[] filteredRowId, ColumnVectorInfo[] vectorInfo, int chunkIndex,
           KeyStructureInfo restructuringInfo) {
    -    throw new UnsupportedOperationException("internal error");
    +    ColumnVectorInfo columnVectorInfo = vectorInfo[chunkIndex];
    +    CarbonColumnVector vector = columnVectorInfo.vector;
    +    fillData(filteredRowId, columnVectorInfo, vector);
    +    return chunkIndex + 1;
       }
     
    -  @Override
    -  public byte[] getChunkData(int rowId) {
    -    return columnPage.getBytes(rowId);
    +  @Override public byte[] getChunkData(int rowId) {
    +    ColumnType columnType = columnPage.getColumnSpec().getColumnType();
    +    // TODO: No need to convert to Byte array, handle like measure
    +    // But interface currently doesn't support, need to add new interface.
    +    if (columnType == ColumnType.PLAIN_VALUE) {
    +      if (columnPage.getNullBits().get(rowId)) {
    +        // if this row is null, return default null represent in byte array
    +        return CarbonCommonConstants.MEMBER_DEFAULT_VAL_ARRAY;
    +      }
    +      if (columnPage.getDataType() == DataTypes.BYTE) {
    +        byte byteData = columnPage.getByte(rowId);
    +        return ByteUtil.toBytes(byteData);
    +      } else if (columnPage.getDataType() == DataTypes.SHORT) {
    --- End diff --
    
    Use Switch instead of ifelse


---