[
https://issues.apache.org/jira/browse/BAHIR-154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16311721#comment-16311721
]
ASF GitHub Bot commented on BAHIR-154:
--------------------------------------
Github user ricellis commented on a diff in the pull request:
https://github.com/apache/bahir/pull/61#discussion_r159709935
--- 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)
+ }
+ }
+
+ def getDocs(limit: Int): List[JsonObject] = {
+ if (viewPath != null) {
+ // "limit=" + limit + "&skip=" + skip
+
buildViewRequest(limit).build().getResponse.getDocsAs(classOf[JsonObject]).asScala.toList
+ } else if (indexPath != null) {
+ var searchDocs = mutable.ListBuffer[JsonObject]()
+ for (result: SearchResult[JsonObject]#SearchResultRow <-
+ buildSearchRequest(limit).getRows.asScala) {
+ searchDocs += result.getDoc
+ }
+ searchDocs.toList
+ } else {
+ // /_all_docs?limit=1
+ // val response = client.executeRequest(Http.GET(
--- End diff --
Remove commented out code?
> Refactor sql-cloudant to use Cloudant's java-cloudant features
> --------------------------------------------------------------
>
> Key: BAHIR-154
> URL: https://issues.apache.org/jira/browse/BAHIR-154
> Project: Bahir
> Issue Type: Improvement
> Affects Versions: Spark-2.2.0
> Reporter: Esteban Laver
> Assignee: Esteban Laver
>
> Cloudant's java-cloudant library (which is currently used for testing)
> contains several features that sql-cloudant can benefit from:
> - HTTP 429 backoff
> - View builder API to potentially simplify loading for _all_docs/views
> - Improved exception handling when executing HTTP requests
> - Future support for IAM API key
> Would need to replace current scala HTTP library with OkHttp library, and
> also replace play-json with GSON library.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)