Skip to content
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

[HUDI-3862] Fix default configurations of HoodieHBaseIndexConfig #5308

Merged
merged 5 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -1453,43 +1453,43 @@ public String getHbaseTableName() {
}

public int getHbaseIndexGetBatchSize() {
return getInt(HoodieHBaseIndexConfig.GET_BATCH_SIZE);
return getIntOrDefault(HoodieHBaseIndexConfig.GET_BATCH_SIZE);
nsivabalan marked this conversation as resolved.
Show resolved Hide resolved
}

public Boolean getHBaseIndexRollbackSync() {
return getBoolean(HoodieHBaseIndexConfig.ROLLBACK_SYNC_ENABLE);
return getBooleanOrDefault(HoodieHBaseIndexConfig.ROLLBACK_SYNC_ENABLE);
}

public int getHbaseIndexPutBatchSize() {
return getInt(HoodieHBaseIndexConfig.PUT_BATCH_SIZE);
return getIntOrDefault(HoodieHBaseIndexConfig.PUT_BATCH_SIZE);
}

public boolean getHbaseIndexPutBatchSizeAutoCompute() {
return getBooleanOrDefault(HoodieHBaseIndexConfig.PUT_BATCH_SIZE_AUTO_COMPUTE);
}

public String getHBaseQPSResourceAllocatorClass() {
return getString(HoodieHBaseIndexConfig.QPS_ALLOCATOR_CLASS_NAME);
return getStringOrDefault(HoodieHBaseIndexConfig.QPS_ALLOCATOR_CLASS_NAME);
}

public String getHBaseQPSZKnodePath() {
return getString(HoodieHBaseIndexConfig.ZKPATH_QPS_ROOT);
return getStringOrDefault(HoodieHBaseIndexConfig.ZKPATH_QPS_ROOT);
}

public String getHBaseZkZnodeSessionTimeout() {
return getString(HoodieHBaseIndexConfig.ZK_SESSION_TIMEOUT_MS);
return getStringOrDefault(HoodieHBaseIndexConfig.ZK_SESSION_TIMEOUT_MS);
}

public String getHBaseZkZnodeConnectionTimeout() {
return getString(HoodieHBaseIndexConfig.ZK_CONNECTION_TIMEOUT_MS);
return getStringOrDefault(HoodieHBaseIndexConfig.ZK_CONNECTION_TIMEOUT_MS);
}

public boolean getHBaseIndexShouldComputeQPSDynamically() {
return getBoolean(HoodieHBaseIndexConfig.COMPUTE_QPS_DYNAMICALLY);
return getBooleanOrDefault(HoodieHBaseIndexConfig.COMPUTE_QPS_DYNAMICALLY);
}

public int getHBaseIndexDesiredPutsTime() {
return getInt(HoodieHBaseIndexConfig.DESIRED_PUTS_TIME_IN_SECONDS);
return getIntOrDefault(HoodieHBaseIndexConfig.DESIRED_PUTS_TIME_IN_SECONDS);
}

public String getBloomFilterType() {
Expand All @@ -1506,7 +1506,7 @@ public int getDynamicBloomFilterMaxNumEntries() {
* the jobs would be (0.17) 1/6, 0.33 (2/6) and 0.5 (3/6) respectively.
*/
public float getHbaseIndexQPSFraction() {
return getFloat(HoodieHBaseIndexConfig.QPS_FRACTION);
return getFloatOrDefault(HoodieHBaseIndexConfig.QPS_FRACTION);
}

public float getHBaseIndexMinQPSFraction() {
Expand All @@ -1522,7 +1522,7 @@ public float getHBaseIndexMaxQPSFraction() {
* Hoodie jobs to an Hbase Region Server
*/
public int getHbaseIndexMaxQPSPerRegionServer() {
return getInt(HoodieHBaseIndexConfig.MAX_QPS_PER_REGION_SERVER);
return getIntOrDefault(HoodieHBaseIndexConfig.MAX_QPS_PER_REGION_SERVER);
}

public boolean getHbaseIndexUpdatePartitionPath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ public <T> Float getFloat(ConfigProperty<T> configProperty) {
return rawValue.map(v -> Float.parseFloat(v.toString())).orElse(null);
}

public <T> Float getFloatOrDefault(ConfigProperty<T> configProperty) {
return getFloatOrDefault(configProperty, configProperty.defaultValue());
}

public <T> Float getFloatOrDefault(ConfigProperty<T> configProperty, T defaultVal) {
Option<Object> rawValue = getRawValue(configProperty);
return rawValue.map(v -> Float.parseFloat(v.toString())).orElse((Float)defaultVal);
}

public <T> Double getDouble(ConfigProperty<T> configProperty) {
Option<Object> rawValue = getRawValue(configProperty);
return rawValue.map(v -> Double.parseDouble(v.toString())).orElse(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public class TestConfigProperty extends HoodieConfig {
})
.withDocumentation("Fake config only for testing");

public static ConfigProperty<Float> FAKE_FLOAT_CONFIG = ConfigProperty
.key("test.fake.float.config")
.defaultValue(0.5f)
.withDocumentation("Fake config only for testing");

@Test
public void testGetTypedValue() {
HoodieConfig hoodieConfig = new HoodieConfig();
Expand Down Expand Up @@ -87,6 +92,7 @@ public void testGetOrDefault() {
HoodieConfig hoodieConfig = new HoodieConfig(props);
assertEquals("1", hoodieConfig.getStringOrDefault(FAKE_STRING_CONFIG));
assertEquals("2", hoodieConfig.getStringOrDefault(FAKE_STRING_CONFIG, "2"));
assertEquals(0.5f, hoodieConfig.getFloatOrDefault(FAKE_FLOAT_CONFIG));
}

@Test
Expand All @@ -113,6 +119,6 @@ public void testInference() {
@Test
public void testSetDefaults() {
setDefaults(this.getClass().getName());
assertEquals(3, getProps().size());
assertEquals(4, getProps().size());
}
}