Package org.apache.hadoop.hbase.mapreduce.WALPlayer

Examples of org.apache.hadoop.hbase.mapreduce.WALPlayer.HLogKeyValueMapper


   */
  @Test
  public void testHLogKeyValueMapper() throws Exception {
    Configuration configuration = new Configuration();
    configuration.set(WALPlayer.TABLES_KEY, "table");
    HLogKeyValueMapper mapper = new HLogKeyValueMapper();
    HLogKey key = mock(HLogKey.class);
    when(key.getTablename()).thenReturn(TableName.valueOf("table"));
    @SuppressWarnings("unchecked")
    Mapper<HLogKey, WALEdit, ImmutableBytesWritable, KeyValue>.Context context =
        mock(Context.class);
    when(context.getConfiguration()).thenReturn(configuration);

    WALEdit value = mock(WALEdit.class);
    ArrayList<Cell> values = new ArrayList<Cell>();
    KeyValue kv1 = mock(KeyValue.class);
    when(kv1.getFamily()).thenReturn(Bytes.toBytes("family"));
    when(kv1.getRow()).thenReturn(Bytes.toBytes("row"));
    values.add(kv1);
    when(value.getCells()).thenReturn(values);
    mapper.setup(context);

    doAnswer(new Answer<Void>() {

      @Override
      public Void answer(InvocationOnMock invocation) throws Throwable {
        ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArguments()[0];
        KeyValue key = (KeyValue) invocation.getArguments()[1];
        assertEquals("row", Bytes.toString(writer.get()));
        assertEquals("row", Bytes.toString(key.getRow()));
        return null;
      }
    }).when(context).write(any(ImmutableBytesWritable.class), any(KeyValue.class));

    mapper.map(key, value, context);

  }
View Full Code Here


   */
  @Test
  public void testHLogKeyValueMapper() throws Exception {
    Configuration configuration = new Configuration();
    configuration.set(WALPlayer.TABLES_KEY, "table");
    HLogKeyValueMapper mapper = new HLogKeyValueMapper();
    HLogKey key = mock(HLogKey.class);
    when(key.getTablename()).thenReturn(TableName.valueOf("table"));
    @SuppressWarnings("unchecked")
    Mapper<HLogKey, WALEdit, ImmutableBytesWritable, KeyValue>.Context context =
        mock(Context.class);
    when(context.getConfiguration()).thenReturn(configuration);

    WALEdit value = mock(WALEdit.class);
    ArrayList<Cell> values = new ArrayList<Cell>();
    KeyValue kv1 = mock(KeyValue.class);
    when(kv1.getFamily()).thenReturn(Bytes.toBytes("family"));
    when(kv1.getRow()).thenReturn(Bytes.toBytes("row"));
    values.add(kv1);
    when(value.getCells()).thenReturn(values);
    mapper.setup(context);

    doAnswer(new Answer<Void>() {

      @Override
      public Void answer(InvocationOnMock invocation) throws Throwable {
        ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArguments()[0];
        KeyValue key = (KeyValue) invocation.getArguments()[1];
        assertEquals("row", Bytes.toString(writer.get()));
        assertEquals("row", Bytes.toString(key.getRow()));
        return null;
      }
    }).when(context).write(any(ImmutableBytesWritable.class), any(KeyValue.class));

    mapper.map(key, value, context);

  }
View Full Code Here

   */
  @Test
  public void testHLogKeyValueMapper() throws Exception {
    Configuration configuration = new Configuration();
    configuration.set(WALPlayer.TABLES_KEY, "table");
    HLogKeyValueMapper mapper = new HLogKeyValueMapper();
    HLogKey key = mock(HLogKey.class);
    when(key.getTablename()).thenReturn(TableName.valueOf("table"));
    @SuppressWarnings("unchecked")
    Mapper<HLogKey, WALEdit, ImmutableBytesWritable, KeyValue>.Context context =
        mock(Context.class);
    when(context.getConfiguration()).thenReturn(configuration);

    WALEdit value = mock(WALEdit.class);
    ArrayList<KeyValue> values = new ArrayList<KeyValue>();
    KeyValue kv1 = mock(KeyValue.class);
    when(kv1.getFamily()).thenReturn(Bytes.toBytes("family"));
    when(kv1.getRow()).thenReturn(Bytes.toBytes("row"));
    values.add(kv1);
    when(value.getKeyValues()).thenReturn(values);
    mapper.setup(context);

    doAnswer(new Answer<Void>() {

      @Override
      public Void answer(InvocationOnMock invocation) throws Throwable {
        ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArguments()[0];
        KeyValue key = (KeyValue) invocation.getArguments()[1];
        assertEquals("row", Bytes.toString(writer.get()));
        assertEquals("row", Bytes.toString(key.getRow()));
        return null;
      }
    }).when(context).write(any(ImmutableBytesWritable.class), any(KeyValue.class));

    mapper.map(key, value, context);

  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.mapreduce.WALPlayer.HLogKeyValueMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.