Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
minihippo committed Dec 28, 2021
1 parent 219fa01 commit ce3c0a2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ public Builder fromProperties(Properties props) {
return this;
}

public Builder withLayoutType(String type) {
layoutConfig.setValue(LAYOUT_TYPE, type);
return this;
}

public Builder withLayoutPartitioner(String partitionerClass) {
layoutConfig.setValue(LAYOUT_PARTITIONER_CLASS_NAME, partitionerClass);
return this;
}

public HoodieLayoutConfig build() {
setDefault();
return layoutConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,12 @@ public Builder withCallbackConfig(HoodieWriteCommitCallbackConfig callbackConfig
return this;
}

public Builder withLayoutConfig(HoodieLayoutConfig layoutConfig) {
writeConfig.getProps().putAll(layoutConfig.getProps());
isLayoutConfigSet = true;
return this;
}

public Builder withFinalizeWriteParallelism(int parallelism) {
writeConfig.setValue(FINALIZE_WRITE_PARALLELISM_VALUE, String.valueOf(parallelism));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.hudi.common.util.collection.Pair;
import org.apache.hudi.config.HoodieCompactionConfig;
import org.apache.hudi.config.HoodieIndexConfig;
import org.apache.hudi.config.HoodieLayoutConfig;
import org.apache.hudi.config.HoodieStorageConfig;
import org.apache.hudi.config.HoodieWriteConfig;
import org.apache.hudi.index.HoodieIndex;
Expand All @@ -44,6 +45,7 @@
import org.apache.hudi.metadata.SparkHoodieBackedTableMetadataWriter;
import org.apache.hudi.table.HoodieSparkTable;
import org.apache.hudi.table.HoodieTable;
import org.apache.hudi.table.action.commit.SparkBucketIndexPartitioner;
import org.apache.hudi.testutils.Assertions;
import org.apache.hudi.testutils.HoodieClientTestHarness;
import org.apache.hudi.testutils.HoodieSparkWriteableTestTable;
Expand Down Expand Up @@ -120,7 +122,9 @@ private void setUp(IndexType indexType, boolean populateMetaFields, boolean enab
.withProperties(populateMetaFields ? new Properties() : getPropertiesForKeyGen())
.withRollbackUsingMarkers(rollbackUsingMarkers)
.withIndexConfig(indexBuilder
.build()).withAutoCommit(false).withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(enableMetadata).build()).build();
.build()).withAutoCommit(false).withMetadataConfig(HoodieMetadataConfig.newBuilder().enable(enableMetadata).build())
.withLayoutConfig(HoodieLayoutConfig.newBuilder().fromProperties(indexBuilder.build().getProps())
.withLayoutPartitioner(SparkBucketIndexPartitioner.class.getName()).build()).build();
writeClient = getHoodieWriteClient(config);
this.index = writeClient.getIndex();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,17 @@ private HoodieWriteConfig.Builder makeHoodieClientConfigBuilder() {

private Properties makeIndexConfig(HoodieIndex.IndexType indexType) {
Properties props = new Properties();
props.setProperty(KeyGeneratorOptions.RECORDKEY_FIELD_NAME.key(), "_row_key");
HoodieIndexConfig.Builder indexConfig = HoodieIndexConfig.newBuilder()
.fromProperties(props).withIndexType(indexType);
.withIndexType(indexType);
props.putAll(indexConfig.build().getProps());
if (indexType.equals(HoodieIndex.IndexType.BUCKET)) {
indexConfig.withIndexKeyField("_row_key").withBucketNum("1");
props.setProperty(HoodieLayoutConfig.LAYOUT_TYPE.key(), HoodieStorageLayout.LayoutType.BUCKET.name());
props.setProperty(HoodieLayoutConfig.LAYOUT_PARTITIONER_CLASS_NAME.key(), SparkBucketIndexPartitioner.class.getName());
props.setProperty(KeyGeneratorOptions.RECORDKEY_FIELD_NAME.key(), "_row_key");
indexConfig.fromProperties(props).withIndexKeyField("_row_key").withBucketNum("1");
props.putAll(indexConfig.build().getProps());
props.putAll(HoodieLayoutConfig.newBuilder().fromProperties(props)
.withLayoutType(HoodieStorageLayout.LayoutType.BUCKET.name())
.withLayoutPartitioner(SparkBucketIndexPartitioner.class.getName()).build().getProps());
}
props.putAll(indexConfig.build().getProps());
return props;
}

Expand Down

0 comments on commit ce3c0a2

Please sign in to comment.