@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)); }
public TxInfo getTransactionInfo(final Bytes prow, final Column pcol, final long startTs) { return getTransactionInfo(new PrimaryRowColumn(prow, pcol, startTs)); }
private static Map<PrimaryRowColumn, List<LockInfo>> groupLocksByPrimary(List<LockInfo> locks) { Map<PrimaryRowColumn, List<LockInfo>> groupedLocks = new HashMap<>(); Map<PrimaryRowColumn, Long> transactorIds = new HashMap<>(); for (LockInfo lockInfo : locks) { PrimaryRowColumn prc = new PrimaryRowColumn(lockInfo.prow, lockInfo.pcol, lockInfo.lockTs); List<LockInfo> lockList = groupedLocks.computeIfAbsent(prc, k -> new ArrayList<>()); Long trid = transactorIds.get(prc); if (trid == null) { transactorIds.put(prc, lockInfo.transactorId); } else if (!trid.equals(lockInfo.transactorId)) { // 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 + " " + lockInfo.entry.getKey() + " " + trid + " " + lockInfo.transactorId); } lockList.add(lockInfo); } return groupedLocks; }
@Override public int weigh(PrimaryRowColumn key, TxInfo value) { return key.weight() + (value.lockValue == null ? 0 : value.lockValue.length) + 24; } }
private static Map<PrimaryRowColumn, List<LockInfo>> groupLocksByPrimary(List<LockInfo> locks) { Map<PrimaryRowColumn, List<LockInfo>> groupedLocks = new HashMap<>(); Map<PrimaryRowColumn, Long> transactorIds = new HashMap<>(); for (LockInfo lockInfo : locks) { PrimaryRowColumn prc = new PrimaryRowColumn(lockInfo.prow, lockInfo.pcol, lockInfo.lockTs); List<LockInfo> lockList = groupedLocks.computeIfAbsent(prc, k -> new ArrayList<>()); Long trid = transactorIds.get(prc); if (trid == null) { transactorIds.put(prc, lockInfo.transactorId); } else if (!trid.equals(lockInfo.transactorId)) { // 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 + " " + lockInfo.entry.getKey() + " " + trid + " " + lockInfo.transactorId); } lockList.add(lockInfo); } return groupedLocks; }