org.apache.accumulo.core.data.ConditionalMutation

Here are the examples of the java api class org.apache.accumulo.core.data.ConditionalMutation taken from open source projects.

1. TransactionImpl#beginCommitAsync()

Project: incubator-fluo
Source File: TransactionImpl.java
View license
private void beginCommitAsync(CommitData cd, AsyncCommitObserver commitCallback, RowColumn primary) {
    if (updates.size() == 0) {
        // TODO do async
        deleteWeakRow();
        commitCallback.committed();
        return;
    }
    for (Map<Column, Bytes> cols : updates.values()) {
        stats.incrementEntriesSet(cols.size());
    }
    Bytes primRow;
    Column primCol;
    if (primary != null) {
        primRow = primary.getRow();
        primCol = primary.getColumn();
        if (notification != null && !primary.equals(notification)) {
            throw new IllegalArgumentException("Primary must be notification");
        }
    } else if (notification != null) {
        primRow = notification.getRow();
        primCol = notification.getColumn();
    } else {
        primRow = updates.keySet().iterator().next();
        Map<Column, Bytes> colSet = updates.get(primRow);
        primCol = colSet.keySet().iterator().next();
    }
    // get a primary column
    cd.prow = primRow;
    Map<Column, Bytes> colSet = updates.get(cd.prow);
    cd.pcol = primCol;
    cd.pval = colSet.remove(primCol);
    if (colSet.size() == 0) {
        updates.remove(cd.prow);
    }
    cd.commitObserver = commitCallback;
    // try to lock primary column
    final ConditionalMutation pcm = prewrite(cd.prow, cd.pcol, cd.pval, cd.prow, cd.pcol, isTriggerRow(cd.prow));
    ListenableFuture<Iterator<Result>> future = cd.acw.apply(Collections.singletonList(pcm));
    Futures.addCallback(future, new CommitCallback<Iterator<Result>>(cd) {

        @Override
        protected void onSuccess(CommitData cd, Iterator<Result> result) throws Exception {
            postLockPrimary(cd, pcm, Iterators.getOnlyElement(result));
        }
    }, env.getSharedResources().getAsyncCommitExecutor());
}

2. TransactionImpl#commmitPrimary()

Project: incubator-fluo
Source File: TransactionImpl.java
View license
private void commmitPrimary(CommitData cd, final long commitTs) {
    // try to delete lock and add write for primary column
    IteratorSetting iterConf = new IteratorSetting(10, PrewriteIterator.class);
    PrewriteIterator.setSnaptime(iterConf, startTs);
    boolean isTrigger = isTriggerRow(cd.prow) && cd.pcol.equals(notification.getColumn());
    Condition lockCheck = new FluoCondition(env, cd.pcol).setIterators(iterConf).setValue(LockValue.encode(cd.prow, cd.pcol, isWrite(cd.pval), isDelete(cd.pval), isTrigger, getTransactorID()));
    final ConditionalMutation delLockMutation = new ConditionalFlutation(env, cd.prow, lockCheck);
    ColumnUtil.commitColumn(env, isTrigger, true, cd.pcol, isWrite(cd.pval), isDelete(cd.pval), startTs, commitTs, observedColumns, delLockMutation);
    ListenableFuture<Iterator<Result>> future = cd.acw.apply(Collections.singletonList(delLockMutation));
    Futures.addCallback(future, new CommitCallback<Iterator<Result>>(cd) {

        @Override
        protected void onSuccess(CommitData cd, Iterator<Result> result) throws Exception {
            handleUnkownStatsAfterPrimary(cd, commitTs, delLockMutation, Iterators.getOnlyElement(result));
        }
    }, env.getSharedResources().getAsyncCommitExecutor());
}