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 #45: [WIP] [BAHIR-110] Implement _changes API for non-str...
Date Mon, 10 Jul 2017 14:42:52 GMT
Github user ricellis commented on a diff in the pull request:

    https://github.com/apache/bahir/pull/45#discussion_r126428690
  
    --- Diff: sql-cloudant/src/main/scala/org/apache/bahir/cloudant/CloudantConfig.scala ---
    @@ -30,81 +28,83 @@ import org.apache.bahir.cloudant.common._
     */
     
     class CloudantConfig(val protocol: String, val host: String,
    -    val dbName: String, val indexName: String = null, val viewName: String = null)
    +    val dbName: String, val indexName: String, val viewName: String)
         (implicit val username: String, val password: String,
         val partitions: Int, val maxInPartition: Int, val minInPartition: Int,
         val requestTimeout: Long, val bulkSize: Int, val schemaSampleSize: Int,
    -    val createDBOnSave: Boolean, val selector: String, val useQuery: Boolean = false,
    -    val queryLimit: Int)
    -    extends Serializable{
    +    val createDBOnSave: Boolean, val apiReceiver: String,
    +    val useQuery: Boolean = false, val queryLimit: Int)
    +    extends Serializable {
     
    -  private lazy val dbUrl = {protocol + "://" + host + "/" + dbName}
    +  lazy val dbUrl: String = {protocol + "://" + host + "/" + dbName}
     
       val pkField = "_id"
    -  val defaultIndex = "_all_docs" // "_changes" does not work for partition
    +  val defaultIndex: String = apiReceiver
       val default_filter: String = "*:*"
     
    -  def getContinuousChangesUrl(): String = {
    -    var url = dbUrl + "/_changes?include_docs=true&feed=continuous&heartbeat=3000"
    -    if (selector != null) {
    -      url = url + "&filter=_selector"
    -    }
    -    url
    -  }
    -
    -  def getSelector() : String = {
    -    selector
    -  }
    -
    -  def getDbUrl(): String = {
    +  def getDbUrl: String = {
         dbUrl
       }
     
    -  def getSchemaSampleSize(): Int = {
    +  def getSchemaSampleSize: Int = {
         schemaSampleSize
       }
     
    -  def getCreateDBonSave(): Boolean = {
    +  def getCreateDBonSave: Boolean = {
         createDBOnSave
       }
     
    -  def getTotalUrl(url: String): String = {
    -    if (url.contains('?')) {
    -      url + "&limit=1"
    -    } else {
    -      url + "?limit=1"
    -    }
    -  }
    -
    -  def getDbname(): String = {
    -    dbName
    -  }
    -
    -  def queryEnabled(): Boolean = {useQuery && indexName==null && viewName==null}
    -
    -  def allowPartition(queryUsed: Boolean): Boolean = {indexName==null && !queryUsed}
    -
    -  def getAllDocsUrl(limit: Int, excludeDDoc: Boolean = false): String = {
    +  def getLastNum(result: JsValue): JsValue = (result \ "last_seq").get
     
    +  /* Url containing limit for docs in a Cloudant database.
    +  * If a view is not defined, use the _all_docs endpoint.
    +  * @return url with one doc limit for retrieving total doc count
    +  */
    +  def getUrl(limit: Int, excludeDDoc: Boolean = false): String = {
         if (viewName == null) {
    -      val baseUrl = (
    -          if ( excludeDDoc) dbUrl + "/_all_docs?startkey=%22_design0/%22&include_docs=true"
    -          else dbUrl + "/_all_docs?include_docs=true"
    -          )
    -      if (limit == JsonStoreConfigManager.ALL_DOCS_LIMIT) {
    +      val baseUrl = {
    +        if (excludeDDoc) {
    +          dbUrl + "/_all_docs?startkey=%22_design0/%22&include_docs=true"
    --- End diff --
    
    See https://github.com/cloudant/java-cloudant/issues/344#issuecomment-276938689
    This `startkey` makes the assumption that no document IDs will start with upper case letters.
Possibly one for another issue.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message