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

    https://github.com/apache/carbondata/pull/1000#discussion_r121940029
  
    --- Diff: 
core/src/main/java/org/apache/carbondata/core/datastore/page/VarLengthColumnPageBase.java
 ---
    @@ -0,0 +1,212 @@
    +/*
    + * 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;
    +
    +import java.util.ArrayList;
    +import java.util.List;
    +
    +import org.apache.carbondata.core.memory.MemoryException;
    +import org.apache.carbondata.core.metadata.datatype.DataType;
    +
    +import static 
org.apache.carbondata.core.metadata.datatype.DataType.DECIMAL;
    +
    +public abstract class VarLengthColumnPageBase extends ColumnPage {
    +
    +  // the offset of row whose id is (N + 1) in the unsafe memory
    +  // for example, if first two rows are 8 bytes and 4 bytes, then 
rowOffset[0] == 8,
    +  // and rowOffset[1] == 12
    +  int[] rowOffset;
    +
    +  // the length of bytes added in the page
    +  int totolLength;
    +
    +  VarLengthColumnPageBase(DataType dataType, int pageSize) {
    +    super(dataType, pageSize);
    +  }
    +
    +  @Override
    +  public void setBytePage(byte[] byteData) {
    +    throw new UnsupportedOperationException("invalid data type: " + 
dataType);
    +  }
    +
    +  @Override
    +  public void setShortPage(short[] shortData) {
    +    throw new UnsupportedOperationException("invalid data type: " + 
dataType);
    +  }
    +
    +  @Override
    +  public void setIntPage(int[] intData) {
    +    throw new UnsupportedOperationException("invalid data type: " + 
dataType);
    +  }
    +
    +  @Override
    +  public void setLongPage(long[] longData) {
    +    throw new UnsupportedOperationException("invalid data type: " + 
dataType);
    +  }
    +
    +  @Override
    +  public void setFloatPage(float[] floatData) {
    +    throw new UnsupportedOperationException("invalid data type: " + 
dataType);
    +  }
    +
    +  @Override
    +  public void setDoublePage(double[] doubleData) {
    +    throw new UnsupportedOperationException("invalid data type: " + 
dataType);
    +  }
    +
    +  @Override
    +  public void setByteArrayPage(byte[][] byteArray) {
    +    throw new UnsupportedOperationException("invalid data type: " + 
dataType);
    +  }
    +
    +  /**
    +   * Create a new column page based on the LV (Length Value) encoded bytes
    +   */
    +  static ColumnPage newDecimalColumnPage(byte[] lvEncodedBytes) throws 
MemoryException {
    +    // extract length and data, set them to rowOffset and unsafe memory 
correspondingly
    +    int rowId = 0;
    +    List<Integer> rowOffset = new ArrayList<>();
    +    List<Integer> rowLength = new ArrayList<>();
    +    int length;
    +    int offset = 0;
    +    int nextRowOffset;
    +
    +    // extract Length field in input and calculate total length
    +    for (offset = 0; offset < lvEncodedBytes.length; offset = 
nextRowOffset) {
    +      length = (((int)lvEncodedBytes[offset]) << 24) + 
(((int)lvEncodedBytes[offset + 1]) << 16) +
    --- End diff --
    
    `ByteUtil.toInt` internal is using Unsafe, which it is wrong in this context


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