public static ColumnType from(Key k) { return from(k.getTimestamp()); }
public void skipToPrefix(Key curCol, ColumnType colType) throws IOException { skipToTimestamp(curCol, colType.first()); }
ColumnType colType = ColumnType.from(source.getTopKey()); long ts = source.getTopKey().getTimestamp() & ColumnConstants.TIMESTAMP_MASK; continue; } else { source.skipToTimestamp(curCol, ColumnType.WRITE.encode(snaptime)); continue; continue outer; } else { source.skipToTimestamp(curCol, ColumnType.DATA.encode(dataPointer)); continue; source.skipToTimestamp(curCol, ColumnType.DATA.encode(dataPointer)); continue; continue outer; } else { source.skipToTimestamp(curCol, ColumnType.DATA.encode(dataPointer)); continue;
endKey.setTimestamp(ColumnType.DATA.first()); } else { endKey.setTimestamp(ColumnType.ACK.first()); PartialKey.ROW_COLFAM_COLQUAL_COLVIS)) { ColumnType colType = ColumnType.from(source.getTopKey()); long ts = source.getTopKey().getTimestamp() & ColumnConstants.TIMESTAMP_MASK; colType = ColumnType.from(source.getTopKey()); ts = source.getTopKey().getTimestamp() & ColumnConstants.TIMESTAMP_MASK; rlts = ReadLockUtil.decodeTs(ts);
public Entry<Key, Value> getNext() { mloop: while (true) { // its possible a next could exist then be rolled back if (!iterator.hasNext()) { return null; } Entry<Key, Value> entry = iterator.next(); ColumnType colType = ColumnType.from(entry.getKey()); switch (colType) { case LOCK: resolveLock(entry); continue mloop; case DATA: stats.incrementEntriesReturned(1); return entry; case RLOCK: return entry; default: throw new IllegalArgumentException("Unexpected column type " + colType); } } }
@Override public Collection<Mutation> createMutations(CommitData cd) { // mark transaction as complete for garbage collection purposes Flutation m = new Flutation(env, cd.prow); m.put(cd.pcol, ColumnType.DEL_LOCK.encode(startTs), DelLockValue.encodeRollback(startTs, true, true)); m.put(cd.pcol, ColumnType.TX_DONE.encode(startTs), EMPTY); return Collections.singletonList(m); } }
private void scan(Map<Bytes, Map<Column, Bytes>> ret, List<Entry<Key, Value>> locks) { BatchScanner bs = setupBatchScanner(); try { for (Entry<Key, Value> entry : bs) { Bytes row = rowConverter.apply(entry.getKey().getRowData()); Column col = columnConverter.apply(entry.getKey()); ColumnType colType = ColumnType.from(entry.getKey()); switch (colType) { case LOCK: locks.add(entry); break; case DATA: ret.computeIfAbsent(row, k -> new HashMap<>()).put(col, Bytes.of(entry.getValue().get())); break; case RLOCK: readLocksSeen.computeIfAbsent(row, k -> new HashSet<>()).add(col); break; default: throw new IllegalArgumentException("Unexpected column type " + colType); } } } finally { bs.close(); } } }
@Override public Collection<Mutation> createMutations(CommitData cd) { // roll back locks // TODO let rollback be done lazily? this makes GC more difficult Flutation m; ArrayList<Mutation> mutations = new ArrayList<>(cd.acceptedRows.size()); for (Bytes row : cd.acceptedRows) { m = new Flutation(env, row); for (Entry<Column, Bytes> entry : updates.get(row).entrySet()) { if (isReadLock(entry.getValue())) { m.put(entry.getKey(), ColumnType.RLOCK.encode(ReadLockUtil.encodeTs(startTs, true)), DelReadLockValue.encodeRollback()); } else { m.put(entry.getKey(), ColumnType.DEL_LOCK.encode(startTs), DelLockValue.encodeRollback(false, true)); } } mutations.add(m); } return mutations; } }
private boolean wasRolledBackPrimary(long startTs, String rolledBackRow) throws TableNotFoundException { boolean sawExpected = false; Scanner scanner = aClient.createScanner(getCurTableName(), Authorizations.EMPTY); for (Entry<Key, Value> entry : scanner) { ColumnType colType = ColumnType.from(entry.getKey()); long ts = entry.getKey().getTimestamp() & ColumnConstants.TIMESTAMP_MASK; String row = entry.getKey().getRowData().toString(); byte[] val = entry.getValue().get(); if (row.equals(rolledBackRow) && colType == ColumnType.DEL_LOCK && ts == startTs && DelLockValue.isPrimary(val)) { sawExpected = true; } } return sawExpected; }
public static void commitColumn(Environment env, boolean isTrigger, boolean isPrimary, Column col, boolean isWrite, boolean isDelete, boolean isReadlock, long startTs, long commitTs, Set<Column> observedColumns, Mutation m) { if (isReadlock) { Flutation.put(env, m, col, ColumnType.RLOCK.encode(ReadLockUtil.encodeTs(startTs, true)), DelReadLockValue.encodeCommit(commitTs)); } else if (isWrite) { Flutation.put(env, m, col, ColumnType.WRITE.encode(commitTs), WriteValue.encode(startTs, isPrimary, isDelete)); } else { Flutation.put(env, m, col, ColumnType.DEL_LOCK.encode(startTs), DelLockValue.encodeCommit(commitTs, isPrimary)); } if (isTrigger) { Flutation.put(env, m, col, ColumnType.ACK.encode(startTs), TransactionImpl.EMPTY); } }
ColumnType colType = ColumnType.from(entry.getKey()); long ts = entry.getKey().getTimestamp() & ColumnConstants.TIMESTAMP_MASK;
@Override public Collection<Mutation> createMutations(CommitData cd) { long commitTs = getStats().getCommitTs(); ArrayList<Mutation> afterFlushMutations = new ArrayList<>(2); Flutation m = new Flutation(env, cd.prow); // mark transaction as complete for garbage collection purposes m.put(cd.pcol, ColumnType.TX_DONE.encode(commitTs), EMPTY); afterFlushMutations.add(m); if (weakNotification != null) { afterFlushMutations.add(weakNotification.newDelete(env, startTs)); } if (notification != null) { afterFlushMutations.add(notification.newDelete(env, startTs)); } return afterFlushMutations; }
Entry<Key, Value> entry = iterator.next(); if (ColumnType.from(entry.getKey()) == ColumnType.LOCK) { locks.add(entry); locksSeen.accept(lockEntry);
/** * Translates the Fluo row, column, and value set into the persistent format that is stored in * Accumulo. * * <p> * The objects returned by this method are reused each time its called. So each time this is * called it invalidates what was returned by previous calls to this method. * * @return A an array of Accumulo key values in correct sorted order. */ public FluoKeyValue[] getKeyValues() { FluoKeyValue kv = keyVals[0]; kv.setKey(new Key(row, fam, qual, vis, ColumnType.WRITE.encode(1))); kv.getValue().set(WriteValue.encode(0, false, false)); kv = keyVals[1]; kv.setKey(new Key(row, fam, qual, vis, ColumnType.DATA.encode(0))); kv.getValue().set(val); return keyVals; } }
if (ColumnType.from(kve.getKey()) == ColumnType.RLOCK) { if (readLockCols == null) { readLockCols = readLocksSeen.computeIfAbsent(row, k -> new HashSet<>());
private static void rollback(Environment env, long startTs, PrimaryRowColumn prc, List<LockInfo> value, Map<ByteSequence, Mutation> mutations) { for (LockInfo lockInfo : value) { if (isPrimary(prc, lockInfo.entry.getKey())) { continue; } Mutation mut = getMutation(lockInfo.entry.getKey().getRowData(), mutations); Key k = lockInfo.entry.getKey(); if (lockInfo.isReadLock) { mut.put(k.getColumnFamilyData().toArray(), k.getColumnQualifierData().toArray(), k.getColumnVisibilityParsed(), ColumnType.RLOCK.encode(ReadLockUtil.encodeTs(lockInfo.lockTs, true)), DelReadLockValue.encodeRollback()); } else { mut.put(k.getColumnFamilyData().toArray(), k.getColumnQualifierData().toArray(), k.getColumnVisibilityParsed(), ColumnType.DEL_LOCK.encode(lockInfo.lockTs), DelLockValue.encodeRollback(false, true)); } } }