@Test public void testScanAttributes() { Scan scan = new Scan(); Assert.assertTrue(scan.getAttributesMap().isEmpty()); Assert.assertNull(scan.getAttribute("absent")); Assert.assertTrue(scan.getAttributesMap().isEmpty()); Assert.assertNull(scan.getAttribute("absent")); Assert.assertEquals(1, scan.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), scan.getAttributesMap().get("attribute1"))); Assert.assertEquals(1, scan.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), scan.getAttributesMap().get("attribute1"))); Assert.assertEquals(2, scan.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), scan.getAttributesMap().get("attribute2"))); Assert.assertEquals(1, scan.getAttributesMap().size()); Assert.assertNull(scan.getAttributesMap().get("attribute2")); Assert.assertEquals(1, scan.getAttributesMap().size()); Assert.assertNull(scan.getAttributesMap().get("attribute2")); Assert.assertTrue(scan.getAttributesMap().isEmpty()); Assert.assertNull(scan.getAttributesMap().get("attribute1"));
@Test public void testAttributesSerialization() throws IOException { Scan scan = new Scan(); scan.setAttribute("attribute1", Bytes.toBytes("value1")); scan.setAttribute("attribute2", Bytes.toBytes("value2")); scan.setAttribute("attribute3", Bytes.toBytes("value3")); ClientProtos.Scan scanProto = ProtobufUtil.toScan(scan); Scan scan2 = ProtobufUtil.toScan(scanProto); Assert.assertNull(scan2.getAttribute("absent")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), scan2.getAttribute("attribute1"))); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), scan2.getAttribute("attribute2"))); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value3"), scan2.getAttribute("attribute3"))); Assert.assertEquals(3, scan2.getAttributesMap().size()); }
out.setBatchSize(in.getBatch()); for (Map.Entry<String, byte[]> attribute : in.getAttributesMap().entrySet()) { out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())), ByteBuffer.wrap(attribute.getValue()));
for (Map.Entry<String, byte[]> attr : scan.getAttributesMap().entrySet()) { setAttribute(attr.getKey(), attr.getValue());
}); scanBuilder.setTimeRange(toTimeRange(scan.getTimeRange())); Map<String, byte[]> attributes = scan.getAttributesMap(); if (!attributes.isEmpty()) { NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
}); scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(scan.getTimeRange())); Map<String, byte[]> attributes = scan.getAttributesMap(); if (!attributes.isEmpty()) { NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
assertEquals(scan.getAttribute("test_key"), scanCopy.getAttribute("test_key")); assertEquals(scan.getAttributeSize(), scanCopy.getAttributeSize()); assertEquals(scan.getAttributesMap(), scanCopy.getAttributesMap()); assertEquals(scan.getAuthorizations().getLabels(), scanCopy.getAuthorizations().getLabels()); assertEquals(scan.getBatch(), scanCopy.getBatch());
if (LOG.isDebugEnabled()) { LOG.debug("Split for scan : " + aScan + "with scanAttribute : " + aScan .getAttributesMap() + " [scanCache, cacheBlock, scanBatch] : [" + aScan.getCaching() + ", " + aScan.getCacheBlocks() + ", " + aScan .getBatch() + "] and regionLocation : " + regionLocation); .size() - 1).getStopRow())); LOG.debug("First scan : " + scans.get(0) + "with scanAttribute : " + scans .get(0).getAttributesMap() + " [scanCache, cacheBlock, scanBatch] : " + "[" + scans.get(0).getCaching() + ", " + scans.get(0).getCacheBlocks() + ", " + scans.get(0).getBatch() + "] and regionLocation : " +
if (LOG.isDebugEnabled()) { LOG.debug("Split for scan : " + aScan + "with scanAttribute : " + aScan .getAttributesMap() + " [scanCache, cacheBlock, scanBatch] : [" + aScan.getCaching() + ", " + aScan.getCacheBlocks() + ", " + aScan .getBatch() + "] and regionLocation : " + regionLocation); .size() - 1).getStopRow())); LOG.debug("First scan : " + scans.get(0) + "with scanAttribute : " + scans .get(0).getAttributesMap() + " [scanCache, cacheBlock, scanBatch] : " + "[" + scans.get(0).getCaching() + ", " + scans.get(0).getCacheBlocks() + ", " + scans.get(0).getBatch() + "] and regionLocation : " +
@Test public void testAttributesSerialization() throws IOException { Scan scan = new Scan(); scan.setAttribute("attribute1", Bytes.toBytes("value1")); scan.setAttribute("attribute2", Bytes.toBytes("value2")); scan.setAttribute("attribute3", Bytes.toBytes("value3")); ClientProtos.Scan scanProto = ProtobufUtil.toScan(scan); Scan scan2 = ProtobufUtil.toScan(scanProto); Assert.assertNull(scan2.getAttribute("absent")); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), scan2.getAttribute("attribute1"))); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), scan2.getAttribute("attribute2"))); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value3"), scan2.getAttribute("attribute3"))); Assert.assertEquals(3, scan2.getAttributesMap().size()); }
@Test public void testScanAttributes() { Scan scan = new Scan(); Assert.assertTrue(scan.getAttributesMap().isEmpty()); Assert.assertNull(scan.getAttribute("absent")); Assert.assertTrue(scan.getAttributesMap().isEmpty()); Assert.assertNull(scan.getAttribute("absent")); Assert.assertEquals(1, scan.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value1"), scan.getAttributesMap().get("attribute1"))); Assert.assertEquals(1, scan.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value12"), scan.getAttributesMap().get("attribute1"))); Assert.assertEquals(2, scan.getAttributesMap().size()); Assert.assertTrue(Arrays.equals(Bytes.toBytes("value2"), scan.getAttributesMap().get("attribute2"))); Assert.assertEquals(1, scan.getAttributesMap().size()); Assert.assertNull(scan.getAttributesMap().get("attribute2")); Assert.assertEquals(1, scan.getAttributesMap().size()); Assert.assertNull(scan.getAttributesMap().get("attribute2")); Assert.assertTrue(scan.getAttributesMap().isEmpty()); Assert.assertNull(scan.getAttributesMap().get("attribute1"));
.getStopRow())); LOG.debug("First scan : " + scans.get(0) + " scanAttribute : " + scans.get(0) .getAttributesMap());
for (Map.Entry<String, byte[]> attr : scan.getAttributesMap().entrySet()) { setAttribute(attr.getKey(), attr.getValue());
}); scanBuilder.setTimeRange(toTimeRange(scan.getTimeRange())); Map<String, byte[]> attributes = scan.getAttributesMap(); if (!attributes.isEmpty()) { NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
}); scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(scan.getTimeRange())); Map<String, byte[]> attributes = scan.getAttributesMap(); if (!attributes.isEmpty()) { NameBytesPair.Builder attributeBuilder = NameBytesPair.newBuilder();
public GettingResultIterator(StatementContext context, Expression where) { this.context = context; this.where = where; this.gets = Lists.newArrayListWithExpectedSize(context.getScanRanges().getPointLookupCount()); Scan scan = context.getScan(); List<List<KeyRange>> ranges = context.getScanRanges().getRanges(); for (KeyRange range : ranges.get(0)) { Get get = new Get(range.getLowerRange()); for (Map.Entry<byte[], NavigableSet<byte[]>> entry : scan.getFamilyMap().entrySet()) { byte[] family = entry.getKey(); if (entry.getValue() != null) { for (byte[] q : entry.getValue()) { get.addColumn(family, q); } } else { get.addFamily(family); } } for (Map.Entry<String, byte[]> attr : scan.getAttributesMap().entrySet()) { get.setAttribute(attr.getKey(), attr.getValue()); } setGetAttribute(get); gets.add(get); } }
assertEquals(scan.getAttribute("test_key"), scanCopy.getAttribute("test_key")); assertEquals(scan.getAttributeSize(), scanCopy.getAttributeSize()); assertEquals(scan.getAttributesMap(), scanCopy.getAttributesMap()); assertEquals(scan.getAuthorizations().getLabels(), scanCopy.getAuthorizations().getLabels()); assertEquals(scan.getBatch(), scanCopy.getBatch());
for (Map.Entry<String, byte[]> attr : scan.getAttributesMap().entrySet()) { setAttribute(attr.getKey(), attr.getValue());
for (Map.Entry<String, byte[]> attr : scan.getAttributesMap().entrySet()) { setAttribute(attr.getKey(), attr.getValue());
for (Map.Entry<String, byte[]> attr : scan.getAttributesMap().entrySet()) { setAttribute(attr.getKey(), attr.getValue());