You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ch...@apache.org on 2016/08/15 07:09:11 UTC

[26/52] [partial] incubator-carbondata git commit: Renamed packages to org.apache.carbondata and fixed errors

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/filter/resolver/resolverinfo/visitor/NoDictionaryTypeVisitor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/filter/resolver/resolverinfo/visitor/NoDictionaryTypeVisitor.java b/core/src/main/java/org/apache/carbondata/scan/filter/resolver/resolverinfo/visitor/NoDictionaryTypeVisitor.java
new file mode 100644
index 0000000..e7db0dc
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/filter/resolver/resolverinfo/visitor/NoDictionaryTypeVisitor.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.scan.filter.resolver.resolverinfo.visitor;
+
+import java.util.List;
+
+import org.apache.carbondata.common.logging.LogService;
+import org.apache.carbondata.common.logging.LogServiceFactory;
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
+import org.apache.carbondata.scan.expression.exception.FilterIllegalMemberException;
+import org.apache.carbondata.scan.expression.exception.FilterUnsupportedException;
+import org.apache.carbondata.scan.filter.DimColumnFilterInfo;
+import org.apache.carbondata.scan.filter.FilterUtil;
+import org.apache.carbondata.scan.filter.resolver.metadata.FilterResolverMetadata;
+import org.apache.carbondata.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
+
+public class NoDictionaryTypeVisitor implements ResolvedFilterInfoVisitorIntf {
+  private static final LogService LOGGER =
+      LogServiceFactory.getLogService(NoDictionaryTypeVisitor.class.getName());
+
+  /**
+   * Visitor Method will update the filter related details in visitableObj, For no dictionary
+   * type columns the filter members will resolved directly, no need to look up in dictionary
+   * since it will not be part of dictionary, directly the actual data can be converted as
+   * byte[] and can be set. this type of encoding is effective when the particular column
+   * is having very high cardinality.
+   *
+   * @param visitableObj
+   * @param metadata
+   * @throws FilterUnsupportedException,if exception occurs while evaluating
+   * filter models.
+   */
+  public void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj,
+      FilterResolverMetadata metadata) throws FilterUnsupportedException {
+    DimColumnFilterInfo resolvedFilterObject = null;
+    List<String> evaluateResultListFinal;
+    try {
+      evaluateResultListFinal = metadata.getExpression().evaluate(null).getListAsString();
+      // Adding default  null member inorder to not display the same while
+      // displaying the report as per hive compatibility.
+      if (!metadata.isIncludeFilter() && !evaluateResultListFinal
+          .contains(CarbonCommonConstants.MEMBER_DEFAULT_VAL)) {
+        evaluateResultListFinal.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL);
+      }
+    } catch (FilterIllegalMemberException e) {
+      throw new FilterUnsupportedException(e);
+    }
+    resolvedFilterObject = FilterUtil
+        .getNoDictionaryValKeyMemberForFilter(metadata.getTableIdentifier(),
+            metadata.getColumnExpression(), evaluateResultListFinal, metadata.isIncludeFilter());
+    visitableObj.setFilterValues(resolvedFilterObject);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/filter/resolver/resolverinfo/visitor/ResolvedFilterInfoVisitorIntf.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/filter/resolver/resolverinfo/visitor/ResolvedFilterInfoVisitorIntf.java b/core/src/main/java/org/apache/carbondata/scan/filter/resolver/resolverinfo/visitor/ResolvedFilterInfoVisitorIntf.java
new file mode 100644
index 0000000..19ad3aa
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/filter/resolver/resolverinfo/visitor/ResolvedFilterInfoVisitorIntf.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.scan.filter.resolver.resolverinfo.visitor;
+
+import org.apache.carbondata.scan.expression.exception.FilterUnsupportedException;
+import org.apache.carbondata.scan.filter.resolver.metadata.FilterResolverMetadata;
+import org.apache.carbondata.scan.filter.resolver.resolverinfo.DimColumnResolvedFilterInfo;
+
+public interface ResolvedFilterInfoVisitorIntf {
+
+  /**
+   * Visitor pattern is been used in this scenario inorder to populate the
+   * dimColResolvedFilterInfo visitable object with filter member values based
+   * on the visitor type, currently there 3 types of visitors custom,direct
+   * and no dictionary, all types of visitor populate the visitable instance
+   * as per its buisness logic which is different for all the visitors.
+   *
+   * @param visitableObj
+   * @param metadata
+   * @throws QueryExecutionException
+   */
+  void populateFilterResolvedInfo(DimColumnResolvedFilterInfo visitableObj,
+      FilterResolverMetadata metadata) throws FilterUnsupportedException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/model/CarbonQueryPlan.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/model/CarbonQueryPlan.java b/core/src/main/java/org/apache/carbondata/scan/model/CarbonQueryPlan.java
new file mode 100644
index 0000000..18945d6
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/model/CarbonQueryPlan.java
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ *
+ */
+package org.apache.carbondata.scan.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
+import org.apache.carbondata.scan.expression.Expression;
+
+/**
+ * This class contains all the logical information about the query like dimensions,measures,
+ * sort order, topN etc..
+ */
+public class CarbonQueryPlan implements Serializable {
+  /**
+   *
+   */
+  private static final long serialVersionUID = -9036044826928017164L;
+
+  /**
+   * Database name
+   */
+  private String databaseName;
+
+  /**
+   * Table name
+   */
+  private String tableName;
+
+  /**
+   * List of dimensions.
+   * Ex : select employee_name,department_name,sum(salary) from employee, then employee_name
+   * and department_name are dimensions
+   * If there is no dimensions asked in query then it would be remained as empty.
+   */
+  private List<QueryDimension> dimensions =
+      new ArrayList<QueryDimension>(CarbonCommonConstants.CONSTANT_SIZE_TEN);
+
+  /**
+   * List of measures.
+   * Ex : select employee_name,department_name,sum(salary) from employee, then sum(salary)
+   * would be measure.
+   * If there is no dimensions asked in query then it would be remained as empty.
+   */
+  private List<QueryMeasure> measures =
+      new ArrayList<QueryMeasure>(CarbonCommonConstants.CONSTANT_SIZE_TEN);
+
+  /**
+   * Limit
+   */
+  private int limit = -1;
+
+  /**
+   * If it is detail query, no need to aggregate in backend
+   */
+  private boolean detailQuery;
+
+  /**
+   * expression
+   */
+  private Expression expression;
+
+  /**
+   * queryId
+   */
+  private String queryId;
+
+  /**
+   * outLocationPath
+   */
+  private String outLocationPath;
+
+  /**
+   * isCountStarQuery
+   */
+  private boolean isCountStartQuery;
+
+  private List<QueryDimension> sortedDimensions;
+
+  /**
+   * If it is raw detail query, no need to aggregate in backend. And it reurns with dictionary data
+   * with out decoding.
+   */
+  private boolean rawDetailQuery;
+
+  /**
+   * Constructor created with table name.
+   *
+   * @param tableName
+   */
+  public CarbonQueryPlan(String tableName) {
+    this.tableName = tableName;
+  }
+
+  /**
+   * Constructor created with database name and table name.
+   *
+   * @param databaseName
+   * @param tableName
+   */
+  public CarbonQueryPlan(String databaseName, String tableName) {
+    this.tableName = tableName;
+    this.databaseName = databaseName;
+  }
+
+  /**
+   * @return the dimensions
+   */
+  public List<QueryDimension> getDimensions() {
+    return dimensions;
+  }
+
+  public void addDimension(QueryDimension dimension) {
+    this.dimensions.add(dimension);
+  }
+
+  /**
+   * @return the measures
+   */
+  public List<QueryMeasure> getMeasures() {
+    return measures;
+  }
+
+  public void addMeasure(QueryMeasure measure) {
+    this.measures.add(measure);
+  }
+
+  public Expression getFilterExpression() {
+    return expression;
+  }
+
+  public void setFilterExpression(Expression expression) {
+    this.expression = expression;
+  }
+
+  /**
+   * @return the databaseName
+   */
+  public String getDatabaseName() {
+    return databaseName;
+  }
+
+  /**
+   * @return the tableName
+   */
+  public String getTableName() {
+    return tableName;
+  }
+
+  /**
+   * @return the limit
+   */
+  public int getLimit() {
+    return limit;
+  }
+
+  /**
+   * @param limit the limit to set
+   */
+  public void setLimit(int limit) {
+    this.limit = limit;
+  }
+
+  /**
+   * @return the detailQuery
+   */
+  public boolean isDetailQuery() {
+    return detailQuery;
+  }
+
+  /**
+   * @param detailQuery the detailQuery to set
+   */
+  public void setDetailQuery(boolean detailQuery) {
+    this.detailQuery = detailQuery;
+  }
+
+  public String getQueryId() {
+    return queryId;
+  }
+
+  public void setQueryId(String queryId) {
+    this.queryId = queryId;
+  }
+
+  public String getOutLocationPath() {
+    return outLocationPath;
+  }
+
+  public void setOutLocationPath(String outLocationPath) {
+    this.outLocationPath = outLocationPath;
+  }
+
+  public boolean isCountStarQuery() {
+    return isCountStartQuery;
+  }
+
+  public void setCountStartQuery(boolean isCountStartQuery) {
+    this.isCountStartQuery = isCountStartQuery;
+  }
+
+  public List<QueryDimension> getSortedDimemsions() {
+    return sortedDimensions;
+  }
+
+  public void setSortedDimemsions(List<QueryDimension> dims) {
+    this.sortedDimensions = dims;
+  }
+
+  public boolean isRawDetailQuery() {
+    return rawDetailQuery;
+  }
+
+  public void setRawDetailQuery(boolean rawDetailQuery) {
+    this.rawDetailQuery = rawDetailQuery;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/model/QueryColumn.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/model/QueryColumn.java b/core/src/main/java/org/apache/carbondata/scan/model/QueryColumn.java
new file mode 100644
index 0000000..0aa5266
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/model/QueryColumn.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.scan.model;
+
+import java.io.Serializable;
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants;
+
+/**
+ * query column  which will have information about column
+ */
+public class QueryColumn implements Serializable {
+
+  /**
+   * serialVersionUID
+   */
+  private static final long serialVersionUID = -4222306600480181084L;
+
+  /**
+   * name of the column
+   */
+  protected String columnName;
+
+  /**
+   * sort order in which column output will be sorted default it will be none
+   */
+  private SortOrderType sortOrder = SortOrderType.NONE;
+
+  /**
+   * query order in which result of the query will be send
+   */
+  private int queryOrder;
+
+  /**
+   * aggregation function applied on column
+   */
+
+  private String aggregationFunction=CarbonCommonConstants.DUMMY;
+
+  public QueryColumn(String columnName) {
+    this.columnName = columnName;
+  }
+
+  /**
+   * @return the sortOrder
+   */
+  public SortOrderType getSortOrder() {
+    return sortOrder;
+  }
+
+  /**
+   * @param sortOrder the sortOrder to set
+   */
+  public void setSortOrder(SortOrderType sortOrder) {
+    this.sortOrder = sortOrder;
+  }
+
+  /**
+   * @return the columnName
+   */
+  public String getColumnName() {
+    return columnName;
+  }
+
+  /**
+   * @return the queryOrder
+   */
+  public int getQueryOrder() {
+    return queryOrder;
+  }
+
+  /**
+   * @param queryOrder the queryOrder to set
+   */
+  public void setQueryOrder(int queryOrder) {
+    this.queryOrder = queryOrder;
+  }
+
+  /**
+   * @return the aggregationFunction
+   */
+  public String getAggregateFunction() {
+    return aggregationFunction;
+  }
+
+  /**
+   * @param aggregationFunction the aggregationFunction to set
+   */
+  public void setAggregateFunction(String aggregationFunction) {
+    this.aggregationFunction = aggregationFunction;
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/model/QueryDimension.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/model/QueryDimension.java b/core/src/main/java/org/apache/carbondata/scan/model/QueryDimension.java
new file mode 100644
index 0000000..1f1f2cb
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/model/QueryDimension.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.scan.model;
+
+import java.io.Serializable;
+
+import org.apache.carbondata.core.carbon.metadata.schema.table.column.CarbonDimension;
+
+/**
+ * query plan dimension which will holds the information about the query plan dimension
+ * this is done to avoid heavy object serialization
+ */
+public class QueryDimension extends QueryColumn implements Serializable {
+
+  /**
+   * serialVersionUID
+   */
+  private static final long serialVersionUID = -8492704093776645651L;
+  /**
+   * actual dimension column
+   */
+  private transient CarbonDimension dimension;
+
+  public QueryDimension(String columName) {
+    super(columName);
+  }
+
+  /**
+   * @return the dimension
+   */
+  public CarbonDimension getDimension() {
+    return dimension;
+  }
+
+  /**
+   * @param dimension the dimension to set
+   */
+  public void setDimension(CarbonDimension dimension) {
+    this.dimension = dimension;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/model/QueryMeasure.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/model/QueryMeasure.java b/core/src/main/java/org/apache/carbondata/scan/model/QueryMeasure.java
new file mode 100644
index 0000000..0ea84c7
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/model/QueryMeasure.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.scan.model;
+
+import java.io.Serializable;
+
+import org.apache.carbondata.core.carbon.metadata.schema.table.column.CarbonMeasure;
+
+/**
+ * query plan measure, this class will holds the information
+ * about measure present in the query, this is done to avoid the serialization
+ * of the heavy object
+ */
+public class QueryMeasure extends QueryColumn implements Serializable {
+
+  /**
+   * serialVersionUID
+   */
+  private static final long serialVersionUID = 1035512411375495414L;
+
+  /**
+   * actual carbon measure object
+   */
+  private transient CarbonMeasure measure;
+
+  public QueryMeasure(String columName) {
+    super(columName);
+  }
+
+  /**
+   * @return the measure
+   */
+  public CarbonMeasure getMeasure() {
+    return measure;
+  }
+
+  /**
+   * @param measure the measure to set
+   */
+  public void setMeasure(CarbonMeasure measure) {
+    this.measure = measure;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/model/QueryModel.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/model/QueryModel.java b/core/src/main/java/org/apache/carbondata/scan/model/QueryModel.java
new file mode 100644
index 0000000..81eb728
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/model/QueryModel.java
@@ -0,0 +1,507 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.scan.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.carbondata.core.cache.dictionary.Dictionary;
+import org.apache.carbondata.core.carbon.AbsoluteTableIdentifier;
+import org.apache.carbondata.core.carbon.datastore.block.TableBlockInfo;
+import org.apache.carbondata.core.carbon.metadata.schema.table.CarbonTable;
+import org.apache.carbondata.core.carbon.metadata.schema.table.column.CarbonColumn;
+import org.apache.carbondata.core.carbon.metadata.schema.table.column.CarbonDimension;
+import org.apache.carbondata.core.carbon.metadata.schema.table.column.CarbonMeasure;
+import org.apache.carbondata.core.carbon.querystatistics.QueryStatisticsRecorder;
+import org.apache.carbondata.core.util.CarbonUtil;
+import org.apache.carbondata.scan.expression.ColumnExpression;
+import org.apache.carbondata.scan.expression.Expression;
+import org.apache.carbondata.scan.expression.UnknownExpression;
+import org.apache.carbondata.scan.expression.conditional.ConditionalExpression;
+import org.apache.carbondata.scan.filter.resolver.FilterResolverIntf;
+
+/**
+ * Query model which will have all the detail
+ * about the query, This will be sent from driver to executor '
+ * This will be refereed to executing the query.
+ */
+public class QueryModel implements Serializable {
+
+  /**
+   * serialization version
+   */
+  private static final long serialVersionUID = -4674677234007089052L;
+  /**
+   * this will hold the information about the dictionary dimension
+   * which to
+   */
+  public transient Map<String, Dictionary> columnToDictionaryMapping;
+  /**
+   * Number of records to keep in memory.
+   */
+  public int inMemoryRecordSize;
+  /**
+   * list of dimension selected for in query
+   */
+  private List<QueryDimension> queryDimension;
+  /**
+   * list of dimension in which sorting is applied
+   */
+  private List<QueryDimension> sortDimension;
+  /**
+   * list of measure selected in query
+   */
+  private List<QueryMeasure> queryMeasures;
+  /**
+   * query id
+   */
+  private String queryId;
+  /**
+   * to check if it a aggregate table
+   */
+  private boolean isAggTable;
+  /**
+   * filter tree
+   */
+  private FilterResolverIntf filterExpressionResolverTree;
+  /**
+   * in case of lime query we need to know how many
+   * records will passed from executor
+   */
+  private int limit;
+
+  /**
+   * to check if it is a count star query , so processing will be different
+   */
+  private boolean isCountStarQuery;
+  /**
+   * to check whether aggregation is required during query execution
+   */
+  private boolean detailQuery;
+  /**
+   * table block information in which query will be executed
+   */
+  private List<TableBlockInfo> tableBlockInfos;
+  /**
+   * sort in which dimension will be get sorted
+   */
+  private byte[] sortOrder;
+  /**
+   * absolute table identifier
+   */
+  private AbsoluteTableIdentifier absoluteTableIdentifier;
+  /**
+   * in case of detail query with sort we are spilling to disk
+   * to this location will be used to write the temp file in this location
+   */
+  private String queryTempLocation;
+  /**
+   * To handle most of the computation in query engines like spark and hive, carbon should give
+   * raw detailed records to it.
+   */
+  private boolean forcedDetailRawQuery;
+  /**
+   * paritition column list
+   */
+  private List<String> paritionColumns;
+  /**
+   * table on which query will be executed
+   * TODO need to remove this ad pass only the path
+   * and carbon metadata will load the table from metadata file
+   */
+  private CarbonTable table;
+
+  private QueryStatisticsRecorder statisticsRecorder;
+
+  public QueryModel() {
+    tableBlockInfos = new ArrayList<TableBlockInfo>();
+    queryDimension = new ArrayList<QueryDimension>();
+    queryMeasures = new ArrayList<QueryMeasure>();
+    sortDimension = new ArrayList<QueryDimension>();
+    sortOrder = new byte[0];
+    paritionColumns = new ArrayList<String>();
+  }
+
+  public static QueryModel createModel(AbsoluteTableIdentifier absoluteTableIdentifier,
+      CarbonQueryPlan queryPlan, CarbonTable carbonTable) {
+    QueryModel queryModel = new QueryModel();
+    String factTableName = carbonTable.getFactTableName();
+    queryModel.setAbsoluteTableIdentifier(absoluteTableIdentifier);
+
+    fillQueryModel(queryPlan, carbonTable, queryModel, factTableName);
+
+    queryModel.setLimit(queryPlan.getLimit());
+    queryModel.setDetailQuery(queryPlan.isDetailQuery());
+    queryModel.setForcedDetailRawQuery(queryPlan.isRawDetailQuery());
+    queryModel.setQueryId(queryPlan.getQueryId());
+    queryModel.setQueryTempLocation(queryPlan.getOutLocationPath());
+    return queryModel;
+  }
+
+  private static void fillQueryModel(CarbonQueryPlan queryPlan, CarbonTable carbonTable,
+      QueryModel queryModel, String factTableName) {
+    queryModel.setAbsoluteTableIdentifier(carbonTable.getAbsoluteTableIdentifier());
+    queryModel.setQueryDimension(queryPlan.getDimensions());
+    fillSortInfoInModel(queryModel, queryPlan.getSortedDimemsions());
+    queryModel.setQueryMeasures(queryPlan.getMeasures());
+    if (null != queryPlan.getFilterExpression()) {
+      processFilterExpression(queryPlan.getFilterExpression(),
+          carbonTable.getDimensionByTableName(factTableName),
+          carbonTable.getMeasureByTableName(factTableName));
+    }
+    queryModel.setCountStarQuery(queryPlan.isCountStarQuery());
+    //TODO need to remove this code, and executor will load the table
+    // from file metadata
+    queryModel.setTable(carbonTable);
+  }
+
+  private static void fillSortInfoInModel(QueryModel executorModel,
+      List<QueryDimension> sortedDims) {
+    if (null != sortedDims) {
+      byte[] sortOrderByteArray = new byte[sortedDims.size()];
+      int i = 0;
+      for (QueryColumn mdim : sortedDims) {
+        sortOrderByteArray[i++] = (byte) mdim.getSortOrder().ordinal();
+      }
+      executorModel.setSortOrder(sortOrderByteArray);
+      executorModel.setSortDimension(sortedDims);
+    } else {
+      executorModel.setSortOrder(new byte[0]);
+      executorModel.setSortDimension(new ArrayList<QueryDimension>(0));
+    }
+
+  }
+
+  public static void processFilterExpression(
+      Expression filterExpression, List<CarbonDimension> dimensions, List<CarbonMeasure> measures) {
+    if (null != filterExpression) {
+      if (null != filterExpression.getChildren() && filterExpression.getChildren().size() == 0) {
+        if (filterExpression instanceof ConditionalExpression) {
+          List<ColumnExpression> listOfCol =
+              ((ConditionalExpression) filterExpression).getColumnList();
+          for (ColumnExpression expression : listOfCol) {
+            setDimAndMsrColumnNode(dimensions, measures, (ColumnExpression) expression);
+          }
+
+        }
+      }
+      for (Expression expression : filterExpression.getChildren()) {
+
+        if (expression instanceof ColumnExpression) {
+          setDimAndMsrColumnNode(dimensions, measures, (ColumnExpression) expression);
+        } else if (expression instanceof UnknownExpression) {
+          UnknownExpression exp = ((UnknownExpression) expression);
+          List<ColumnExpression> listOfColExpression = exp.getAllColumnList();
+          for (ColumnExpression col : listOfColExpression) {
+            setDimAndMsrColumnNode(dimensions, measures, col);
+          }
+        } else {
+          processFilterExpression(expression, dimensions, measures);
+        }
+      }
+    }
+
+  }
+
+  private static CarbonMeasure getCarbonMetadataMeasure(String name, List<CarbonMeasure> measures) {
+    for (CarbonMeasure measure : measures) {
+      if (measure.getColName().equalsIgnoreCase(name)) {
+        return measure;
+      }
+    }
+    return null;
+  }
+
+  private static void setDimAndMsrColumnNode(List<CarbonDimension> dimensions,
+      List<CarbonMeasure> measures, ColumnExpression col) {
+    CarbonDimension dim;
+    CarbonMeasure msr;
+    String columnName;
+    columnName = col.getColumnName();
+    dim = CarbonUtil.findDimension(dimensions, columnName);
+    col.setCarbonColumn(dim);
+    col.setDimension(dim);
+    col.setDimension(true);
+    if (null == dim) {
+      msr = getCarbonMetadataMeasure(columnName, measures);
+      col.setCarbonColumn(msr);
+      col.setDimension(false);
+    }
+  }
+
+  /**
+   * It gets the projection columns
+   */
+  public CarbonColumn[] getProjectionColumns() {
+    CarbonColumn[] carbonColumns =
+        new CarbonColumn[getQueryDimension().size() + getQueryMeasures().size()];
+    for (QueryDimension dimension : getQueryDimension()) {
+      carbonColumns[dimension.getQueryOrder()] = dimension.getDimension();
+    }
+    for (QueryMeasure msr : getQueryMeasures()) {
+      carbonColumns[msr.getQueryOrder()] = msr.getMeasure();
+    }
+    return carbonColumns;
+  }
+
+  /**
+   * @return the queryDimension
+   */
+  public List<QueryDimension> getQueryDimension() {
+    return queryDimension;
+  }
+
+  /**
+   * @param queryDimension the queryDimension to set
+   */
+  public void setQueryDimension(List<QueryDimension> queryDimension) {
+    this.queryDimension = queryDimension;
+  }
+
+  /**
+   * @return the queryMeasures
+   */
+  public List<QueryMeasure> getQueryMeasures() {
+    return queryMeasures;
+  }
+
+  /**
+   * @param queryMeasures the queryMeasures to set
+   */
+  public void setQueryMeasures(List<QueryMeasure> queryMeasures) {
+    this.queryMeasures = queryMeasures;
+  }
+
+  /**
+   * @return the queryId
+   */
+  public String getQueryId() {
+    return queryId;
+  }
+
+  /**
+   * @param queryId the queryId to set
+   */
+  public void setQueryId(String queryId) {
+    this.queryId = queryId;
+  }
+
+  /**
+   * @return the isAggTable
+   */
+  public boolean isAggTable() {
+    return isAggTable;
+  }
+
+  /**
+   * @param isAggTable the isAggTable to set
+   */
+  public void setAggTable(boolean isAggTable) {
+    this.isAggTable = isAggTable;
+  }
+
+  /**
+   * @return the limit
+   */
+  public int getLimit() {
+    return limit;
+  }
+
+  /**
+   * @param limit the limit to set
+   */
+  public void setLimit(int limit) {
+    this.limit = limit;
+  }
+
+  /**
+   * @return the isCountStarQuery
+   */
+  public boolean isCountStarQuery() {
+    return isCountStarQuery;
+  }
+
+  /**
+   * @param isCountStarQuery the isCountStarQuery to set
+   */
+  public void setCountStarQuery(boolean isCountStarQuery) {
+    this.isCountStarQuery = isCountStarQuery;
+  }
+
+  /**
+   * @return the isdetailQuery
+   */
+  public boolean isDetailQuery() {
+    return detailQuery;
+  }
+
+  public void setDetailQuery(boolean detailQuery) {
+    this.detailQuery = detailQuery;
+  }
+
+  /**
+   * @return the tableBlockInfos
+   */
+  public List<TableBlockInfo> getTableBlockInfos() {
+    return tableBlockInfos;
+  }
+
+  /**
+   * @param tableBlockInfos the tableBlockInfos to set
+   */
+  public void setTableBlockInfos(List<TableBlockInfo> tableBlockInfos) {
+    this.tableBlockInfos = tableBlockInfos;
+  }
+
+  /**
+   * @return the queryTempLocation
+   */
+  public String getQueryTempLocation() {
+    return queryTempLocation;
+  }
+
+  /**
+   * @param queryTempLocation the queryTempLocation to set
+   */
+  public void setQueryTempLocation(String queryTempLocation) {
+    this.queryTempLocation = queryTempLocation;
+  }
+
+  /**
+   * @return the sortOrder
+   */
+  public byte[] getSortOrder() {
+    return sortOrder;
+  }
+
+  /**
+   * @param sortOrder the sortOrder to set
+   */
+  public void setSortOrder(byte[] sortOrder) {
+    this.sortOrder = sortOrder;
+  }
+
+  /**
+   * @return the sortDimension
+   */
+  public List<QueryDimension> getSortDimension() {
+    return sortDimension;
+  }
+
+  /**
+   * @param sortDimension the sortDimension to set
+   */
+  public void setSortDimension(List<QueryDimension> sortDimension) {
+    this.sortDimension = sortDimension;
+  }
+
+  /**
+   * @return the filterEvaluatorTree
+   */
+  public FilterResolverIntf getFilterExpressionResolverTree() {
+    return filterExpressionResolverTree;
+  }
+
+  public void setFilterExpressionResolverTree(FilterResolverIntf filterExpressionResolverTree) {
+    this.filterExpressionResolverTree = filterExpressionResolverTree;
+  }
+
+  /**
+   * @return the absoluteTableIdentifier
+   */
+  public AbsoluteTableIdentifier getAbsoluteTableIdentifier() {
+    return absoluteTableIdentifier;
+  }
+
+  /**
+   * @param absoluteTableIdentifier the absoluteTableIdentifier to set
+   */
+  public void setAbsoluteTableIdentifier(AbsoluteTableIdentifier absoluteTableIdentifier) {
+    this.absoluteTableIdentifier = absoluteTableIdentifier;
+  }
+
+  /**
+   * @return the paritionColumns
+   */
+  public List<String> getParitionColumns() {
+    return paritionColumns;
+  }
+
+  /**
+   * @param paritionColumns the paritionColumns to set
+   */
+  public void setParitionColumns(List<String> paritionColumns) {
+    this.paritionColumns = paritionColumns;
+  }
+
+  /**
+   * @return the table
+   */
+  public CarbonTable getTable() {
+    return table;
+  }
+
+  /**
+   * @param table the table to set
+   */
+  public void setTable(CarbonTable table) {
+    this.table = table;
+  }
+
+  public boolean isForcedDetailRawQuery() {
+    return forcedDetailRawQuery;
+  }
+
+  public void setForcedDetailRawQuery(boolean forcedDetailRawQuery) {
+    this.forcedDetailRawQuery = forcedDetailRawQuery;
+  }
+
+  /**
+   * @return
+   */
+  public Map<String, Dictionary> getColumnToDictionaryMapping() {
+    return columnToDictionaryMapping;
+  }
+
+  /**
+   * @param columnToDictionaryMapping
+   */
+  public void setColumnToDictionaryMapping(Map<String, Dictionary> columnToDictionaryMapping) {
+    this.columnToDictionaryMapping = columnToDictionaryMapping;
+  }
+
+  public int getInMemoryRecordSize() {
+    return inMemoryRecordSize;
+  }
+
+  public void setInMemoryRecordSize(int inMemoryRecordSize) {
+    this.inMemoryRecordSize = inMemoryRecordSize;
+  }
+
+  public QueryStatisticsRecorder getStatisticsRecorder() {
+    return statisticsRecorder;
+  }
+
+  public void setStatisticsRecorder(QueryStatisticsRecorder statisticsRecorder) {
+    this.statisticsRecorder = statisticsRecorder;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/model/QuerySchemaInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/model/QuerySchemaInfo.java b/core/src/main/java/org/apache/carbondata/scan/model/QuerySchemaInfo.java
new file mode 100644
index 0000000..185609f
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/model/QuerySchemaInfo.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.scan.model;
+
+import java.io.Serializable;
+
+import org.apache.carbondata.core.keygenerator.KeyGenerator;
+
+public class QuerySchemaInfo implements Serializable {
+
+  private int[] maskedByteIndexes;
+
+  private KeyGenerator keyGenerator;
+
+  private QueryDimension[] queryDimensions;
+
+  private QueryMeasure[] queryMeasures;
+
+  private int[] queryOrder;
+
+  private int[] queryReverseOrder;
+
+  public int[] getMaskedByteIndexes() {
+    return maskedByteIndexes;
+  }
+
+  public void setMaskedByteIndexes(int[] maskedByteIndexes) {
+    this.maskedByteIndexes = maskedByteIndexes;
+  }
+
+  public KeyGenerator getKeyGenerator() {
+    return keyGenerator;
+  }
+
+  public void setKeyGenerator(KeyGenerator keyGenerator) {
+    this.keyGenerator = keyGenerator;
+  }
+
+  public QueryDimension[] getQueryDimensions() {
+    return queryDimensions;
+  }
+
+  public void setQueryDimensions(QueryDimension[] queryDimensions) {
+    this.queryDimensions = queryDimensions;
+  }
+
+  public QueryMeasure[] getQueryMeasures() {
+    return queryMeasures;
+  }
+
+  public void setQueryMeasures(QueryMeasure[] queryMeasures) {
+    this.queryMeasures = queryMeasures;
+  }
+
+  public int[] getQueryOrder() {
+    return queryOrder;
+  }
+
+  public void setQueryOrder(int[] queryOrder) {
+    this.queryOrder = queryOrder;
+  }
+
+  public int[] getQueryReverseOrder() {
+    return queryReverseOrder;
+  }
+
+  public void setQueryReverseOrder(int[] queryReverseOrder) {
+    this.queryReverseOrder = queryReverseOrder;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/model/SortOrderType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/model/SortOrderType.java b/core/src/main/java/org/apache/carbondata/scan/model/SortOrderType.java
new file mode 100644
index 0000000..ba725b7
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/model/SortOrderType.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.scan.model;
+
+/**
+ * enum for sorting the columns
+ */
+public enum SortOrderType {
+
+    /**
+     * Ascending order
+     */
+    ASC(0),
+
+    /**
+     * Descending order.
+     */
+    DSC(1),
+
+    /**
+     * No order mentioned
+     */
+    NONE(-1);
+  /**
+   * Order type in numeric
+   */
+  private int orderType;
+
+  SortOrderType(int orderType) {
+    this.orderType = orderType;
+  }
+
+  /**
+   * Order type in number
+   *
+   * @return orderType int
+   */
+  public int getOrderType() {
+    return orderType;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/processor/AbstractDataBlockIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/processor/AbstractDataBlockIterator.java b/core/src/main/java/org/apache/carbondata/scan/processor/AbstractDataBlockIterator.java
new file mode 100644
index 0000000..c6bc32c
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/processor/AbstractDataBlockIterator.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.scan.processor;
+
+import java.util.List;
+
+import org.apache.carbondata.common.CarbonIterator;
+import org.apache.carbondata.common.logging.LogService;
+import org.apache.carbondata.common.logging.LogServiceFactory;
+import org.apache.carbondata.core.carbon.datastore.DataRefNode;
+import org.apache.carbondata.core.datastorage.store.FileHolder;
+import org.apache.carbondata.scan.collector.ScannedResultCollector;
+import org.apache.carbondata.scan.collector.impl.DictionaryBasedResultCollector;
+import org.apache.carbondata.scan.collector.impl.RawBasedResultCollector;
+import org.apache.carbondata.scan.executor.exception.QueryExecutionException;
+import org.apache.carbondata.scan.executor.infos.BlockExecutionInfo;
+import org.apache.carbondata.scan.result.AbstractScannedResult;
+import org.apache.carbondata.scan.scanner.BlockletScanner;
+import org.apache.carbondata.scan.scanner.impl.FilterScanner;
+import org.apache.carbondata.scan.scanner.impl.NonFilterScanner;
+
+/**
+ * This abstract class provides a skeletal implementation of the
+ * Block iterator.
+ */
+public abstract class AbstractDataBlockIterator extends CarbonIterator<List<Object[]>> {
+
+  private static final LogService LOGGER =
+      LogServiceFactory.getLogService(AbstractDataBlockIterator.class.getName());
+  /**
+   * iterator which will be used to iterate over data blocks
+   */
+  protected CarbonIterator<DataRefNode> dataBlockIterator;
+
+  /**
+   * execution details
+   */
+  protected BlockExecutionInfo blockExecutionInfo;
+
+  /**
+   * result collector which will be used to aggregate the scanned result
+   */
+  protected ScannedResultCollector scannerResultAggregator;
+
+  /**
+   * processor which will be used to process the block processing can be
+   * filter processing or non filter processing
+   */
+  protected BlockletScanner blockletScanner;
+
+  /**
+   * to hold the data block
+   */
+  protected BlocksChunkHolder blocksChunkHolder;
+
+  /**
+   * batch size of result
+   */
+  protected int batchSize;
+
+  protected AbstractScannedResult scannedResult;
+
+  public AbstractDataBlockIterator(BlockExecutionInfo blockExecutionInfo,
+      FileHolder fileReader, int batchSize) {
+    this.blockExecutionInfo = blockExecutionInfo;
+    dataBlockIterator = new BlockletIterator(blockExecutionInfo.getFirstDataBlock(),
+        blockExecutionInfo.getNumberOfBlockToScan());
+    blocksChunkHolder = new BlocksChunkHolder(blockExecutionInfo.getTotalNumberDimensionBlock(),
+        blockExecutionInfo.getTotalNumberOfMeasureBlock());
+    blocksChunkHolder.setFileReader(fileReader);
+
+    if (blockExecutionInfo.getFilterExecuterTree() != null) {
+      blockletScanner = new FilterScanner(blockExecutionInfo);
+    } else {
+      blockletScanner = new NonFilterScanner(blockExecutionInfo);
+    }
+    if (blockExecutionInfo.isRawRecordDetailQuery()) {
+      this.scannerResultAggregator =
+          new RawBasedResultCollector(blockExecutionInfo);
+    } else {
+      this.scannerResultAggregator =
+          new DictionaryBasedResultCollector(blockExecutionInfo);
+    }
+    this.batchSize = batchSize;
+  }
+
+  public boolean hasNext() {
+    if (scannedResult != null && scannedResult.hasNext()) {
+      return true;
+    } else {
+      return dataBlockIterator.hasNext();
+    }
+  }
+
+  protected boolean updateScanner() {
+    try {
+      if (scannedResult != null && scannedResult.hasNext()) {
+        return true;
+      } else {
+        scannedResult = getNextScannedResult();
+        while (scannedResult != null) {
+          if (scannedResult.hasNext()) {
+            return true;
+          }
+          scannedResult = getNextScannedResult();
+        }
+        return false;
+      }
+    } catch (QueryExecutionException ex) {
+      throw new RuntimeException(ex);
+    }
+  }
+
+  private AbstractScannedResult getNextScannedResult() throws QueryExecutionException {
+    if (dataBlockIterator.hasNext()) {
+      blocksChunkHolder.setDataBlock(dataBlockIterator.next());
+      blocksChunkHolder.reset();
+      return blockletScanner.scanBlocklet(blocksChunkHolder);
+    }
+    return null;
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/processor/BlockletIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/processor/BlockletIterator.java b/core/src/main/java/org/apache/carbondata/scan/processor/BlockletIterator.java
new file mode 100644
index 0000000..73ac1be
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/processor/BlockletIterator.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.scan.processor;
+
+import org.apache.carbondata.common.CarbonIterator;
+import org.apache.carbondata.core.carbon.datastore.DataRefNode;
+
+/**
+ * Below class will be used to iterate over data block
+ */
+public class BlockletIterator extends CarbonIterator<DataRefNode> {
+  /**
+   * data store block
+   */
+  protected DataRefNode datablock;
+  /**
+   * block counter to keep a track how many block has been processed
+   */
+  private int blockCounter;
+
+  /**
+   * flag to be used to check any more data block is present or not
+   */
+  private boolean hasNext = true;
+
+  /**
+   * total number blocks assgned to this iterator
+   */
+  private long totalNumberOfBlocksToScan;
+
+  /**
+   * Constructor
+   *
+   * @param datablock                 first data block
+   * @param totalNumberOfBlocksToScan total number of blocks to be scanned
+   */
+  public BlockletIterator(DataRefNode datablock, long totalNumberOfBlocksToScan) {
+    this.datablock = datablock;
+    this.totalNumberOfBlocksToScan = totalNumberOfBlocksToScan;
+  }
+
+  /**
+   * is all the blocks assigned to this iterator has been processed
+   */
+  @Override public boolean hasNext() {
+    return hasNext;
+  }
+
+  @Override
+  /**
+   * To get the next block
+   * @return next data block
+   *
+   */
+  public DataRefNode next() {
+    // get the current blocks
+    DataRefNode datablockTemp = datablock;
+    // store the next data block
+    datablock = datablock.getNextDataRefNode();
+    // increment the counter
+    blockCounter++;
+    // if all the data block is processed then
+    // set the has next flag to false
+    // or if number of blocks assigned to this iterator is processed
+    // then also set the hasnext flag to false
+    if (null == datablock || blockCounter >= this.totalNumberOfBlocksToScan) {
+      hasNext = false;
+    }
+    return datablockTemp;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/processor/BlocksChunkHolder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/processor/BlocksChunkHolder.java b/core/src/main/java/org/apache/carbondata/scan/processor/BlocksChunkHolder.java
new file mode 100644
index 0000000..47cac0c
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/processor/BlocksChunkHolder.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.scan.processor;
+
+import org.apache.carbondata.core.carbon.datastore.DataRefNode;
+import org.apache.carbondata.core.carbon.datastore.chunk.DimensionColumnDataChunk;
+import org.apache.carbondata.core.carbon.datastore.chunk.MeasureColumnDataChunk;
+import org.apache.carbondata.core.datastorage.store.FileHolder;
+
+/**
+ * Block chunk holder which will hold the dimension and
+ * measure chunk
+ */
+public class BlocksChunkHolder {
+
+  /**
+   * dimension column data chunk
+   */
+  private DimensionColumnDataChunk[] dimensionDataChunk;
+
+  /**
+   * measure column data chunk
+   */
+  private MeasureColumnDataChunk[] measureDataChunk;
+
+  /**
+   * file reader which will use to read the block from file
+   */
+  private FileHolder fileReader;
+
+  /**
+   * data block
+   */
+  private DataRefNode dataBlock;
+
+  public BlocksChunkHolder(int numberOfDimensionBlock, int numberOfMeasureBlock) {
+    dimensionDataChunk = new DimensionColumnDataChunk[numberOfDimensionBlock];
+    measureDataChunk = new MeasureColumnDataChunk[numberOfMeasureBlock];
+  }
+
+  /**
+   * @return the dimensionDataChunk
+   */
+  public DimensionColumnDataChunk[] getDimensionDataChunk() {
+    return dimensionDataChunk;
+  }
+
+  /**
+   * @param dimensionDataChunk the dimensionDataChunk to set
+   */
+  public void setDimensionDataChunk(DimensionColumnDataChunk[] dimensionDataChunk) {
+    this.dimensionDataChunk = dimensionDataChunk;
+  }
+
+  /**
+   * @return the measureDataChunk
+   */
+  public MeasureColumnDataChunk[] getMeasureDataChunk() {
+    return measureDataChunk;
+  }
+
+  /**
+   * @param measureDataChunk the measureDataChunk to set
+   */
+  public void setMeasureDataChunk(MeasureColumnDataChunk[] measureDataChunk) {
+    this.measureDataChunk = measureDataChunk;
+  }
+
+  /**
+   * @return the fileReader
+   */
+  public FileHolder getFileReader() {
+    return fileReader;
+  }
+
+  /**
+   * @param fileReader the fileReader to set
+   */
+  public void setFileReader(FileHolder fileReader) {
+    this.fileReader = fileReader;
+  }
+
+  /**
+   * @return the dataBlock
+   */
+  public DataRefNode getDataBlock() {
+    return dataBlock;
+  }
+
+  /**
+   * @param dataBlock the dataBlock to set
+   */
+  public void setDataBlock(DataRefNode dataBlock) {
+    this.dataBlock = dataBlock;
+  }
+
+  /***
+   * To reset the measure chunk and dimension chunk
+   * array
+   */
+  public void reset() {
+    for (int i = 0; i < measureDataChunk.length; i++) {
+      this.measureDataChunk[i] = null;
+    }
+    for (int i = 0; i < dimensionDataChunk.length; i++) {
+      this.dimensionDataChunk[i] = null;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/processor/impl/DataBlockIteratorImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/processor/impl/DataBlockIteratorImpl.java b/core/src/main/java/org/apache/carbondata/scan/processor/impl/DataBlockIteratorImpl.java
new file mode 100644
index 0000000..3bdbf3a
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/processor/impl/DataBlockIteratorImpl.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.scan.processor.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.carbondata.core.datastorage.store.FileHolder;
+import org.apache.carbondata.scan.executor.infos.BlockExecutionInfo;
+import org.apache.carbondata.scan.processor.AbstractDataBlockIterator;
+
+/**
+ * Below class will be used to process the block for detail query
+ */
+public class DataBlockIteratorImpl extends AbstractDataBlockIterator {
+
+  /**
+   * DataBlockIteratorImpl Constructor
+   *
+   * @param blockExecutionInfo execution information
+   */
+  public DataBlockIteratorImpl(BlockExecutionInfo blockExecutionInfo, FileHolder fileReader,
+      int batchSize) {
+    super(blockExecutionInfo, fileReader, batchSize);
+  }
+
+  /**
+   * It scans the block and returns the result with @batchSize
+   *
+   * @return Result of @batchSize
+   */
+  public List<Object[]> next() {
+    List<Object[]> collectedResult = null;
+    if (updateScanner()) {
+      collectedResult = this.scannerResultAggregator.collectData(scannedResult, batchSize);
+      while (collectedResult.size() < batchSize && updateScanner()) {
+        List<Object[]> data = this.scannerResultAggregator
+            .collectData(scannedResult, batchSize - collectedResult.size());
+        collectedResult.addAll(data);
+      }
+    } else {
+      collectedResult = new ArrayList<>();
+    }
+    return collectedResult;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/result/AbstractScannedResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/result/AbstractScannedResult.java b/core/src/main/java/org/apache/carbondata/scan/result/AbstractScannedResult.java
new file mode 100644
index 0000000..1e7b7d8
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/result/AbstractScannedResult.java
@@ -0,0 +1,437 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.scan.result;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.apache.carbondata.common.logging.LogService;
+import org.apache.carbondata.common.logging.LogServiceFactory;
+import org.apache.carbondata.core.carbon.datastore.chunk.DimensionColumnDataChunk;
+import org.apache.carbondata.core.carbon.datastore.chunk.MeasureColumnDataChunk;
+import org.apache.carbondata.core.util.CarbonUtil;
+import org.apache.carbondata.scan.executor.infos.BlockExecutionInfo;
+import org.apache.carbondata.scan.executor.infos.KeyStructureInfo;
+import org.apache.carbondata.scan.filter.GenericQueryType;
+
+/**
+ * Scanned result class which will store and provide the result on request
+ */
+public abstract class AbstractScannedResult {
+
+  private static final LogService LOGGER =
+      LogServiceFactory.getLogService(AbstractScannedResult.class.getName());
+  /**
+   * current row number
+   */
+  protected int currentRow = -1;
+  /**
+   * row mapping indexes
+   */
+  protected int[] rowMapping;
+  /**
+   * key size of the fixed length column
+   */
+  private int fixedLengthKeySize;
+  /**
+   * total number of rows
+   */
+  private int totalNumberOfRows;
+  /**
+   * to keep track of number of rows process
+   */
+  private int rowCounter;
+  /**
+   * dimension column data chunk
+   */
+  private DimensionColumnDataChunk[] dataChunks;
+  /**
+   * measure column data chunk
+   */
+  private MeasureColumnDataChunk[] measureDataChunks;
+  /**
+   * dictionary column block index in file
+   */
+  private int[] dictionaryColumnBlockIndexes;
+
+  /**
+   * no dictionary column block index in file
+   */
+  private int[] noDictionaryColumnBlockIndexes;
+
+  /**
+   * column group to is key structure info
+   * which will be used to get the key from the complete
+   * column group key
+   * For example if only one dimension of the column group is selected
+   * then from complete column group key it will be used to mask the key and
+   * get the particular column key
+   */
+  private Map<Integer, KeyStructureInfo> columnGroupKeyStructureInfo;
+
+  /**
+   *
+   */
+  private Map<Integer, GenericQueryType> complexParentIndexToQueryMap;
+
+  private int totalDimensionsSize;
+
+  /**
+   * parent block indexes
+   */
+  private int[] complexParentBlockIndexes;
+
+  public AbstractScannedResult(BlockExecutionInfo blockExecutionInfo) {
+    this.fixedLengthKeySize = blockExecutionInfo.getFixedLengthKeySize();
+    this.noDictionaryColumnBlockIndexes = blockExecutionInfo.getNoDictionaryBlockIndexes();
+    this.dictionaryColumnBlockIndexes = blockExecutionInfo.getDictionaryColumnBlockIndex();
+    this.columnGroupKeyStructureInfo = blockExecutionInfo.getColumnGroupToKeyStructureInfo();
+    this.complexParentIndexToQueryMap = blockExecutionInfo.getComlexDimensionInfoMap();
+    this.complexParentBlockIndexes = blockExecutionInfo.getComplexColumnParentBlockIndexes();
+    this.totalDimensionsSize = blockExecutionInfo.getQueryDimensions().length;
+  }
+
+  /**
+   * Below method will be used to set the dimension chunks
+   * which will be used to create a row
+   *
+   * @param dataChunks dimension chunks used in query
+   */
+  public void setDimensionChunks(DimensionColumnDataChunk[] dataChunks) {
+    this.dataChunks = dataChunks;
+  }
+
+  /**
+   * Below method will be used to set the measure column chunks
+   *
+   * @param measureDataChunks measure data chunks
+   */
+  public void setMeasureChunks(MeasureColumnDataChunk[] measureDataChunks) {
+    this.measureDataChunks = measureDataChunks;
+  }
+
+  /**
+   * Below method will be used to get the chunk based in measure ordinal
+   *
+   * @param ordinal measure ordinal
+   * @return measure column chunk
+   */
+  public MeasureColumnDataChunk getMeasureChunk(int ordinal) {
+    return measureDataChunks[ordinal];
+  }
+
+  /**
+   * Below method will be used to get the key for all the dictionary dimensions
+   * which is present in the query
+   *
+   * @param rowId row id selected after scanning
+   * @return return the dictionary key
+   */
+  protected byte[] getDictionaryKeyArray(int rowId) {
+    byte[] completeKey = new byte[fixedLengthKeySize];
+    int offset = 0;
+    for (int i = 0; i < this.dictionaryColumnBlockIndexes.length; i++) {
+      offset += dataChunks[dictionaryColumnBlockIndexes[i]]
+          .fillChunkData(completeKey, offset, rowId,
+              columnGroupKeyStructureInfo.get(dictionaryColumnBlockIndexes[i]));
+    }
+    rowCounter++;
+    return completeKey;
+  }
+
+  /**
+   * Below method will be used to get the key for all the dictionary dimensions
+   * in integer array format which is present in the query
+   *
+   * @param rowId row id selected after scanning
+   * @return return the dictionary key
+   */
+  protected int[] getDictionaryKeyIntegerArray(int rowId) {
+    int[] completeKey = new int[totalDimensionsSize];
+    int column = 0;
+    for (int i = 0; i < this.dictionaryColumnBlockIndexes.length; i++) {
+      column = dataChunks[dictionaryColumnBlockIndexes[i]]
+          .fillConvertedChunkData(rowId, column, completeKey,
+              columnGroupKeyStructureInfo.get(dictionaryColumnBlockIndexes[i]));
+    }
+    rowCounter++;
+    return completeKey;
+  }
+
+  /**
+   * Just increment the counter incase of query only on measures.
+   */
+  public void incrementCounter() {
+    rowCounter ++;
+    currentRow ++;
+  }
+
+  /**
+   * Below method will be used to get the dimension data based on dimension
+   * ordinal and index
+   *
+   * @param dimOrdinal dimension ordinal present in the query
+   * @param rowId      row index
+   * @return dimension data based on row id
+   */
+  protected byte[] getDimensionData(int dimOrdinal, int rowId) {
+    return dataChunks[dimOrdinal].getChunkData(rowId);
+  }
+
+  /**
+   * Below method will be used to get the dimension key array
+   * for all the no dictionary dimension present in the query
+   *
+   * @param rowId row number
+   * @return no dictionary keys for all no dictionary dimension
+   */
+  protected byte[][] getNoDictionaryKeyArray(int rowId) {
+    byte[][] noDictionaryColumnsKeys = new byte[noDictionaryColumnBlockIndexes.length][];
+    int position = 0;
+    for (int i = 0; i < this.noDictionaryColumnBlockIndexes.length; i++) {
+      noDictionaryColumnsKeys[position++] =
+          dataChunks[noDictionaryColumnBlockIndexes[i]].getChunkData(rowId);
+    }
+    return noDictionaryColumnsKeys;
+  }
+
+  /**
+   * Below method will be used to get the dimension key array
+   * for all the no dictionary dimension present in the query
+   *
+   * @param rowId row number
+   * @return no dictionary keys for all no dictionary dimension
+   */
+  protected String[] getNoDictionaryKeyStringArray(int rowId) {
+    String[] noDictionaryColumnsKeys = new String[noDictionaryColumnBlockIndexes.length];
+    int position = 0;
+    for (int i = 0; i < this.noDictionaryColumnBlockIndexes.length; i++) {
+      noDictionaryColumnsKeys[position++] =
+          new String(dataChunks[noDictionaryColumnBlockIndexes[i]].getChunkData(rowId));
+    }
+    return noDictionaryColumnsKeys;
+  }
+
+  /**
+   * Below method will be used to get the complex type keys array based
+   * on row id for all the complex type dimension selected in query
+   *
+   * @param rowId row number
+   * @return complex type key array for all the complex dimension selected in query
+   */
+  protected byte[][] getComplexTypeKeyArray(int rowId) {
+    byte[][] complexTypeData = new byte[complexParentBlockIndexes.length][];
+    for (int i = 0; i < complexTypeData.length; i++) {
+      GenericQueryType genericQueryType =
+          complexParentIndexToQueryMap.get(complexParentBlockIndexes[i]);
+      ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+      DataOutputStream dataOutput = new DataOutputStream(byteStream);
+      try {
+        genericQueryType.parseBlocksAndReturnComplexColumnByteArray(dataChunks, rowId, dataOutput);
+        complexTypeData[i] = byteStream.toByteArray();
+      } catch (IOException e) {
+        LOGGER.error(e);
+      } finally {
+        CarbonUtil.closeStreams(dataOutput);
+        CarbonUtil.closeStreams(byteStream);
+      }
+    }
+    return complexTypeData;
+  }
+
+  /**
+   * @return return the total number of row after scanning
+   */
+  public int numberOfOutputRows() {
+    return this.totalNumberOfRows;
+  }
+
+  /**
+   * to check whether any more row is present in the result
+   *
+   * @return
+   */
+  public boolean hasNext() {
+    return rowCounter < this.totalNumberOfRows;
+  }
+
+  /**
+   * As this class will be a flyweight object so
+   * for one block all the blocklet scanning will use same result object
+   * in that case we need to reset the counter to zero so
+   * for new result it will give the result from zero
+   */
+  public void reset() {
+    rowCounter = 0;
+    currentRow = -1;
+  }
+
+  /**
+   * @param totalNumberOfRows set total of number rows valid after scanning
+   */
+  public void setNumberOfRows(int totalNumberOfRows) {
+    this.totalNumberOfRows = totalNumberOfRows;
+  }
+
+  /**
+   * After applying filter it will return the  bit set with the valid row indexes
+   * so below method will be used to set the row indexes
+   *
+   * @param indexes
+   */
+  public void setIndexes(int[] indexes) {
+    this.rowMapping = indexes;
+  }
+
+  /**
+   * Below method will be used to check whether measure value is null or not
+   *
+   * @param ordinal  measure ordinal
+   * @param rowIndex row number to be checked
+   * @return whether it is null or not
+   */
+  protected boolean isNullMeasureValue(int ordinal, int rowIndex) {
+    return measureDataChunks[ordinal].getNullValueIndexHolder().getBitSet().get(rowIndex);
+  }
+
+  /**
+   * Below method will be used to get the measure value of
+   * long type
+   *
+   * @param ordinal  measure ordinal
+   * @param rowIndex row number of the measure value
+   * @return measure value of long type
+   */
+  protected long getLongMeasureValue(int ordinal, int rowIndex) {
+    return measureDataChunks[ordinal].getMeasureDataHolder().getReadableLongValueByIndex(rowIndex);
+  }
+
+  /**
+   * Below method will be used to get the measure value of double type
+   *
+   * @param ordinal  measure ordinal
+   * @param rowIndex row number
+   * @return measure value of double type
+   */
+  protected double getDoubleMeasureValue(int ordinal, int rowIndex) {
+    return measureDataChunks[ordinal].getMeasureDataHolder()
+        .getReadableDoubleValueByIndex(rowIndex);
+  }
+
+  /**
+   * Below method will be used to get the measure type of big decimal data type
+   *
+   * @param ordinal  ordinal of the of the measure
+   * @param rowIndex row number
+   * @return measure of big decimal type
+   */
+  protected BigDecimal getBigDecimalMeasureValue(int ordinal, int rowIndex) {
+    return measureDataChunks[ordinal].getMeasureDataHolder()
+        .getReadableBigDecimalValueByIndex(rowIndex);
+  }
+
+  /**
+   * will return the current valid row id
+   *
+   * @return valid row id
+   */
+  public abstract int getCurrenrRowId();
+
+  /**
+   * @return dictionary key array for all the dictionary dimension
+   * selected in query
+   */
+  public abstract byte[] getDictionaryKeyArray();
+
+  /**
+   * @return dictionary key array for all the dictionary dimension in integer array forat
+   * selected in query
+   */
+  public abstract int[] getDictionaryKeyIntegerArray();
+
+  /**
+   * Return the dimension data based on dimension ordinal
+   *
+   * @param dimensionOrdinal dimension ordinal
+   * @return dimension data
+   */
+  public abstract byte[] getDimensionKey(int dimensionOrdinal);
+
+  /**
+   * Below method will be used to get the complex type key array
+   *
+   * @return complex type key array
+   */
+  public abstract byte[][] getComplexTypeKeyArray();
+
+  /**
+   * Below method will be used to get the no dictionary key
+   * array for all the no dictionary dimension selected in query
+   *
+   * @return no dictionary key array for all the no dictionary dimension
+   */
+  public abstract byte[][] getNoDictionaryKeyArray();
+
+  /**
+   * Below method will be used to get the no dictionary key
+   * array in string array format for all the no dictionary dimension selected in query
+   *
+   * @return no dictionary key array for all the no dictionary dimension
+   */
+  public abstract String[] getNoDictionaryKeyStringArray();
+
+  /**
+   * Below method will be used to to check whether measure value
+   * is null or for a measure
+   *
+   * @param ordinal measure ordinal
+   * @return is null or not
+   */
+  public abstract boolean isNullMeasureValue(int ordinal);
+
+  /**
+   * Below method will be used to get the measure value for measure
+   * of long data type
+   *
+   * @param ordinal measure ordinal
+   * @return long value of measure
+   */
+  public abstract long getLongMeasureValue(int ordinal);
+
+  /**
+   * Below method will be used to get the value of measure of double
+   * type
+   *
+   * @param ordinal measure ordinal
+   * @return measure value
+   */
+  public abstract double getDoubleMeasureValue(int ordinal);
+
+  /**
+   * Below method will be used to get the data of big decimal type
+   * of a measure
+   *
+   * @param ordinal measure ordinal
+   * @return measure value
+   */
+  public abstract BigDecimal getBigDecimalMeasureValue(int ordinal);
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/result/BatchResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/result/BatchResult.java b/core/src/main/java/org/apache/carbondata/scan/result/BatchResult.java
new file mode 100644
index 0000000..9bb9c21
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/result/BatchResult.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.scan.result;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import org.apache.carbondata.common.CarbonIterator;
+
+/**
+ * Below class holds the query result
+ */
+public class BatchResult extends CarbonIterator<Object[]> {
+
+  /**
+   * list of keys
+   */
+  protected List<Object[]> rows;
+
+  /**
+   * counter to check whether all the records are processed or not
+   */
+  protected int counter;
+
+  public BatchResult() {
+    this.rows = new ArrayList<>();
+  }
+
+  /**
+   * Below method will be used to get the rows
+   *
+   * @return
+   */
+  public List<Object[]> getRows() {
+    return rows;
+  }
+
+  /**
+   * Below method will be used to get the set the values
+   *
+   * @param rows
+   */
+  public void setRows(List<Object[]> rows) {
+    this.rows = rows;
+  }
+
+  /**
+   * This method will return one row at a time based on the counter given.
+   * @param counter
+   * @return
+   */
+  public Object[] getRawRow(int counter) {
+    return rows.get(counter);
+  }
+
+  /**
+   * For getting the total size.
+   * @return
+   */
+  public int getSize() {
+    return rows.size();
+  }
+
+
+  /**
+   * Returns {@code true} if the iteration has more elements.
+   *
+   * @return {@code true} if the iteration has more elements
+   */
+  @Override public boolean hasNext() {
+    return counter < rows.size();
+  }
+
+  /**
+   * Returns the next element in the iteration.
+   *
+   * @return the next element in the iteration
+   */
+  @Override public Object[] next() {
+    if (!hasNext()) {
+      throw new NoSuchElementException();
+    }
+    Object[] row = rows.get(counter);
+    counter++;
+    return row;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/result/Result.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/result/Result.java b/core/src/main/java/org/apache/carbondata/scan/result/Result.java
new file mode 100644
index 0000000..618af73
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/result/Result.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.scan.result;
+
+import org.apache.carbondata.scan.wrappers.ByteArrayWrapper;
+
+/**
+ * Result interface for storing the result
+ */
+public interface Result<K, V> {
+  /**
+   * Below method will be used to
+   * add the sccaed result
+   *
+   * @param result
+   */
+  void addScannedResult(K result);
+
+  /**
+   * Returns {@code true} if the iteration has more elements.
+   *
+   * @return {@code true} if the iteration has more elements
+   */
+  boolean hasNext();
+
+  /**
+   * Below method will return the result key
+   *
+   * @return key
+   */
+  ByteArrayWrapper getKey();
+
+  /**
+   * Below code will return the result value
+   *
+   * @return value
+   */
+  V[] getValue();
+
+  void merge(Result<K, V> otherResult);
+
+  /**
+   * Below method will be used to get the result
+   *
+   * @return
+   */
+  K getResult();
+
+  /**
+   * @return size of the result
+   */
+  int size();
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/result/impl/FilterQueryScannedResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/result/impl/FilterQueryScannedResult.java b/core/src/main/java/org/apache/carbondata/scan/result/impl/FilterQueryScannedResult.java
new file mode 100644
index 0000000..f1e6594
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/result/impl/FilterQueryScannedResult.java
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.scan.result.impl;
+
+import java.math.BigDecimal;
+
+import org.apache.carbondata.scan.executor.infos.BlockExecutionInfo;
+import org.apache.carbondata.scan.result.AbstractScannedResult;
+
+/**
+ * Result provider class in case of filter query
+ * In case of filter query data will be send
+ * based on filtered row index
+ */
+public class FilterQueryScannedResult extends AbstractScannedResult {
+
+  public FilterQueryScannedResult(BlockExecutionInfo tableBlockExecutionInfos) {
+    super(tableBlockExecutionInfos);
+  }
+
+  /**
+   * @return dictionary key array for all the dictionary dimension
+   * selected in query
+   */
+  @Override public byte[] getDictionaryKeyArray() {
+    ++currentRow;
+    return getDictionaryKeyArray(rowMapping[currentRow]);
+  }
+
+  /**
+   * @return dictionary key integer array for all the dictionary dimension
+   * selected in query
+   */
+  @Override public int[] getDictionaryKeyIntegerArray() {
+    ++currentRow;
+    return getDictionaryKeyIntegerArray(rowMapping[currentRow]);
+  }
+
+  /**
+   * Below method will be used to get the complex type key array
+   *
+   * @return complex type key array
+   */
+  @Override public byte[][] getComplexTypeKeyArray() {
+    return getComplexTypeKeyArray(rowMapping[currentRow]);
+  }
+
+  /**
+   * Below method will be used to get the no dictionary key
+   * array for all the no dictionary dimension selected in query
+   *
+   * @return no dictionary key array for all the no dictionary dimension
+   */
+  @Override public byte[][] getNoDictionaryKeyArray() {
+    return getNoDictionaryKeyArray(rowMapping[currentRow]);
+  }
+
+  /**
+   * Below method will be used to get the no dictionary key
+   * string array for all the no dictionary dimension selected in query
+   *
+   * @return no dictionary key array for all the no dictionary dimension
+   */
+  @Override public String[] getNoDictionaryKeyStringArray() {
+    return getNoDictionaryKeyStringArray(rowMapping[currentRow]);
+  }
+
+  /**
+   * will return the current valid row id
+   *
+   * @return valid row id
+   */
+  @Override public int getCurrenrRowId() {
+    return rowMapping[currentRow];
+  }
+
+  /**
+   * Return the dimension data based on dimension ordinal
+   *
+   * @param dimensionOrdinal dimension ordinal
+   * @return dimension data
+   */
+  @Override public byte[] getDimensionKey(int dimensionOrdinal) {
+    return getDimensionData(dimensionOrdinal, rowMapping[currentRow]);
+  }
+
+  /**
+   * Below method will be used to to check whether measure value
+   * is null or for a measure
+   *
+   * @param ordinal measure ordinal
+   * @return is null or not
+   */
+  @Override public boolean isNullMeasureValue(int ordinal) {
+    return isNullMeasureValue(ordinal, rowMapping[currentRow]);
+  }
+
+  /**
+   * Below method will be used to get the measure value for measure
+   * of long data type
+   *
+   * @param ordinal measure ordinal
+   * @return long value of measure
+   */
+  @Override public long getLongMeasureValue(int ordinal) {
+    return getLongMeasureValue(ordinal, rowMapping[currentRow]);
+  }
+
+  /**
+   * Below method will be used to get the value of measure of double
+   * type
+   *
+   * @param ordinal measure ordinal
+   * @return measure value
+   */
+  @Override public double getDoubleMeasureValue(int ordinal) {
+    return getDoubleMeasureValue(ordinal, rowMapping[currentRow]);
+  }
+
+  /**
+   * Below method will be used to get the data of big decimal type
+   * of a measure
+   *
+   * @param ordinal measure ordinal
+   * @return measure value
+   */
+  @Override public BigDecimal getBigDecimalMeasureValue(int ordinal) {
+    return getBigDecimalMeasureValue(ordinal, rowMapping[currentRow]);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/apache/carbondata/scan/result/impl/NonFilterQueryScannedResult.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/result/impl/NonFilterQueryScannedResult.java b/core/src/main/java/org/apache/carbondata/scan/result/impl/NonFilterQueryScannedResult.java
new file mode 100644
index 0000000..e08d525
--- /dev/null
+++ b/core/src/main/java/org/apache/carbondata/scan/result/impl/NonFilterQueryScannedResult.java
@@ -0,0 +1,146 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.carbondata.scan.result.impl;
+
+import java.math.BigDecimal;
+
+import org.apache.carbondata.scan.executor.infos.BlockExecutionInfo;
+import org.apache.carbondata.scan.result.AbstractScannedResult;
+
+/**
+ * Result provide class for non filter query
+ * In case of no filter query we need to return
+ * complete data
+ */
+public class NonFilterQueryScannedResult extends AbstractScannedResult {
+
+  public NonFilterQueryScannedResult(BlockExecutionInfo blockExecutionInfo) {
+    super(blockExecutionInfo);
+  }
+
+  /**
+   * @return dictionary key array for all the dictionary dimension selected in
+   * query
+   */
+  @Override public byte[] getDictionaryKeyArray() {
+    ++currentRow;
+    return getDictionaryKeyArray(currentRow);
+  }
+
+  /**
+   * @return dictionary key integer array for all the dictionary dimension
+   * selected in query
+   */
+  @Override public int[] getDictionaryKeyIntegerArray() {
+    ++currentRow;
+    return getDictionaryKeyIntegerArray(currentRow);
+  }
+
+  /**
+   * Below method will be used to get the complex type key array
+   *
+   * @return complex type key array
+   */
+  @Override public byte[][] getComplexTypeKeyArray() {
+    return getComplexTypeKeyArray(currentRow);
+  }
+
+  /**
+   * Below method will be used to get the no dictionary key array for all the
+   * no dictionary dimension selected in query
+   *
+   * @return no dictionary key array for all the no dictionary dimension
+   */
+  @Override public byte[][] getNoDictionaryKeyArray() {
+    return getNoDictionaryKeyArray(currentRow);
+  }
+
+  /**
+   * Below method will be used to get the no dictionary key
+   * string array for all the no dictionary dimension selected in query
+   *
+   * @return no dictionary key array for all the no dictionary dimension
+   */
+  @Override public String[] getNoDictionaryKeyStringArray() {
+    return getNoDictionaryKeyStringArray(currentRow);
+  }
+
+  /**
+   * will return the current valid row id
+   *
+   * @return valid row id
+   */
+  @Override public int getCurrenrRowId() {
+    return currentRow;
+  }
+
+  /**
+   * Return the dimension data based on dimension ordinal
+   *
+   * @param dimensionOrdinal dimension ordinal
+   * @return dimension data
+   */
+  @Override public byte[] getDimensionKey(int dimensionOrdinal) {
+    return getDimensionData(dimensionOrdinal, currentRow);
+  }
+
+  /**
+   * Below method will be used to to check whether measure value is null or
+   * for a measure
+   *
+   * @param ordinal measure ordinal
+   * @return is null or not
+   */
+  @Override public boolean isNullMeasureValue(int ordinal) {
+    return isNullMeasureValue(ordinal, currentRow);
+  }
+
+  /**
+   * Below method will be used to get the measure value for measure of long
+   * data type
+   *
+   * @param ordinal measure ordinal
+   * @return long value of measure
+   */
+  @Override public long getLongMeasureValue(int ordinal) {
+    return getLongMeasureValue(ordinal, currentRow);
+  }
+
+  /**
+   * Below method will be used to get the value of measure of double type
+   *
+   * @param ordinal measure ordinal
+   * @return measure value
+   */
+  @Override public double getDoubleMeasureValue(int ordinal) {
+    return getDoubleMeasureValue(ordinal, currentRow);
+  }
+
+  /**
+   * Below method will be used to get the data of big decimal type of a
+   * measure
+   *
+   * @param ordinal measure ordinal
+   * @return measure value
+   */
+  @Override public BigDecimal getBigDecimalMeasureValue(int ordinal) {
+    return getBigDecimalMeasureValue(ordinal, currentRow);
+  }
+
+}