@Test public void testAggregationNullResponse() throws Throwable { Table table = new HTable(util.getConfiguration(), TEST_TABLE); ColumnAggregationWithNullResponseProtos.SumRequest.Builder builder = ColumnAggregationWithNullResponseProtos.SumRequest .newBuilder(); builder.setFamily(ByteStringer.wrap(TEST_FAMILY)); if (TEST_QUALIFIER != null && TEST_QUALIFIER.length > 0) { builder.setQualifier(ByteStringer.wrap(TEST_QUALIFIER)); } Map<byte[], ColumnAggregationWithNullResponseProtos.SumResponse> results = table.batchCoprocessorService( ColumnAggregationServiceNullResponse.getDescriptor().findMethodByName("sum"), builder.build(), ROWS[0], ROWS[ROWS.length - 1], ColumnAggregationWithNullResponseProtos.SumResponse.getDefaultInstance()); int sumResult = 0; int expectedResult = 0; for (Map.Entry<byte[], ColumnAggregationWithNullResponseProtos.SumResponse> e : results.entrySet()) { LOG.info("Got value " + e.getValue().getSum() + " for region " + Bytes.toStringBinary(e.getKey())); sumResult += e.getValue().getSum(); } for (int i = 0; i < rowSeperator2; i++) { expectedResult += i; } assertEquals("Invalid result", expectedResult, sumResult); table.close(); }
@Test public void testAggregationNullResponse() throws Throwable { HTable table = new HTable(util.getConfiguration(), TEST_TABLE); ColumnAggregationWithNullResponseProtos.SumRequest.Builder builder = ColumnAggregationWithNullResponseProtos.SumRequest .newBuilder(); builder.setFamily(HBaseZeroCopyByteString.wrap(TEST_FAMILY)); if (TEST_QUALIFIER != null && TEST_QUALIFIER.length > 0) { builder.setQualifier(HBaseZeroCopyByteString.wrap(TEST_QUALIFIER)); } Map<byte[], ColumnAggregationWithNullResponseProtos.SumResponse> results = table.batchCoprocessorService( ColumnAggregationServiceNullResponse.getDescriptor().findMethodByName("sum"), builder.build(), ROWS[0], ROWS[ROWS.length - 1], ColumnAggregationWithNullResponseProtos.SumResponse.getDefaultInstance()); int sumResult = 0; int expectedResult = 0; for (Map.Entry<byte[], ColumnAggregationWithNullResponseProtos.SumResponse> e : results.entrySet()) { LOG.info("Got value " + e.getValue().getSum() + " for region " + Bytes.toStringBinary(e.getKey())); sumResult += e.getValue().getSum(); } for (int i = 0; i < rowSeperator2; i++) { expectedResult += i; } assertEquals("Invalid result", expectedResult, sumResult); table.close(); }