Here you can find the source of extractSingleHighCardDims(byte[] highCardArr, int index, int highCardinalityCount, ByteBuffer outBuffer)
Parameter | Description |
---|---|
highCardArr | a parameter |
index | a parameter |
highCardinalityCount | a parameter |
outBuffer | a parameter |
public static void extractSingleHighCardDims(byte[] highCardArr, int index, int highCardinalityCount, ByteBuffer outBuffer)
//package com.java2s; /*//from w ww.j a v a 2 s. c o m * 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. */ import java.nio.ByteBuffer; public class Main { /** * This method will extract the single dimension from the complete high card dims byte[].+ * * The format of the byte [] will be, Totallength,CompleteStartOffsets,Dat * * @param highCardArr * @param index * @param highCardinalityCount * @param outBuffer */ public static void extractSingleHighCardDims(byte[] highCardArr, int index, int highCardinalityCount, ByteBuffer outBuffer) { ByteBuffer buff = null; short secIndex = 0; short firstIndex = 0; int length; // if the requested index is a last one then we need to calculate length // based on byte[] length. if (index == highCardinalityCount - 1) { // need to read 2 bytes(1 short) to determine starting offset and // length can be calculated by array length. buff = ByteBuffer.wrap(highCardArr, (index * 2) + 2, 2); } else { // need to read 4 bytes(2 short) to determine starting offset and // length. buff = ByteBuffer.wrap(highCardArr, (index * 2) + 2, 4); } firstIndex = buff.getShort(); // if it is a last dimension in high card then this will be last // offset.so calculate length from total length if (index == highCardinalityCount - 1) { secIndex = (short) highCardArr.length; } else { secIndex = buff.getShort(); } length = secIndex - firstIndex; outBuffer.position(firstIndex); outBuffer.limit(outBuffer.position() + length); } }