@Override public void setLastUpdated(DateTime lastUpdated) { if (lastUpdated == null) { keyValueStore.remove(lastUpdatedKey); } else { keyValueStore.put(lastUpdatedKey, lastUpdated.toString()); } }
@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(); }
/** * Internal method for cleaning the dimension rows. */ public void deleteAllDimensionRows() { try { String dimRowIndexes = keyValueStore.get(DimensionStoreKeyUtils.getAllValuesKey()); if (dimRowIndexes == null) { return; } String[] keys = objectMapper.readValue(dimRowIndexes, String[].class); LinkedHashSet<String> dimRowKeys = new LinkedHashSet<>(Arrays.asList(keys)); for (String dimRowKey : dimRowKeys) { keyValueStore.remove(dimRowKey); } searchProvider.setKeyValueStore(keyValueStore); // Reset cardinality to 0 keyValueStore.put(DimensionStoreKeyUtils.getCardinalityKey(), "0"); // Reset list to empty String allValuesKey = DimensionStoreKeyUtils.getAllValuesKey(); keyValueStore.put(allValuesKey, "[]"); } catch (IOException e) { LOG.error("Exception while reading dimension rows {}", e); throw new RuntimeException(e); } }
oldRowValuesKeySet.remove(rowId); if (oldRowValuesKeySet.isEmpty()) { keyValueStore.remove(oldRowValueKey); } else { String updatedOldRowValueSKeys = objectMapper.writeValueAsString(oldRowValuesKeySet);