@Override public DimensionRow findDimensionRowByKeyValue(String value) { /* * Key to fetch row from keyValueStore * eg: if key column is ID and value is 12345 * rowKey would be id_12345_row_key */ String rowKey = DimensionStoreKeyUtils.getRowKey(getKey().getName(), value); DimensionRow drByKey = null; try { String dimRowJson = keyValueStore.get(rowKey); if (dimRowJson != null) { Map<String, String> dimensionRowMap = objectMapper.readValue( dimRowJson, new TypeReference<LinkedHashMap<String, String>>() { } ); drByKey = parseDimensionRow(dimensionRowMap); } } catch (IOException e) { LOG.error("Cannot map string to DimensionRow object. {}", e); throw new RuntimeException(e); } return drByKey; }
@Override public void clearDimension() { //Remove all dimension data from the store. findAllDimensionRows().stream() .flatMap(dimensionRow -> dimensionRow.entrySet().stream()) .map(entry -> DimensionStoreKeyUtils.getRowKey(entry.getKey().getName(), entry.getValue())) .forEach(keyValueStore::remove); //Since the indices are being dropped, the dimension field stored via the columnKey is becoming stale. keyValueStore.remove(DimensionStoreKeyUtils.getColumnKey(dimension.getKey().getName())); // The allValues key mapping needs to reflect the fact that we are dropping all dimension data. keyValueStore.put(DimensionStoreKeyUtils.getAllValuesKey(), "[]"); //We're resetting the keyValueStore, so we don't want any stale last updated date floating around. keyValueStore.remove(DimensionStoreKeyUtils.getLastUpdatedKey()); refreshCardinality(); }
String rowIdKey = DimensionStoreKeyUtils.getRowKey(getKey().getName(), dimensionRow.get(getKey()));
.map(DimensionRow::getRowMap) .map(map -> map.get(rowId)) .map(id -> DimensionStoreKeyUtils.getRowKey(rowId, id)) .forEach(keyValueStore::remove);