FirebaseRecyclerAdapter检查另一个表中是否存在Id

时间:2018-05-13 19:46:54

标签: android firebase-realtime-database firebaseui

我有两个FirebaseRecyclerAdapter,一个获取所有listattendees,另一个获取平台上的所有人。我希望第二个FirebaseRecyclerAdapter不显示已经是listattendee的人(所以基本上所有人都减去了第一个适配器的人)。是否可以使用第一个适配器查询第二个适配器?像这样:

import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.functions.desc
import org.apache.spark.sql.Dataset
import org.apache.spark.sql.expressions.Window
import org.apache.spark.sql.functions.{col,udf,collect_list}
import org.apache.spark.sql.Row

case class Foo(a:Int, b:String ) {
  def toFooWrapper:FooWrapper = FooWrapper(this,true)
}

// utility class to convert Foo from correctly defined Row
object Foo {
  def fromRow( row:Row ):Foo = {
    Foo(row.getAs[Int]("a"),row.getAs[String]("b"))
  }
}

case class FooWrapper(foo:Foo, wrapper:Boolean)

case class FooResult(a1:Int, b1:String, a2:Int, b2:String, a3:Int, b3:String, computation1:Int, computation2:String )

object Main extends App {

    val ss = SparkSession.builder()
      .appName("DataSet Test")
        .master("local[*]").getOrCreate()

    import ss.implicits._

    val foos = Seq(Foo(-18, "Z"),
        Foo(-11, "G"),
        Foo(-8, "A"),
        Foo(-4, "C"),
        Foo(-1,"F")).toDS()

    // workaround - build wrapper
    val fooWrappers = foos.map( x => x.toFooWrapper )

    // work on 3 rows
    // ordering based on first column, second column, etc within Foo structure
    val sliding_window_spec = Window.orderBy(desc("foo")).rowsBetween(-2, 0)

    // grab foo from fooWrapper
  fooWrappers.select(slidingUdf( collect_list("foo").over(sliding_window_spec) ).as("test"))
    .filter(col("test").isNotNull)
    .select(col("test.*"))
    .show(false)

    ss.stop()

    def slidingUdf = udf( (rows:Seq[Row]) => {
        if(rows.size < 3) {
            null
        }
        else {
            val foos = rows.map( x => Foo.fromRow(x))
            FooResult(foos(0).a, foos(0).b, foos(1).a, foos(1).b, foos(2).a, foos(2).b, foos(0).a + foos(1).a, foos(0).b + foos(1).b + foos(2).b )
        }
    })

}

mListAttendees也适用于boolean.class。

1 个答案:

答案 0 :(得分:2)

FirebaseUI中没有内置任何内容,Firebase数据库查询模型不支持“不在”类型查询。

我能想到的最简单的方法是隐藏重复的项目,如下所示:How to hide an item from Recycler View on a particular condition?