Github user manishgupta88 commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2654#discussion_r214044420 --- 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, + int size, int sizeInBytes) { + dataType = DataTypeUtil.valueOf(dataType.getName()); + Object data = new Object(); + if (dataType == DataTypes.BOOLEAN) { + data = CarbonUnsafe.getUnsafe().getBoolean(baseObject, address + size); + } else if (dataType == DataTypes.BYTE) { + data = CarbonUnsafe.getUnsafe().getByte(baseObject, address + size); + } else if (dataType == DataTypes.SHORT) { + data = CarbonUnsafe.getUnsafe().getShort(baseObject, address + size); + } else if (dataType == DataTypes.INT) { + data = CarbonUnsafe.getUnsafe().getInt(baseObject, address + size); + } else if (dataType == DataTypes.LONG) { + data = CarbonUnsafe.getUnsafe().getLong(baseObject, address + size); + } else if (DataTypes.isDecimal(dataType) || dataType == DataTypes.DOUBLE) { + data = CarbonUnsafe.getUnsafe().getDouble(baseObject, address + size); + } else if (dataType == DataTypes.FLOAT) { + data = CarbonUnsafe.getUnsafe().getDouble(baseObject, address + size); + } else if (dataType == DataTypes.BYTE_ARRAY) { + CarbonUnsafe.getUnsafe() + .copyMemory(baseObject, address + size, data, CarbonUnsafe.BYTE_ARRAY_OFFSET, + sizeInBytes); + } + return data; + } + + /** + * Put the data to vector + * + * @param vector + * @param value + * @param vectorRow + * @param length + */ + public static void putDataToVector(CarbonColumnVector vector, byte[] value, int vectorRow, --- End diff -- Move this method to DimensionVectorDataProcessor.java
---