for (int j = 0; j < numAccts; j++) { String cf = Utils.getAccount(j); m.addCondition(new Condition(cf, "seq")); m.put(cf, "bal", "100"); m.put(cf, "seq", Utils.getSeq(0));
/** * Creates a {@link ConditionalMutation} that only updates the cardinality * of the PCJ table if the old value has not changed by the time this mutation * is committed to Accumulo. * * @param current - The current cardinality value. * @param delta - How much the cardinality will change. * @return The mutation that will perform the conditional update. */ private static ConditionalMutation makeUpdateCardinalityMutation(final long current, final long delta) { // Try to update the cardinality by the delta. final ConditionalMutation mutation = new ConditionalMutation(PCJ_METADATA_ROW_ID); final Condition lastCardinalityStillCurrent = new Condition( PCJ_METADATA_FAMILY, PCJ_METADATA_CARDINALITY); // Require the old cardinality to be the value we just read. final byte[] currentCardinalityBytes = longLexicoder.encode( current ); lastCardinalityStillCurrent.setValue( currentCardinalityBytes ); mutation.addCondition(lastCardinalityStillCurrent); // If that is the case, then update to the new value. final Value newCardinality = new Value( longLexicoder.encode(current + delta) ); mutation.put(PCJ_METADATA_FAMILY, PCJ_METADATA_CARDINALITY, newCardinality); return mutation; }
mutation.addCondition( condition ); final byte[] newDetailsBytes = serializer.serialize(newDetails); mutation.put(COL_FAMILY, COL_QUALIFIER, new Value(newDetailsBytes));
mutation.addCondition( condition ); final byte[] newDetailsBytes = serializer.serialize(newDetails); mutation.put(COL_FAMILY, COL_QUALIFIER, new Value(newDetailsBytes));