Search in sources :

Example 11 with KeyGenException

use of org.apache.carbondata.core.keygenerator.KeyGenException 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 12 with KeyGenException

use of org.apache.carbondata.core.keygenerator.KeyGenException in project carbondata by apache.

the class FilterUtil method getKeyArray.

/**
   * Below method will be used to covert the filter surrogate keys
   * to mdkey
   *
   * @param dimColumnFilterInfo
   * @param carbonDimension
   * @param segmentProperties
   * @return
   */
public static byte[][] getKeyArray(DimColumnFilterInfo dimColumnFilterInfo, CarbonDimension carbonDimension, SegmentProperties segmentProperties) {
    if (!carbonDimension.hasEncoding(Encoding.DICTIONARY)) {
        return dimColumnFilterInfo.getNoDictionaryFilterValuesList().toArray((new byte[dimColumnFilterInfo.getNoDictionaryFilterValuesList().size()][]));
    }
    KeyGenerator blockLevelKeyGenerator = segmentProperties.getDimensionKeyGenerator();
    int[] dimColumnsCardinality = segmentProperties.getDimColumnsCardinality();
    int[] keys = new int[blockLevelKeyGenerator.getDimCount()];
    List<byte[]> filterValuesList = new ArrayList<byte[]>(20);
    Arrays.fill(keys, 0);
    int keyOrdinalOfDimensionFromCurrentBlock = carbonDimension.getKeyOrdinal();
    if (null != dimColumnFilterInfo) {
        int[] rangesForMaskedByte = getRangesForMaskedByte(keyOrdinalOfDimensionFromCurrentBlock, blockLevelKeyGenerator);
        for (Integer surrogate : dimColumnFilterInfo.getFilterList()) {
            try {
                if (surrogate <= dimColumnsCardinality[keyOrdinalOfDimensionFromCurrentBlock]) {
                    keys[keyOrdinalOfDimensionFromCurrentBlock] = surrogate;
                    filterValuesList.add(getMaskedKey(rangesForMaskedByte, blockLevelKeyGenerator.generateKey(keys)));
                } else {
                    break;
                }
            } catch (KeyGenException e) {
                LOGGER.error(e.getMessage());
            }
        }
    }
    return filterValuesList.toArray(new byte[filterValuesList.size()][]);
}
Also used : ArrayList(java.util.ArrayList) KeyGenException(org.apache.carbondata.core.keygenerator.KeyGenException) KeyGenerator(org.apache.carbondata.core.keygenerator.KeyGenerator)

Example 13 with KeyGenException

use of org.apache.carbondata.core.keygenerator.KeyGenException in project carbondata by apache.

the class DataWriterProcessorStepImpl method processRow.

public void processRow(CarbonRow row, CarbonFactHandler dataHandler) throws KeyGenException {
    try {
        readCounter++;
        dataHandler.addDataToStore(row);
    } catch (Exception e) {
        throw new CarbonDataLoadingException("unable to generate the mdkey", e);
    }
    rowCounter.getAndAdd(1);
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException) KeyGenException(org.apache.carbondata.core.keygenerator.KeyGenException) CarbonDataWriterException(org.apache.carbondata.core.datastore.exception.CarbonDataWriterException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException)

Example 14 with KeyGenException

use of org.apache.carbondata.core.keygenerator.KeyGenException in project carbondata by apache.

the class InMemoryBTreeIndex method getDataBlocksOfIndex.

/**
 * get data blocks of given btree
 */
private List<DataRefNode> getDataBlocksOfIndex(AbstractIndex abstractIndex) {
    List<DataRefNode> blocks = new LinkedList<DataRefNode>();
    SegmentProperties segmentProperties = abstractIndex.getSegmentProperties();
    try {
        IndexKey startIndexKey = FilterUtil.prepareDefaultStartIndexKey(segmentProperties);
        IndexKey endIndexKey = FilterUtil.prepareDefaultEndIndexKey(segmentProperties);
        // Add all blocks of btree into result
        DataRefNodeFinder blockFinder = new BTreeDataRefNodeFinder(segmentProperties.getEachDimColumnValueSize(), segmentProperties.getNumberOfSortColumns(), segmentProperties.getNumberOfNoDictSortColumns());
        DataRefNode startBlock = blockFinder.findFirstDataBlock(abstractIndex.getDataRefNode(), startIndexKey);
        DataRefNode endBlock = blockFinder.findLastDataBlock(abstractIndex.getDataRefNode(), endIndexKey);
        while (startBlock != endBlock) {
            blocks.add(startBlock);
            startBlock = startBlock.getNextDataRefNode();
        }
        blocks.add(endBlock);
    } catch (KeyGenException e) {
        LOG.error("Could not generate start key", e);
    }
    return blocks;
}
Also used : IndexKey(org.apache.carbondata.core.datastore.IndexKey) KeyGenException(org.apache.carbondata.core.keygenerator.KeyGenException) DataRefNode(org.apache.carbondata.core.datastore.DataRefNode) SegmentProperties(org.apache.carbondata.core.datastore.block.SegmentProperties) BTreeDataRefNodeFinder(org.apache.carbondata.core.datastore.impl.btree.BTreeDataRefNodeFinder) DataRefNodeFinder(org.apache.carbondata.core.datastore.DataRefNodeFinder) LinkedList(java.util.LinkedList) BTreeDataRefNodeFinder(org.apache.carbondata.core.datastore.impl.btree.BTreeDataRefNodeFinder)

Example 15 with KeyGenException

use of org.apache.carbondata.core.keygenerator.KeyGenException 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)

Aggregations

KeyGenException (org.apache.carbondata.core.keygenerator.KeyGenException)16 ArrayList (java.util.ArrayList)8 IndexKey (org.apache.carbondata.core.datastore.IndexKey)6 BTreeDataRefNodeFinder (org.apache.carbondata.core.datastore.impl.btree.BTreeDataRefNodeFinder)5 DataRefNode (org.apache.carbondata.core.datastore.DataRefNode)4 DataRefNodeFinder (org.apache.carbondata.core.datastore.DataRefNodeFinder)4 SegmentProperties (org.apache.carbondata.core.datastore.block.SegmentProperties)4 KeyGenerator (org.apache.carbondata.core.keygenerator.KeyGenerator)3 KeyStructureInfo (org.apache.carbondata.core.scan.executor.infos.KeyStructureInfo)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 CarbonDataWriterException (org.apache.carbondata.core.datastore.exception.CarbonDataWriterException)2 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)2 CarbonMeasure (org.apache.carbondata.core.metadata.schema.table.column.CarbonMeasure)2 QueryExecutionException (org.apache.carbondata.core.scan.executor.exception.QueryExecutionException)2 BlockExecutionInfo (org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo)2 FilterExecuter (org.apache.carbondata.core.scan.filter.executer.FilterExecuter)2 ProjectionDimension (org.apache.carbondata.core.scan.model.ProjectionDimension)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1