Skip to content

HBASE-25839 Bulk Import fails with java.io.IOException: Type mismatch in value from map #6547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,11 @@ public CellWritableComparable(Cell kv) {

@Override
public void write(DataOutput out) throws IOException {
out.writeInt(PrivateCellUtil.estimatedSerializedSizeOfKey(kv));
out.writeInt(0);
int keyLen = PrivateCellUtil.estimatedSerializedSizeOfKey(kv);
int valueLen = 0; // We avoid writing value here. So just serialize as if an empty value.
out.writeInt(keyLen + valueLen + KeyValue.KEYVALUE_INFRASTRUCTURE_SIZE);
out.writeInt(keyLen);
out.writeInt(valueLen);
PrivateCellUtil.writeFlatKey(kv, out);
}

Expand Down Expand Up @@ -413,7 +416,7 @@ public void map(ImmutableBytesWritable row, Result value, Context context) throw
// skip if we filtered it out
if (kv == null) continue;
Cell ret = convertKv(kv, cfRenameMap);
context.write(new CellWritableComparable(ret), ret);
context.write(new CellWritableComparable(ret), new MapReduceExtendedCell(ret));
}
Copy link
Contributor

@pankaj72981 pankaj72981 Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add UT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this issue.
Comment addressed, please verify.

}
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,47 @@ public void testWithFilter() throws Throwable {
importTable.close();
}

/**
* Create a simple table, run an Export Job on it, Import with bulk output and enable largeResult
*/
@Test
public void testBulkImportAndLargeResult() throws Throwable {
// Create simple table to export
TableDescriptor desc = TableDescriptorBuilder
.newBuilder(TableName.valueOf(name.getMethodName()))
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILYA).setMaxVersions(5).build())
.build();
UTIL.getAdmin().createTable(desc);
Table exportTable = UTIL.getConnection().getTable(desc.getTableName());

Put p1 = new Put(ROW1);
p1.addColumn(FAMILYA, QUAL, now, QUAL);

// Having another row would actually test the filter.
Put p2 = new Put(ROW2);
p2.addColumn(FAMILYA, QUAL, now, QUAL);

exportTable.put(Arrays.asList(p1, p2));

// Export the simple table
String[] args = new String[] { name.getMethodName(), FQ_OUTPUT_DIR, "1000" };
assertTrue(runExport(args));

// Import to a new table
final String IMPORT_TABLE = name.getMethodName() + "import";
desc = TableDescriptorBuilder.newBuilder(TableName.valueOf(IMPORT_TABLE))
.setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(FAMILYA).setMaxVersions(5).build())
.build();
UTIL.getAdmin().createTable(desc);

String O_OUTPUT_DIR =
new Path(OUTPUT_DIR + 1).makeQualified(FileSystem.get(UTIL.getConfiguration())).toString();

args = new String[] { "-D" + Import.BULK_OUTPUT_CONF_KEY + "=" + O_OUTPUT_DIR,
"-D" + Import.HAS_LARGE_RESULT + "=" + true, IMPORT_TABLE, FQ_OUTPUT_DIR, "1000" };
assertTrue(runImport(args));
}

/**
* Count the number of keyvalues in the specified table with the given filter
* @param table the table to scan
Expand Down