private int getCount(Table t, byte[] type) throws IOException { Get test = new Get(row); test.setAttribute("count", new byte[] {}); Result res = t.get(test); return Bytes.toInt(res.getValue(count, type)); }
@Test public void testAttributesSerialization() throws IOException { Get get = new Get(Bytes.toBytes("row")); get.setAttribute("attribute1", Bytes.toBytes("value1")); get.setAttribute("attribute2", Bytes.toBytes("value2")); get.setAttribute("attribute3", Bytes.toBytes("value3")); ClientProtos.Get getProto = ProtobufUtil.toGet(get); Get get2 = ProtobufUtil.toGet(getProto); Assert.assertNull(get2.getAttribute("absent")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get2.getAttribute("attribute1"))); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get2.getAttribute("attribute2"))); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value3"), get2.getAttribute("attribute3"))); Assert.assertEquals(3, get2.getAttributesMap().size()); }
@Test public void testReadFromCorruptMobFilesWithReadEmptyValueOnMobCellMiss() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); setUp(0, tableName); createRecordAndCorruptMobFile(tableName, row1, family, qf1, Bytes.toBytes("value1")); Get get = new Get(row1); get.setAttribute(MobConstants.EMPTY_VALUE_ON_MOBCELL_MISS, Bytes.toBytes(true)); Result result = table.get(get); Cell cell = result.getColumnLatestCell(family, qf1); Assert.assertEquals(0, cell.getValueLength()); }
setAttribute(attr.getKey(), attr.getValue());
get.setAttribute("absent", null); Assert.assertTrue(get.getAttributesMap().isEmpty()); Assert.assertNull(get.getAttribute("absent")); get.setAttribute("attribute1", Bytes.toBytes("value1")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttribute("attribute1"))); Assert.assertEquals(1, get.getAttributesMap().size()); get.setAttribute("attribute1", Bytes.toBytes("value12")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttribute("attribute1"))); Assert.assertEquals(1, get.getAttributesMap().size()); get.setAttribute("attribute2", Bytes.toBytes("value2")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttribute("attribute2"))); Assert.assertEquals(2, get.getAttributesMap().size()); get.setAttribute("attribute2", null); Assert.assertNull(get.getAttribute("attribute2")); Assert.assertEquals(1, get.getAttributesMap().size()); get.setAttribute("attribute2", null); Assert.assertNull(get.getAttribute("attribute2")); Assert.assertEquals(1, get.getAttributesMap().size()); get.setAttribute("attribute1", null); Assert.assertNull(get.getAttribute("attribute1")); Assert.assertTrue(get.getAttributesMap().isEmpty());
get.setAttribute(MobConstants.MOB_SCAN_RAW, Bytes.toBytes(true)); result = table.get(get); cell = result.getColumnLatestCell(hcd1.getName(), Bytes.toBytes(qf1));
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
.setRowOffsetPerColumnFamily(5) .setTimeRange(0, 13) .setAttribute("att_v0", Bytes.toBytes("att_v0")) .setColumnFamilyTimeRange(Bytes.toBytes("cf"), 0, 123) .setReplicaId(3)
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
@Test public void testAttributesSerialization() throws IOException { Get get = new Get(Bytes.toBytes("row")); get.setAttribute("attribute1", Bytes.toBytes("value1")); get.setAttribute("attribute2", Bytes.toBytes("value2")); get.setAttribute("attribute3", Bytes.toBytes("value3")); ClientProtos.Get getProto = ProtobufUtil.toGet(get); Get get2 = ProtobufUtil.toGet(getProto); Assert.assertNull(get2.getAttribute("absent")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get2.getAttribute("attribute1"))); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get2.getAttribute("attribute2"))); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value3"), get2.getAttribute("attribute3"))); Assert.assertEquals(3, get2.getAttributesMap().size()); }
setAttribute(attr.getKey(), attr.getValue());
get.setAttribute("absent", null); Assert.assertTrue(get.getAttributesMap().isEmpty()); Assert.assertNull(get.getAttribute("absent")); get.setAttribute("attribute1", Bytes.toBytes("value1")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), get.getAttribute("attribute1"))); Assert.assertEquals(1, get.getAttributesMap().size()); get.setAttribute("attribute1", Bytes.toBytes("value12")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), get.getAttribute("attribute1"))); Assert.assertEquals(1, get.getAttributesMap().size()); get.setAttribute("attribute2", Bytes.toBytes("value2")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), get.getAttribute("attribute2"))); Assert.assertEquals(2, get.getAttributesMap().size()); get.setAttribute("attribute2", null); Assert.assertNull(get.getAttribute("attribute2")); Assert.assertEquals(1, get.getAttributesMap().size()); get.setAttribute("attribute2", null); Assert.assertNull(get.getAttribute("attribute2")); Assert.assertEquals(1, get.getAttributesMap().size()); get.setAttribute("attribute1", null); Assert.assertNull(get.getAttribute("attribute1")); Assert.assertTrue(get.getAttributesMap().isEmpty());
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
.setRowOffsetPerColumnFamily(5) .setTimeRange(0, 13) .setAttribute("att_v0", Bytes.toBytes("att_v0")) .setColumnFamilyTimeRange(Bytes.toBytes("cf"), 0, 123) .setReplicaId(3)
get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
@Test public void testReadFromCorruptMobFilesWithReadEmptyValueOnMobCellMiss() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); setUp(0, tableName); createRecordAndCorruptMobFile(tableName, row1, family, qf1, Bytes.toBytes("value1")); Get get = new Get(row1); get.setAttribute(MobConstants.EMPTY_VALUE_ON_MOBCELL_MISS, Bytes.toBytes(true)); Result result = table.get(get); Cell cell = result.getColumnLatestCell(family, qf1); Assert.assertEquals(0, cell.getValueLength()); }