Github user sv71294 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2412#discussion_r199069988
--- Diff:
integration/presto/src/main/java/org/apache/carbondata/presto/readers/BooleanStreamReader.java
---
@@ -17,91 +17,64 @@
package org.apache.carbondata.presto.readers;
-import java.io.IOException;
-
import org.apache.carbondata.core.cache.dictionary.Dictionary;
+import org.apache.carbondata.core.metadata.datatype.DataType;
import org.apache.carbondata.core.metadata.datatype.DataTypes;
+import
org.apache.carbondata.core.scan.result.vector.impl.CarbonColumnVectorImpl;
import org.apache.carbondata.core.util.DataTypeUtil;
import com.facebook.presto.spi.block.Block;
import com.facebook.presto.spi.block.BlockBuilder;
import com.facebook.presto.spi.block.BlockBuilderStatus;
+import com.facebook.presto.spi.type.BooleanType;
import com.facebook.presto.spi.type.Type;
-public class BooleanStreamReader extends AbstractStreamReader {
+public class BooleanStreamReader extends CarbonColumnVectorImpl
+ implements PrestoVectorBlockBuilder {
- private boolean isDictionary;
- private Dictionary dictionary;
+ protected int batchSize;
- public BooleanStreamReader() {
+ protected Type type = BooleanType.BOOLEAN;
- }
+ protected BlockBuilder builder;
- public BooleanStreamReader(boolean isDictionary, Dictionary dictionary) {
- this.isDictionary = isDictionary;
+ private Dictionary dictionary;
+
+ public BooleanStreamReader(int batchSize, DataType dataType, Dictionary
dictionary) {
+ super(batchSize, dataType);
+ this.batchSize = batchSize;
+ this.builder = type.createBlockBuilder(new BlockBuilderStatus(),
batchSize);
this.dictionary = dictionary;
}
- public Block readBlock(Type type) throws IOException {
- int numberOfRows = 0;
- BlockBuilder builder = null;
- if (isVectorReader) {
- numberOfRows = batchSize;
- builder = type.createBlockBuilder(new BlockBuilderStatus(),
numberOfRows);
- if (columnVector != null) {
- if (isDictionary) {
- populateDictionaryVector(type, numberOfRows, builder);
- } else {
- if (columnVector.anyNullsSet()) {
- handleNullInVector(type, numberOfRows, builder);
- } else {
- populateVector(type, numberOfRows, builder);
- }
- }
- }
- } else {
- numberOfRows = streamData.length;
- builder = type.createBlockBuilder(new BlockBuilderStatus(),
numberOfRows);
- for (int i = 0; i < numberOfRows; i++) {
- type.writeBoolean(builder, byteToBoolean(streamData[i]));
- }
- }
-
+ @Override public Block buildBlock() {
return builder.build();
}
- private void handleNullInVector(Type type, int numberOfRows,
BlockBuilder builder) {
- for (int i = 0; i < numberOfRows; i++) {
- if (columnVector.isNullAt(i)) {
- builder.appendNull();
- } else {
- type.writeBoolean(builder, byteToBoolean(columnVector.getData(i)));
- }
+ @Override public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ @Override public void putInt(int rowId, int value) {
--- End diff --
in case of dictionary over the column, int is received and the actual value
is retrieved from the dictionary support
---