HBASE-10534 Rowkey in TsvImporterTextMapper initializing with wrong length(Rajesh)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1569837 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
rajeshbabu 2014-02-19 17:29:13 +00:00
parent 2e2162ccc8
commit 318888fd00
2 changed files with 11 additions and 4 deletions

View File

@ -349,6 +349,13 @@ public class ImportTsv extends Configured implements Tool {
private static final long serialVersionUID = 1L;
}
/**
* Return starting position and length of row key from the specified line bytes.
* @param lineBytes
* @param length
* @return Pair of row key offset and length.
* @throws BadTsvLineException
*/
public Pair<Integer, Integer> parseRowKey(byte[] lineBytes, int length)
throws BadTsvLineException {
int rkColumnIndex = 0;
@ -371,7 +378,7 @@ public class ImportTsv extends Configured implements Tool {
+ " are less than row key position.");
}
}
return new Pair<Integer, Integer>(startPos, endPos);
return new Pair<Integer, Integer>(startPos, endPos - startPos + 1);
}
}

View File

@ -220,7 +220,7 @@ public class TestImportTsvParser {
byte[] line = Bytes.toBytes("rowkey\tval_a\t1234");
Pair<Integer, Integer> rowKeyOffsets = parser.parseRowKey(line, line.length);
assertEquals(0, rowKeyOffsets.getFirst().intValue());
assertEquals(5, rowKeyOffsets.getSecond().intValue());
assertEquals(6, rowKeyOffsets.getSecond().intValue());
try {
line = Bytes.toBytes("\t\tval_a\t1234");
parser.parseRowKey(line, line.length);
@ -233,7 +233,7 @@ public class TestImportTsvParser {
line = Bytes.toBytes("val_a\trowkey\t1234");
rowKeyOffsets = parser.parseRowKey(line, line.length);
assertEquals(6, rowKeyOffsets.getFirst().intValue());
assertEquals(11, rowKeyOffsets.getSecond().intValue());
assertEquals(6, rowKeyOffsets.getSecond().intValue());
try {
line = Bytes.toBytes("val_a");
rowKeyOffsets = parser.parseRowKey(line, line.length);
@ -246,7 +246,7 @@ public class TestImportTsvParser {
line = Bytes.toBytes("val_a\t1234\trowkey");
rowKeyOffsets = parser.parseRowKey(line, line.length);
assertEquals(11, rowKeyOffsets.getFirst().intValue());
assertEquals(16, rowKeyOffsets.getSecond().intValue());
assertEquals(6, rowKeyOffsets.getSecond().intValue());
}
@Test