carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jackylk <...@git.apache.org>
Subject [GitHub] carbondata pull request #987: [CARBONDATA-1017] Add EncodingStrategy and use...
Date Tue, 13 Jun 2017 08:50:08 GMT
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/987#discussion_r121618486
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/UpscaleFloatingCodec.java
---
    @@ -0,0 +1,190 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.carbondata.core.datastore.page.encoding;
    +
    +import org.apache.carbondata.core.datastore.compression.Compressor;
    +import org.apache.carbondata.core.datastore.page.ColumnPage;
    +import org.apache.carbondata.core.datastore.page.LazyColumnPage;
    +import org.apache.carbondata.core.datastore.page.PrimitiveCodec;
    +import org.apache.carbondata.core.datastore.page.statistics.ColumnPageStatsVO;
    +import org.apache.carbondata.core.metadata.datatype.DataType;
    +
    +/**
    + * Codec for floating point (float, double) data type page.
    + * This codec will upscale the diff from page max value to integer value,
    + * and do type casting to make storage minimum.
    + */
    +public class UpscaleFloatingCodec extends AdaptiveCompressionCodec {
    +
    +  private ColumnPage encodedPage;
    +  private double factor;
    +
    +  public static ColumnPageCodec newInstance(DataType srcDataType, DataType targetDataType,
    +      ColumnPageStatsVO stats, Compressor compressor) {
    +    return new UpscaleFloatingCodec(srcDataType, targetDataType, stats, compressor);
    +  }
    +
    +  private UpscaleFloatingCodec(DataType srcDataType, DataType targetDataType,
    +      ColumnPageStatsVO stats, Compressor compressor) {
    +    super(srcDataType, targetDataType, stats, compressor);
    +    this.factor = Math.pow(10, stats.getDecimal());
    +  }
    +
    +  @Override public String getName() {
    +    return "UpscaleFloatingCodec";
    +  }
    +
    +  @Override
    +  public byte[] encode(ColumnPage input) {
    +    encodedPage = ColumnPage.newPage(targetDataType, input.getPageSize());
    +    input.encode(codec);
    +    return encodedPage.compress(compressor);
    +  }
    +
    +
    +  @Override
    +  public ColumnPage decode(byte[] input, int offset, int length) {
    +    ColumnPage page = ColumnPage.decompress(compressor, targetDataType, input, offset,
length);
    +    return LazyColumnPage.newPage(page, codec);
    +  }
    +
    +  private PrimitiveCodec codec = new PrimitiveCodec() {
    --- End diff --
    
    ok


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

Mime
View raw message