use of org.apache.hudi.table.action.commit.BucketInfo in project hudi by apache.
the class TestBucketAssigner method testAddUpdate.
@Test
public void testAddUpdate() {
MockBucketAssigner mockBucketAssigner = new MockBucketAssigner(context, writeConfig);
BucketInfo bucketInfo = mockBucketAssigner.addUpdate("par1", "file_id_0");
assertBucketEquals(bucketInfo, "par1", BucketType.UPDATE, "file_id_0");
mockBucketAssigner.addUpdate("par1", "file_id_0");
bucketInfo = mockBucketAssigner.addUpdate("par1", "file_id_0");
assertBucketEquals(bucketInfo, "par1", BucketType.UPDATE, "file_id_0");
mockBucketAssigner.addUpdate("par1", "file_id_1");
bucketInfo = mockBucketAssigner.addUpdate("par1", "file_id_1");
assertBucketEquals(bucketInfo, "par1", BucketType.UPDATE, "file_id_1");
bucketInfo = mockBucketAssigner.addUpdate("par2", "file_id_0");
assertBucketEquals(bucketInfo, "par2", BucketType.UPDATE, "file_id_0");
bucketInfo = mockBucketAssigner.addUpdate("par3", "file_id_2");
assertBucketEquals(bucketInfo, "par3", BucketType.UPDATE, "file_id_2");
}
use of org.apache.hudi.table.action.commit.BucketInfo in project hudi by apache.
the class TestBucketAssigner method assertBucketEquals.
private void assertBucketEquals(BucketInfo bucketInfo, String partition, BucketType bucketType, String fileId) {
BucketInfo actual = new BucketInfo(bucketType, fileId, partition);
assertThat(bucketInfo, is(actual));
}
use of org.apache.hudi.table.action.commit.BucketInfo in project hudi by apache.
the class TestBucketAssigner method testUpdateAndInsertWithPartialSmallFiles.
/**
* Test that only partial small files are assigned to the task.
*/
@Test
public void testUpdateAndInsertWithPartialSmallFiles() {
SmallFile f0 = new SmallFile();
f0.location = new HoodieRecordLocation("t0", "f0");
f0.sizeBytes = 12;
SmallFile f1 = new SmallFile();
f1.location = new HoodieRecordLocation("t0", "f1");
// no left space to append new records to this bucket
f1.sizeBytes = 122879;
SmallFile f2 = new SmallFile();
f2.location = new HoodieRecordLocation("t0", "f2");
f2.sizeBytes = 56;
Map<String, List<SmallFile>> smallFilesMap = new HashMap<>();
smallFilesMap.put("par1", Arrays.asList(f0, f1, f2));
MockBucketAssigner mockBucketAssigner = new MockBucketAssigner(0, 2, context, writeConfig, smallFilesMap);
mockBucketAssigner.addUpdate("par1", "f0");
BucketInfo bucketInfo = mockBucketAssigner.addInsert("par1");
assertBucketEquals(bucketInfo, "par1", BucketType.UPDATE, "f2");
mockBucketAssigner.addInsert("par1");
bucketInfo = mockBucketAssigner.addInsert("par1");
assertBucketEquals(bucketInfo, "par1", BucketType.UPDATE, "f2");
mockBucketAssigner.addUpdate("par1", "f2");
mockBucketAssigner.addInsert("par1");
bucketInfo = mockBucketAssigner.addInsert("par1");
assertBucketEquals(bucketInfo, "par1", BucketType.UPDATE, "f2");
MockBucketAssigner mockBucketAssigner2 = new MockBucketAssigner(1, 2, context, writeConfig, smallFilesMap);
mockBucketAssigner2.addUpdate("par1", "f0");
BucketInfo bucketInfo2 = mockBucketAssigner2.addInsert("par1");
assertBucketEquals(bucketInfo2, "par1", BucketType.UPDATE, "f0");
mockBucketAssigner2.addInsert("par1");
bucketInfo2 = mockBucketAssigner2.addInsert("par1");
assertBucketEquals(bucketInfo2, "par1", BucketType.UPDATE, "f0");
mockBucketAssigner2.addUpdate("par1", "f2");
mockBucketAssigner2.addInsert("par1");
bucketInfo2 = mockBucketAssigner2.addInsert("par1");
assertBucketEquals(bucketInfo2, "par1", BucketType.UPDATE, "f0");
}
use of org.apache.hudi.table.action.commit.BucketInfo in project hudi by apache.
the class TestBucketAssigner method testInsertWithSmallFiles.
@Test
public void testInsertWithSmallFiles() {
SmallFile f0 = new SmallFile();
f0.location = new HoodieRecordLocation("t0", "f0");
f0.sizeBytes = 12;
SmallFile f1 = new SmallFile();
f1.location = new HoodieRecordLocation("t0", "f1");
// no left space to append new records to this bucket
f1.sizeBytes = 122879;
SmallFile f2 = new SmallFile();
f2.location = new HoodieRecordLocation("t0", "f2");
f2.sizeBytes = 56;
Map<String, List<SmallFile>> smallFilesMap = new HashMap<>();
smallFilesMap.put("par1", Arrays.asList(f0, f1));
smallFilesMap.put("par2", Collections.singletonList(f2));
MockBucketAssigner mockBucketAssigner = new MockBucketAssigner(context, writeConfig, smallFilesMap);
BucketInfo bucketInfo = mockBucketAssigner.addInsert("par1");
assertBucketEquals(bucketInfo, "par1", BucketType.UPDATE, "f0");
mockBucketAssigner.addInsert("par1");
bucketInfo = mockBucketAssigner.addInsert("par1");
assertBucketEquals(bucketInfo, "par1", BucketType.UPDATE, "f0");
mockBucketAssigner.addInsert("par2");
bucketInfo = mockBucketAssigner.addInsert("par2");
assertBucketEquals(bucketInfo, "par2", BucketType.UPDATE, "f2");
bucketInfo = mockBucketAssigner.addInsert("par3");
assertBucketEquals(bucketInfo, "par3", BucketType.INSERT);
bucketInfo = mockBucketAssigner.addInsert("par3");
assertBucketEquals(bucketInfo, "par3", BucketType.INSERT);
}
use of org.apache.hudi.table.action.commit.BucketInfo in project hudi by apache.
the class TestBucketAssigner method testInsertOverBucketAssigned.
@Test
public void testInsertOverBucketAssigned() {
conf.setInteger(HoodieCompactionConfig.COPY_ON_WRITE_INSERT_SPLIT_SIZE.key(), 2);
writeConfig = StreamerUtil.getHoodieClientConfig(conf);
MockBucketAssigner mockBucketAssigner = new MockBucketAssigner(context, writeConfig);
BucketInfo bucketInfo1 = mockBucketAssigner.addInsert("par1");
assertBucketEquals(bucketInfo1, "par1", BucketType.INSERT);
BucketInfo bucketInfo2 = mockBucketAssigner.addInsert("par1");
assertBucketEquals(bucketInfo2, "par1", BucketType.INSERT);
assertEquals(bucketInfo1, bucketInfo2);
BucketInfo bucketInfo3 = mockBucketAssigner.addInsert("par1");
assertBucketEquals(bucketInfo3, "par1", BucketType.INSERT);
assertNotEquals(bucketInfo1, bucketInfo3);
}
Aggregations