override def filter()

in common/scala/src/main/scala/org/apache/openwhisk/core/database/memory/MemoryViewMapper.scala [131:161]


  override def filter(ddoc: String,
                      view: String,
                      startKey: List[Any],
                      endKey: List[Any],
                      d: JsObject,
                      c: JsObject): Boolean = {
    checkKeys(startKey, endKey)
    val entityType = WhisksHandler.getEntityTypeForDesignDoc(ddoc, view)

    val matchTypeAndView = equal(d, TYPE, entityType) && matchViewConditions(ddoc, view, d)
    val matchNS = equal(d, NS, startKey.head.asInstanceOf[String])
    val matchRootNS = equal(c, ROOT_NS, startKey.head.asInstanceOf[String])

    //Here ddocs for actions, rules and triggers use
    //namespace and namespace/packageName as first key

    val filterResult = (startKey, endKey) match {
      case (ns :: Nil, _ :: `TOP` :: Nil) =>
        (matchTypeAndView && matchNS) || (matchTypeAndView && matchRootNS)

      case (ns :: (since: Number) :: Nil, _ :: `TOP` :: `TOP` :: Nil) =>
        (matchTypeAndView && matchNS && gte(d, UPDATED, since)) ||
          (matchTypeAndView && matchRootNS && gte(d, UPDATED, since))
      case (ns :: (since: Number) :: Nil, _ :: (upto: Number) :: `TOP` :: Nil) =>
        (matchTypeAndView && matchNS && gte(d, UPDATED, since) && lte(d, UPDATED, upto)) ||
          (matchTypeAndView && matchRootNS && gte(d, UPDATED, since) && lte(d, UPDATED, upto))

      case _ => throw UnsupportedQueryKeys(s"$ddoc/$view -> ($startKey, $endKey)")
    }
    filterResult
  }