Skip to content

Commit 53be03d

Browse files
HBASE-25839 Bulk Import fails with java.io.IOException: Type mismatch in value from map
1 parent 4170fba commit 53be03d

File tree

1 file changed

+8
-4
lines changed
  • hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce

1 file changed

+8
-4
lines changed

hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/Import.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.DataInput;
2222
import java.io.DataInputStream;
2323
import java.io.DataOutput;
24+
import java.io.DataOutputStream;
2425
import java.io.IOException;
2526
import java.lang.reflect.InvocationTargetException;
2627
import java.lang.reflect.Method;
@@ -202,9 +203,12 @@ public CellWritableComparable(Cell kv) {
202203

203204
@Override
204205
public void write(DataOutput out) throws IOException {
205-
out.writeInt(PrivateCellUtil.estimatedSerializedSizeOfKey(kv));
206-
out.writeInt(0);
207-
PrivateCellUtil.writeFlatKey(kv, out);
206+
int keyLen = CellUtil.estimatedSerializedSizeOfKey(kv);
207+
int valueLen = 0; // We avoid writing value here. So just serialize as if an empty value.
208+
out.writeInt(keyLen + valueLen + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE);
209+
out.writeInt(keyLen);
210+
out.writeInt(valueLen);
211+
CellUtil.writeFlatKey(kv, (DataOutputStream) out);
208212
}
209213

210214
@Override
@@ -413,7 +417,7 @@ public void map(ImmutableBytesWritable row, Result value, Context context) throw
413417
// skip if we filtered it out
414418
if (kv == null) continue;
415419
Cell ret = convertKv(kv, cfRenameMap);
416-
context.write(new CellWritableComparable(ret), ret);
420+
context.write(new CellWritableComparable(ret), new MapReduceExtendedCell(ret));
417421
}
418422
}
419423
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)