マッパーが複数の HBase テーブルから読み取る mapreduce ジョブがあります。私のクラスターでは問題なく動作します。MRUnit を使用して遡及的にいくつかの単体テストを作成しています。map() メソッドへの入力として使用するために、手動でインスタンス化された KeyValue オブジェクトのリストから Result オブジェクトを作成しようとしています。その後、map() メソッドでいくつかの列を読み込もうとすると、リストの最初の KeyValue オブジェクトだけが Result オブジェクトに保持されているようです。他の列は null です。以下では、「0」という名前の単一の列ファミリーがあります。
private MapDriver<ImmutableBytesWritable, Result, Text, Text> mapDriver;
private HopperHbaseMapper hopperHbaseMapper;
@Before
public void setUp() {
hopperHbaseMapper = new HopperHbaseMapper();
mapDriver = MapDriver.newMapDriver(hopperHbaseMapper);
}
@Test
public void testMapHbase() throws Exception {
String testKey = "123";
ImmutableBytesWritable key = new ImmutableBytesWritable(testKey.getBytes());
List<KeyValue> keyValues = new ArrayList<KeyValue>();
KeyValue keyValue1 = new KeyValue(testKey.getBytes(), "0".getBytes(), "first_name".getBytes(), "Joe".getBytes());
KeyValue keyValue2 = new KeyValue(testKey.getBytes(), "0".getBytes(), "last_name".getBytes(), "Blow".getBytes());
keyValues.add(keyValue1);
keyValues.add(keyValue2);
Result result = new Result(keyValues);
mapDriver.withInput(key, result);
mapDriver.withOutput(new Text(testKey), new Text(testKey + "\tJoe\tBlow"));
mapDriver.runTest();
}
Result オブジェクトを正しく作成していませんか? 前述のように、マッパーはクラスター上の実際の HBase データに対して正常に動作するため、テスト セットアップに問題があると思います。