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

[GitHub] incubator-carbondata pull request #103: Fix the bug that when using Decimal ...

GitHub user Zhangshunyu opened a pull request:

    https://github.com/apache/incubator-carbondata/pull/103

    Fix the bug that when using Decimal type as dictionary gen surrogate key will mismatch for the same values during increment load.

    ## Why raise this pr?
    **Fix bug: when using Decimal type as dictionary gen surrogate key will mismatch for the same values during increment load.**
    For example, when we specify Decimal type column using dictionary, as the using of `DataTypeUtil.normalizeColumnValueForItsDataType`, deciaml data for example 45, if we specify the precision of this column as 3, parsedValue would be 45.000, and this  45.000 would be written into dic file by writer.write(parsedValue). As a result, the second time we load the same data 45, dictionary.getSurrogateKey(value) would compare the value with dic value, but here the value is 45, our dic value is 45.000 stored as string, so dic would think that i don not have 45, this would lead to repeated values in dic,  this is a mistake.
    How to solve this?
    Before check the surrogate key, if the datatype is decimal, we first using his parsedValue as value to check, this would not take 45 itself as different value.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Zhangshunyu/incubator-carbondata decimalDic

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-carbondata/pull/103.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #103
    
----
commit 0403b9fe4ed32b9cbc4727b5a541cfccb089422e
Author: Zhangshunyu <zh...@huawei.com>
Date:   2016-08-29T08:29:54Z

    Fix the bug that when Decimal type as dictionary gen surrogate key will mismatch for the same values

----


---
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.
---

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

Posted by manishgupta88 <gi...@git.apache.org>.
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.
---

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

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-carbondata/pull/103


---
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.
---