You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@carbondata.apache.org by manishgupta88 <gi...@git.apache.org> on 2016/08/30 07:06:55 UTC

[GitHub] incubator-carbondata pull request #103: [CARBONDATA-187]Fix the bug that whe...

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

    https://github.com/apache/incubator-carbondata/pull/103#discussion_r76740221
  
    --- Diff: integration/spark/src/main/scala/org/apache/carbondata/spark/tasks/DictionaryWriterTask.scala ---
    @@ -63,18 +64,26 @@ class DictionaryWriterTask(valuesBuffer: mutable.HashSet[String],
           if (values.length >= 1) {
             if (model.dictFileExists(columnIndex)) {
               for (value <- values) {
    -            if (dictionary.getSurrogateKey(value) ==
    -                CarbonCommonConstants.INVALID_SURROGATE_KEY) {
    -              val parsedValue = org.apache.carbondata.core.util.DataTypeUtil
    +            var newValue = value
    +            if (DataType.DECIMAL == model.primDimensions(columnIndex).getDataType) {
    +              newValue = org.apache.carbondata.core.util.DataTypeUtil
                     .normalizeColumnValueForItsDataType(value,
                       model.primDimensions(columnIndex))
    +            }
    +            if (null != newValue && dictionary.getSurrogateKey(newValue) ==
    +              CarbonCommonConstants.INVALID_SURROGATE_KEY) {
    +              var parsedValue = newValue
    +              if (DataType.DECIMAL != model.primDimensions(columnIndex).getDataType) {
    +                parsedValue = org.apache.carbondata.core.util.DataTypeUtil
    +                  .normalizeColumnValueForItsDataType(value,
    +                    model.primDimensions(columnIndex))
    +              }
    --- End diff --
    
    @Zhangshunyu ...I think you can just move the parsing logic above the dictionary look up logic. This will avoid 2 extra if checks. You can check the sample code below.
    if (model.dictFileExists(columnIndex)) {
              for (value <- values) {
                val parsedValue = org.apache.carbondata.core.util.DataTypeUtil
                  .normalizeColumnValueForItsDataType(value,
                    model.primDimensions(columnIndex))
                if (null != parsedValue && dictionary.getSurrogateKey(value) ==
                    CarbonCommonConstants.INVALID_SURROGATE_KEY) {
                  if (null != parsedValue) {
                    writer.write(parsedValue)
                    distinctValues.add(parsedValue)
                  }
                }
              }
            }


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---