Package org.apache.hadoop.hbase.mapreduce.IndexBuilder

Examples of org.apache.hadoop.hbase.mapreduce.IndexBuilder.Map


    IndexBuilder.configureJob(configuration, args);
    assertEquals("tableName", configuration.get("index.tablename"));
    assertEquals("tableName", configuration.get(TableInputFormat.INPUT_TABLE));
    assertEquals("column1,column2", configuration.get("index.fields"));

    Map map = new Map();
    ImmutableBytesWritable rowKey = new ImmutableBytesWritable(Bytes.toBytes("test"));
    Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Put>.Context ctx =
        mock(Context.class);
    when(ctx.getConfiguration()).thenReturn(configuration);
    doAnswer(new Answer<Void>() {

      @Override
      public Void answer(InvocationOnMock invocation) throws Throwable {
        ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArguments()[0];
        Put put = (Put) invocation.getArguments()[1];
        assertEquals("tableName-column1", Bytes.toString(writer.get()));
        assertEquals("test", Bytes.toString(put.getRow()));
        return null;
      }
    }).when(ctx).write(any(ImmutableBytesWritable.class), any(Put.class));
    Result result = mock(Result.class);
    when(result.getValue(Bytes.toBytes("columnFamily"), Bytes.toBytes("column1"))).thenReturn(
        Bytes.toBytes("test"));
    map.setup(ctx);
    map.map(rowKey, result, ctx);
  }
View Full Code Here


    IndexBuilder.configureJob(configuration, args);
    assertEquals("tableName", configuration.get("index.tablename"));
    assertEquals("tableName", configuration.get(TableInputFormat.INPUT_TABLE));
    assertEquals("column1,column2", configuration.get("index.fields"));

    Map map = new Map();
    ImmutableBytesWritable rowKey = new ImmutableBytesWritable(Bytes.toBytes("test"));
    Mapper<ImmutableBytesWritable, Result, ImmutableBytesWritable, Put>.Context ctx =
        mock(Context.class);
    when(ctx.getConfiguration()).thenReturn(configuration);
    doAnswer(new Answer<Void>() {

      @Override
      public Void answer(InvocationOnMock invocation) throws Throwable {
        ImmutableBytesWritable writer = (ImmutableBytesWritable) invocation.getArguments()[0];
        Put put = (Put) invocation.getArguments()[1];
        assertEquals("tableName-column1", Bytes.toString(writer.get()));
        assertEquals("test", Bytes.toString(put.getRow()));
        return null;
      }
    }).when(ctx).write(any(ImmutableBytesWritable.class), any(Put.class));
    Result result = mock(Result.class);
    when(result.getValue(Bytes.toBytes("columnFamily"), Bytes.toBytes("column1"))).thenReturn(
        Bytes.toBytes("test"));
    map.setup(ctx);
    map.map(rowKey, result, ctx);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.mapreduce.IndexBuilder.Map

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.