@Override public Update apply(byte[] input) { return new PutValue(input); } };
if (base instanceof PutValue) { PutValue put = (PutValue) base; byte[] putBytes = put.getBytes(); if (putBytes != null && putBytes.length != Bytes.SIZEOF_LONG) { throw new NumberFormatException("Attempted to increment a value that is not convertible to long"); return new PutValue(Bytes.toBytes(newValue)); } else if (base instanceof IncrementValue) { IncrementValue baseIncrement = (IncrementValue) base;
@Override protected void persist(NavigableMap<byte[], NavigableMap<byte[], Update>> changes) throws Exception { persistedVersion = tx == null ? System.currentTimeMillis() : tx.getWritePointer(); NavigableMap<byte[], NavigableMap<byte[], byte[]>> puts = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); NavigableMap<byte[], NavigableMap<byte[], Long>> increments = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); for (Map.Entry<byte[], NavigableMap<byte[], Update>> rowEntry : changes.entrySet()) { for (Map.Entry<byte[], Update> colEntry : rowEntry.getValue().entrySet()) { Update val = colEntry.getValue(); if (val instanceof IncrementValue) { NavigableMap<byte[], Long> incrCols = increments.get(rowEntry.getKey()); if (incrCols == null) { incrCols = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); increments.put(rowEntry.getKey(), incrCols); } incrCols.put(colEntry.getKey(), ((IncrementValue) val).getValue()); } else if (val instanceof PutValue) { NavigableMap<byte[], byte[]> putCols = puts.get(rowEntry.getKey()); if (putCols == null) { putCols = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); puts.put(rowEntry.getKey(), putCols); } putCols.put(colEntry.getKey(), ((PutValue) val).getValue()); } } } if (!increments.isEmpty() || !puts.isEmpty()) { persist(increments, puts); } }
if (base instanceof PutValue) { PutValue put = (PutValue) base; byte[] putBytes = put.getBytes(); if (putBytes != null && putBytes.length != Bytes.SIZEOF_LONG) { throw new NumberFormatException("Attempted to increment a value that is not convertible to long"); return new PutValue(Bytes.toBytes(newValue)); } else if (base instanceof IncrementValue) { IncrementValue baseIncrement = (IncrementValue) base;
@Override protected void persist(NavigableMap<byte[], NavigableMap<byte[], Update>> changes) throws Exception { persistedVersion = tx == null ? System.currentTimeMillis() : tx.getWritePointer(); NavigableMap<byte[], NavigableMap<byte[], byte[]>> puts = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); NavigableMap<byte[], NavigableMap<byte[], Long>> increments = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); for (Map.Entry<byte[], NavigableMap<byte[], Update>> rowEntry : changes.entrySet()) { for (Map.Entry<byte[], Update> colEntry : rowEntry.getValue().entrySet()) { Update val = colEntry.getValue(); if (val instanceof IncrementValue) { NavigableMap<byte[], Long> incrCols = increments.get(rowEntry.getKey()); if (incrCols == null) { incrCols = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); increments.put(rowEntry.getKey(), incrCols); } incrCols.put(colEntry.getKey(), ((IncrementValue) val).getValue()); } else if (val instanceof PutValue) { NavigableMap<byte[], byte[]> putCols = puts.get(rowEntry.getKey()); if (putCols == null) { putCols = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); puts.put(rowEntry.getKey(), putCols); } putCols.put(colEntry.getKey(), ((PutValue) val).getValue()); } } } if (!increments.isEmpty() || !puts.isEmpty()) { persist(increments, puts); } }
@Override public Update apply(byte[] input) { return new PutValue(input); } };
persisted.put(key, copy(((PutValue) val).getValue()));
@Override public Update<byte[]> deepCopy() { return new PutValue(bytes == null ? null : bytes.clone()); } }
persisted.put(key, copy(((PutValue) val).getValue()));
@Override public Update apply(Long input) { return new PutValue(Bytes.toBytes(input)); } };
@Override public Update apply(Long input) { return new PutValue(Bytes.toBytes(input)); } };
@Override public Update<byte[]> deepCopy() { return new PutValue(bytes == null ? null : bytes.clone()); } }
private void putInternal(byte[] row, byte[][] columns, byte[][] values) { NavigableMap<byte[], Update> colVals = buff.get(row); boolean newRow = false; if (colVals == null) { colVals = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); newRow = true; } for (int i = 0; i < columns.length; i++) { // NOTE: we copy passed column's and value's byte arrays to protect buffer against possible changes of these // arrays on client if (values[i] != null && values[i].length == 0) { warnAboutEmptyValue(columns[i]); } colVals.put(copy(columns[i]), new PutValue(copy(values[i]))); } if (newRow) { // NOTE: we copy passed row's byte arrays to protect buffer against possible changes of this array on client buff.put(copy(row), colVals); } }
private void putInternal(byte[] row, byte[][] columns, byte[][] values) { NavigableMap<byte[], Update> colVals = buff.get(row); boolean newRow = false; if (colVals == null) { colVals = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); newRow = true; } for (int i = 0; i < columns.length; i++) { // NOTE: we copy passed column's and value's byte arrays to protect buffer against possible changes of these // arrays on client if (values[i] != null && values[i].length == 0) { warnAboutEmptyValue(columns[i]); } colVals.put(copy(columns[i]), new PutValue(copy(values[i]))); } if (newRow) { // NOTE: we copy passed row's byte arrays to protect buffer against possible changes of this array on client buff.put(copy(row), colVals); } }
rowMap.put(column, columnMap); PutValue newPut = new PutValue(newValue); columnMap.put(System.currentTimeMillis(), newPut);
rowMap.put(column, columnMap); PutValue newPut = new PutValue(newValue); columnMap.put(System.currentTimeMillis(), newPut);
byte[] columnParam = new byte[] {2}; byte[] valParam = new byte[] {3}; rowUpdate.put(columnParam, new PutValue(valParam)); updates.put(rowParam, rowUpdate);