use of org.apache.hadoop.hbase.mapreduce.ImportTsv.TsvParser in project hbase by apache.
the class TestImportTsvParser method testTsvParserBadTsvLineZeroColumn.
@Test(expected = BadTsvLineException.class)
public void testTsvParserBadTsvLineZeroColumn() throws BadTsvLineException {
TsvParser parser = new TsvParser("HBASE_ROW_KEY,col_a", "\t");
byte[] line = Bytes.toBytes("");
parser.parse(line, line.length);
}
use of org.apache.hadoop.hbase.mapreduce.ImportTsv.TsvParser in project hbase by apache.
the class TestImportTsvParser method testTsvParserWithTimestamp.
@Test
public void testTsvParserWithTimestamp() throws BadTsvLineException {
TsvParser parser = new TsvParser("HBASE_ROW_KEY,HBASE_TS_KEY,col_a,", "\t");
assertNull(parser.getFamily(0));
assertNull(parser.getQualifier(0));
assertNull(parser.getFamily(1));
assertNull(parser.getQualifier(1));
assertBytesEquals(Bytes.toBytes("col_a"), parser.getFamily(2));
assertBytesEquals(HConstants.EMPTY_BYTE_ARRAY, parser.getQualifier(2));
assertEquals(0, parser.getRowKeyColumnIndex());
assertEquals(1, parser.getTimestampKeyColumnIndex());
byte[] line = Bytes.toBytes("rowkey\t1234\tval_a");
ParsedLine parsed = parser.parse(line, line.length);
assertEquals(1234l, parsed.getTimestamp(-1));
checkParsing(parsed, Splitter.on("\t").split(Bytes.toString(line)));
}
Aggregations