private static Put deletePut(byte[] row, long startId, byte[] columnsWritten) throws IOException { Columns cols = new Columns(columnsWritten); Put ret = new Put(row); byte[] status = new byte[1 + Bytes.SIZEOF_LONG]; status[0] = DominoConst.S_DELETE_BYTE; Bytes.putLong(status, 1, startId); ret.add(DominoConst.INNER_FAMILY, DominoConst.COLUMNS_COL, startId, cols.toByteArray()); ret.add(DominoConst.INNER_FAMILY, DominoConst.STATUS_COL, startId, status); return ret; }
private static Put clonePut(Put put) { long startId = 0; long commitId = 1; Put ret = new Put(put.getRow()); Map<byte[], List<KeyValue>> families = put.getFamilyMap(); Columns cols = new Columns(null); for (byte[] family : families.keySet()) { List<KeyValue> columns = families.get(family); Iterator<KeyValue> it = columns.iterator(); while (it.hasNext()) { KeyValue kv = it.next(); // byte[] column = DominoConst.getColumnKey(kv.getQualifier(), startId); byte[] qualifier = kv.getQualifier(); ret.add(family, qualifier, startId, kv.getValue()); cols.add(family, qualifier); } } Map<String, byte[]> attributes = put.getAttributesMap(); for (String key : attributes.keySet()) { ret.setAttribute(key, attributes.get(key)); } ret.add(DominoConst.INNER_FAMILY, DominoConst.COLUMNS_COL, startId, cols.toByteArray()); ret.add(DominoConst.INNER_FAMILY, DominoConst.VERSION_COL, commitId, DominoConst.versionValue(startId, false)); return ret; }
long prevStartId = DominoConst.getVersion(prevValue); boolean isFresh = (removeCommitId != commitId); Columns removeCols = new Columns(DominoConst.getColumnsAt(r, removeStartId)); if (!DominoConst.isDeleteVersion(removeValue) && !DominoConst.isDeleteVersion(prevValue)) { Columns prevCols = new Columns(DominoConst.getColumnsAt(r, prevStartId)); Get get = new Get(row); get.setTimeStamp(removeStartId); Result res = region.get(get, lockId); for (Column col : removeCols.cols) { if (prevCols.contains(col.family, col.qualifier)) { continue; // a newer value prevCols.add(col.family, col.qualifier); commit.add(col.family, col.qualifier, prevStartId, value); prevStartId, prevCols.toByteArray());
@SuppressWarnings("deprecation") @Override public void rollbackRow(byte[] row, long startId, Integer lockId) throws IOException { byte[] family = DominoConst.INNER_FAMILY; Get get = new Get(row); get.setTimeStamp(startId); get.addFamily(family); Result r = region.get(get, lockId); if (r == null || r.isEmpty()) return; byte[] colBytes = r.getValue(family, DominoConst.COLUMNS_COL); if (colBytes == null || colBytes.length == 0) return; Delete del = new Delete(row); Columns cols = new Columns(colBytes); for (Column col : cols.cols) { del.deleteColumn(col.family, col.qualifier, startId); } del.deleteColumn(family, DominoConst.COLUMNS_COL, startId); del.deleteColumn(family, DominoConst.STATUS_COL, startId); mutateRow(del, lockId); }
private static Put clonePut(Put put, long startId, boolean locking, byte[] columnsWritten) { Put ret = new Put(put.getRow()); Map<byte[], List<KeyValue>> families = put.getFamilyMap(); Columns cols = new Columns(columnsWritten); for (byte[] family : families.keySet()) { List<KeyValue> columns = families.get(family); Iterator<KeyValue> it = columns.iterator(); while (it.hasNext()) { KeyValue kv = it.next(); // byte[] column = DominoConst.getColumnKey(kv.getQualifier(), startId); byte[] qualifier = kv.getQualifier(); ret.add(family, qualifier, startId, kv.getValue()); cols.add(family, qualifier); } } Map<String, byte[]> attributes = put.getAttributesMap(); for (String key : attributes.keySet()) { ret.setAttribute(key, attributes.get(key)); } byte[] state = new byte[1 + Bytes.SIZEOF_LONG]; state[0] = locking ? DominoConst.S_STATEFUL_BYTE : DominoConst.S_STATELESS_BYTE; Bytes.putLong(state, 1, startId); ret.add(DominoConst.INNER_FAMILY, DominoConst.COLUMNS_COL, startId, cols.toByteArray()); ret.add(DominoConst.INNER_FAMILY, DominoConst.STATUS_COL, startId, state); return ret; }