carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenliang...@apache.org
Subject [24/52] [partial] incubator-carbondata git commit: Renamed packages to org.apache.carbondata and fixed errors
Date Mon, 15 Aug 2016 07:09:09 GMT
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/AbstractDictionaryCache.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/AbstractDictionaryCache.java b/core/src/main/java/org/carbondata/core/cache/dictionary/AbstractDictionaryCache.java
deleted file mode 100644
index 390bcc8..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/AbstractDictionaryCache.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.carbondata.common.factory.CarbonCommonFactory;
-import org.carbondata.core.cache.Cache;
-import org.carbondata.core.cache.CacheType;
-import org.carbondata.core.cache.CarbonLRUCache;
-import org.carbondata.core.carbon.path.CarbonTablePath;
-import org.carbondata.core.constants.CarbonCommonConstants;
-import org.carbondata.core.datastorage.store.filesystem.CarbonFile;
-import org.carbondata.core.datastorage.store.impl.FileFactory;
-import org.carbondata.core.reader.CarbonDictionaryColumnMetaChunk;
-import org.carbondata.core.reader.CarbonDictionaryMetadataReader;
-import org.carbondata.core.service.DictionaryService;
-import org.carbondata.core.service.PathService;
-import org.carbondata.core.util.CarbonProperties;
-import org.carbondata.core.util.CarbonUtil;
-import org.carbondata.core.util.CarbonUtilException;
-
-/**
- * Abstract class which implements methods common to reverse and forward dictionary cache
- */
-public abstract class AbstractDictionaryCache<K extends DictionaryColumnUniqueIdentifier,
-    V extends Dictionary>
-    implements Cache<DictionaryColumnUniqueIdentifier, Dictionary> {
-
-  /**
-   * thread pool size to be used for dictionary data reading
-   */
-  protected int thread_pool_size;
-
-  /**
-   * LRU cache variable
-   */
-  protected CarbonLRUCache carbonLRUCache;
-
-  /**
-   * c store path
-   */
-  protected String carbonStorePath;
-
-  /**
-   * @param carbonStorePath
-   * @param carbonLRUCache
-   */
-  public AbstractDictionaryCache(String carbonStorePath, CarbonLRUCache carbonLRUCache) {
-    this.carbonStorePath = carbonStorePath;
-    this.carbonLRUCache = carbonLRUCache;
-    initThreadPoolSize();
-  }
-
-  /**
-   * This method will initialize the thread pool size to be used for creating the
-   * max number of threads for a job
-   */
-  private void initThreadPoolSize() {
-    try {
-      thread_pool_size = Integer.parseInt(CarbonProperties.getInstance()
-          .getProperty(CarbonCommonConstants.NUM_CORES_LOADING,
-              CarbonCommonConstants.NUM_CORES_DEFAULT_VAL));
-    } catch (NumberFormatException e) {
-      thread_pool_size = Integer.parseInt(CarbonCommonConstants.NUM_CORES_DEFAULT_VAL);
-    }
-  }
-
-  /**
-   * This method will check if dictionary and its metadata file exists for a given column
-   *
-   * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName,
-   *                                         tableName and columnIdentifier
-   * @return
-   */
-  protected boolean isFileExistsForGivenColumn(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) {
-    PathService pathService = CarbonCommonFactory.getPathService();
-    CarbonTablePath carbonTablePath = pathService
-        .getCarbonTablePath(dictionaryColumnUniqueIdentifier.getColumnIdentifier(), carbonStorePath,
-            dictionaryColumnUniqueIdentifier.getCarbonTableIdentifier());
-
-    String dictionaryFilePath =
-        carbonTablePath.getDictionaryFilePath(dictionaryColumnUniqueIdentifier
-            .getColumnIdentifier().getColumnId());
-    String dictionaryMetadataFilePath =
-        carbonTablePath.getDictionaryMetaFilePath(dictionaryColumnUniqueIdentifier
-            .getColumnIdentifier().getColumnId());
-    // check if both dictionary and its metadata file exists for a given column
-    return CarbonUtil.isFileExists(dictionaryFilePath) && CarbonUtil
-        .isFileExists(dictionaryMetadataFilePath);
-  }
-
-  /**
-   * This method will read dictionary metadata file and return the dictionary meta chunks
-   *
-   * @param dictionaryColumnUniqueIdentifier
-   * @return list of dictionary metadata chunks
-   * @throws IOException read and close method throws IO exception
-   */
-  protected CarbonDictionaryColumnMetaChunk readLastChunkFromDictionaryMetadataFile(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) throws IOException {
-    DictionaryService dictService = CarbonCommonFactory.getDictionaryService();
-    CarbonDictionaryMetadataReader columnMetadataReaderImpl = dictService
-        .getDictionaryMetadataReader(dictionaryColumnUniqueIdentifier.getCarbonTableIdentifier(),
-            dictionaryColumnUniqueIdentifier.getColumnIdentifier(), carbonStorePath);
-
-    CarbonDictionaryColumnMetaChunk carbonDictionaryColumnMetaChunk = null;
-    // read metadata file
-    try {
-      carbonDictionaryColumnMetaChunk =
-          columnMetadataReaderImpl.readLastEntryOfDictionaryMetaChunk();
-    } finally {
-      // close the metadata reader
-      columnMetadataReaderImpl.close();
-    }
-    return carbonDictionaryColumnMetaChunk;
-  }
-
-  /**
-   * This method will validate dictionary metadata file for any modification
-   *
-   * @param carbonFile
-   * @param fileTimeStamp
-   * @param endOffset
-   * @return
-   */
-  private boolean isDictionaryMetaFileModified(CarbonFile carbonFile, long fileTimeStamp,
-      long endOffset) {
-    return carbonFile.isFileModified(fileTimeStamp, endOffset);
-  }
-
-  /**
-   * This method will return the carbon file objetc based on its type (local, HDFS)
-   *
-   * @param dictionaryColumnUniqueIdentifier
-   * @return
-   */
-  private CarbonFile getDictionaryMetaCarbonFile(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) {
-    PathService pathService = CarbonCommonFactory.getPathService();
-    CarbonTablePath carbonTablePath = pathService
-        .getCarbonTablePath(dictionaryColumnUniqueIdentifier.getColumnIdentifier(), carbonStorePath,
-            dictionaryColumnUniqueIdentifier.getCarbonTableIdentifier());
-    String dictionaryFilePath =
-        carbonTablePath.getDictionaryMetaFilePath(dictionaryColumnUniqueIdentifier
-            .getColumnIdentifier().getColumnId());
-    FileFactory.FileType fileType = FileFactory.getFileType(dictionaryFilePath);
-    CarbonFile carbonFile = FileFactory.getCarbonFile(dictionaryFilePath, fileType);
-    return carbonFile;
-  }
-
-  /**
-   * This method will get the value for the given key. If value does not exist
-   * for the given key, it will check and load the value.
-   *
-   * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName,
-   *                                         tableName and columnIdentifier
-   * @param dictionaryInfo
-   * @param lruCacheKey
-   * @param loadSortIndex                    read and load sort index file in memory
-   * @throws CarbonUtilException in case memory is not sufficient to load dictionary into memory
-   */
-  protected void checkAndLoadDictionaryData(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier,
-      DictionaryInfo dictionaryInfo, String lruCacheKey, boolean loadSortIndex)
-      throws CarbonUtilException {
-    try {
-      // read last segment dictionary meta chunk entry to get the end offset of file
-      CarbonFile carbonFile = getDictionaryMetaCarbonFile(dictionaryColumnUniqueIdentifier);
-      boolean dictionaryMetaFileModified =
-          isDictionaryMetaFileModified(carbonFile, dictionaryInfo.getFileTimeStamp(),
-              dictionaryInfo.getDictionaryMetaFileLength());
-      // if dictionary metadata file is modified then only read the last entry from dictionary
-      // meta file
-      if (dictionaryMetaFileModified) {
-        synchronized (dictionaryInfo) {
-          carbonFile = getDictionaryMetaCarbonFile(dictionaryColumnUniqueIdentifier);
-          dictionaryMetaFileModified =
-              isDictionaryMetaFileModified(carbonFile, dictionaryInfo.getFileTimeStamp(),
-                  dictionaryInfo.getDictionaryMetaFileLength());
-          // Double Check :
-          // if dictionary metadata file is modified then only read the last entry from dictionary
-          // meta file
-          if (dictionaryMetaFileModified) {
-            CarbonDictionaryColumnMetaChunk carbonDictionaryColumnMetaChunk =
-                readLastChunkFromDictionaryMetadataFile(dictionaryColumnUniqueIdentifier);
-            // required size will be size total size of file - offset till file is
-            // already read
-            long requiredSize =
-                carbonDictionaryColumnMetaChunk.getEnd_offset() - dictionaryInfo.getMemorySize();
-            if (requiredSize > 0) {
-              boolean columnAddedToLRUCache =
-                  carbonLRUCache.put(lruCacheKey, dictionaryInfo, requiredSize);
-              // if column is successfully added to lru cache then only load the
-              // dictionary data
-              if (columnAddedToLRUCache) {
-                // load dictionary data
-                loadDictionaryData(dictionaryInfo, dictionaryColumnUniqueIdentifier,
-                    dictionaryInfo.getMemorySize(), carbonDictionaryColumnMetaChunk.getEnd_offset(),
-                    loadSortIndex);
-                // set the end offset till where file is read
-                dictionaryInfo
-                    .setOffsetTillFileIsRead(carbonDictionaryColumnMetaChunk.getEnd_offset());
-                dictionaryInfo.setFileTimeStamp(carbonFile.getLastModifiedTime());
-                dictionaryInfo.setDictionaryMetaFileLength(carbonFile.getSize());
-              } else {
-                throw new CarbonUtilException(
-                    "Cannot load dictionary into memory. Not enough memory available");
-              }
-            }
-          }
-        }
-      }
-      // increment the column access count
-      incrementDictionaryAccessCount(dictionaryInfo);
-    } catch (IOException e) {
-      throw new CarbonUtilException(e.getMessage());
-    }
-  }
-
-  /**
-   * This method will prepare the lru cache key and return the same
-   *
-   * @param columnIdentifier
-   * @return
-   */
-  protected String getLruCacheKey(String columnIdentifier, CacheType cacheType) {
-    String lruCacheKey =
-        columnIdentifier + CarbonCommonConstants.UNDERSCORE + cacheType.getCacheName();
-    return lruCacheKey;
-  }
-
-  /**
-   * This method will check and load the dictionary file in memory for a given column
-   *
-   * @param dictionaryInfo                   holds dictionary information and data
-   * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName,
-   *                                         tableName and columnIdentifier
-   * @param dictionaryChunkStartOffset       start offset from where dictionary file has to
-   *                                         be read
-   * @param dictionaryChunkEndOffset         end offset till where dictionary file has to
-   *                                         be read
-   * @param loadSortIndex
-   * @throws IOException
-   */
-  private void loadDictionaryData(DictionaryInfo dictionaryInfo,
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier,
-      long dictionaryChunkStartOffset, long dictionaryChunkEndOffset, boolean loadSortIndex)
-      throws IOException {
-    DictionaryCacheLoader dictionaryCacheLoader =
-        new DictionaryCacheLoaderImpl(dictionaryColumnUniqueIdentifier.getCarbonTableIdentifier(),
-            carbonStorePath);
-    dictionaryCacheLoader
-        .load(dictionaryInfo, dictionaryColumnUniqueIdentifier.getColumnIdentifier(),
-            dictionaryChunkStartOffset, dictionaryChunkEndOffset, loadSortIndex);
-  }
-
-  /**
-   * This method will increment the access count for a given dictionary column
-   *
-   * @param dictionaryInfo
-   */
-  protected void incrementDictionaryAccessCount(DictionaryInfo dictionaryInfo) {
-    dictionaryInfo.incrementAccessCount();
-  }
-
-  /**
-   * This method will update the dictionary acceess count which is required for its removal
-   * from column LRU cache
-   *
-   * @param dictionaryList
-   */
-  protected void clearDictionary(List<Dictionary> dictionaryList) {
-    for (Dictionary dictionary : dictionaryList) {
-      dictionary.clear();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/ColumnDictionaryInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/ColumnDictionaryInfo.java b/core/src/main/java/org/carbondata/core/cache/dictionary/ColumnDictionaryInfo.java
deleted file mode 100644
index 59bafb0..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/ColumnDictionaryInfo.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import java.nio.charset.Charset;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.carbondata.core.carbon.metadata.datatype.DataType;
-import org.carbondata.core.constants.CarbonCommonConstants;
-import org.carbondata.core.util.ByteUtil;
-import org.carbondata.core.util.CarbonProperties;
-
-/**
- * class that implements methods specific for dictionary data look up
- */
-public class ColumnDictionaryInfo extends AbstractColumnDictionaryInfo {
-
-  /**
-   * index after members are sorted
-   */
-  private AtomicReference<List<Integer>> sortOrderReference =
-      new AtomicReference<List<Integer>>(new ArrayList<Integer>());
-
-  /**
-   * inverted index to retrieve the member
-   */
-  private AtomicReference<List<Integer>> sortReverseOrderReference =
-      new AtomicReference<List<Integer>>(new ArrayList<Integer>());
-
-  private DataType dataType;
-
-  public ColumnDictionaryInfo(DataType dataType) {
-    this.dataType = dataType;
-  }
-
-  /**
-   * This method will find and return the surrogate key for a given dictionary value
-   * Applicable scenario:
-   * 1. Incremental data load : Dictionary will not be generated for existing values. For
-   * that values have to be looked up in the existing dictionary cache.
-   * 2. Filter scenarios where from value surrogate key has to be found.
-   *
-   * @param value dictionary value as byte array
-   * @return if found returns key else 0
-   */
-  @Override public int getSurrogateKey(byte[] value) {
-    return getSurrogateKeyFromDictionaryValue(value);
-  }
-
-  /**
-   * This method will find and return the sort index for a given dictionary id.
-   * Applicable scenarios:
-   * 1. Used in case of order by queries when data sorting is required
-   *
-   * @param surrogateKey a unique ID for a dictionary value
-   * @return if found returns key else 0
-   */
-  @Override public int getSortedIndex(int surrogateKey) {
-    if (surrogateKey > sortReverseOrderReference.get().size()
-        || surrogateKey < MINIMUM_SURROGATE_KEY) {
-      return -1;
-    }
-    // decrement surrogate key as surrogate key basically means the index in array list
-    // because surrogate key starts from 1 and index of list from 0, so it needs to be
-    // decremented by 1
-    return sortReverseOrderReference.get().get(surrogateKey - 1);
-  }
-
-  /**
-   * This method will find and return the dictionary value from sorted index.
-   * Applicable scenarios:
-   * 1. Query final result preparation in case of order by queries:
-   * While convert the final result which will
-   * be surrogate key back to original dictionary values this method will be used
-   *
-   * @param sortedIndex sort index of dictionary value
-   * @return value if found else null
-   */
-  @Override public String getDictionaryValueFromSortedIndex(int sortedIndex) {
-    if (sortedIndex > sortReverseOrderReference.get().size()
-        || sortedIndex < MINIMUM_SURROGATE_KEY) {
-      return null;
-    }
-    // decrement surrogate key as surrogate key basically means the index in array list
-    // because surrogate key starts from 1, sort index will start form 1 and index
-    // of list from 0, so it needs to be decremented by 1
-    int surrogateKey = sortOrderReference.get().get(sortedIndex - 1);
-    return getDictionaryValueForKey(surrogateKey);
-  }
-
-  /**
-   * This method will add a new dictionary chunk to existing list of dictionary chunks
-   *
-   * @param dictionaryChunk
-   */
-  @Override public void addDictionaryChunk(List<byte[]> dictionaryChunk) {
-    dictionaryChunks.add(dictionaryChunk);
-  }
-
-  /**
-   * This method will set the sort order index of a dictionary column.
-   * Sort order index if the index of dictionary values after they are sorted.
-   *
-   * @param sortOrderIndex
-   */
-  @Override public void setSortOrderIndex(List<Integer> sortOrderIndex) {
-    sortOrderReference.set(sortOrderIndex);
-  }
-
-  /**
-   * This method will set the sort reverse index of a dictionary column.
-   * Sort reverse index is the index of dictionary values before they are sorted.
-   *
-   * @param sortReverseOrderIndex
-   */
-  @Override public void setSortReverseOrderIndex(List<Integer> sortReverseOrderIndex) {
-    sortReverseOrderReference.set(sortReverseOrderIndex);
-  }
-
-  /**
-   * This method will apply binary search logic to find the surrogate key for the
-   * given value
-   *
-   * @param key to be searched
-   * @return
-   */
-  private int getSurrogateKeyFromDictionaryValue(byte[] key) {
-    String filterKey = new String(key, Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-    int low = 0;
-    List<Integer> sortedSurrogates = sortOrderReference.get();
-    int high = sortedSurrogates.size() - 1;
-    while (low <= high) {
-      int mid = (low + high) >>> 1;
-      int surrogateKey = sortedSurrogates.get(mid);
-      byte[] dictionaryValue = getDictionaryBytesFromSurrogate(surrogateKey);
-      int cmp = -1;
-      if (this.getDataType() != DataType.STRING) {
-        cmp = compareFilterKeyWithDictionaryKey(new String(dictionaryValue), filterKey,
-            this.getDataType());
-
-      } else {
-        cmp = ByteUtil.UnsafeComparer.INSTANCE.compareTo(dictionaryValue, key);
-      }
-      if (cmp < 0) {
-        low = mid + 1;
-      } else if (cmp > 0) {
-        high = mid - 1;
-      } else {
-        return surrogateKey; // key found
-      }
-    }
-    return 0;
-  }
-
-  /**
-   * This method will apply binary search logic to find the surrogate key for the
-   * given value
-   *
-   * @param byteValuesOfFilterMembers to be searched
-   * @param surrogates
-   * @return
-   */
-  public void getIncrementalSurrogateKeyFromDictionary(List<byte[]> byteValuesOfFilterMembers,
-      List<Integer> surrogates) {
-    List<Integer> sortedSurrogates = sortOrderReference.get();
-    int low = 0;
-    for (byte[] byteValueOfFilterMember : byteValuesOfFilterMembers) {
-      String filterKey = new String(byteValueOfFilterMember,
-          Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-      if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(filterKey)) {
-        surrogates.add(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY);
-        continue;
-      }
-      int high = sortedSurrogates.size() - 1;
-      while (low <= high) {
-        int mid = (low + high) >>> 1;
-        int surrogateKey = sortedSurrogates.get(mid);
-        byte[] dictionaryValue = getDictionaryBytesFromSurrogate(surrogateKey);
-        int cmp = -1;
-        //fortify fix
-        if (null == dictionaryValue) {
-          cmp = -1;
-        } else if (this.getDataType() != DataType.STRING) {
-          cmp = compareFilterKeyWithDictionaryKey(new String(dictionaryValue), filterKey,
-              this.getDataType());
-
-        } else {
-          cmp =
-              ByteUtil.UnsafeComparer.INSTANCE.compareTo(dictionaryValue, byteValueOfFilterMember);
-        }
-        if (cmp < 0) {
-          low = mid + 1;
-        } else if (cmp > 0) {
-          high = mid - 1;
-        } else {
-
-          surrogates.add(surrogateKey);
-          low = mid;
-          break;
-        }
-      }
-    }
-    //Default value has to be added
-    if (surrogates.isEmpty()) {
-      surrogates.add(0);
-    }
-  }
-
-  private int compareFilterKeyWithDictionaryKey(String dictionaryVal, String memberVal,
-      DataType dataType) {
-    try {
-      switch (dataType) {
-        case SHORT:
-          return Short.compare((Short.parseShort(dictionaryVal)), (Short.parseShort(memberVal)));
-        case INT:
-          return Integer.compare((Integer.parseInt(dictionaryVal)), (Integer.parseInt(memberVal)));
-        case DOUBLE:
-          return Double
-              .compare((Double.parseDouble(dictionaryVal)), (Double.parseDouble(memberVal)));
-        case LONG:
-          return Long.compare((Long.parseLong(dictionaryVal)), (Long.parseLong(memberVal)));
-        case BOOLEAN:
-          return Boolean
-              .compare((Boolean.parseBoolean(dictionaryVal)), (Boolean.parseBoolean(memberVal)));
-        case TIMESTAMP:
-          SimpleDateFormat parser = new SimpleDateFormat(CarbonProperties.getInstance()
-              .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
-                  CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT));
-          Date dateToStr;
-          Date dictionaryDate;
-          dateToStr = parser.parse(memberVal);
-          dictionaryDate = parser.parse(dictionaryVal);
-          return dictionaryDate.compareTo(dateToStr);
-        case DECIMAL:
-          java.math.BigDecimal javaDecValForDictVal = new java.math.BigDecimal(dictionaryVal);
-          java.math.BigDecimal javaDecValForMemberVal = new java.math.BigDecimal(memberVal);
-          return javaDecValForDictVal.compareTo(javaDecValForMemberVal);
-        default:
-          return -1;
-      }
-    } catch (Exception e) {
-      //In all data types excluding String data type the null member will be the highest
-      //while doing search in dictioary when the member comparison happens with filter member
-      //which is also null member, since the parsing fails in other data type except string
-      //explicit comparison is required, is both are null member then system has to return 0.
-      if (memberVal.equals(dictionaryVal)) {
-        return 0;
-      }
-      return 1;
-    }
-  }
-
-  /**
-   * getDataType().
-   *
-   * @return
-   */
-  public DataType getDataType() {
-    return dataType;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/ColumnReverseDictionaryInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/ColumnReverseDictionaryInfo.java b/core/src/main/java/org/carbondata/core/cache/dictionary/ColumnReverseDictionaryInfo.java
deleted file mode 100644
index 86ff971..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/ColumnReverseDictionaryInfo.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.carbondata.core.constants.CarbonCommonConstants;
-import org.carbondata.core.util.CarbonProperties;
-
-import net.jpountz.xxhash.XXHash32;
-import net.jpountz.xxhash.XXHashFactory;
-
-/**
- * class that implements methods specific for dictionary data look up
- */
-public class ColumnReverseDictionaryInfo extends AbstractColumnDictionaryInfo {
-
-  /**
-   * Map which will maintain mapping of byte array to surrogate key
-   */
-  private Map<DictionaryByteArrayWrapper, Integer> dictionaryByteArrayToSurrogateKeyMap;
-
-  /**
-   * hashing algorithm to calculate hash code
-   */
-  private XXHash32 xxHash32;
-
-  /**
-   * check and initialize xxHash32 if enabled
-   */
-  public ColumnReverseDictionaryInfo() {
-    boolean useXXHash = Boolean.valueOf(CarbonProperties.getInstance()
-        .getProperty(CarbonCommonConstants.ENABLE_XXHASH,
-            CarbonCommonConstants.ENABLE_XXHASH_DEFAULT));
-    if (useXXHash) {
-      xxHash32 = XXHashFactory.fastestInstance().hash32();
-    }
-  }
-
-  /**
-   * This method will find and return the surrogate key for a given dictionary value
-   * Applicable scenario:
-   * 1. Incremental data load : Dictionary will not be generated for existing values. For
-   * that values have to be looked up in the existing dictionary cache.
-   * 2. Filter scenarios where from value surrogate key has to be found.
-   *
-   * @param value dictionary value as byte array. It will be treated as key here
-   * @return if found returns key else 0
-   */
-  @Override public int getSurrogateKey(byte[] value) {
-    DictionaryByteArrayWrapper dictionaryByteArrayWrapper =
-        new DictionaryByteArrayWrapper(value, xxHash32);
-    Integer surrogateKeyInMap =
-        dictionaryByteArrayToSurrogateKeyMap.get(dictionaryByteArrayWrapper);
-    if (null == surrogateKeyInMap) {
-      return CarbonCommonConstants.INVALID_SURROGATE_KEY;
-    }
-    return surrogateKeyInMap;
-  }
-
-  /**
-   * This method will add a new dictionary chunk to existing list of dictionary chunks
-   *
-   * @param dictionaryChunk
-   */
-  @Override public void addDictionaryChunk(List<byte[]> dictionaryChunk) {
-    dictionaryChunks.add(dictionaryChunk);
-    if (null == dictionaryByteArrayToSurrogateKeyMap) {
-      createDictionaryByteArrayToSurrogateKeyMap(dictionaryChunk.size());
-    }
-    addDataToDictionaryMap();
-  }
-
-  /**
-   * This method will add the new dictionary data to map
-   */
-  private void addDataToDictionaryMap() {
-    int surrogateKey = dictionaryByteArrayToSurrogateKeyMap.size();
-    List<byte[]> oneDictionaryChunk = dictionaryChunks.get(dictionaryChunks.size() - 1);
-    for (int i = 0; i < oneDictionaryChunk.size(); i++) {
-      // create a wrapper class that will calculate hash code for byte array
-      DictionaryByteArrayWrapper dictionaryByteArrayWrapper =
-          new DictionaryByteArrayWrapper(oneDictionaryChunk.get(i), xxHash32);
-      dictionaryByteArrayToSurrogateKeyMap.put(dictionaryByteArrayWrapper, ++surrogateKey);
-    }
-  }
-
-  /**
-   * This method will create the dictionary map. First time it will
-   * create dictionary map with capacity equal to list of byte arrays
-   *
-   * @param initialMapSize capacity to which map is to be instantiated
-   */
-  private void createDictionaryByteArrayToSurrogateKeyMap(int initialMapSize) {
-    dictionaryByteArrayToSurrogateKeyMap = new ConcurrentHashMap<>(initialMapSize);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/Dictionary.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/Dictionary.java b/core/src/main/java/org/carbondata/core/cache/dictionary/Dictionary.java
deleted file mode 100644
index 3f395c1..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/Dictionary.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-/**
- * dictionary interface which declares methods for finding surrogate key for a
- * given dictionary value and finding dictionary value from a given surrogate key
- */
-public interface Dictionary {
-
-  /**
-   * This method will find and return the surrogate key for a given dictionary value
-   * Applicable scenario:
-   * 1. Incremental data load : Dictionary will not be generated for existing values. For
-   * that values have to be looked up in the existing dictionary cache.
-   * 2. Filter scenarios where from value surrogate key has to be found.
-   *
-   * @param value dictionary value
-   * @return if found returns key else 0
-   */
-  int getSurrogateKey(String value);
-
-  /**
-   * This method will find and return the surrogate key for a given dictionary value
-   * Applicable scenario:
-   * 1. Incremental data load : Dictionary will not be generated for existing values. For
-   * that values have to be looked up in the existing dictionary cache.
-   * 2. Filter scenarios where from value surrogate key has to be found.
-   *
-   * @param value dictionary value as byte array
-   * @return if found returns key else -1
-   */
-  int getSurrogateKey(byte[] value);
-
-  /**
-   * This method will find and return the dictionary value for a given surrogate key.
-   * Applicable scenarios:
-   * 1. Query final result preparation : While convert the final result which will
-   * be surrogate key back to original dictionary values this method will be used
-   *
-   * @param surrogateKey a unique ID for a dictionary value
-   * @return value if found else null
-   */
-  String getDictionaryValueForKey(int surrogateKey);
-
-  /**
-   * This method will find and return the sort index for a given dictionary id.
-   * Applicable scenarios:
-   * 1. Used in case of order by queries when data sorting is required
-   *
-   * @param surrogateKey a unique ID for a dictionary value
-   * @return if found returns key else 0
-   */
-  int getSortedIndex(int surrogateKey);
-
-  /**
-   * This method will find and return the dictionary value from sorted index.
-   * Applicable scenarios:
-   * 1. Query final result preparation in case of order by queries:
-   * While convert the final result which will
-   * be surrogate key back to original dictionary values this method will be used
-   *
-   * @param sortedIndex sort index of dictionary value
-   * @return value if found else null
-   */
-  String getDictionaryValueFromSortedIndex(int sortedIndex);
-
-  /**
-   * The method return the dictionary chunks wrapper of a column
-   * The wrapper wraps the list<list<bye[]>> and provide the iterator to retrieve the chunks
-   * members.
-   * Applications Scenario:
-   * For preparing the column Sort info while writing the sort index file.
-   *
-   * @return
-   */
-  DictionaryChunksWrapper getDictionaryChunks();
-
-  /**
-   * This method will release the objects and set default value for primitive types
-   */
-  void clear();
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryByteArrayWrapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryByteArrayWrapper.java b/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryByteArrayWrapper.java
deleted file mode 100644
index ee8f991..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryByteArrayWrapper.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import java.util.Arrays;
-
-import org.carbondata.core.util.ByteUtil;
-
-import net.jpountz.xxhash.XXHash32;
-
-/**
- * class that holds the byte array and overrides equals and hashcode method which
- * will be useful for object comparison
- */
-public class DictionaryByteArrayWrapper {
-
-  /**
-   * dictionary value as byte array
-   */
-  private byte[] data;
-
-  /**
-   * hashing algorithm to calculate hash code
-   */
-  private XXHash32 xxHash32;
-
-  /**
-   * @param data
-   */
-  public DictionaryByteArrayWrapper(byte[] data) {
-    this.data = data;
-  }
-
-  /**
-   * @param data
-   * @param xxHash32
-   */
-  public DictionaryByteArrayWrapper(byte[] data, XXHash32 xxHash32) {
-    this(data);
-    this.xxHash32 = xxHash32;
-  }
-
-  /**
-   * This method will compare 2 DictionaryByteArrayWrapper objects
-   *
-   * @param other
-   * @return
-   */
-  @Override public boolean equals(Object other) {
-    if (this == other) {
-      return true;
-    }
-    if (other == null || getClass() != other.getClass()) {
-      return false;
-    }
-    DictionaryByteArrayWrapper otherObjectToCompare = (DictionaryByteArrayWrapper) other;
-    if (data.length != otherObjectToCompare.data.length) {
-      return false;
-    }
-    return ByteUtil.UnsafeComparer.INSTANCE.equals(data, otherObjectToCompare.data);
-
-  }
-
-  /**
-   * This method will calculate the hash code for given data
-   *
-   * @return
-   */
-  @Override public int hashCode() {
-    if (null != xxHash32) {
-      return xxHash32.hash(data, 0, data.length, 0);
-    }
-    int result = Arrays.hashCode(data);
-    result = 31 * result;
-    return result;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryCacheLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryCacheLoader.java b/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryCacheLoader.java
deleted file mode 100644
index a28d58d..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryCacheLoader.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import java.io.IOException;
-
-import org.carbondata.core.carbon.ColumnIdentifier;
-
-public interface DictionaryCacheLoader {
-
-  /**
-   * This method will load the dictionary data for a given columnIdentifier
-   *
-   * @param dictionaryInfo             dictionary info object which will hold the required data
-   *                                   for a given column
-   * @param columnIdentifier           column unique identifier
-   * @param dictionaryChunkStartOffset start offset from where dictionary file has to
-   *                                   be read
-   * @param dictionaryChunkEndOffset   end offset till where dictionary file has to
-   *                                   be read
-   * @param loadSortIndex              flag to indicate whether the sort index file has to be
-   *                                   read in memory after dictionary loading
-   * @throws IOException
-   */
-  void load(DictionaryInfo dictionaryInfo, ColumnIdentifier columnIdentifier,
-      long dictionaryChunkStartOffset, long dictionaryChunkEndOffset, boolean loadSortIndex)
-      throws IOException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryCacheLoaderImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryCacheLoaderImpl.java b/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryCacheLoaderImpl.java
deleted file mode 100644
index 770cb07..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryCacheLoaderImpl.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.carbondata.common.factory.CarbonCommonFactory;
-import org.carbondata.core.carbon.CarbonTableIdentifier;
-import org.carbondata.core.carbon.ColumnIdentifier;
-import org.carbondata.core.reader.CarbonDictionaryReader;
-import org.carbondata.core.reader.sortindex.CarbonDictionarySortIndexReader;
-import org.carbondata.core.service.DictionaryService;
-
-/**
- * This class is responsible for loading the dictionary data for given columns
- */
-public class DictionaryCacheLoaderImpl implements DictionaryCacheLoader {
-
-  /**
-   * carbon table identifier
-   */
-  private CarbonTableIdentifier carbonTableIdentifier;
-
-  /**
-   * carbon store path
-   */
-  private String carbonStorePath;
-
-  /**
-   * @param carbonTableIdentifier fully qualified table name
-   * @param carbonStorePath       hdfs store path
-   */
-  public DictionaryCacheLoaderImpl(CarbonTableIdentifier carbonTableIdentifier,
-      String carbonStorePath) {
-    this.carbonTableIdentifier = carbonTableIdentifier;
-    this.carbonStorePath = carbonStorePath;
-  }
-
-  /**
-   * This method will load the dictionary data for a given columnIdentifier
-   *
-   * @param dictionaryInfo             dictionary info object which will hold the required data
-   *                                   for a given column
-   * @param columnIdentifier           column unique identifier
-   * @param dictionaryChunkStartOffset start offset from where dictionary file has to
-   *                                   be read
-   * @param dictionaryChunkEndOffset   end offset till where dictionary file has to
-   *                                   be read
-   * @param loadSortIndex              flag to indicate whether the sort index file has to be
-   *                                   read in memory after dictionary loading
-   * @throws IOException
-   */
-  @Override public void load(DictionaryInfo dictionaryInfo, ColumnIdentifier columnIdentifier,
-      long dictionaryChunkStartOffset, long dictionaryChunkEndOffset, boolean loadSortIndex)
-      throws IOException {
-    List<byte[]> dictionaryChunk =
-        load(columnIdentifier, dictionaryChunkStartOffset, dictionaryChunkEndOffset);
-    if (loadSortIndex) {
-      readSortIndexFile(dictionaryInfo, columnIdentifier);
-    }
-    dictionaryInfo.addDictionaryChunk(dictionaryChunk);
-  }
-
-  /**
-   * This method will load the dictionary data between a given start and end offset
-   *
-   * @param columnIdentifier column unique identifier
-   * @param startOffset      start offset of dictionary file
-   * @param endOffset        end offset of dictionary file
-   * @return list of dictionary value
-   * @throws IOException
-   */
-  private List<byte[]> load(ColumnIdentifier columnIdentifier, long startOffset, long endOffset)
-      throws IOException {
-    CarbonDictionaryReader dictionaryReader = getDictionaryReader(columnIdentifier);
-    List<byte[]> dictionaryValue = null;
-    try {
-      dictionaryValue = dictionaryReader.read(startOffset, endOffset);
-    } finally {
-      dictionaryReader.close();
-    }
-    return dictionaryValue;
-  }
-
-  /**
-   * This method will read the sort index file and load into memory
-   *
-   * @param dictionaryInfo
-   * @param columnIdentifier
-   * @throws IOException
-   */
-  private void readSortIndexFile(DictionaryInfo dictionaryInfo, ColumnIdentifier columnIdentifier)
-      throws IOException {
-    CarbonDictionarySortIndexReader sortIndexReader = getSortIndexReader(columnIdentifier);
-    try {
-      dictionaryInfo.setSortOrderIndex(sortIndexReader.readSortIndex());
-      dictionaryInfo.setSortReverseOrderIndex(sortIndexReader.readInvertedSortIndex());
-    } finally {
-      sortIndexReader.close();
-    }
-  }
-
-  /**
-   * This method will create a dictionary reader instance to read the dictionary file
-   *
-   * @param columnIdentifier unique column identifier
-   * @return carbon dictionary reader instance
-   */
-  private CarbonDictionaryReader getDictionaryReader(ColumnIdentifier columnIdentifier) {
-    DictionaryService dictService = CarbonCommonFactory.getDictionaryService();
-    return dictService
-        .getDictionaryReader(carbonTableIdentifier, columnIdentifier, carbonStorePath);
-  }
-
-  /**
-   * @param columnIdentifier unique column identifier
-   * @return sort index reader instance
-   */
-  private CarbonDictionarySortIndexReader getSortIndexReader(ColumnIdentifier columnIdentifier) {
-    DictionaryService dictService = CarbonCommonFactory.getDictionaryService();
-    return dictService
-        .getDictionarySortIndexReader(carbonTableIdentifier, columnIdentifier, carbonStorePath);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryChunksWrapper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryChunksWrapper.java b/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryChunksWrapper.java
deleted file mode 100644
index e88d722..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryChunksWrapper.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * The wrapper class wraps the list<list<bye[]>> and provide the iterator to retrieve the chunks
- * members and expose the getSize API to get size of members in the List<List<byte>> chunks.
- * Applications Scenario:
- * For preparing the column Sort info while writing the sort index file.
- */
-public class DictionaryChunksWrapper implements Iterator<byte[]> {
-
-  /**
-   * list of dictionaryChunks
-   */
-  private List<List<byte[]>> dictionaryChunks;
-
-  /**
-   * size of the list
-   */
-  private int size;
-
-  /**
-   * Current index of the list
-   */
-  private int currentIndex;
-
-  /**
-   * variable holds the count of elements already iterated
-   */
-  private int iteratorIndex;
-
-  /**
-   * variable holds the current index of List<List<byte[]>> being traversed
-   */
-  private int outerIndex;
-
-  /**
-   * Constructor of DictionaryChunksWrapper
-   *
-   * @param dictionaryChunks
-   */
-  public DictionaryChunksWrapper(List<List<byte[]>> dictionaryChunks) {
-    this.dictionaryChunks = dictionaryChunks;
-    for (List<byte[]> chunk : dictionaryChunks) {
-      this.size += chunk.size();
-    }
-  }
-
-  /**
-   * Returns {@code true} if the iteration has more elements.
-   * (In other words, returns {@code true} if {@link #next} would
-   * return an element rather than throwing an exception.)
-   *
-   * @return {@code true} if the iteration has more elements
-   */
-  @Override public boolean hasNext() {
-    return (currentIndex < size);
-  }
-
-  /**
-   * Returns the next element in the iteration.
-   * The method pics the next elements from the first inner list till first is not finished, pics
-   * the second inner list ...
-   *
-   * @return the next element in the iteration
-   */
-  @Override public byte[] next() {
-    if (iteratorIndex >= dictionaryChunks.get(outerIndex).size()) {
-      iteratorIndex = 0;
-      outerIndex++;
-    }
-    byte[] value = dictionaryChunks.get(outerIndex).get(iteratorIndex);
-    currentIndex++;
-    iteratorIndex++;
-    return value;
-  }
-
-  /**
-   * Removes from the underlying collection the last element returned
-   * by this iterator (optional operation).  This method can be called
-   * only once per call to {@link #next}.  The behavior of an iterator
-   * is unspecified if the underlying collection is modified while the
-   * iteration is in progress in any way other than by calling this
-   * method.
-   *
-   * @throws UnsupportedOperationException if the {@code remove}
-   *                                       operation is not supported by this iterator
-   * @throws IllegalStateException         if the {@code next} method has not
-   *                                       yet been called, or the {@code remove} method has already
-   *                                       been called after the last call to the {@code next}
-   *                                       method
-   * @implSpec The default implementation throws an instance of
-   * {@link UnsupportedOperationException} and performs no other action.
-   */
-  @Override public void remove() {
-    throw new UnsupportedOperationException("Remove operation not supported");
-  }
-
-  /**
-   * returns the total element size in List<List<byte[]>>
-   *
-   * @return
-   */
-  public int getSize() {
-    return size;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryColumnUniqueIdentifier.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryColumnUniqueIdentifier.java b/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryColumnUniqueIdentifier.java
deleted file mode 100644
index dea789f..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryColumnUniqueIdentifier.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import org.carbondata.core.carbon.CarbonTableIdentifier;
-import org.carbondata.core.carbon.ColumnIdentifier;
-import org.carbondata.core.carbon.metadata.datatype.DataType;
-
-/**
- * dictionary column identifier which includes table identifier and column identifier
- */
-public class DictionaryColumnUniqueIdentifier {
-
-  /**
-   * table fully qualified name
-   */
-  private CarbonTableIdentifier carbonTableIdentifier;
-
-  /**
-   * unique column id
-   */
-  private ColumnIdentifier columnIdentifier;
-
-  private DataType dataType;
-
-  /**
-   * Will be used in case of reverse dictionary cache which will be used
-   * in case of data loading.
-   *
-   * @param carbonTableIdentifier
-   * @param columnIdentifier
-   */
-  public DictionaryColumnUniqueIdentifier(CarbonTableIdentifier carbonTableIdentifier,
-      ColumnIdentifier columnIdentifier) {
-    this.carbonTableIdentifier = carbonTableIdentifier;
-    this.columnIdentifier = columnIdentifier;
-  }
-
-  /**
-   * Will be used in case of forward dictionary cache in case
-   * of query execution.
-   *
-   * @param carbonTableIdentifier
-   * @param columnIdentifier
-   * @param dataType
-   */
-  public DictionaryColumnUniqueIdentifier(CarbonTableIdentifier carbonTableIdentifier,
-      ColumnIdentifier columnIdentifier, DataType dataType) {
-    this(carbonTableIdentifier, columnIdentifier);
-    this.dataType = dataType;
-  }
-
-  public DataType getDataType() {
-    return dataType;
-  }
-
-  /**
-   * @return table identifier
-   */
-  public CarbonTableIdentifier getCarbonTableIdentifier() {
-    return carbonTableIdentifier;
-  }
-
-  /**
-   * @return columnIdentifier
-   */
-  public ColumnIdentifier getColumnIdentifier() {
-    return columnIdentifier;
-  }
-
-  /**
-   * overridden equals method
-   *
-   * @param other
-   * @return
-   */
-  @Override public boolean equals(Object other) {
-    if (this == other) return true;
-    if (other == null || getClass() != other.getClass()) return false;
-    DictionaryColumnUniqueIdentifier that = (DictionaryColumnUniqueIdentifier) other;
-    if (!carbonTableIdentifier.equals(that.carbonTableIdentifier)) return false;
-    return columnIdentifier.equals(that.columnIdentifier);
-
-  }
-
-  /**
-   * overridden hashcode method
-   *
-   * @return
-   */
-  @Override public int hashCode() {
-    int result = carbonTableIdentifier.hashCode();
-    result = 31 * result + columnIdentifier.hashCode();
-    return result;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryInfo.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryInfo.java b/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryInfo.java
deleted file mode 100644
index 6721b3b..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/DictionaryInfo.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import java.util.List;
-
-import org.carbondata.core.cache.Cacheable;
-
-/**
- * An interface which holds dictionary information like end offset,
- * file timestamp for one column
- */
-public interface DictionaryInfo extends Cacheable, Dictionary {
-
-  /**
-   * This method will increment the access count for a column by 1
-   * whenever a column is getting used in query or incremental data load
-   */
-  void incrementAccessCount();
-
-  /**
-   * This method will update the end offset of file everytime a file is read
-   *
-   * @param offsetTillFileIsRead
-   */
-  void setOffsetTillFileIsRead(long offsetTillFileIsRead);
-
-  /**
-   * This method will update the timestamp of a file if a file is modified
-   * like in case of incremental load
-   *
-   * @param fileTimeStamp
-   */
-  void setFileTimeStamp(long fileTimeStamp);
-
-  /**
-   * This method will add a new dictionary chunk to existing list of dictionary chunks
-   *
-   * @param dictionaryChunk
-   */
-  void addDictionaryChunk(List<byte[]> dictionaryChunk);
-
-  /**
-   * This method will set the sort order index of a dictionary column.
-   * Sort order index if the index of dictionary values after they are sorted.
-   *
-   * @param sortOrderIndex
-   */
-  void setSortOrderIndex(List<Integer> sortOrderIndex);
-
-  /**
-   * This method will set the sort reverse index of a dictionary column.
-   * Sort reverse index is the index of dictionary values before they are sorted.
-   *
-   * @param sortReverseOrderIndex
-   */
-  void setSortReverseOrderIndex(List<Integer> sortReverseOrderIndex);
-
-  /**
-   * dictionary metadata file length which will be set whenever we reload dictionary
-   * data from disk
-   *
-   * @param dictionaryMetaFileLength length of dictionary metadata file
-   */
-  void setDictionaryMetaFileLength(long dictionaryMetaFileLength);
-
-  /**
-   * Dictionary meta file offset which will be read to check whether length of dictionary
-   * meta file has been modified
-   *
-   * @return
-   */
-  long getDictionaryMetaFileLength();
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/ForwardDictionary.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/ForwardDictionary.java b/core/src/main/java/org/carbondata/core/cache/dictionary/ForwardDictionary.java
deleted file mode 100644
index 5ddd093..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/ForwardDictionary.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.carbondata.core.constants.CarbonCommonConstants;
-
-/**
- * This class will be used for dictionary key and value look up
- */
-public class ForwardDictionary implements Dictionary {
-
-  /**
-   * Object which will hold the information related to this dictionary column
-   */
-  private ColumnDictionaryInfo columnDictionaryInfo;
-
-  /**
-   * @param columnDictionaryInfo
-   */
-  public ForwardDictionary(ColumnDictionaryInfo columnDictionaryInfo) {
-    this.columnDictionaryInfo = columnDictionaryInfo;
-  }
-
-  /**
-   * This method will find and return the surrogate key for a given dictionary value
-   * Applicable scenario:
-   * 1. Incremental data load : Dictionary will not be generated for existing values. For
-   * that values have to be looked up in the existing dictionary cache.
-   * 2. Filter scenarios where from value surrogate key has to be found.
-   *
-   * @param value dictionary value
-   * @return if found returns key else 0
-   */
-  @Override public int getSurrogateKey(String value) {
-    return columnDictionaryInfo.getSurrogateKey(value);
-  }
-
-  /**
-   * This method will find and return the surrogate key for a given dictionary value
-   * Applicable scenario:
-   * 1. Incremental data load : Dictionary will not be generated for existing values. For
-   * that values have to be looked up in the existing dictionary cache.
-   * 2. Filter scenarios where from value surrogate key has to be found.
-   *
-   * @param value dictionary value as byte array
-   * @return if found returns key else 0
-   */
-  @Override public int getSurrogateKey(byte[] value) {
-    return columnDictionaryInfo.getSurrogateKey(value);
-  }
-
-  /**
-   * This method will find and return the dictionary value for a given surrogate key.
-   * Applicable scenarios:
-   * 1. Query final result preparation : While convert the final result which will
-   * be surrogate key back to original dictionary values this method will be used
-   *
-   * @param surrogateKey a unique ID for a dictionary value
-   * @return value if found else null
-   */
-  @Override public String getDictionaryValueForKey(int surrogateKey) {
-    return columnDictionaryInfo.getDictionaryValueForKey(surrogateKey);
-  }
-
-  /**
-   * This method will find and return the sort index for a given dictionary id.
-   * Applicable scenarios:
-   * 1. Used in case of order by queries when data sorting is required
-   *
-   * @param surrogateKey a unique ID for a dictionary value
-   * @return if found returns key else 0
-   */
-  @Override public int getSortedIndex(int surrogateKey) {
-    return columnDictionaryInfo.getSortedIndex(surrogateKey);
-  }
-
-  /**
-   * This method will find and return the dictionary value from sorted index.
-   * Applicable scenarios:
-   * 1. Query final result preparation in case of order by queries:
-   * While convert the final result which will
-   * be surrogate key back to original dictionary values this method will be used
-   *
-   * @param sortedIndex sort index of dictionary value
-   * @return value if found else null
-   */
-  @Override public String getDictionaryValueFromSortedIndex(int sortedIndex) {
-    return columnDictionaryInfo.getDictionaryValueFromSortedIndex(sortedIndex);
-  }
-
-  /**
-   * The method return the dictionary chunks wrapper of a column
-   * The wrapper wraps the list<list<bye[]>> and provide the iterator to retrieve the chunks
-   * members.
-   * Applications Scenario:
-   * For preparing the column Sort info while writing the sort index file.
-   *
-   * @return
-   */
-  @Override public DictionaryChunksWrapper getDictionaryChunks() {
-    return columnDictionaryInfo.getDictionaryChunks();
-  }
-
-  /**
-   * This method will release the objects and set default value for primitive types
-   */
-  @Override public void clear() {
-    if (null != columnDictionaryInfo) {
-      columnDictionaryInfo.clear();
-      columnDictionaryInfo = null;
-    }
-  }
-
-  /**
-   * This method will read the surrogates based on search range.
-   *
-   * @param surrogates
-   */
-  public void getSurrogateKeyByIncrementalSearch(List<String> evaluateResultList,
-      List<Integer> surrogates) {
-    List<byte[]> byteValuesOfFilterMembers = new ArrayList<byte[]>(evaluateResultList.size());
-    byte[] keyData = null;
-    for (int i = 0; i < evaluateResultList.size(); i++) {
-      keyData = evaluateResultList.get(i)
-          .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET));
-      byteValuesOfFilterMembers.add(keyData);
-    }
-
-    columnDictionaryInfo
-        .getIncrementalSurrogateKeyFromDictionary(byteValuesOfFilterMembers, surrogates);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/ForwardDictionaryCache.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/ForwardDictionaryCache.java b/core/src/main/java/org/carbondata/core/cache/dictionary/ForwardDictionaryCache.java
deleted file mode 100644
index bee7714..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/ForwardDictionaryCache.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.carbondata.common.logging.LogService;
-import org.carbondata.common.logging.LogServiceFactory;
-import org.carbondata.core.cache.CacheType;
-import org.carbondata.core.cache.CarbonLRUCache;
-import org.carbondata.core.util.CarbonUtilException;
-
-/**
- * This class implements methods to create dictionary cache which will hold
- * dictionary chunks for look up of surrogate keys and values
- */
-public class ForwardDictionaryCache<K extends DictionaryColumnUniqueIdentifier,
-                                    V extends Dictionary>
-    extends AbstractDictionaryCache<K, V> {
-
-  /**
-   * Attribute for Carbon LOGGER
-   */
-  private static final LogService LOGGER =
-      LogServiceFactory.getLogService(ForwardDictionaryCache.class.getName());
-
-  /**
-   * @param carbonStorePath
-   * @param carbonLRUCache
-   */
-  public ForwardDictionaryCache(String carbonStorePath, CarbonLRUCache carbonLRUCache) {
-    super(carbonStorePath, carbonLRUCache);
-  }
-
-  /**
-   * This method will get the value for the given key. If value does not exist
-   * for the given key, it will check and load the value.
-   *
-   * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName,
-   *                                         tableName and columnIdentifier
-   * @return dictionary
-   * @throws CarbonUtilException in case memory is not sufficient to load dictionary into memory
-   */
-  @Override public Dictionary get(DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier)
-      throws CarbonUtilException {
-    return getDictionary(dictionaryColumnUniqueIdentifier);
-  }
-
-  /**
-   * This method will return a list of values for the given list of keys.
-   * For each key, this method will check and load the data if required.
-   *
-   * @param dictionaryColumnUniqueIdentifiers unique identifier which contains dbName,
-   *                                          tableName and columnIdentifier
-   * @return list of dictionary
-   * @throws CarbonUtilException in case memory is not sufficient to load dictionary into memory
-   */
-  @Override public List<Dictionary> getAll(
-      List<DictionaryColumnUniqueIdentifier> dictionaryColumnUniqueIdentifiers)
-      throws CarbonUtilException {
-    boolean exceptionOccurredInDictionaryLoading = false;
-    String exceptionMessage = "";
-    List<Dictionary> forwardDictionaryObjectList =
-        new ArrayList<Dictionary>(dictionaryColumnUniqueIdentifiers.size());
-    List<Future<Dictionary>> taskSubmitList =
-        new ArrayList<>(dictionaryColumnUniqueIdentifiers.size());
-    ExecutorService executorService = Executors.newFixedThreadPool(thread_pool_size);
-    for (final DictionaryColumnUniqueIdentifier uniqueIdent : dictionaryColumnUniqueIdentifiers) {
-      taskSubmitList.add(executorService.submit(new Callable<Dictionary>() {
-        @Override public Dictionary call() throws CarbonUtilException {
-          Dictionary dictionary = getDictionary(uniqueIdent);
-          return dictionary;
-        }
-      }));
-    }
-    try {
-      executorService.shutdown();
-      executorService.awaitTermination(2, TimeUnit.HOURS);
-    } catch (InterruptedException e) {
-      LOGGER.error("Error loading the dictionary: " + e.getMessage());
-    }
-    for (int i = 0; i < taskSubmitList.size(); i++) {
-      try {
-        Dictionary columnDictionary = taskSubmitList.get(i).get();
-        forwardDictionaryObjectList.add(columnDictionary);
-      } catch (Throwable e) {
-        exceptionOccurredInDictionaryLoading = true;
-        exceptionMessage = e.getMessage();
-      }
-    }
-    if (exceptionOccurredInDictionaryLoading) {
-      clearDictionary(forwardDictionaryObjectList);
-      LOGGER.error(exceptionMessage);
-      throw new CarbonUtilException(exceptionMessage);
-    }
-    return forwardDictionaryObjectList;
-  }
-
-  /**
-   * This method will return the value for the given key. It will not check and load
-   * the data for the given key
-   *
-   * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName,
-   *                                         tableName and columnIdentifier
-   * @return
-   */
-  @Override public Dictionary getIfPresent(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) {
-    Dictionary forwardDictionary = null;
-    ColumnDictionaryInfo columnDictionaryInfo = (ColumnDictionaryInfo) carbonLRUCache.get(
-        getLruCacheKey(dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(),
-            CacheType.FORWARD_DICTIONARY));
-    if (null != columnDictionaryInfo) {
-      forwardDictionary = new ForwardDictionary(columnDictionaryInfo);
-      incrementDictionaryAccessCount(columnDictionaryInfo);
-    }
-    return forwardDictionary;
-  }
-
-  /**
-   * This method will remove the cache for a given key
-   *
-   * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName,
-   *                                         tableName and columnIdentifier
-   */
-  @Override public void invalidate(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) {
-    carbonLRUCache.remove(
-        getLruCacheKey(dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(),
-            CacheType.FORWARD_DICTIONARY));
-  }
-
-  /**
-   * This method will get the value for the given key. If value does not exist
-   * for the given key, it will check and load the value.
-   *
-   * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName,
-   *                                         tableName and columnIdentifier
-   * @return dictionary
-   * @throws CarbonUtilException in case memory is not sufficient to load dictionary into memory
-   */
-  private Dictionary getDictionary(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier)
-      throws CarbonUtilException {
-    Dictionary forwardDictionary = null;
-    // create column dictionary info object only if dictionary and its
-    // metadata file exists for a given column identifier
-    if (!isFileExistsForGivenColumn(dictionaryColumnUniqueIdentifier)) {
-      throw new CarbonUtilException(
-          "Either dictionary or its metadata does not exist for column identifier :: "
-              + dictionaryColumnUniqueIdentifier.getColumnIdentifier());
-    }
-    String columnIdentifier = dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId();
-    ColumnDictionaryInfo columnDictionaryInfo =
-        getColumnDictionaryInfo(dictionaryColumnUniqueIdentifier, columnIdentifier);
-    // load sort index file in case of forward dictionary
-    checkAndLoadDictionaryData(dictionaryColumnUniqueIdentifier, columnDictionaryInfo,
-        getLruCacheKey(dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(),
-            CacheType.FORWARD_DICTIONARY), true);
-    forwardDictionary = new ForwardDictionary(columnDictionaryInfo);
-    return forwardDictionary;
-  }
-
-  /**
-   * This method will check and create columnDictionaryInfo object for the given column
-   *
-   * @param dictionaryColumnUniqueIdentifier
-   * @param columnIdentifier
-   * @return
-   */
-  private ColumnDictionaryInfo getColumnDictionaryInfo(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier, String columnIdentifier) {
-    ColumnDictionaryInfo columnDictionaryInfo = (ColumnDictionaryInfo) carbonLRUCache
-        .get(getLruCacheKey(columnIdentifier, CacheType.FORWARD_DICTIONARY));
-    if (null == columnDictionaryInfo) {
-      synchronized (dictionaryColumnUniqueIdentifier) {
-        columnDictionaryInfo = (ColumnDictionaryInfo) carbonLRUCache
-            .get(getLruCacheKey(columnIdentifier, CacheType.FORWARD_DICTIONARY));
-        if (null == columnDictionaryInfo) {
-          columnDictionaryInfo =
-              new ColumnDictionaryInfo(dictionaryColumnUniqueIdentifier.getDataType());
-        }
-      }
-    }
-    return columnDictionaryInfo;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/ReverseDictionary.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/ReverseDictionary.java b/core/src/main/java/org/carbondata/core/cache/dictionary/ReverseDictionary.java
deleted file mode 100644
index a1f50a4..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/ReverseDictionary.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-/**
- * This class will be used for dictionary key and value look up
- */
-public class ReverseDictionary implements Dictionary {
-
-  /**
-   * Object which will hold the information related to this dictionary column
-   */
-  private ColumnReverseDictionaryInfo columnReverseDictionaryInfo;
-
-  /**
-   * @param columnReverseDictionaryInfo
-   */
-  public ReverseDictionary(ColumnReverseDictionaryInfo columnReverseDictionaryInfo) {
-    this.columnReverseDictionaryInfo = columnReverseDictionaryInfo;
-  }
-
-  /**
-   * This method will find and return the surrogate key for a given dictionary value
-   * Applicable scenario:
-   * 1. Incremental data load : Dictionary will not be generated for existing values. For
-   * that values have to be looked up in the existing dictionary cache.
-   * 2. Filter scenarios where from value surrogate key has to be found.
-   *
-   * @param value dictionary value
-   * @return if found returns key else 0
-   */
-  @Override public int getSurrogateKey(String value) {
-    return columnReverseDictionaryInfo.getSurrogateKey(value);
-  }
-
-  /**
-   * This method will find and return the surrogate key for a given dictionary value
-   * Applicable scenario:
-   * 1. Incremental data load : Dictionary will not be generated for existing values. For
-   * that values have to be looked up in the existing dictionary cache.
-   * 2. Filter scenarios where from value surrogate key has to be found.
-   *
-   * @param value dictionary value as byte array
-   * @return if found returns key else 0
-   */
-  @Override public int getSurrogateKey(byte[] value) {
-    return columnReverseDictionaryInfo.getSurrogateKey(value);
-  }
-
-  /**
-   * This method will find and return the dictionary value for a given surrogate key.
-   * Applicable scenarios:
-   * 1. Query final result preparation : While convert the final result which will
-   * be surrogate key back to original dictionary values this method will be used
-   *
-   * @param surrogateKey a unique ID for a dictionary value
-   * @return value if found else null
-   */
-  @Override public String getDictionaryValueForKey(int surrogateKey) {
-    return columnReverseDictionaryInfo.getDictionaryValueForKey(surrogateKey);
-  }
-
-  /**
-   * This method will find and return the sort index for a given dictionary id.
-   * Applicable scenarios:
-   * 1. Used in case of order by queries when data sorting is required
-   *
-   * @param surrogateKey a unique ID for a dictionary value
-   * @return if found returns key else 0
-   */
-  @Override public int getSortedIndex(int surrogateKey) {
-    return columnReverseDictionaryInfo.getSortedIndex(surrogateKey);
-  }
-
-  /**
-   * This method will find and return the dictionary value from sorted index.
-   * Applicable scenarios:
-   * 1. Query final result preparation in case of order by queries:
-   * While convert the final result which will
-   * be surrogate key back to original dictionary values this method will be used
-   *
-   * @param sortedIndex sort index of dictionary value
-   * @return value if found else null
-   */
-  @Override public String getDictionaryValueFromSortedIndex(int sortedIndex) {
-    return columnReverseDictionaryInfo.getDictionaryValueFromSortedIndex(sortedIndex);
-  }
-
-  /**
-   * The method return the dictionary chunks wrapper of a column
-   * The wrapper wraps the list<list<bye[]>> and provide the iterator to retrieve the chunks
-   * members.
-   * Applications Scenario:
-   * For preparing the column Sort info while writing the sort index file.
-   *
-   * @return
-   */
-  @Override public DictionaryChunksWrapper getDictionaryChunks() {
-    return columnReverseDictionaryInfo.getDictionaryChunks();
-  }
-
-  /**
-   * This method will release the objects and set default value for primitive types
-   */
-  @Override public void clear() {
-    if (null != columnReverseDictionaryInfo) {
-      columnReverseDictionaryInfo.clear();
-      columnReverseDictionaryInfo = null;
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/cd6a4ff3/core/src/main/java/org/carbondata/core/cache/dictionary/ReverseDictionaryCache.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/core/cache/dictionary/ReverseDictionaryCache.java b/core/src/main/java/org/carbondata/core/cache/dictionary/ReverseDictionaryCache.java
deleted file mode 100644
index 6e49183..0000000
--- a/core/src/main/java/org/carbondata/core/cache/dictionary/ReverseDictionaryCache.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * 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.carbondata.core.cache.dictionary;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.carbondata.common.logging.LogService;
-import org.carbondata.common.logging.LogServiceFactory;
-import org.carbondata.core.cache.CacheType;
-import org.carbondata.core.cache.CarbonLRUCache;
-import org.carbondata.core.util.CarbonUtilException;
-
-/**
- * This class implements methods to create dictionary cache which will hold
- * dictionary chunks for look up of surrogate keys and values
- */
-public class ReverseDictionaryCache<K extends DictionaryColumnUniqueIdentifier,
-    V extends Dictionary>
-    extends AbstractDictionaryCache<K, V> {
-
-  /**
-   * Attribute for Carbon LOGGER
-   */
-  private static final LogService LOGGER =
-      LogServiceFactory.getLogService(ForwardDictionaryCache.class.getName());
-
-  /**
-   * @param carbonStorePath
-   * @param carbonLRUCache
-   */
-  public ReverseDictionaryCache(String carbonStorePath, CarbonLRUCache carbonLRUCache) {
-    super(carbonStorePath, carbonLRUCache);
-  }
-
-  /**
-   * This method will get the value for the given key. If value does not exist
-   * for the given key, it will check and load the value.
-   *
-   * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName,
-   *                                         tableName and columnIdentifier
-   * @return dictionary
-   * @throws CarbonUtilException in case memory is not sufficient to load dictionary into memory
-   */
-  @Override public Dictionary get(DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier)
-      throws CarbonUtilException {
-    return getDictionary(dictionaryColumnUniqueIdentifier);
-  }
-
-  /**
-   * This method will return a list of values for the given list of keys.
-   * For each key, this method will check and load the data if required.
-   *
-   * @param dictionaryColumnUniqueIdentifiers unique identifier which contains dbName,
-   *                                          tableName and columnIdentifier
-   * @return list of dictionary
-   * @throws CarbonUtilException in case memory is not sufficient to load dictionary into memory
-   */
-  @Override public List<Dictionary> getAll(
-      List<DictionaryColumnUniqueIdentifier> dictionaryColumnUniqueIdentifiers)
-      throws CarbonUtilException {
-    boolean exceptionOccurredInDictionaryLoading = false;
-    String exceptionMessage = "";
-    List<Dictionary> reverseDictionaryObjectList =
-        new ArrayList<Dictionary>(dictionaryColumnUniqueIdentifiers.size());
-    List<Future<Dictionary>> taskSubmitList =
-        new ArrayList<>(dictionaryColumnUniqueIdentifiers.size());
-    ExecutorService executorService = Executors.newFixedThreadPool(thread_pool_size);
-    for (final DictionaryColumnUniqueIdentifier uniqueIdent : dictionaryColumnUniqueIdentifiers) {
-      taskSubmitList.add(executorService.submit(new Callable<Dictionary>() {
-        @Override public Dictionary call() throws CarbonUtilException {
-          Dictionary dictionary = getDictionary(uniqueIdent);
-          return dictionary;
-        }
-      }));
-    }
-    try {
-      executorService.shutdown();
-      executorService.awaitTermination(2, TimeUnit.HOURS);
-    } catch (InterruptedException e) {
-      LOGGER.error("Error loading the dictionary: " + e.getMessage());
-    }
-    for (int i = 0; i < taskSubmitList.size(); i++) {
-      try {
-        Dictionary columnDictionary = taskSubmitList.get(i).get();
-        reverseDictionaryObjectList.add(columnDictionary);
-      } catch (Throwable e) {
-        exceptionOccurredInDictionaryLoading = true;
-        exceptionMessage = e.getMessage();
-      }
-    }
-    if (exceptionOccurredInDictionaryLoading) {
-      clearDictionary(reverseDictionaryObjectList);
-      LOGGER.error(exceptionMessage);
-      throw new CarbonUtilException(exceptionMessage);
-    }
-    return reverseDictionaryObjectList;
-  }
-
-  /**
-   * This method will return the value for the given key. It will not check and load
-   * the data for the given key
-   *
-   * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName,
-   *                                         tableName and columnIdentifier
-   * @return
-   */
-  @Override public Dictionary getIfPresent(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) {
-    Dictionary reverseDictionary = null;
-    ColumnReverseDictionaryInfo columnReverseDictionaryInfo =
-        (ColumnReverseDictionaryInfo) carbonLRUCache.get(
-            getLruCacheKey(dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(),
-                CacheType.REVERSE_DICTIONARY));
-    if (null != columnReverseDictionaryInfo) {
-      reverseDictionary = new ReverseDictionary(columnReverseDictionaryInfo);
-      incrementDictionaryAccessCount(columnReverseDictionaryInfo);
-    }
-    return reverseDictionary;
-  }
-
-  /**
-   * This method will remove the cache for a given key
-   *
-   * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName,
-   *                                         tableName and columnIdentifier
-   */
-  @Override public void invalidate(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier) {
-    carbonLRUCache.remove(
-        getLruCacheKey(dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(),
-            CacheType.REVERSE_DICTIONARY));
-  }
-
-  /**
-   * This method will get the value for the given key. If value does not exist
-   * for the given key, it will check and load the value.
-   *
-   * @param dictionaryColumnUniqueIdentifier unique identifier which contains dbName,
-   *                                         tableName and columnIdentifier
-   * @return dictionary
-   * @throws CarbonUtilException in case memory is not sufficient to load dictionary into memory
-   */
-  private Dictionary getDictionary(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier)
-      throws CarbonUtilException {
-    Dictionary reverseDictionary = null;
-    // create column dictionary info object only if dictionary and its
-    // metadata file exists for a given column identifier
-    if (!isFileExistsForGivenColumn(dictionaryColumnUniqueIdentifier)) {
-      throw new CarbonUtilException(
-          "Either dictionary or its metadata does not exist for column identifier :: "
-              + dictionaryColumnUniqueIdentifier.getColumnIdentifier());
-    }
-    String columnIdentifier = dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId();
-    ColumnReverseDictionaryInfo columnReverseDictionaryInfo =
-        getColumnReverseDictionaryInfo(dictionaryColumnUniqueIdentifier, columnIdentifier);
-    // do not load sort index file for reverse dictionary
-    checkAndLoadDictionaryData(dictionaryColumnUniqueIdentifier, columnReverseDictionaryInfo,
-        getLruCacheKey(dictionaryColumnUniqueIdentifier.getColumnIdentifier().getColumnId(),
-            CacheType.REVERSE_DICTIONARY), false);
-    reverseDictionary = new ReverseDictionary(columnReverseDictionaryInfo);
-    return reverseDictionary;
-  }
-
-  /**
-   * This method will check and create columnReverseDictionaryInfo object for the given column
-   *
-   * @param dictionaryColumnUniqueIdentifier
-   * @param columnIdentifier
-   * @return
-   */
-  private ColumnReverseDictionaryInfo getColumnReverseDictionaryInfo(
-      DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier, String columnIdentifier) {
-    ColumnReverseDictionaryInfo columnReverseDictionaryInfo =
-        (ColumnReverseDictionaryInfo) carbonLRUCache
-            .get(getLruCacheKey(columnIdentifier, CacheType.REVERSE_DICTIONARY));
-    if (null == columnReverseDictionaryInfo) {
-      synchronized (dictionaryColumnUniqueIdentifier) {
-        columnReverseDictionaryInfo = (ColumnReverseDictionaryInfo) carbonLRUCache
-            .get(getLruCacheKey(columnIdentifier, CacheType.REVERSE_DICTIONARY));
-        if (null == columnReverseDictionaryInfo) {
-          columnReverseDictionaryInfo = new ColumnReverseDictionaryInfo();
-        }
-      }
-    }
-    return columnReverseDictionaryInfo;
-  }
-}



Mime
View raw message