vesoft-inc / nebula-algorithm

Nebula-Algorithm is a Spark Application based on GraphX, which enables state of art Graph Algorithms to run on top of NebulaGraph and write back results to NebulaGraph.
71 stars 39 forks source link

Refactor getOrElseBoolean #92

Closed artemkorsakov closed 8 months ago

artemkorsakov commented 10 months ago

What type of PR is this?

What problem(s) does this PR solve?

Issue(s) number:

Description:

If we look at the following code:

  def getOrElseBoolean(config: Map[String, String], key: String, defaultValue: Boolean): Boolean = {
    if (config.contains(key)) {
      config(key).toBoolean
    } else {
      defaultValue
    }
  }

, we can see that the result is true only if the given key exists and its value is true.

This can be expressed using code:

config.get(key).exists(_.toBoolean)

How do you solve it?

Special notes for your reviewer, ex. impact of this fix, design document, etc: