@Override public int weigh(PrimaryRowColumn key, TxInfo value) { return key.weight() + (value.lockValue == null ? 0 : value.lockValue.length) + 24; } }
public TxInfo getTransactionInfo(final Bytes prow, final Column pcol, final long startTs) { return getTransactionInfo(new PrimaryRowColumn(prow, pcol, startTs)); }
private static Map<PrimaryRowColumn, List<Entry<Key, Value>>> groupLocksByPrimary( List<Entry<Key, Value>> locks) { Map<PrimaryRowColumn, List<Entry<Key, Value>>> groupedLocks = new HashMap<>(); Map<PrimaryRowColumn, Long> transactorIds = new HashMap<>(); for (Entry<Key, Value> lock : locks) { LockValue lockVal = new LockValue(lock.getValue().get()); PrimaryRowColumn prc = new PrimaryRowColumn(lockVal.getPrimaryRow(), lockVal.getPrimaryColumn(), lock.getKey() .getTimestamp() & ColumnConstants.TIMESTAMP_MASK); List<Entry<Key, Value>> lockList = groupedLocks.get(prc); if (lockList == null) { lockList = new ArrayList<>(); groupedLocks.put(prc, lockList); } Long trid = transactorIds.get(prc); if (trid == null) { transactorIds.put(prc, lockVal.getTransactor()); } else if (!trid.equals(lockVal.getTransactor())) { // sanity check.. its assumed that all locks w/ the same PrimaryRowColumn should have the // same transactor id as well throw new IllegalStateException("transactor ids not equals " + prc + " " + lock.getKey() + " " + trid + " " + lockVal.getTransactor()); } lockList.add(lock); } return groupedLocks; }