/** * Only instances of {@code DynamicPartitionMapImpl} are supported by this implementation. * * @param partitionMap Must be instance of {@code DynamicPartitionMapImpl}. */ @Override public synchronized void updateMap(DynamicPartitionMap partitionMap) { if (!(partitionMap instanceof DynamicPartitionMapImpl)) { throw new IllegalArgumentException( "Only instances of DynamicPartitionMapImpl are supported!"); } DynamicPartitionMapImpl dpmi = (DynamicPartitionMapImpl) partitionMap; storage.createTable(PARTITION_MAP_TABLE, 1234); storage.truncateTable(PARTITION_MAP_TABLE); storage.put(PARTITION_MAP_TABLE, dpmi.toTable(), 0L); }
@Override public synchronized DynamicPartitionMapImpl getMap() { ClosableIterator<RowResult<Value>> iterator = storage.getRange(PARTITION_MAP_TABLE, RangeRequest.all(), 1L); Map<Cell, byte[]> cells = Maps.newHashMap(); while (iterator.hasNext()) { RowResult<Value> row = iterator.next(); for (Entry<Cell, Value> entry : row.getCells()) { assert !cells.containsKey(entry.getKey()); cells.put(entry.getKey(), entry.getValue().getContents()); } } iterator.close(); return DynamicPartitionMapImpl.fromTable(cells); }