Github user kumarvishal09 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2209#discussion_r184918635
--- Diff:
processing/src/main/java/org/apache/carbondata/processing/datatypes/PrimitiveDataType.java
---
@@ -211,29 +241,66 @@ public int getSurrogateIndex() {
/*
* set surrogate index
*/
- @Override
- public void setSurrogateIndex(int surrIndex) {
- index = surrIndex;
+ @Override public void setSurrogateIndex(int surrIndex) {
+ if (this.carbonDimension != null &&
!this.carbonDimension.hasEncoding(Encoding.DICTIONARY)) {
+ index = 0;
+ } else if (this.carbonDimension == null && isDictionary == false) {
+ index = 0;
+ } else {
+ index = surrIndex;
+ }
+ }
+
+ @Override public Boolean getIsColumnDictionary() {
+ return isDictionary;
}
@Override public void writeByteArray(Object input, DataOutputStream
dataOutputStream)
throws IOException, DictionaryGenerationException {
String parsedValue =
input == null ? null : DataTypeUtil.parseValue(input.toString(),
carbonDimension);
- Integer surrogateKey;
- if (null == parsedValue) {
- surrogateKey =
CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY;
- } else {
- surrogateKey = dictionaryGenerator.getOrGenerateKey(parsedValue);
- if (surrogateKey == CarbonCommonConstants.INVALID_SURROGATE_KEY) {
+ if (this.isDictionary) {
+ Integer surrogateKey;
+ if (null == parsedValue) {
surrogateKey =
CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY;
+ } else {
+ surrogateKey = dictionaryGenerator.getOrGenerateKey(parsedValue);
+ if (surrogateKey == CarbonCommonConstants.INVALID_SURROGATE_KEY) {
+ surrogateKey =
CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY;
+ }
+ }
+ dataOutputStream.writeInt(surrogateKey);
+ } else {
+ // Transform into ByteArray for No Dictionary.
+ // TODO have to refactor and place all the cases present in
NonDictionaryFieldConverterImpl
+ if (null == parsedValue && this.carbonDimension.getDataType() !=
DataTypes.STRING) {
+ updateNullValue(dataOutputStream);
+ } else {
+ byte[] value =
DataTypeUtil.getBytesBasedOnDataTypeForNoDictionaryColumn(parsedValue,
--- End diff --
In case of no dictionary primitive type column NoDictionary field converter
will convert and give the parsed value so no need to call
DataTypeUtil.getBytesBasedOnDataTypeForNoDictionaryColumn again, dictionary
write this value in LV format to outputstream
---