From 6f3da9ecd101498915f0f7d80544937e5710ea9c Mon Sep 17 00:00:00 2001 From: Jan Hentschel Date: Mon, 6 Jan 2020 00:32:28 +0100 Subject: [PATCH 1/2] HBASE-23646 Resolved remaining Checkstyle violations in tests of hbase-rest --- .../hbase/checkstyle-suppressions.xml | 2 + .../hbase/rest/HBaseRESTTestingUtility.java | 15 +- .../hbase/rest/PerformanceEvaluation.java | 58 +-- .../hadoop/hbase/rest/RowResourceBase.java | 101 +++-- .../hbase/rest/TestMultiRowResource.java | 31 +- .../hbase/rest/TestScannersWithFilters.java | 415 +++++++++--------- 6 files changed, 307 insertions(+), 315 deletions(-) diff --git a/hbase-checkstyle/src/main/resources/hbase/checkstyle-suppressions.xml b/hbase-checkstyle/src/main/resources/hbase/checkstyle-suppressions.xml index 983bdae5d49e..0c08c6b3cabf 100644 --- a/hbase-checkstyle/src/main/resources/hbase/checkstyle-suppressions.xml +++ b/hbase-checkstyle/src/main/resources/hbase/checkstyle-suppressions.xml @@ -47,4 +47,6 @@ + + diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/HBaseRESTTestingUtility.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/HBaseRESTTestingUtility.java index ffa183560cc0..00b28c7534b4 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/HBaseRESTTestingUtility.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/HBaseRESTTestingUtility.java @@ -25,7 +25,6 @@ import org.slf4j.LoggerFactory; public class HBaseRESTTestingUtility { - private static final Logger LOG = LoggerFactory.getLogger(HBaseRESTTestingUtility.class); private RESTServer server; @@ -52,12 +51,14 @@ public void startServletContainer(Configuration conf) throws Exception { } public void shutdownServletContainer() { - if (server != null) try { - server.stop(); - server = null; - RESTServlet.stop(); - } catch (Exception e) { - LOG.warn(StringUtils.stringifyException(e)); + if (server != null) { + try { + server.stop(); + server = null; + RESTServlet.stop(); + } catch (Exception e) { + LOG.warn(StringUtils.stringifyException(e)); + } } } } diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java index 94be9d9e0b26..dc6927f4f224 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java @@ -75,6 +75,7 @@ import org.apache.hadoop.hbase.util.Hash; import org.apache.hadoop.hbase.util.MurmurHash; import org.apache.hadoop.hbase.util.Pair; + import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.NullWritable; import org.apache.hadoop.io.Text; @@ -91,6 +92,7 @@ import org.apache.hadoop.util.LineReader; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -204,8 +206,7 @@ public PerformanceEvaluation(final Configuration c) { protected void addCommandDescriptor(Class cmdClass, String name, String description) { - CmdDescriptor cmdDescriptor = - new CmdDescriptor(cmdClass, name, description); + CmdDescriptor cmdDescriptor = new CmdDescriptor(cmdClass, name, description); commands.put(name, cmdDescriptor); } @@ -335,7 +336,7 @@ public List getSplits(JobContext job) throws IOException { // generate splits List splitList = new ArrayList<>(); - for (FileStatus file: listStatus(job)) { + for (FileStatus file : listStatus(job)) { if (file.isDirectory()) { continue; } @@ -344,10 +345,10 @@ public List getSplits(JobContext job) throws IOException { FSDataInputStream fileIn = fs.open(path); LineReader in = new LineReader(fileIn, job.getConfiguration()); int lineLen; - while(true) { + while (true) { Text lineText = new Text(); lineLen = in.readLine(lineText); - if(lineLen <= 0) { + if (lineLen <= 0) { break; } Matcher m = LINE_PATTERN.matcher(lineText.toString()); @@ -406,7 +407,7 @@ public void initialize(InputSplit split, TaskAttemptContext context) { @Override public boolean nextKeyValue() { - if(readOver) { + if (readOver) { return false; } @@ -429,7 +430,7 @@ public PeInputSplit getCurrentValue() { @Override public float getProgress() { - if(readOver) { + if (readOver) { return 1.0f; } else { return 0.0f; @@ -562,7 +563,7 @@ protected byte[][] getSplits() { int numSplitPoints = presplitRegions - 1; byte[][] splits = new byte[numSplitPoints][]; int jump = this.R / this.presplitRegions; - for (int i=0; i < numSplitPoints; i++) { + for (int i = 0; i < numSplitPoints; i++) { int rowkey = jump * (1 + i); splits[i] = format(rowkey); } @@ -635,11 +636,11 @@ public void run() { }; threads.add(t); } - for (Thread t: threads) { + for (Thread t : threads) { t.start(); } - for (Thread t: threads) { - while(t.isAlive()) { + for (Thread t : threads) { + while (t.isAlive()) { try { t.join(); } catch (InterruptedException e) { @@ -708,33 +709,26 @@ private Path writeInputFile(final Configuration c) throws IOException { FileSystem fs = FileSystem.get(c); fs.mkdirs(inputDir); Path inputFile = new Path(inputDir, "input.txt"); - PrintStream out = new PrintStream(fs.create(inputFile)); // Make input random. - Map m = new TreeMap<>(); - Hash h = MurmurHash.getInstance(); - int perClientRows = (this.R / this.N); - try { + try (PrintStream out = new PrintStream(fs.create(inputFile))) { + Map m = new TreeMap<>(); + Hash h = MurmurHash.getInstance(); + int perClientRows = (this.R / this.N); for (int i = 0; i < 10; i++) { for (int j = 0; j < N; j++) { - String s = "tableName=" + this.tableName + - ", startRow=" + ((j * perClientRows) + (i * (perClientRows/10))) + - ", perClientRunRows=" + (perClientRows / 10) + - ", totalRows=" + this.R + - ", clients=" + this.N + - ", flushCommits=" + this.flushCommits + - ", writeToWAL=" + this.writeToWAL + - ", useTags=" + this.useTags + - ", noOfTags=" + this.noOfTags; + String s = "tableName=" + this.tableName + ", startRow=" + ((j * perClientRows) + (i * ( + perClientRows / 10))) + ", perClientRunRows=" + (perClientRows / 10) + ", totalRows=" + + this.R + ", clients=" + this.N + ", flushCommits=" + this.flushCommits + + ", writeToWAL=" + this.writeToWAL + ", useTags=" + this.useTags + ", noOfTags=" + + this.noOfTags; byte[] b = Bytes.toBytes(s); int hash = h.hash(new ByteArrayHashKey(b, 0, b.length), -1); m.put(hash, s); } } - for (Map.Entry e: m.entrySet()) { + for (Map.Entry e : m.entrySet()) { out.println(e.getValue()); } - } finally { - out.close(); } return inputDir; } @@ -1198,15 +1192,9 @@ static class FilteredScanTest extends TableTest { void testRow(int i) throws IOException { byte[] value = generateValue(this.rand); Scan scan = constructScan(value); - ResultScanner scanner = null; - try { - scanner = this.table.getScanner(scan); + try (ResultScanner scanner = this.table.getScanner(scan)) { while (scanner.next() != null) { } - } finally { - if (scanner != null) { - scanner.close(); - } } } diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java index 5ab45f87995c..b32acfb40704 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/RowResourceBase.java @@ -19,6 +19,9 @@ import static org.junit.Assert.assertEquals; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.StringWriter; @@ -31,8 +34,6 @@ import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HColumnDescriptor; @@ -52,7 +53,6 @@ import org.junit.BeforeClass; public class RowResourceBase { - protected static final String TABLE = "TestRowResource"; protected static final TableName TABLE_NAME = TableName.valueOf(TABLE); @@ -83,7 +83,6 @@ public class RowResourceBase { protected static Configuration conf; protected static ObjectMapper jsonMapper; - @BeforeClass public static void setUpBeforeClass() throws Exception { conf = TEST_UTIL.getConfiguration(); @@ -178,8 +177,8 @@ protected static void checkValueXML(String table, String row, String column, assertEquals(Bytes.toString(cell.getValue()), value); } - protected static void checkIncrementValueXML(String table, String row, String column, - long value) throws IOException, JAXBException { + protected static void checkIncrementValueXML(String table, String row, String column, long value) + throws IOException, JAXBException { Response response1 = getValueXML(table, row, column); assertEquals(200, response1.getCode()); assertEquals(Constants.MIMETYPE_XML, response1.getHeader("content-type")); @@ -261,16 +260,17 @@ protected static void checkIncrementValuePB(String table, String row, String col assertEquals(Bytes.toLong(cell.getValue()), value); } - protected static Response checkAndPutValuePB(String url, String table, - String row, String column, String valueToCheck, String valueToPut, HashMap otherCells) - throws IOException { + protected static Response checkAndPutValuePB(String url, String table, String row, String column, + String valueToCheck, String valueToPut, HashMap otherCells) + throws IOException { RowModel rowModel = new RowModel(row); rowModel.addCell(new CellModel(Bytes.toBytes(column), Bytes.toBytes(valueToPut))); - if(otherCells != null) { - for (Map.Entry entry :otherCells.entrySet()) { - rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), Bytes.toBytes(entry.getValue()))); + if (otherCells != null) { + for (Map.Entry entry : otherCells.entrySet()) { + rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), + Bytes.toBytes(entry.getValue()))); } } @@ -290,8 +290,10 @@ protected static Response checkAndPutValuePB(String table, String row, String column, String valueToCheck, String valueToPut) throws IOException { return checkAndPutValuePB(table,row,column,valueToCheck,valueToPut,null); } - protected static Response checkAndPutValuePB(String table, String row, - String column, String valueToCheck, String valueToPut, HashMap otherCells) throws IOException { + + protected static Response checkAndPutValuePB(String table, String row, String column, + String valueToCheck, String valueToPut, HashMap otherCells) + throws IOException { StringBuilder path = new StringBuilder(); path.append('/'); path.append(table); @@ -302,16 +304,17 @@ protected static Response checkAndPutValuePB(String table, String row, valueToCheck, valueToPut, otherCells); } - protected static Response checkAndPutValueXML(String url, String table, - String row, String column, String valueToCheck, String valueToPut, HashMap otherCells) - throws IOException, JAXBException { + protected static Response checkAndPutValueXML(String url, String table, String row, String column, + String valueToCheck, String valueToPut, HashMap otherCells) + throws IOException, JAXBException { RowModel rowModel = new RowModel(row); rowModel.addCell(new CellModel(Bytes.toBytes(column), Bytes.toBytes(valueToPut))); - if(otherCells != null) { - for (Map.Entry entry :otherCells.entrySet()) { - rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), Bytes.toBytes(entry.getValue()))); + if (otherCells != null) { + for (Map.Entry entry : otherCells.entrySet()) { + rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), + Bytes.toBytes(entry.getValue()))); } } @@ -328,9 +331,8 @@ protected static Response checkAndPutValueXML(String url, String table, return response; } - protected static Response checkAndPutValueXML(String table, String row, - String column, String valueToCheck, String valueToPut) - throws IOException, JAXBException { + protected static Response checkAndPutValueXML(String table, String row, String column, + String valueToCheck, String valueToPut) throws IOException, JAXBException { return checkAndPutValueXML(table,row,column,valueToCheck,valueToPut, null); } @@ -352,9 +354,10 @@ protected static Response checkAndDeleteXML(String url, String table, throws IOException, JAXBException { RowModel rowModel = new RowModel(row); - if(cellsToDelete != null) { - for (Map.Entry entry :cellsToDelete.entrySet()) { - rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), Bytes.toBytes(entry.getValue()))); + if (cellsToDelete != null) { + for (Map.Entry entry : cellsToDelete.entrySet()) { + rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), + Bytes.toBytes(entry.getValue()))); } } // Add this at the end @@ -374,8 +377,10 @@ protected static Response checkAndDeleteXML(String table, String row, String column, String valueToCheck) throws IOException, JAXBException { return checkAndDeleteXML(table, row, column, valueToCheck, null); } + protected static Response checkAndDeleteXML(String table, String row, - String column, String valueToCheck, HashMap cellsToDelete) throws IOException, JAXBException { + String column, String valueToCheck, HashMap cellsToDelete) + throws IOException, JAXBException { StringBuilder path = new StringBuilder(); path.append('/'); path.append(table); @@ -386,12 +391,13 @@ protected static Response checkAndDeleteXML(String table, String row, } protected static Response checkAndDeleteJson(String table, String row, - String column, String valueToCheck) throws IOException, JAXBException { + String column, String valueToCheck) throws IOException { return checkAndDeleteJson(table, row, column, valueToCheck, null); } protected static Response checkAndDeleteJson(String table, String row, - String column, String valueToCheck, HashMap cellsToDelete) throws IOException, JAXBException { + String column, String valueToCheck, HashMap cellsToDelete) + throws IOException { StringBuilder path = new StringBuilder(); path.append('/'); path.append(table); @@ -403,12 +409,13 @@ protected static Response checkAndDeleteJson(String table, String row, protected static Response checkAndDeleteJson(String url, String table, String row, String column, String valueToCheck, HashMap cellsToDelete) - throws IOException, JAXBException { + throws IOException { RowModel rowModel = new RowModel(row); - if(cellsToDelete != null) { - for (Map.Entry entry :cellsToDelete.entrySet()) { - rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), Bytes.toBytes(entry.getValue()))); + if (cellsToDelete != null) { + for (Map.Entry entry : cellsToDelete.entrySet()) { + rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), + Bytes.toBytes(entry.getValue()))); } } // Add this at the end @@ -423,9 +430,8 @@ protected static Response checkAndDeleteJson(String url, String table, return response; } - protected static Response checkAndDeletePB(String table, String row, - String column, String value) throws IOException { - + protected static Response checkAndDeletePB(String table, String row, String column, String value) + throws IOException { return checkAndDeletePB(table, row, column, value, null); } @@ -444,9 +450,10 @@ protected static Response checkAndDeleteValuePB(String url, String table, throws IOException { RowModel rowModel = new RowModel(row); - if(cellsToDelete != null) { - for (Map.Entry entry :cellsToDelete.entrySet()) { - rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), Bytes.toBytes(entry.getValue()))); + if (cellsToDelete != null) { + for (Map.Entry entry : cellsToDelete.entrySet()) { + rowModel.addCell(new CellModel(Bytes.toBytes(entry.getKey()), + Bytes.toBytes(entry.getValue()))); } } // Add this at the end @@ -535,12 +542,12 @@ protected static Response getValueJson(String table, String row, } protected static void checkValueJSON(String table, String row, String column, - String value) throws IOException, JAXBException { + String value) throws IOException { Response response = getValueJson(table, row, column); assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); - ObjectMapper mapper = new JacksonJaxbJsonProvider() - .locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE); + ObjectMapper mapper = new JacksonJaxbJsonProvider().locateMapper(CellSetModel.class, + MediaType.APPLICATION_JSON_TYPE); CellSetModel cellSet = mapper.readValue(response.getBody(), CellSetModel.class); RowModel rowModel = cellSet.getRows().get(0); CellModel cell = rowModel.getCells().get(0); @@ -549,7 +556,7 @@ protected static void checkValueJSON(String table, String row, String column, } protected static void checkIncrementValueJSON(String table, String row, String column, - long value) throws IOException, JAXBException { + long value) throws IOException { Response response = getValueJson(table, row, column); assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); @@ -563,7 +570,7 @@ protected static void checkIncrementValueJSON(String table, String row, String c } protected static Response putValueJson(String table, String row, String column, - String value) throws IOException, JAXBException { + String value) throws IOException { StringBuilder path = new StringBuilder(); path.append('/'); path.append(table); @@ -575,7 +582,7 @@ protected static Response putValueJson(String table, String row, String column, } protected static Response putValueJson(String url, String table, String row, String column, - String value) throws IOException, JAXBException { + String value) throws IOException { RowModel rowModel = new RowModel(row); rowModel.addCell(new CellModel(Bytes.toBytes(column), Bytes.toBytes(value))); @@ -600,7 +607,7 @@ protected static Response appendValueXML(String table, String row, String column } protected static Response appendValuePB(String table, String row, String column, - String value) throws IOException, JAXBException { + String value) throws IOException { StringBuilder path = new StringBuilder(); path.append('/'); path.append(table); @@ -633,7 +640,7 @@ protected static Response incrementValueXML(String table, String row, String col } protected static Response incrementValuePB(String table, String row, String column, - String value) throws IOException, JAXBException { + String value) throws IOException { StringBuilder path = new StringBuilder(); path.append('/'); path.append(table); diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java index 5d8602fe7a10..27d3f037a4e7 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestMultiRowResource.java @@ -21,13 +21,14 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; + import java.io.IOException; import java.util.Collection; import javax.ws.rs.core.MediaType; import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; + import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseCommonTestingUtility; @@ -45,8 +46,10 @@ import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RestTests; import org.apache.hadoop.hbase.util.Bytes; + import org.apache.http.Header; import org.apache.http.message.BasicHeader; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -58,7 +61,6 @@ @Category({RestTests.class, MediumTests.class}) @RunWith(Parameterized.class) public class TestMultiRowResource { - @ClassRule public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestMultiRowResource.class); @@ -73,7 +75,6 @@ public class TestMultiRowResource { private static final String ROW_2 = "testrow6"; private static final String VALUE_2 = "testvalue6"; - private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static final HBaseRESTTestingUtility REST_TEST_UTIL = new HBaseRESTTestingUtility(); @@ -95,7 +96,6 @@ public TestMultiRowResource(Boolean csrf) { csrfEnabled = csrf; } - @BeforeClass public static void setUpBeforeClass() throws Exception { conf = TEST_UTIL.getConfiguration(); @@ -129,13 +129,11 @@ public static void tearDownAfterClass() throws Exception { TEST_UTIL.shutdownMiniCluster(); } - @Test - public void testMultiCellGetJSON() throws IOException, JAXBException { + public void testMultiCellGetJSON() throws IOException { String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1; String row_6_url = "/" + TABLE + "/" + ROW_2 + "/" + COLUMN_2; - StringBuilder path = new StringBuilder(); path.append("/"); path.append(TABLE); @@ -152,22 +150,19 @@ public void testMultiCellGetJSON() throws IOException, JAXBException { client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1), extraHdr); client.post(row_6_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_2), extraHdr); - Response response = client.get(path.toString(), Constants.MIMETYPE_JSON); assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_JSON, response.getHeader("content-type")); client.delete(row_5_url, extraHdr); client.delete(row_6_url, extraHdr); - } @Test - public void testMultiCellGetXML() throws IOException, JAXBException { + public void testMultiCellGetXML() throws IOException { String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1; String row_6_url = "/" + TABLE + "/" + ROW_2 + "/" + COLUMN_2; - StringBuilder path = new StringBuilder(); path.append("/"); path.append(TABLE); @@ -179,18 +174,16 @@ public void testMultiCellGetXML() throws IOException, JAXBException { client.post(row_5_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_1), extraHdr); client.post(row_6_url, Constants.MIMETYPE_BINARY, Bytes.toBytes(VALUE_2), extraHdr); - Response response = client.get(path.toString(), Constants.MIMETYPE_XML); assertEquals(200, response.getCode()); assertEquals(Constants.MIMETYPE_XML, response.getHeader("content-type")); client.delete(row_5_url, extraHdr); client.delete(row_6_url, extraHdr); - } @Test - public void testMultiCellGetWithColsJSON() throws IOException, JAXBException { + public void testMultiCellGetWithColsJSON() throws IOException { String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1; String row_6_url = "/" + TABLE + "/" + ROW_2 + "/" + COLUMN_2; @@ -209,8 +202,8 @@ public void testMultiCellGetWithColsJSON() throws IOException, JAXBException { Response response = client.get(path.toString(), Constants.MIMETYPE_JSON); assertEquals(200, response.getCode()); - ObjectMapper mapper = - new JacksonJaxbJsonProvider().locateMapper(CellSetModel.class, MediaType.APPLICATION_JSON_TYPE); + ObjectMapper mapper = new JacksonJaxbJsonProvider().locateMapper(CellSetModel.class, + MediaType.APPLICATION_JSON_TYPE); CellSetModel cellSet = mapper.readValue(response.getBody(), CellSetModel.class); assertEquals(2, cellSet.getRows().size()); assertEquals(ROW_1, Bytes.toString(cellSet.getRows().get(0).getKey())); @@ -220,11 +213,10 @@ public void testMultiCellGetWithColsJSON() throws IOException, JAXBException { client.delete(row_5_url, extraHdr); client.delete(row_6_url, extraHdr); - } @Test - public void testMultiCellGetJSONNotFound() throws IOException, JAXBException { + public void testMultiCellGetJSONNotFound() throws IOException { String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1; StringBuilder path = new StringBuilder(); @@ -248,7 +240,7 @@ public void testMultiCellGetJSONNotFound() throws IOException, JAXBException { } @Test - public void testMultiCellGetWithColsInQueryPathJSON() throws IOException, JAXBException { + public void testMultiCellGetWithColsInQueryPathJSON() throws IOException { String row_5_url = "/" + TABLE + "/" + ROW_1 + "/" + COLUMN_1; String row_6_url = "/" + TABLE + "/" + ROW_2 + "/" + COLUMN_2; @@ -280,4 +272,3 @@ public void testMultiCellGetWithColsInQueryPathJSON() throws IOException, JAXBEx client.delete(row_6_url, extraHdr); } } - diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java index bf7b60c5d9a0..7d548886b984 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/TestScannersWithFilters.java @@ -79,7 +79,6 @@ @Category({RestTests.class, MediumTests.class}) public class TestScannersWithFilters { - @ClassRule public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestScannersWithFilters.class); @@ -88,31 +87,31 @@ public class TestScannersWithFilters { private static final TableName TABLE = TableName.valueOf("TestScannersWithFilters"); - private static final byte [][] ROWS_ONE = { + private static final byte[][] ROWS_ONE = { Bytes.toBytes("testRowOne-0"), Bytes.toBytes("testRowOne-1"), Bytes.toBytes("testRowOne-2"), Bytes.toBytes("testRowOne-3") }; - private static final byte [][] ROWS_TWO = { + private static final byte[][] ROWS_TWO = { Bytes.toBytes("testRowTwo-0"), Bytes.toBytes("testRowTwo-1"), Bytes.toBytes("testRowTwo-2"), Bytes.toBytes("testRowTwo-3") }; - private static final byte [][] FAMILIES = { + private static final byte[][] FAMILIES = { Bytes.toBytes("testFamilyOne"), Bytes.toBytes("testFamilyTwo") }; - private static final byte [][] QUALIFIERS_ONE = { + private static final byte[][] QUALIFIERS_ONE = { Bytes.toBytes("testQualifierOne-0"), Bytes.toBytes("testQualifierOne-1"), Bytes.toBytes("testQualifierOne-2"), Bytes.toBytes("testQualifierOne-3") }; - private static final byte [][] QUALIFIERS_TWO = { + private static final byte[][] QUALIFIERS_TWO = { Bytes.toBytes("testQualifierTwo-0"), Bytes.toBytes("testQualifierTwo-1"), Bytes.toBytes("testQualifierTwo-2"), Bytes.toBytes("testQualifierTwo-3") }; - private static final byte [][] VALUES = { + private static final byte[][] VALUES = { Bytes.toBytes("testValueOne"), Bytes.toBytes("testValueTwo") }; @@ -147,49 +146,49 @@ public static void setUpBeforeClass() throws Exception { admin.createTable(htd); Table table = TEST_UTIL.getConnection().getTable(TABLE); // Insert first half - for(byte [] ROW : ROWS_ONE) { + for (byte[] ROW : ROWS_ONE) { Put p = new Put(ROW); p.setDurability(Durability.SKIP_WAL); - for(byte [] QUALIFIER : QUALIFIERS_ONE) { + for (byte[] QUALIFIER : QUALIFIERS_ONE) { p.addColumn(FAMILIES[0], QUALIFIER, VALUES[0]); } table.put(p); } - for(byte [] ROW : ROWS_TWO) { + for (byte[] ROW : ROWS_TWO) { Put p = new Put(ROW); p.setDurability(Durability.SKIP_WAL); - for(byte [] QUALIFIER : QUALIFIERS_TWO) { + for (byte[] QUALIFIER : QUALIFIERS_TWO) { p.addColumn(FAMILIES[1], QUALIFIER, VALUES[1]); } table.put(p); } // Insert second half (reverse families) - for(byte [] ROW : ROWS_ONE) { + for (byte[] ROW : ROWS_ONE) { Put p = new Put(ROW); p.setDurability(Durability.SKIP_WAL); - for(byte [] QUALIFIER : QUALIFIERS_ONE) { + for (byte[] QUALIFIER : QUALIFIERS_ONE) { p.addColumn(FAMILIES[1], QUALIFIER, VALUES[0]); } table.put(p); } - for(byte [] ROW : ROWS_TWO) { + for (byte[] ROW : ROWS_TWO) { Put p = new Put(ROW); p.setDurability(Durability.SKIP_WAL); - for(byte [] QUALIFIER : QUALIFIERS_TWO) { + for (byte[] QUALIFIER : QUALIFIERS_TWO) { p.addColumn(FAMILIES[0], QUALIFIER, VALUES[1]); } table.put(p); } // Delete the second qualifier from all rows and families - for(byte [] ROW : ROWS_ONE) { + for (byte[] ROW : ROWS_ONE) { Delete d = new Delete(ROW); d.addColumns(FAMILIES[0], QUALIFIERS_ONE[1]); d.addColumns(FAMILIES[1], QUALIFIERS_ONE[1]); table.delete(d); } - for(byte [] ROW : ROWS_TWO) { + for (byte[] ROW : ROWS_TWO) { Delete d = new Delete(ROW); d.addColumns(FAMILIES[0], QUALIFIERS_TWO[1]); d.addColumns(FAMILIES[1], QUALIFIERS_TWO[1]); @@ -198,13 +197,13 @@ public static void setUpBeforeClass() throws Exception { colsPerRow -= 2; // Delete the second rows from both groups, one column at a time - for(byte [] QUALIFIER : QUALIFIERS_ONE) { + for (byte[] QUALIFIER : QUALIFIERS_ONE) { Delete d = new Delete(ROWS_ONE[1]); d.addColumns(FAMILIES[0], QUALIFIER); d.addColumns(FAMILIES[1], QUALIFIER); table.delete(d); } - for(byte [] QUALIFIER : QUALIFIERS_TWO) { + for (byte[] QUALIFIER : QUALIFIERS_TWO) { Delete d = new Delete(ROWS_TWO[1]); d.addColumns(FAMILIES[0], QUALIFIER); d.addColumns(FAMILIES[1], QUALIFIER); @@ -243,9 +242,9 @@ private static void verifyScan(Scan s, long expectedRows, long expectedKeys) unmarshaller.unmarshal(new ByteArrayInputStream(response.getBody())); int rows = cells.getRows().size(); - assertTrue("Scanned too many rows! Only expected " + expectedRows + - " total but scanned " + rows, expectedRows == rows); - for (RowModel row: cells.getRows()) { + assertEquals("Scanned too many rows! Only expected " + expectedRows + + " total but scanned " + rows, expectedRows, rows); + for (RowModel row : cells.getRows()) { int count = row.getCells().size(); assertEquals("Expected " + expectedKeys + " keys per row but " + "returned " + count, expectedKeys, count); @@ -256,8 +255,7 @@ private static void verifyScan(Scan s, long expectedRows, long expectedKeys) assertEquals(200, response.getCode()); } - private static void verifyScanFull(Scan s, KeyValue [] kvs) - throws Exception { + private static void verifyScanFull(Scan s, KeyValue [] kvs) throws Exception { ScannerModel model = ScannerModel.fromScan(s); model.setBatch(Integer.MAX_VALUE); // fetch it all at once StringWriter writer = new StringWriter(); @@ -286,10 +284,16 @@ private static void verifyScanFull(Scan s, KeyValue [] kvs) Iterator i = cellSet.getRows().iterator(); for (boolean done = true; done; row++) { done = i.hasNext(); - if (!done) break; + if (!done) { + break; + } + RowModel rowModel = i.next(); List cells = rowModel.getCells(); - if (cells.isEmpty()) break; + if (cells.isEmpty()) { + break; + } + assertTrue("Scanned too many keys! Only expected " + kvs.length + " total but already scanned " + (cells.size() + idx), kvs.length >= idx + cells.size()); @@ -339,10 +343,16 @@ private static void verifyScanNoEarlyOut(Scan s, long expectedRows, int j = 0; for (boolean done = true; done; j++) { done = i.hasNext(); - if (!done) break; + if (!done) { + break; + } + RowModel rowModel = i.next(); List cells = rowModel.getCells(); - if (cells.isEmpty()) break; + if (cells.isEmpty()) { + break; + } + assertTrue("Scanned too many rows! Only expected " + expectedRows + " total but already scanned " + (j+1), expectedRows > j); assertEquals("Expected " + expectedKeys + " keys per row but " + @@ -517,8 +527,7 @@ public void testQualifierFilter() throws Exception { s.setFilter(f); verifyScanNoEarlyOut(s, expectedRows, expectedKeys); - // Match keys less than or equal - // Expect four keys (two from each family) in half the rows + // Match keys less than or equal. Expect four keys (two from each family) in half the rows expectedRows = numRows / 2; expectedKeys = 4; f = new QualifierFilter(CompareOperator.LESS_OR_EQUAL, @@ -527,8 +536,7 @@ public void testQualifierFilter() throws Exception { s.setFilter(f); verifyScanNoEarlyOut(s, expectedRows, expectedKeys); - // Match keys not equal - // Expect four keys (two from each family) + // Match keys not equal. Expect four keys (two from each family) // Only look in first group of rows expectedRows = numRows / 2; expectedKeys = 4; @@ -538,8 +546,7 @@ public void testQualifierFilter() throws Exception { s.setFilter(f); verifyScanNoEarlyOut(s, expectedRows, expectedKeys); - // Match keys greater or equal - // Expect four keys (two from each family) + // Match keys greater or equal. Expect four keys (two from each family) // Only look in first group of rows expectedRows = numRows / 2; expectedKeys = 4; @@ -549,8 +556,7 @@ public void testQualifierFilter() throws Exception { s.setFilter(f); verifyScanNoEarlyOut(s, expectedRows, expectedKeys); - // Match keys greater - // Expect two keys (one from each family) + // Match keys greater. Expect two keys (one from each family) // Only look in first group of rows expectedRows = numRows / 2; expectedKeys = 2; @@ -560,57 +566,54 @@ public void testQualifierFilter() throws Exception { s.setFilter(f); verifyScanNoEarlyOut(s, expectedRows, expectedKeys); - // Match keys not equal to - // Look across rows and fully validate the keys and ordering - // Expect varied numbers of keys, 4 per row in group one, 6 per row in - // group two + // Match keys not equal to. Look across rows and fully validate the keys and ordering + // Expect varied numbers of keys, 4 per row in group one, 6 per row in group two f = new QualifierFilter(CompareOperator.NOT_EQUAL, new BinaryComparator(QUALIFIERS_ONE[2])); s = new Scan(); s.setFilter(f); KeyValue [] kvs = { - // testRowOne-0 - new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), - new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), - // testRowOne-2 - new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), - // testRowOne-3 - new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), - // testRowTwo-0 - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), - // testRowTwo-2 - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), - // testRowTwo-3 - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowOne-0 + new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), + new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), + // testRowOne-2 + new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), + // testRowOne-3 + new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), + // testRowTwo-0 + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-2 + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-3 + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), }; verifyScanFull(s, kvs); - // Test across rows and groups with a regex - // Filter out "test*-2" + // Test across rows and groups with a regex. Filter out "test*-2" // Expect 4 keys per row across both groups f = new QualifierFilter(CompareOperator.NOT_EQUAL, new RegexStringComparator("test.+-2")); @@ -618,36 +621,36 @@ public void testQualifierFilter() throws Exception { s.setFilter(f); kvs = new KeyValue [] { - // testRowOne-0 - new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), - new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), - // testRowOne-2 - new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), - // testRowOne-3 - new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), - // testRowTwo-0 - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), - // testRowTwo-2 - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), - // testRowTwo-3 - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowOne-0 + new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), + new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), + // testRowOne-2 + new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), + // testRowOne-3 + new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), + // testRowTwo-0 + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-2 + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-3 + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), }; verifyScanFull(s, kvs); } @@ -731,41 +734,41 @@ public void testRowFilter() throws Exception { s.setFilter(f); KeyValue [] kvs = { - // testRowOne-0 - new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[2], VALUES[0]), - new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), - new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[2], VALUES[0]), - new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), - // testRowOne-3 - new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[2], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[2], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), - // testRowTwo-0 - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), - // testRowTwo-2 - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), - // testRowTwo-3 - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowOne-0 + new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[2], VALUES[0]), + new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), + new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[2], VALUES[0]), + new KeyValue(ROWS_ONE[0], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), + // testRowOne-3 + new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[2], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[2], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), + // testRowTwo-0 + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-2 + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-3 + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), }; verifyScanFull(s, kvs); @@ -778,20 +781,20 @@ public void testRowFilter() throws Exception { s.setFilter(f); kvs = new KeyValue [] { - // testRowOne-2 - new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[2], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[2], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), - // testRowTwo-2 - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]) + // testRowOne-2 + new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[2], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[3], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[2], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[1], QUALIFIERS_ONE[3], VALUES[0]), + // testRowTwo-2 + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]) }; verifyScanFull(s, kvs); } @@ -894,27 +897,27 @@ public void testValueFilter() throws Exception { s.setFilter(f); KeyValue [] kvs = { - // testRowTwo-0 - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), - // testRowTwo-2 - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), - // testRowTwo-3 - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-0 + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-2 + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-3 + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), }; verifyScanFull(s, kvs); } @@ -929,27 +932,27 @@ public void testSkipFilter() throws Exception { s.setFilter(f); KeyValue [] kvs = { - // testRowTwo-0 - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), - // testRowTwo-2 - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), - // testRowTwo-3 - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-0 + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[0], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-2 + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), + // testRowTwo-3 + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[3], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[2], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[1], QUALIFIERS_TWO[3], VALUES[1]), }; verifyScanFull(s, kvs); } @@ -971,7 +974,7 @@ public void testFilterList() throws Exception { s.addFamily(FAMILIES[0]); s.setFilter(f); KeyValue [] kvs = { - new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[2], VALUES[0]) + new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[2], VALUES[0]) }; verifyScanFull(s, kvs); @@ -996,12 +999,12 @@ public void testFirstKeyOnlyFilter() throws Exception { s.setFilter(new FirstKeyOnlyFilter()); // Expected KVs, the first KV from each of the remaining 6 rows KeyValue [] kvs = { - new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), - new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), - new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]) + new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), + new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), + new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]) }; verifyScanFull(s, kvs); } From a0c0821a51e2e65b5c42f2007b6122dfd884ead6 Mon Sep 17 00:00:00 2001 From: Jan Hentschel Date: Wed, 8 Jan 2020 10:48:07 +0100 Subject: [PATCH 2/2] HBASE-23646 Moved from String to StringBuilder --- .../hbase/rest/PerformanceEvaluation.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java index dc6927f4f224..a6f36fa01621 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/PerformanceEvaluation.java @@ -716,14 +716,20 @@ private Path writeInputFile(final Configuration c) throws IOException { int perClientRows = (this.R / this.N); for (int i = 0; i < 10; i++) { for (int j = 0; j < N; j++) { - String s = "tableName=" + this.tableName + ", startRow=" + ((j * perClientRows) + (i * ( - perClientRows / 10))) + ", perClientRunRows=" + (perClientRows / 10) + ", totalRows=" - + this.R + ", clients=" + this.N + ", flushCommits=" + this.flushCommits - + ", writeToWAL=" + this.writeToWAL + ", useTags=" + this.useTags + ", noOfTags=" - + this.noOfTags; - byte[] b = Bytes.toBytes(s); + StringBuilder s = new StringBuilder(); + s.append("tableName=").append(tableName); + s.append(", startRow=").append((j * perClientRows) + (i * (perClientRows / 10))); + s.append(", perClientRunRows=").append(perClientRows / 10); + s.append(", totalRows=").append(R); + s.append(", clients=").append(N); + s.append(", flushCommits=").append(flushCommits); + s.append(", writeToWAL=").append(writeToWAL); + s.append(", useTags=").append(useTags); + s.append(", noOfTags=").append(noOfTags); + + byte[] b = Bytes.toBytes(s.toString()); int hash = h.hash(new ByteArrayHashKey(b, 0, b.length), -1); - m.put(hash, s); + m.put(hash, s.toString()); } } for (Map.Entry e : m.entrySet()) {