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

    https://github.com/apache/carbondata/pull/2654#discussion_r214086463
  
    --- Diff: 
core/src/main/java/org/apache/carbondata/core/datastore/columnar/BlockIndexerStorageForNoDictionary.java
 ---
    @@ -0,0 +1,157 @@
    +/*
    + * 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.columnar;
    +
    +import java.util.ArrayList;
    +import java.util.Arrays;
    +import java.util.List;
    +
    +import org.apache.carbondata.core.constants.CarbonCommonConstants;
    +import org.apache.carbondata.core.metadata.datatype.DataType;
    +
    +public class BlockIndexerStorageForNoDictionary {
    +
    +  private short[] rowIdPage;
    +
    +  private short[] rowIdRlePage;
    +
    +  private DataType dataType;
    +
    +  public BlockIndexerStorageForNoDictionary(Object[] dataPage, DataType 
dataType,
    +      boolean isNoDictionary, boolean isSortRequired) {
    +    this.dataType = dataType;
    +    ColumnWithRowIdForNoDictionary<Short>[] dataWithRowId =
    +        createColumnWithRowId(dataPage, isNoDictionary);
    +    if (isSortRequired) {
    +      Arrays.sort(dataWithRowId);
    +    }
    +    short[] rowIds = extractDataAndReturnRowId(dataWithRowId, dataPage);
    +    rleEncodeOnRowId(rowIds);
    +  }
    +
    +  /**
    +   * Create an object with each column array and respective rowId
    +   *
    +   * @return
    +   */
    +  private ColumnWithRowIdForNoDictionary<Short>[] 
createColumnWithRowId(Object[] dataPage,
    +      boolean isNoDictionary) {
    +    ColumnWithRowIdForNoDictionary<Short>[] columnWithIndexs =
    +        new ColumnWithRowIdForNoDictionary[dataPage.length];
    +    if (isNoDictionary) {
    +      for (short i = 0; i < columnWithIndexs.length; i++) {
    +        columnWithIndexs[i] = new 
ColumnWithRowIdForNoDictionary<>(dataPage[i], i, dataType);
    +      }
    +    }
    +    return columnWithIndexs;
    +  }
    +
    +  private short[] 
extractDataAndReturnRowId(ColumnWithRowIdForNoDictionary<Short>[] dataWithRowId,
    +      Object[] dataPage) {
    +    short[] indexes = new short[dataWithRowId.length];
    +    for (int i = 0; i < indexes.length; i++) {
    +      indexes[i] = dataWithRowId[i].getIndex();
    +      dataPage[i] = dataWithRowId[i].getColumn();
    +    }
    +    return indexes;
    +  }
    +
    +  /**
    +   * It compresses depends up on the sequence numbers.
    +   * [1,2,3,4,6,8,10,11,12,13] is translated to [1,4,6,8,10,13] and [0,6]. 
In
    +   * first array the start and end of sequential numbers and second array
    +   * keeps the indexes of where sequential numbers starts. If there is no
    +   * sequential numbers then the same array it returns with empty second
    +   * array.
    +   *
    +   * @param rowIds
    +   */
    +  private void rleEncodeOnRowId(short[] rowIds) {
    --- End diff --
    
    This method is common for BlockIndexStorageForShot please move it to some 
util class


---

Reply via email to