public void put(Column col, long ts, byte[] val) { Flutation.put(env, this, col, ts, val); } }
private void rollback(CommitData cd) throws MutationsRejectedException { // 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 (Column col : updates.get(row).keySet()) { m.put(col, ColumnConstants.DEL_LOCK_PREFIX | startTs, DelLockValue.encode(startTs, false, true)); } mutations.add(m); } env.getSharedResources().getBatchWriter().writeMutations(mutations); // mark transaction as complete for garbage collection purposes m = new Flutation(env, cd.prow); // TODO timestamp? // TODO writing the primary column with a batch writer is iffy m.put(cd.pcol, ColumnConstants.DEL_LOCK_PREFIX | startTs, DelLockValue.encode(startTs, false, true)); m.put(cd.pcol, ColumnConstants.TX_DONE_PREFIX | startTs, EMPTY); env.getSharedResources().getBatchWriter().writeMutation(m); }
private void writeWeakNotifications(long commitTs) { if (weakNotifications.size() > 0) { SharedBatchWriter sbw = env.getSharedResources().getBatchWriter(); ArrayList<Mutation> mutations = new ArrayList<>(); for (Entry<Bytes, Set<Column>> entry : weakNotifications.entrySet()) { Flutation m = new Flutation(env, entry.getKey()); for (Column col : entry.getValue()) { Notification.put(env, m, col, commitTs); } mutations.add(m); } sbw.writeMutations(mutations); } }
public boolean finishCommit(CommitData cd, Stamp commitStamp) throws TableNotFoundException, MutationsRejectedException { long commitTs = commitStamp.getTxTimestamp(); // delete locks and add writes for other columns ArrayList<Mutation> mutations = new ArrayList<>(updates.size() + 1); for (Entry<Bytes, Map<Column, Bytes>> rowUpdates : updates.entrySet()) { Flutation m = new Flutation(env, rowUpdates.getKey()); boolean isTriggerRow = isTriggerRow(rowUpdates.getKey()); for (Entry<Column, Bytes> colUpdates : rowUpdates.getValue().entrySet()) { ColumnUtil.commitColumn(env, isTriggerRow && colUpdates.getKey().equals(notification.getColumn()), false, colUpdates.getKey(), colUpdates.getValue() != null, colUpdates.getValue() == DELETE, startTs, commitTs, observedColumns, m); } mutations.add(m); } 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, ColumnConstants.TX_DONE_PREFIX | commitTs, EMPTY); afterFlushMutations.add(m); if (weakNotification != null) { afterFlushMutations.add(weakNotification.newDelete(env, startTs)); } if (notification != null) { afterFlushMutations.add(notification.newDelete(env, startTs)); } env.getSharedResources().getBatchWriter().writeMutationsAsync(mutations, afterFlushMutations); return true; }
public Flutation newDelete(Environment env, long ts) { Flutation m = new Flutation(env, getRow()); ColumnVisibility cv = env.getSharedResources().getVisCache().getCV(getColumn()); m.put(ColumnConstants.NOTIFY_CF.toArray(), encodeCol(getColumn()), cv, encodeTs(ts, true), TransactionImpl.EMPTY); return m; }
public void put(Column col, long ts, byte[] val) { put(env, this, col, ts, val); }
public static void put(Mutation m, Column col, long ts, byte[] val) { put(null, m, col, ts, val); }
public static void commitColumn(Environment env, boolean isTrigger, boolean isPrimary, Column col, boolean isWrite, boolean isDelete, long startTs, long commitTs, Set<Column> observedColumns, Mutation m) { if (isWrite) { Flutation.put(env, m, col, ColumnConstants.WRITE_PREFIX | commitTs, WriteValue.encode(startTs, isPrimary, isDelete)); } else { Flutation.put(env, m, col, ColumnConstants.DEL_LOCK_PREFIX | commitTs, DelLockValue.encode(startTs, isPrimary, false)); } if (isTrigger) { Flutation.put(env, m, col, ColumnConstants.ACK_PREFIX | startTs, TransactionImpl.EMPTY); } if (observedColumns.contains(col) && isWrite && !isDelete) { Notification.put(env, m, col, commitTs); } }