private void refreshIndexForDimensionFields(String rowId,DimensionRow dimensionRow,DimensionRow dimensionRowOld){
  try {
    for (    DimensionField field : dimension.getDimensionFields()) {
      if (field == dimension.getKey()) {
        continue;
      }
      if (dimensionRowOld != null) {
        String oldRowValue=dimensionRowOld.get(field);
        String oldRowValueKey=DimensionStoreKeyUtils.getRowKey(field.getName(),oldRowValue);
        String oldRowValuesKeysJson=keyValueStore.get(oldRowValueKey);
        String[] oldRowValueSKeys=objectMapper.readValue(oldRowValuesKeysJson,String[].class);
        Set<String> oldRowValuesKeySet=new LinkedHashSet<>(Arrays.asList(oldRowValueSKeys));
        oldRowValuesKeySet.remove(rowId);
        if (oldRowValuesKeySet.isEmpty()) {
          keyValueStore.remove(oldRowValueKey);
        }
 else {
          String updatedOldRowValueSKeys=objectMapper.writeValueAsString(oldRowValuesKeySet);
          keyValueStore.put(oldRowValueKey,updatedOldRowValueSKeys);
        }
      }
      String rowValue=dimensionRow.get(field);
      String rowValueKey=DimensionStoreKeyUtils.getRowKey(field.getName(),rowValue);
      String rowValueSKeys=keyValueStore.get(rowValueKey);
      Set<String> rowValueSKeySet=new LinkedHashSet<>();
      if (rowValueSKeys != null) {
        rowValueSKeySet.addAll(Arrays.asList(objectMapper.readValue(rowValueSKeys,String[].class)));
      }
      rowValueSKeySet.add(rowId);
      String updatedRowValueSKeys=objectMapper.writeValueAsString(rowValueSKeySet);
      keyValueStore.put(rowValueKey,updatedRowValueSKeys);
    }
  }
 catch (  IOException e) {
    LOG.error("Exception while adding dimension description entry in key value store : {}",e);
    throw new RuntimeException(e);
  }
}

private void refreshIndexForDimensionFields ( String rowId , DimensionRow dimensionRow , DimensionRow dimensionRowOld ) { try { for ( DimensionField field : dimension . getDimensionFields ( ) ) { if ( field == dimension . getKey ( ) ) { continue ; } if ( dimensionRowOld != null ) { String oldRowValue = dimensionRowOld . get ( field ) ; String oldRowValueKey = DimensionStoreKeyUtils . getRowKey ( field . getName ( ) , oldRowValue ) ; String oldRowValuesKeysJson = keyValueStore . get ( oldRowValueKey ) ; String [ ] oldRowValueSKeys = objectMapper . readValue ( oldRowValuesKeysJson , String [ ] . class ) ; Set < String > oldRowValuesKeySet = new LinkedHashSet < > ( Arrays . asList ( oldRowValueSKeys ) ) ; oldRowValuesKeySet . remove ( rowId ) ; if ( oldRowValuesKeySet . isEmpty ( ) ) { keyValueStore . remove ( oldRowValueKey ) ; } else { String updatedOldRowValueSKeys = objectMapper . writeValueAsString ( oldRowValuesKeySet ) ; keyValueStore . put ( oldRowValueKey , updatedOldRowValueSKeys ) ; } } String rowValue = dimensionRow . get ( field ) ; String rowValueKey = DimensionStoreKeyUtils . getRowKey ( field . getName ( ) , rowValue ) ; String rowValueSKeys = keyValueStore . get ( rowValueKey ) ; Set < String > rowValueSKeySet = new LinkedHashSet < > ( ) ; if ( rowValueSKeys != null ) { rowValueSKeySet . addAll ( Arrays . asList ( objectMapper . readValue ( rowValueSKeys , String [ ] . class ) ) ) ; } rowValueSKeySet . add ( rowId ) ; String updatedRowValueSKeys = objectMapper . writeValueAsString ( rowValueSKeySet ) ; keyValueStore . put ( rowValueKey , updatedRowValueSKeys ) ; } } catch ( IOException e ) { LOG . error ( "Exception while adding dimension description entry in key value store : {}" , e ) ; throw new RuntimeException ( e ) ; } }
this method updates the store to allow point lookups using the non - key field ( s ) . it loops through all the fields for a dimension ( ignores the key field ) < p > for a new dimensionrow say id v1 and desc value1 a new entry is added in store < p > desc_value1_row_key - > [ id_v1_row_key ] < p > for a new dimensionrow with duplicate description say id v2 and desc value1 the store is updated to look like this < p > desc_value1_row_key - > [ id_v1_row_key , id_v2_row_key ] < p > for a dimensionrow say id v2 and desc value2 , dimensionrow - > ( v2 , value2 ) dimensionrowold - > ( v2 , value1 ) < p > the store is updated to look like this < p > desc_value1_row_key - > [ id_v1_row_key ] desc_value2_row_key - > [ id_v2_row_key ]
