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

    https://github.com/apache/carbondata/pull/1240#discussion_r132899540
  
    --- Diff: 
core/src/main/java/org/apache/carbondata/core/datastore/page/encoding/RLECodec.java
 ---
    @@ -0,0 +1,417 @@
    +/*
    + * 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 java.io.ByteArrayInputStream;
    +import java.io.ByteArrayOutputStream;
    +import java.io.DataInputStream;
    +import java.io.DataOutputStream;
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.List;
    +
    +import org.apache.carbondata.core.datastore.page.ColumnPage;
    +import org.apache.carbondata.core.datastore.page.ComplexColumnPage;
    +import 
org.apache.carbondata.core.datastore.page.statistics.SimpleStatsResult;
    +import org.apache.carbondata.core.memory.MemoryException;
    +import org.apache.carbondata.core.metadata.CodecMetaFactory;
    +import org.apache.carbondata.core.metadata.datatype.DataType;
    +
    +/**
    + * RLE encoding implementation for integral column page.
    + * This encoding keeps track of repeated-run and non-repeated-run, and 
make use
    + * of the highest bit of the length field to indicate the type of run.
    + * The length field is encoded as 32bits value.
    + *
    + * For example: input data {5, 5, 1, 2, 3, 3, 3, 3, 3} will be encoded to
    + * {0x00, 0x00, 0x00, 0x02, 0x05,             (repeated-run, 2 values of 5)
    + *  0x80, 0x00, 0x00, 0x03, 0x01, 0x02, 0x03, (non-repeated-run, 3 values: 
1, 2, 3)
    + *  0x00, 0x00, 0x00, 0x04, 0x03}             (repeated-run, 4 values of 3)
    + */
    +public class RLECodec implements ColumnPageCodec {
    +
    +  enum RUN_STATE { INIT, START, REPEATED_RUN, NONREPEATED_RUN }
    +
    +  private DataType dataType;
    +  private int pageSize;
    +
    +  /**
    +   * New RLECodec
    +   * @param dataType data type of the raw column page before encode
    +   * @param pageSize page size of the raw column page before encode
    +   */
    +  RLECodec(DataType dataType, int pageSize) {
    +    this.dataType = dataType;
    +    this.pageSize = pageSize;
    +  }
    +
    +  @Override
    +  public String getName() {
    +    return "RLECodec";
    +  }
    +
    +  @Override
    +  public EncodedColumnPage encode(ColumnPage input) throws 
MemoryException, IOException {
    +    Encoder encoder = new Encoder();
    +    return encoder.encode(input);
    +  }
    +
    +  @Override
    +  public EncodedColumnPage[] encodeComplexColumn(ComplexColumnPage input) {
    +    throw new UnsupportedOperationException("complex column does not 
support RLE encoding");
    +  }
    +
    +  @Override
    +  public ColumnPage decode(byte[] input, int offset, int length) throws 
MemoryException,
    +      IOException {
    +    Decoder decoder = new Decoder(dataType, pageSize);
    +    return decoder.decode(input, offset, length);
    +  }
    +
    +  // This codec supports integral type only
    +  private void validateDataType(DataType dataType) {
    +    switch (dataType) {
    +      case BYTE:
    +      case SHORT:
    +      case INT:
    +      case LONG:
    --- End diff --
    
    ideally double and decimal also can be supported right with this encoding, 
why those are not supported


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to