Search in sources :

Example 1 with ByteArrayWrapper

use of org.apache.carbondata.core.scan.wrappers.ByteArrayWrapper in project carbondata by apache.

the class RawBasedResultCollector method prepareRow.

protected void prepareRow(AbstractScannedResult scannedResult, List<Object[]> listBasedResult, QueryMeasure[] queryMeasures) {
    Object[] row = new Object[1 + queryMeasures.length];
    wrapper = new ByteArrayWrapper();
    wrapper.setDictionaryKey(dictionaryKeyArray);
    wrapper.setNoDictionaryKeys(noDictionaryKeyArray);
    wrapper.setComplexTypesKeys(complexTypeKeyArray);
    wrapper.setImplicitColumnByteArray(implicitColumnByteArray);
    row[0] = wrapper;
    fillMeasureData(row, 1, scannedResult);
    listBasedResult.add(row);
}
Also used : ByteArrayWrapper(org.apache.carbondata.core.scan.wrappers.ByteArrayWrapper)

Example 2 with ByteArrayWrapper

use of org.apache.carbondata.core.scan.wrappers.ByteArrayWrapper in project carbondata by apache.

the class CompactionResultSortProcessor method prepareRowObjectForSorting.

/**
   * This method will prepare the data from raw object that will take part in sorting
   *
   * @param row
   * @return
   */
private Object[] prepareRowObjectForSorting(Object[] row) {
    ByteArrayWrapper wrapper = (ByteArrayWrapper) row[0];
    // ByteBuffer[] noDictionaryBuffer = new ByteBuffer[noDictionaryCount];
    List<CarbonDimension> dimensions = segmentProperties.getDimensions();
    Object[] preparedRow = new Object[dimensions.size() + measureCount];
    // convert the dictionary from MDKey to surrogate key
    byte[] dictionaryKey = wrapper.getDictionaryKey();
    long[] keyArray = segmentProperties.getDimensionKeyGenerator().getKeyArray(dictionaryKey);
    Object[] dictionaryValues = new Object[dimensionColumnCount + measureCount];
    for (int i = 0; i < keyArray.length; i++) {
        dictionaryValues[i] = Long.valueOf(keyArray[i]).intValue();
    }
    int noDictionaryIndex = 0;
    int dictionaryIndex = 0;
    for (int i = 0; i < dimensions.size(); i++) {
        CarbonDimension dims = dimensions.get(i);
        if (dims.hasEncoding(Encoding.DICTIONARY)) {
            // dictionary
            preparedRow[i] = dictionaryValues[dictionaryIndex++];
        } else {
            // no dictionary dims
            preparedRow[i] = wrapper.getNoDictionaryKeyByIndex(noDictionaryIndex++);
        }
    }
    // fill all the measures
    // measures will always start from 1st index in the row object array
    int measureIndexInRow = 1;
    for (int i = 0; i < measureCount; i++) {
        preparedRow[dimensionColumnCount + i] = getConvertedMeasureValue(row[measureIndexInRow++], dataTypes[i]);
    }
    return preparedRow;
}
Also used : ByteArrayWrapper(org.apache.carbondata.core.scan.wrappers.ByteArrayWrapper) CarbonDimension(org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)

Aggregations

ByteArrayWrapper (org.apache.carbondata.core.scan.wrappers.ByteArrayWrapper)2 CarbonDimension (org.apache.carbondata.core.metadata.schema.table.column.CarbonDimension)1