/** * An atomic operation that appends a value to an existing bin value. Bin value must be a string type. * * @param fieldName Name of the bin or, if mapped Class was provided, name of the mapped field * @param value Value to append to the bin value. */ public SingleKeyCommander<T> append(String fieldName, String value) { String binName = mapper != null ? mapper.getBinName(fieldName) : fieldName; operations.add(Operation.append(new Bin(binName, value))); return this; }
@SuppressWarnings("unchecked") @Override public <T> T append(T objectToAppendTo, Map<String, String> values) { Assert.notNull(objectToAppendTo, "Object to append to must not be null!"); try { AerospikeWriteData data = AerospikeWriteData.forWrite(); converter.write(objectToAppendTo, data); Operation[] ops = new Operation[values.size() + 1]; int x = 0; for (Map.Entry<String, String> entry : values.entrySet()) { Bin newBin = new Bin(entry.getKey(), entry.getValue()); ops[x] = Operation.append(newBin); x++; } ops[x] = Operation.get(); Record record = this.client.operate(null, data.getKey(), ops); return mapToEntity(data.getKey(), (Class<T>) objectToAppendTo.getClass(), record); } catch (AerospikeException o_O) { DataAccessException translatedException = exceptionTranslator .translateExceptionIfPossible(o_O); throw translatedException == null ? o_O : translatedException; } }
@SuppressWarnings("unchecked") @Override public <T> T append(T objectToAppendTo, String binName, String value) { Assert.notNull(objectToAppendTo, "Object to append to must not be null!"); try { AerospikeWriteData data = AerospikeWriteData.forWrite(); converter.write(objectToAppendTo, data); Record record = this.client.operate(null, data.getKey(), Operation.append(new Bin(binName, value)), Operation.get(binName)); return mapToEntity(data.getKey(), (Class<T>) objectToAppendTo.getClass(), record); } catch (AerospikeException o_O) { DataAccessException translatedException = exceptionTranslator .translateExceptionIfPossible(o_O); throw translatedException == null ? o_O : translatedException; } }