use of org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo in project carbondata by apache.
the class AbstractDetailQueryResultIterator method intialiseInfos.
private void intialiseInfos() {
for (BlockExecutionInfo blockInfo : blockExecutionInfos) {
DataRefNodeFinder finder = new BTreeDataRefNodeFinder(blockInfo.getEachColumnValueSize(), blockInfo.getDataBlock().getSegmentProperties().getNumberOfSortColumns(), blockInfo.getDataBlock().getSegmentProperties().getNumberOfNoDictSortColumns());
DataRefNode startDataBlock = finder.findFirstDataBlock(blockInfo.getDataBlock().getDataRefNode(), blockInfo.getStartKey());
while (startDataBlock.nodeNumber() < blockInfo.getStartBlockletIndex()) {
startDataBlock = startDataBlock.getNextDataRefNode();
}
long numberOfBlockToScan = blockInfo.getNumberOfBlockletToScan();
//if number of block is less than 0 then take end block.
if (numberOfBlockToScan <= 0) {
DataRefNode endDataBlock = finder.findLastDataBlock(blockInfo.getDataBlock().getDataRefNode(), blockInfo.getEndKey());
numberOfBlockToScan = endDataBlock.nodeNumber() - startDataBlock.nodeNumber() + 1;
}
blockInfo.setFirstDataBlock(startDataBlock);
blockInfo.setNumberOfBlockToScan(numberOfBlockToScan);
}
}
use of org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo in project carbondata by apache.
the class RestructureUtilTest method testToGetAggregatorInfos.
@Test
public void testToGetAggregatorInfos() {
ColumnSchema columnSchema1 = new ColumnSchema();
columnSchema1.setColumnName("Id");
columnSchema1.setDataType(DataType.STRING);
columnSchema1.setColumnUniqueId(UUID.randomUUID().toString());
ColumnSchema columnSchema2 = new ColumnSchema();
columnSchema2.setColumnName("Name");
columnSchema2.setDataType(DataType.STRING);
columnSchema2.setColumnUniqueId(UUID.randomUUID().toString());
ColumnSchema columnSchema3 = new ColumnSchema();
columnSchema3.setColumnName("Age");
columnSchema3.setDataType(DataType.STRING);
columnSchema3.setColumnUniqueId(UUID.randomUUID().toString());
CarbonMeasure carbonMeasure1 = new CarbonMeasure(columnSchema1, 1);
CarbonMeasure carbonMeasure2 = new CarbonMeasure(columnSchema2, 2);
CarbonMeasure carbonMeasure3 = new CarbonMeasure(columnSchema3, 3);
carbonMeasure3.getColumnSchema().setDefaultValue("3".getBytes());
List<CarbonMeasure> currentBlockMeasures = Arrays.asList(carbonMeasure1, carbonMeasure2);
QueryMeasure queryMeasure1 = new QueryMeasure("Id");
queryMeasure1.setMeasure(carbonMeasure1);
QueryMeasure queryMeasure2 = new QueryMeasure("Name");
queryMeasure2.setMeasure(carbonMeasure2);
QueryMeasure queryMeasure3 = new QueryMeasure("Age");
queryMeasure3.setMeasure(carbonMeasure3);
List<QueryMeasure> queryMeasures = Arrays.asList(queryMeasure1, queryMeasure2, queryMeasure3);
BlockExecutionInfo blockExecutionInfo = new BlockExecutionInfo();
RestructureUtil.createMeasureInfoAndGetCurrentBlockQueryMeasures(blockExecutionInfo, queryMeasures, currentBlockMeasures);
MeasureInfo measureInfo = blockExecutionInfo.getMeasureInfo();
boolean[] measuresExist = { true, true, false };
assertThat(measureInfo.getMeasureExists(), is(equalTo(measuresExist)));
Object[] defaultValues = { null, null, 3.0 };
assertThat(measureInfo.getDefaultValues(), is(equalTo(defaultValues)));
}
use of org.apache.carbondata.core.scan.executor.infos.BlockExecutionInfo in project carbondata by apache.
the class RestructureUtilTest method testToGetUpdatedQueryDimension.
@Test
public void testToGetUpdatedQueryDimension() {
BlockExecutionInfo blockExecutionInfo = new BlockExecutionInfo();
List<Encoding> encodingList = new ArrayList<Encoding>();
encodingList.add(Encoding.DICTIONARY);
ColumnSchema columnSchema1 = new ColumnSchema();
columnSchema1.setColumnName("Id");
columnSchema1.setColumnUniqueId(UUID.randomUUID().toString());
columnSchema1.setEncodingList(encodingList);
ColumnSchema columnSchema2 = new ColumnSchema();
columnSchema2.setColumnName("Name");
columnSchema2.setColumnUniqueId(UUID.randomUUID().toString());
columnSchema2.setEncodingList(encodingList);
ColumnSchema columnSchema3 = new ColumnSchema();
columnSchema3.setColumnName("Age");
columnSchema3.setColumnUniqueId(UUID.randomUUID().toString());
columnSchema3.setEncodingList(encodingList);
ColumnSchema columnSchema4 = new ColumnSchema();
columnSchema4.setColumnName("Salary");
columnSchema4.setColumnUniqueId(UUID.randomUUID().toString());
columnSchema4.setEncodingList(encodingList);
ColumnSchema columnSchema5 = new ColumnSchema();
columnSchema5.setColumnName("Address");
columnSchema5.setColumnUniqueId(UUID.randomUUID().toString());
columnSchema5.setEncodingList(encodingList);
CarbonDimension tableBlockDimension1 = new CarbonDimension(columnSchema1, 1, 1, 1, 1);
CarbonDimension tableBlockDimension2 = new CarbonDimension(columnSchema2, 5, 5, 5, 5);
List<CarbonDimension> tableBlockDimensions = Arrays.asList(tableBlockDimension1, tableBlockDimension2);
CarbonDimension tableComplexDimension1 = new CarbonDimension(columnSchema3, 4, 4, 4, 4);
CarbonDimension tableComplexDimension2 = new CarbonDimension(columnSchema4, 2, 2, 2, 2);
List<CarbonDimension> tableComplexDimensions = Arrays.asList(tableComplexDimension1, tableComplexDimension2);
QueryDimension queryDimension1 = new QueryDimension("Id");
queryDimension1.setDimension(tableBlockDimension1);
QueryDimension queryDimension2 = new QueryDimension("Name");
queryDimension2.setDimension(tableComplexDimension2);
QueryDimension queryDimension3 = new QueryDimension("Address");
queryDimension3.setDimension(new CarbonDimension(columnSchema5, 3, 3, 3, 3));
List<QueryDimension> queryDimensions = Arrays.asList(queryDimension1, queryDimension2, queryDimension3);
List<QueryDimension> result = null;
result = RestructureUtil.createDimensionInfoAndGetCurrentBlockQueryDimension(blockExecutionInfo, queryDimensions, tableBlockDimensions, tableComplexDimensions);
List<CarbonDimension> resultDimension = new ArrayList<>(result.size());
for (QueryDimension queryDimension : result) {
resultDimension.add(queryDimension.getDimension());
}
assertThat(resultDimension, is(equalTo(Arrays.asList(queryDimension1.getDimension(), queryDimension2.getDimension()))));
}
Aggregations