use of org.apache.carbondata.core.scan.result.vector.CarbonColumnVector in project carbondata by apache.
the class AbstractScannedResult method fillColumnarImplicitBatch.
/**
* Fill the column data to vector
*/
public void fillColumnarImplicitBatch(ColumnVectorInfo[] vectorInfo) {
int column = 0;
for (int i = 0; i < vectorInfo.length; i++) {
ColumnVectorInfo columnVectorInfo = vectorInfo[column];
CarbonColumnVector vector = columnVectorInfo.vector;
int offset = columnVectorInfo.offset;
int vectorOffset = columnVectorInfo.vectorOffset;
int len = offset + columnVectorInfo.size;
for (int j = offset; j < len; j++) {
// Considering only String case now as we support only
String data = getBlockletId();
if (CarbonCommonConstants.CARBON_IMPLICIT_COLUMN_TUPLEID.equals(columnVectorInfo.dimension.getColumnName())) {
data = data + CarbonCommonConstants.FILE_SEPARATOR + (rowMapping == null ? j : rowMapping[pageCounter][j]);
}
vector.putBytes(vectorOffset++, offset, data.length(), data.getBytes());
}
}
}
use of org.apache.carbondata.core.scan.result.vector.CarbonColumnVector in project carbondata by apache.
the class AbstractScannedResult method fillColumnarComplexBatch.
public void fillColumnarComplexBatch(ColumnVectorInfo[] vectorInfos) {
for (int i = 0; i < vectorInfos.length; i++) {
int offset = vectorInfos[i].offset;
int len = offset + vectorInfos[i].size;
int vectorOffset = vectorInfos[i].vectorOffset;
CarbonColumnVector vector = vectorInfos[i].vector;
for (int j = offset; j < len; j++) {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
DataOutputStream dataOutput = new DataOutputStream(byteStream);
try {
vectorInfos[i].genericQueryType.parseBlocksAndReturnComplexColumnByteArray(rawColumnChunks, rowMapping == null ? j : rowMapping[pageCounter][j], pageCounter, dataOutput);
Object data = vectorInfos[i].genericQueryType.getDataBasedOnDataTypeFromSurrogates(ByteBuffer.wrap(byteStream.toByteArray()));
vector.putObject(vectorOffset++, data);
} catch (IOException e) {
LOGGER.error(e);
} finally {
CarbonUtil.closeStreams(dataOutput);
CarbonUtil.closeStreams(byteStream);
}
}
}
}
use of org.apache.carbondata.core.scan.result.vector.CarbonColumnVector in project carbondata by apache.
the class RestructureBasedVectorResultCollector method fillDataForNonExistingMeasures.
/**
* This method will fill the default values of non existing measures in the current block
*/
private void fillDataForNonExistingMeasures() {
for (int i = 0; i < tableBlockExecutionInfos.getActualQueryMeasures().length; i++) {
if (!measureInfo.getMeasureExists()[i]) {
int queryOrder = tableBlockExecutionInfos.getActualQueryMeasures()[i].getQueryOrder();
CarbonMeasure measure = tableBlockExecutionInfos.getActualQueryMeasures()[i].getMeasure();
ColumnVectorInfo columnVectorInfo = allColumnInfo[queryOrder];
CarbonColumnVector vector = columnVectorInfo.vector;
Object defaultValue = measureDefaultValues[i];
if (null == defaultValue) {
vector.putNulls(columnVectorInfo.vectorOffset, columnVectorInfo.size);
} else {
switch(measureInfo.getMeasureDataTypes()[i]) {
case SHORT:
vector.putShorts(columnVectorInfo.vectorOffset, columnVectorInfo.size, (short) defaultValue);
break;
case INT:
vector.putInts(columnVectorInfo.vectorOffset, columnVectorInfo.size, (int) defaultValue);
break;
case LONG:
vector.putLongs(columnVectorInfo.vectorOffset, columnVectorInfo.size, (long) defaultValue);
break;
case DECIMAL:
vector.putDecimals(columnVectorInfo.vectorOffset, columnVectorInfo.size, (Decimal) defaultValue, measure.getPrecision());
break;
default:
vector.putDoubles(columnVectorInfo.vectorOffset, columnVectorInfo.size, (double) defaultValue);
}
}
}
}
}
Aggregations