bahir-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ricellis <...@git.apache.org>
Subject [GitHub] bahir pull request #61: [BAHIR-154] Refactor sql-cloudant to use Cloudant's ...
Date Fri, 05 Jan 2018 14:49:58 GMT
Github user ricellis commented on a diff in the pull request:

    https://github.com/apache/bahir/pull/61#discussion_r159890761
  
    --- Diff: sql-cloudant/src/main/scala/org/apache/bahir/cloudant/common/JsonStoreRDD.scala
---
    @@ -191,20 +199,30 @@ class JsonStoreRDD(sc: SparkContext, config: CloudantConfig)
        (0 until totalPartition).map(i => {
           val skip = i * limitPerPartition
           new JsonStoreRDDPartition(url, skip, limitPerPartition, i,
    -          config, selector, fields, queryUsed).asInstanceOf[Partition]
    +          config, selector, fields, queryUsed)
    +        .asInstanceOf[Partition]
         }).toArray
       }
     
       override def compute(splitIn: Partition, context: TaskContext):
           Iterator[String] = {
         val myPartition = splitIn.asInstanceOf[JsonStoreRDDPartition]
         implicit val postData : String = {
    +      val jsonObject = new JsonObject
           if (myPartition.queryUsed && myPartition.fields != null) {
    -        Json.stringify(Json.obj("selector" -> myPartition.selector, "fields" ->
myPartition.fields,
    -            "limit" -> myPartition.limit, "skip" -> myPartition.skip))
    +        // Json.stringify(Json.obj("selector" -> myPartition.selector, "fields" ->
    +        // myPartition.fields, "limit" -> myPartition.limit, "skip" -> myPartition.skip))
    +        jsonObject.add("selector", myPartition.selector)
    +        jsonObject.add("fields", myPartition.fields)
    +        jsonObject.addProperty("skip", myPartition.skip)
    +        jsonObject.toString
           } else if (myPartition.queryUsed) {
    -        Json.stringify(Json.obj("selector" -> myPartition.selector, "limit" ->
myPartition.limit,
    -            "skip" -> myPartition.skip))
    +        // Json.stringify(Json.obj("selector" -> myPartition.selector,
    +        // "limit" -> myPartition.limit, "skip" -> myPartition.skip))
    +        jsonObject.add("selector", myPartition.selector)
    --- End diff --
    
    Could add the `selector` and `skip` before the `if`/`else` and avoid the duplication


---

Mime
View raw message