Search in sources :

Example 11 with TsvParser

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);
}
Also used : TsvParser(org.apache.hadoop.hbase.mapreduce.ImportTsv.TsvParser) Test(org.junit.Test)

Example 12 with TsvParser

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)));
}
Also used : ParsedLine(org.apache.hadoop.hbase.mapreduce.ImportTsv.TsvParser.ParsedLine) TsvParser(org.apache.hadoop.hbase.mapreduce.ImportTsv.TsvParser) Test(org.junit.Test)

Aggregations

TsvParser (org.apache.hadoop.hbase.mapreduce.ImportTsv.TsvParser)12 Test (org.junit.Test)12 ParsedLine (org.apache.hadoop.hbase.mapreduce.ImportTsv.TsvParser.ParsedLine)5 BadTsvLineException (org.apache.hadoop.hbase.mapreduce.ImportTsv.TsvParser.BadTsvLineException)2