当前位置: 首页>>代码示例>>Scala>>正文


Scala RoaringBitmap类代码示例

本文整理汇总了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}
} 
开发者ID:adform,项目名称:bitmap-dsl,代码行数:27,代码来源:Example.scala

示例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 
开发者ID:sorhus,项目名称:webalytics,代码行数:29,代码来源:Command.scala

示例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()
} 
开发者ID:sorhus,项目名称:webalytics,代码行数:30,代码来源:ImmutableTest.scala


注:本文中的org.roaringbitmap.RoaringBitmap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。