@Test public void testPutAttributes() { Put put = new Put(ROW); Assert.assertTrue(put.getAttributesMap().isEmpty()); Assert.assertNull(put.getAttribute("absent")); Assert.assertTrue(put.getAttributesMap().isEmpty()); Assert.assertNull(put.getAttribute("absent")); Assert.assertEquals(1, put.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), put.getAttributesMap().get("attribute1"))); Assert.assertEquals(1, put.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), put.getAttributesMap().get("attribute1"))); Assert.assertEquals(2, put.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), put.getAttributesMap().get("attribute2"))); Assert.assertEquals(1, put.getAttributesMap().size()); Assert.assertNull(put.getAttributesMap().get("attribute2")); Assert.assertEquals(1, put.getAttributesMap().size()); Assert.assertNull(put.getAttributesMap().get("attribute2")); Assert.assertTrue(put.getAttributesMap().isEmpty()); Assert.assertNull(put.getAttributesMap().get("attribute1"));
for (Map.Entry<String, byte[]> attribute : in.getAttributesMap().entrySet()) { out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())), ByteBuffer.wrap(attribute.getValue()));
@Test public void testPutAttributes() { Put put = new Put(ROW); Assert.assertTrue(put.getAttributesMap().isEmpty()); Assert.assertNull(put.getAttribute("absent")); Assert.assertTrue(put.getAttributesMap().isEmpty()); Assert.assertNull(put.getAttribute("absent")); Assert.assertEquals(1, put.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), put.getAttributesMap().get("attribute1"))); Assert.assertEquals(1, put.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), put.getAttributesMap().get("attribute1"))); Assert.assertEquals(2, put.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), put.getAttributesMap().get("attribute2"))); Assert.assertEquals(1, put.getAttributesMap().size()); Assert.assertNull(put.getAttributesMap().get("attribute2")); Assert.assertEquals(1, put.getAttributesMap().size()); Assert.assertNull(put.getAttributesMap().get("attribute2")); Assert.assertTrue(put.getAttributesMap().isEmpty()); Assert.assertNull(put.getAttributesMap().get("attribute1"));
/** * Copy constructor. Creates a Put operation cloned from the specified Put. * @param putToCopy put to copy */ public Put(Put putToCopy) { this(putToCopy.getRow(), putToCopy.ts); this.familyMap = new TreeMap<byte [], List<Cell>>(Bytes.BYTES_COMPARATOR); for(Map.Entry<byte [], List<Cell>> entry: putToCopy.getFamilyCellMap().entrySet()) { this.familyMap.put(entry.getKey(), new ArrayList<Cell>(entry.getValue())); } this.durability = putToCopy.durability; for (Map.Entry<String, byte[]> entry : putToCopy.getAttributesMap().entrySet()) { this.setAttribute(entry.getKey(), entry.getValue()); } }
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; }
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; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }
private Put transactionalizeAction(Put put) throws IOException { Put txPut = new Put(put.getRow(), tx.getWritePointer()); Set<Map.Entry<byte[], List<Cell>>> familyMap = put.getFamilyCellMap().entrySet(); if (!familyMap.isEmpty()) { for (Map.Entry<byte[], List<Cell>> family : familyMap) { List<Cell> familyValues = family.getValue(); if (!familyValues.isEmpty()) { for (Cell value : familyValues) { txPut.add(value.getFamily(), value.getQualifier(), tx.getWritePointer(), value.getValue()); addToChangeSet(txPut.getRow(), value.getFamily(), value.getQualifier()); } } } } for (Map.Entry<String, byte[]> entry : put.getAttributesMap().entrySet()) { txPut.setAttribute(entry.getKey(), entry.getValue()); } txPut.setDurability(put.getDurability()); addToOperation(txPut, tx); return txPut; }