private void writeSortIndexFile(List<String> data,String columnId) throws IOException {
  ColumnIdentifier columnIdentifier=new ColumnIdentifier(columnId,null,null);
  Map<String,Integer> dataToSurrogateKeyMap=new HashMap<>(data.size());
  int surrogateKey=0;
  List<Integer> invertedIndexList=new ArrayList<>(data.size());
  for (int i=0; i < data.size(); i++) {
    dataToSurrogateKeyMap.put(data.get(i),++surrogateKey);
  }
  List<String> sortedKeyList=new ArrayList<>(dataToSurrogateKeyMap.keySet());
  Collections.sort(sortedKeyList);
  List<Integer> sortedIndexList=new ArrayList<>(data.size());
  int[] invertedIndexArray=new int[sortedKeyList.size()];
  for (int i=0; i < sortedKeyList.size(); i++) {
    Integer key=dataToSurrogateKeyMap.get(sortedKeyList.get(i));
    sortedIndexList.add(key);
    invertedIndexArray[--key]=i + 1;
  }
  for (int i=0; i < invertedIndexArray.length; i++) {
    invertedIndexList.add(invertedIndexArray[i]);
  }
  CarbonDictionarySortIndexWriter dictionarySortIndexWriter=new CarbonDictionarySortIndexWriterImpl(carbonTableIdentifier,columnIdentifier,carbonStorePath);
  try {
    dictionarySortIndexWriter.writeSortIndex(sortedIndexList);
    dictionarySortIndexWriter.writeInvertedSortIndex(invertedIndexList);
  }
  finally {
    dictionarySortIndexWriter.close();
  }
}

private void writeSortIndexFile ( List < String > data , String columnId ) throws IOException { ColumnIdentifier columnIdentifier = new ColumnIdentifier ( columnId , null , null ) ; Map < String , Integer > dataToSurrogateKeyMap = new HashMap < > ( data . size ( ) ) ; int surrogateKey = 0 ; List < Integer > invertedIndexList = new ArrayList < > ( data . size ( ) ) ; for ( int i = 0 ; i < data . size ( ) ; i ++ ) { dataToSurrogateKeyMap . put ( data . get ( i ) , ++ surrogateKey ) ; } List < String > sortedKeyList = new ArrayList < > ( dataToSurrogateKeyMap . keySet ( ) ) ; Collections . sort ( sortedKeyList ) ; List < Integer > sortedIndexList = new ArrayList < > ( data . size ( ) ) ; int [ ] invertedIndexArray = new int [ sortedKeyList . size ( ) ] ; for ( int i = 0 ; i < sortedKeyList . size ( ) ; i ++ ) { Integer key = dataToSurrogateKeyMap . get ( sortedKeyList . get ( i ) ) ; sortedIndexList . add ( key ) ; invertedIndexArray [ -- key ] = i + 1 ; } for ( int i = 0 ; i < invertedIndexArray . length ; i ++ ) { invertedIndexList . add ( invertedIndexArray [ i ] ) ; } CarbonDictionarySortIndexWriter dictionarySortIndexWriter = new CarbonDictionarySortIndexWriterImpl ( carbonTableIdentifier , columnIdentifier , carbonStorePath ) ; try { dictionarySortIndexWriter . writeSortIndex ( sortedIndexList ) ; dictionarySortIndexWriter . writeInvertedSortIndex ( invertedIndexList ) ; } finally { dictionarySortIndexWriter . close ( ) ; } }
this method will prepare the sort index data from the given data and write it to a sort index file
