Github user sounakr commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2417#discussion_r199081933 --- Diff: core/src/main/java/org/apache/carbondata/core/datastore/page/ColumnPage.java --- @@ -405,13 +446,30 @@ public void putData(int rowId, Object value) { } else if (dataType == DataTypes.STRING || dataType == DataTypes.BYTE_ARRAY || dataType == DataTypes.VARCHAR) { - putBytes(rowId, (byte[]) value); - statsCollector.update((byte[]) value); + byte[] valueWithLength; + if (columnSpec.getColumnType() != ColumnType.PLAIN_VALUE) { + // This case is for GLOBAL_DICTIONARY and DIRECT_DICTIONARY. In this + // scenario the dataType is BYTE_ARRAY and passed bytearray should + // be saved. + putBytes(rowId, (byte[]) value); + statsCollector.update((byte[]) value); + } else { + if (dataType == DataTypes.VARCHAR) { + // Add length and then add the data. + valueWithLength = addIntLengthToByteArray((byte[]) value); + } else { + valueWithLength = addShortLengthToByteArray((byte[]) value); + } + putBytes(rowId, valueWithLength); + statsCollector.update((byte[]) valueWithLength); + } } else { throw new RuntimeException("unsupported data type: " + dataType); } } + --- End diff -- Done
---