Search in sources :

Example 6 with KeyStructureInfo

use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo in project carbondata by apache.

the class RowLevelFilterExecuterImpl method readSurrogatesFromColumnGroupBlock.

/**
   * @param index
   * @param dimColumnEvaluatorInfo
   * @return read surrogate of given row of given column group dimension
   */
private int readSurrogatesFromColumnGroupBlock(DimensionColumnDataChunk chunk, int index, DimColumnResolvedFilterInfo dimColumnEvaluatorInfo) {
    try {
        KeyStructureInfo keyStructureInfo = QueryUtil.getKeyStructureInfo(segmentProperties, dimColumnEvaluatorInfo);
        byte[] colData = chunk.getChunkData(index);
        long[] result = keyStructureInfo.getKeyGenerator().getKeyArray(colData);
        int colGroupId = QueryUtil.getColumnGroupId(segmentProperties, dimensionBlocksIndex[0]);
        return (int) result[segmentProperties.getColumnGroupMdKeyOrdinal(colGroupId, dimensionBlocksIndex[0])];
    } catch (KeyGenException e) {
        LOGGER.error(e);
    }
    return 0;
}
Also used : KeyStructureInfo(org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo) KeyGenException(org.apache.carbondata.core.keygenerator.KeyGenException)

Example 7 with KeyStructureInfo

use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo in project carbondata by apache.

the class ExcludeColGroupFilterExecuterImpl method getFilteredIndexes.

/**
   * It fills BitSet with row index which matches filter key
   */
protected BitSet getFilteredIndexes(DimensionColumnDataChunk dimensionColumnDataChunk, int numerOfRows) {
    BitSet bitSet = new BitSet(numerOfRows);
    bitSet.flip(0, numerOfRows);
    try {
        KeyStructureInfo keyStructureInfo = getKeyStructureInfo();
        byte[][] filterValues = dimColumnExecuterInfo.getFilterKeys();
        for (int i = 0; i < filterValues.length; i++) {
            byte[] filterVal = filterValues[i];
            for (int rowId = 0; rowId < numerOfRows; rowId++) {
                byte[] colData = new byte[keyStructureInfo.getMaskByteRanges().length];
                dimensionColumnDataChunk.fillChunkData(colData, 0, rowId, keyStructureInfo);
                if (ByteUtil.UnsafeComparer.INSTANCE.compareTo(filterVal, colData) == 0) {
                    bitSet.flip(rowId);
                }
            }
        }
    } catch (Exception e) {
        LOGGER.error(e);
    }
    return bitSet;
}
Also used : KeyStructureInfo(org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo) BitSet(java.util.BitSet) KeyGenException(org.apache.carbondata.core.keygenerator.KeyGenException)

Example 8 with KeyStructureInfo

use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo in project carbondata by apache.

the class ColumnGroupDimensionDataChunkTest method fillConvertedChunkDataTest.

@Test
public void fillConvertedChunkDataTest() {
    int[] row = new int[3];
    int[] expected = { 0, 0, 3 };
    List<Integer> ordinals = new ArrayList<Integer>();
    ordinals.add(2);
    KeyStructureInfo keyStructureInfo = getKeyStructureInfo(ordinals, keyGenerator);
    keyStructureInfo.setMdkeyQueryDimensionOrdinal(new int[] { 2 });
    int res = columnGroupDimensionDataChunk.fillConvertedChunkData(2, 2, row, keyStructureInfo);
    assert (Arrays.equals(row, expected));
}
Also used : KeyStructureInfo(org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 9 with KeyStructureInfo

use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo in project carbondata by apache.

the class ColumnGroupDimensionDataChunkTest method getKeyStructureInfo.

/**
   * Below method will be used to get the key structure info for the query
   *
   * @param ordinals   query model
   * @param keyGenerator
   * @return key structure info
   */
private KeyStructureInfo getKeyStructureInfo(List<Integer> ordinals, KeyGenerator keyGenerator) {
    // getting the masked byte range for dictionary column
    int[] maskByteRanges = QueryUtil.getMaskedByteRangeBasedOrdinal(ordinals, keyGenerator);
    // getting the masked bytes for query dimension dictionary column
    int[] maskedBytes = QueryUtil.getMaskedByte(keyGenerator.getKeySizeInBytes(), maskByteRanges);
    // max key for the dictionary dimension present in the query
    byte[] maxKey = null;
    try {
        // getting the max key which will be used to masked and get the
        // masked key
        maxKey = QueryUtil.getMaxKeyBasedOnOrinal(ordinals, keyGenerator);
    } catch (KeyGenException e) {
    }
    KeyStructureInfo restructureInfos = new KeyStructureInfo();
    restructureInfos.setKeyGenerator(keyGenerator);
    restructureInfos.setMaskByteRanges(maskByteRanges);
    restructureInfos.setMaxKey(maxKey);
    return restructureInfos;
}
Also used : KeyStructureInfo(org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo) KeyGenException(org.apache.carbondata.core.keygenerator.KeyGenException)

Example 10 with KeyStructureInfo

use of org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo in project carbondata by apache.

the class ColumnGroupDimensionDataChunkTest method fillChunkDataTest.

@Test
public void fillChunkDataTest() {
    List<Integer> ordinals = new ArrayList<Integer>();
    ordinals.add(1);
    KeyStructureInfo keyStructureInfo = getKeyStructureInfo(ordinals, keyGenerator);
    byte[] buffer = new byte[1];
    columnGroupDimensionDataChunk.fillChunkData(buffer, 0, 1, keyStructureInfo);
    assertEquals(buffer[0], 2);
}
Also used : KeyStructureInfo(org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

KeyStructureInfo (org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo)12 ArrayList (java.util.ArrayList)6 KeyGenException (org.apache.carbondata.core.keygenerator.KeyGenException)4 KeyGenerator (org.apache.carbondata.core.keygenerator.KeyGenerator)4 Test (org.junit.Test)4 BitSet (java.util.BitSet)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Entry (java.util.Map.Entry)1