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 Thu, 04 Jan 2018 17:30:58 GMT
Github user ricellis commented on a diff in the pull request:

    https://github.com/apache/bahir/pull/61#discussion_r159709382
  
    --- Diff: sql-cloudant/src/main/scala/org/apache/bahir/cloudant/CloudantConfig.scala ---
    @@ -95,15 +189,49 @@ class CloudantConfig(val protocol: String, val host: String,
         }
       }
     
    +  def getTotalDocCount: Int = {
    +    val limit = 1
    +    if (viewPath != null) {
    +      // "limit=" + limit + "&skip=" + skip
    +      buildViewRequest(limit, includeDocs = false).build().getResponse.getTotalRowCount.toInt
    +    } else {
    +      // /_all_docs?limit=1
    +      // Note: java-cloudant's AllDocsRequest doesn't have a getTotalRowCount method
    +      // buildAllDocsRequest(1, includeDocs = false).build().getResponse.getTotalRowCount.toInt
    +      val response = client.executeRequest(Http.GET(
    +        new URL(database.getDBUri + File.separator + endpoint + "?limit=" + limit)))
    +      getResultTotalRows(response.responseAsString)
    --- End diff --
    
    It might be easier to use
    `com.cloudant.client.api.model.DbInfo#getDocCount` instead of trying to do it via `_all_docs`


---

Mime
View raw message