support.bitvector 模块

An implementation of an object that acts like a collection of on/off bits.

基类

class whoosh.idsets.DocIdSet

一组正整数的基类,实现内置整数的子集 set 类型与其他与docid相关的方法的接口。

这是内置的可选集实现的超类 set 它的内存效率更高,专门用于存储正整数的排序列表,尽管它们不可避免地会比 set for most operations since they're pure Python.

after(i)

返回后面集合中的下一个整数 i 或者没有。

before(i)

返回前面集合中的前一个整数 i 或者没有。

first()

返回集合中的第一个(最低)整数。

invert_update(size)

更新就地设置以包含范围内的数字 [0 - size) 除了这个集合中的数字。

last()

返回集合中的最后一个(最高)整数。

class whoosh.idsets.BaseBitSet

实现类

class whoosh.idsets.BitSet(source=None, size=0)

由位数组支持的一种文档标识集。这也可以用作位数组(例如用于Bloom过滤器)。它比一个大的内置整数集更节省内存,但会为稀疏集浪费内存。

参数
  • maxsize -- 位数组的最大大小。

  • source -- 要添加到此集合的正整数的可Itable。

  • bits -- 用作底层位数组的无符号字节数组(“B”)。这被一些对象的方法使用。

class whoosh.idsets.OnDiskBitSet(dbfile, basepos, bytecount)

由磁盘上的一组位所支持的一种文档标识集。

>>> st = RamStorage()
>>> f = st.create_file("test.bin")
>>> bs = BitSet([1, 10, 15, 7, 2])
>>> bytecount = bs.to_disk(f)
>>> f.close()
>>> # ...
>>> f = st.open_file("test.bin")
>>> odbs = OnDiskBitSet(f, bytecount)
>>> list(odbs)
[1, 2, 7, 10, 15]
参数
  • dbfile -- 一 StructFile 要读取的对象。

  • basepos -- 给定文件中字节的基位置。

  • bytecount -- 用于位数组的字节数。

class whoosh.idsets.SortedIntSet(source=None, typecode='I')

由整数排序数组支持的docidset。

class whoosh.idsets.MultiIdSet(idsets, offsets)

包装多个串行子文档集对象,并将其显示为聚合的只读集。

参数
  • idsets -- docidset对象列表。

  • offsets -- 与中的docidset对象对应的偏移列表 idsets .