You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by manishgupta88 <gi...@git.apache.org> on 2018/08/30 14:37:01 UTC

[GitHub] carbondata pull request #2654: [CARBONDATA-2896] Adaptive Encoding for Primi...

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

    https://github.com/apache/carbondata/pull/2654#discussion_r214038624
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/util/DataTypeUtil.java ---
    @@ -976,4 +978,122 @@ public static long getDataBasedOnRestructuredDataType(byte[] data, DataType rest
         return value;
       }
     
    +  /**
    +   * Check if the column is a no dictionary primitive column
    +   *
    +   * @param dataType
    +   * @return
    +   */
    +  public static boolean isPrimitiveColumn(DataType dataType) {
    +    if (dataType == DataTypes.BOOLEAN || dataType == DataTypes.BYTE || dataType == DataTypes.SHORT
    +        || dataType == DataTypes.INT || dataType == DataTypes.LONG || DataTypes.isDecimal(dataType)
    +        || dataType == DataTypes.FLOAT || dataType == DataTypes.DOUBLE
    +        || dataType == DataTypes.BYTE_ARRAY) {
    +      return true;
    +    }
    +    return false;
    +  }
    +
    +  /**
    +   * Put the data to unsafe memory
    +   *
    +   * @param dataType
    +   * @param data
    +   * @param baseObject
    +   * @param address
    +   * @param size
    +   * @param sizeInBytes
    +   */
    +  public static void putDataToUnsafe(DataType dataType, Object data, Object baseObject,
    +      long address, int size, int sizeInBytes) {
    +    dataType = DataTypeUtil.valueOf(dataType.getName());
    +    if (dataType == DataTypes.BOOLEAN) {
    +      CarbonUnsafe.getUnsafe().putBoolean(baseObject, address + size, (boolean) data);
    +    } else if (dataType == DataTypes.BYTE) {
    +      CarbonUnsafe.getUnsafe().putByte(baseObject, address + size, (byte) data);
    +    } else if (dataType == DataTypes.SHORT) {
    +      CarbonUnsafe.getUnsafe().putShort(baseObject, address + size, (short) data);
    +    } else if (dataType == DataTypes.INT) {
    +      CarbonUnsafe.getUnsafe().putInt(baseObject, address + size, (int) data);
    +    } else if (dataType == DataTypes.LONG) {
    +      CarbonUnsafe.getUnsafe().putLong(baseObject, address + size, (long) data);
    +    } else if (DataTypes.isDecimal(dataType) || dataType == DataTypes.DOUBLE) {
    +      CarbonUnsafe.getUnsafe().putDouble(baseObject, address + size, (double) data);
    +    } else if (dataType == DataTypes.FLOAT) {
    +      CarbonUnsafe.getUnsafe().putFloat(baseObject, address + size, (float) data);
    +    } else if (dataType == DataTypes.BYTE_ARRAY) {
    +      CarbonUnsafe.getUnsafe()
    +          .copyMemory(data, CarbonUnsafe.BYTE_ARRAY_OFFSET, baseObject, address + size,
    +              sizeInBytes);
    +    }
    +  }
    +
    +  /**
    +   * Retrieve/Get the data from unsafe memory
    +   *
    +   * @param dataType
    +   * @param baseObject
    +   * @param address
    +   * @param size
    +   * @param sizeInBytes
    +   * @return
    +   */
    +  public static Object getDataFromUnsafe(DataType dataType, Object baseObject, long address,
    --- End diff --
    
    same comment as above


---