List of usage examples for java.util.concurrent ConcurrentNavigableMap containsKey
boolean containsKey(Object key);
From source file:com.palantir.atlasdb.transaction.impl.SerializableTransaction.java
private void verifyRanges(Transaction ro) { // verify each set of reads to ensure they are the same. for (String table : rangeEndByTable.keySet()) { for (Entry<RangeRequest, byte[]> e : rangeEndByTable.get(table).entrySet()) { RangeRequest range = e.getKey(); byte[] rangeEnd = e.getValue(); if (rangeEnd.length != 0 && !RangeRequests.isTerminalRow(range.isReverse(), rangeEnd)) { range = range.getBuilder() .endRowExclusive(RangeRequests.getNextStartRow(range.isReverse(), rangeEnd)).build(); }/*from w ww .j a v a 2 s. c o m*/ final ConcurrentNavigableMap<Cell, byte[]> writes = writesByTable.get(table); BatchingVisitableView<RowResult<byte[]>> bv = BatchingVisitableView.of(ro.getRange(table, range)); NavigableMap<Cell, ByteBuffer> readsInRange = Maps.transformValues(getReadsInRange(table, e, range), new Function<byte[], ByteBuffer>() { @Override public ByteBuffer apply(byte[] input) { return ByteBuffer.wrap(input); } }); boolean isEqual = bv .transformBatch(new Function<List<RowResult<byte[]>>, List<Entry<Cell, ByteBuffer>>>() { @Override public List<Entry<Cell, ByteBuffer>> apply(List<RowResult<byte[]>> input) { List<Entry<Cell, ByteBuffer>> ret = Lists.newArrayList(); for (RowResult<byte[]> row : input) { for (Entry<Cell, byte[]> cell : row.getCells()) { // NB: We filter our write set out here because our normal SI checking handles this case to ensure the value hasn't changed. if (writes == null || !writes.containsKey(cell.getKey())) { ret.add(Maps.immutableEntry(cell.getKey(), ByteBuffer.wrap(cell.getValue()))); } } } return ret; } }).isEqual(readsInRange.entrySet()); if (!isEqual) { throw TransactionSerializableConflictException.create(table, getTimestamp(), System.currentTimeMillis() - timeCreated); } } } }