Skip to content

Commit

Permalink
[CARBONDATA-3145] Read improvement for complex column pages while que…
Browse files Browse the repository at this point in the history
…rying
  • Loading branch information
dhatchayani committed Dec 5, 2018
1 parent 382ce43 commit 2f1f8b0
Showing 1 changed file with 15 additions and 2 deletions.
Expand Up @@ -18,7 +18,10 @@
package org.apache.carbondata.core.scan.complextypes;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.apache.carbondata.core.datastore.chunk.DimensionColumnPage;
import org.apache.carbondata.core.datastore.chunk.impl.DimensionRawColumnChunk;
import org.apache.carbondata.core.scan.processor.RawBlockletColumnChunks;

Expand All @@ -29,6 +32,8 @@ public class ComplexQueryType {

protected int blockIndex;

protected Map<Integer, DimensionColumnPage> decodedPagesWithPageNumber = new HashMap<>();

public ComplexQueryType(String name, String parentname, int blockIndex) {
this.name = name;
this.parentname = parentname;
Expand All @@ -41,8 +46,7 @@ public ComplexQueryType(String name, String parentname, int blockIndex) {
*/
protected byte[] copyBlockDataChunk(DimensionRawColumnChunk[] rawColumnChunks,
int rowNumber, int pageNumber) {
byte[] data =
rawColumnChunks[blockIndex].decodeColumnPage(pageNumber).getChunkData(rowNumber);
byte[] data = getDecodedPage(rawColumnChunks[blockIndex], pageNumber).getChunkData(rowNumber);
byte[] output = new byte[data.length];
System.arraycopy(data, 0, output, 0, output.length);
return output;
Expand All @@ -57,4 +61,13 @@ protected void readBlockDataChunk(RawBlockletColumnChunks blockChunkHolder) thro
.readDimensionChunk(blockChunkHolder.getFileReader(), blockIndex);
}
}

private DimensionColumnPage getDecodedPage(DimensionRawColumnChunk dimensionRawColumnChunk,
int pageNumber) {
if (null == this.decodedPagesWithPageNumber.get(pageNumber)) {
this.decodedPagesWithPageNumber
.put(pageNumber, dimensionRawColumnChunk.decodeColumnPage(pageNumber));
}
return this.decodedPagesWithPageNumber.get(pageNumber);
}
}

0 comments on commit 2f1f8b0

Please sign in to comment.