Skip to content

Conversation

houzhizhen
Copy link
Contributor

No description provided.

@codecov-io
Copy link

codecov-io commented Mar 16, 2021

Codecov Report

Merging #21 (cf3361d) into master (df826c0) will increase coverage by 0.19%.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #21 +/- ## ============================================ + Coverage 80.88% 81.08% +0.19%  - Complexity 793 804 +11  ============================================ Files 79 79 Lines 2611 2638 +27 Branches 236 242 +6 ============================================ + Hits 2112 2139 +27  Misses 380 380 Partials 119 119 
Impacted Files Coverage Δ Complexity Δ
...m/baidu/hugegraph/computer/core/config/Config.java 78.87% <100.00%> (+12.96%) 22.00 <11.00> (+11.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df826c0...cf3361d. Read the comment docs.

Copy link
Contributor

@javeme javeme left a comment

Choose a reason for hiding this comment

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

improve title: add Config getXxValue for number type

return this.allConfig.get(option);
}

public int getByte(String key, byte defaultValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why not call get(TypedOption)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The algorithm specific parameters are not in ComputerOptions.

@houzhizhen houzhizhen changed the title add getByte, getShort, getInt, getLong, getFloat, getDouble Config add getByte, getShort, getInt, getLong, getFloat, getDouble for numeric type Mar 16, 2021
Copy link
Contributor

@javeme javeme left a comment

Choose a reason for hiding this comment

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

remove getByte and getShort

if (value == null) {
return defaultValue;
} else {
return Double.parseDouble(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

check exception and throw more friendly exception

return Integer.parseInt(value);
} catch (Exception e) {
throw new ComputerException(
"Can't parse '%s' into int for key '%s'",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't parse byte value from '%s' for key '%s'

}
}

public int getShort(String key, short defaultValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

delete this method

if (value == null) {
return defaultValue;
} else {
return Boolean.parseBoolean(value);
Copy link
Contributor

Choose a reason for hiding this comment

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

cache exception

Copy link
Contributor Author

@houzhizhen houzhizhen Mar 18, 2021

Choose a reason for hiding this comment

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

no exception when parseBoolean, anything not "true" will regard it "false".
public static boolean parseBoolean(String s) {
return ((s != null) && s.equalsIgnoreCase("true"));
}

return this.allConfig.get(option);
}

public boolean getBoolean(String key, boolean defaultValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

also update PR title

@houzhizhen houzhizhen changed the title Config add getByte, getShort, getInt, getLong, getFloat, getDouble for numeric type Config add getBoolean, getInt, getLong, getDouble, getString Mar 18, 2021
"Can't parse boolean value from '%s' for key '%s'",
value, key);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty line

Config config = new Config(options);
Assert.assertEquals(value, config.getString(KEY, defaultValue));
Assert.assertEquals(defaultValue,
config.getString(KEY_EMPTY, defaultValue));
Copy link
Contributor

Choose a reason for hiding this comment

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

test pass defaultValue=null

@houzhizhen houzhizhen merged commit ccea733 into master Mar 22, 2021
@houzhizhen houzhizhen deleted the config branch March 22, 2021 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants