本文整理汇总了Scala中org.roaringbitmap.RoaringBitmap类的典型用法代码示例。如果您正苦于以下问题:Scala RoaringBitmap类的具体用法?Scala RoaringBitmap怎么用?Scala RoaringBitmap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RoaringBitmap类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: ExampleDB
//设置package包名称以及导入依赖的类
import com.adform.bitmaps._
import org.roaringbitmap.RoaringBitmap
//example storage implementation
case class ExampleDB(map: Map[String, RoaringBitmap]) extends BitmapDB[RoaringBitmap] {
override def getBitmap(key: String) = map.getOrElse(key, new RoaringBitmap())
override def full = getBitmap("FULL")
}
object Example extends App {
val students = ExampleDB(Map(
"study|MIT" -> RoaringBitmap.bitmapOf(1, 2, 7, 9),
"born|USA" -> RoaringBitmap.bitmapOf(1, 2),
"born|PL" -> RoaringBitmap.bitmapOf(3, 9)))
val expr =
And(
Get("study|MIT"),
Or(
Get("born|USA"),
Get("born|PL")
))
import com.adform.bitmaps.Implicits.RoaringBitmapImpl
val result = new BitmapExecutor(students).execute(expr)
print(s"MIT Students born in USA or PL: $result") // {1,2,9}
}
示例2: CloseBucket
//设置package包名称以及导入依赖的类
package com.github.sorhus.webalytics.akka.event
import com.github.sorhus.webalytics.model._
import com.github.sorhus.webalytics.akka.segment.{Bitset, QuerySegmentState}
import org.roaringbitmap.RoaringBitmap
sealed trait Command
case class CloseBucket(b: Bucket) extends Command
case object Debug extends Command
case object GetAll extends Command
case class LoadImmutable(bucket: Bucket, space: Option[Element] = None) extends Command
case class MakeImmutable(bucket: Bucket, state: Map[Dimension, Map[Value, Bitset[RoaringBitmap]]] = Map.empty)
case class PostCommand(bucket: Bucket, elementId: ElementId, element: Element, persist: Boolean = true) extends Command
case object SaveSnapshot extends Command
case object Shutdown extends Command
case class QueryCommand(query: Query, space: Element, state: Option[QuerySegmentState] = None) extends Command
case class CountCommand(domain: Option[Element] = None, state: Option[QuerySegmentState] = None) extends Command
sealed trait AckOrNack {
def *(that: AckOrNack): AckOrNack = Nack
}
case object Ack extends AckOrNack {
override def *(that: AckOrNack) = if(that == Ack) Ack else Nack
}
case object Nack extends AckOrNack
示例3: ImmutableTest
//设置package包名称以及导入依赖的类
package com.github.sorhus.webalytics.cruft
import java.io.{DataOutputStream, File, FileOutputStream, RandomAccessFile}
import java.nio.channels.FileChannel.MapMode
import org.roaringbitmap.RoaringBitmap
import org.roaringbitmap.buffer.ImmutableRoaringBitmap
object ImmutableTest extends App {
val outFile = new File(args(0))
outFile.createNewFile()
val fos = new FileOutputStream(outFile)
val dos = new DataOutputStream(fos)
val x = RoaringBitmap.bitmapOf(1,3,5)
x.runOptimize()
x.serialize(dos)
dos.close()
val inFile = new RandomAccessFile(args(0), "r")
val memoryMapped = inFile.getChannel.map(MapMode.READ_ONLY, 0, inFile.length())
val bb = memoryMapped.slice()
val bitset = new ImmutableRoaringBitmap(bb)
println(ImmutableRoaringBitmap.and(bitset,bitset).getCardinality)
println(ImmutableRoaringBitmap.andCardinality(bitset,bitset))
inFile.close()
}