def test_pickleability(): # Ignore base classes ignore = (columns.Column, columns.WrappedColumn, columns.ListColumn) # Required arguments init_args = { "ClampedNumericColumn": (columns.NumericColumn("B"), ), "FixedBytesColumn": (5, ), "FixedBytesListColumn": (5, ), "NumericColumn": ("i", ), "PickleColumn": (columns.VarBytesColumn(), ), "StructColumn": ("=if", (0, 0.0)), } coltypes = [ c for _, c in inspect.getmembers(columns, inspect.isclass) if issubclass(c, columns.Column) and not c in ignore ] for coltype in coltypes: args = init_args.get(coltype.__name__, ()) try: inst = coltype(*args) except TypeError: e = sys.exc_info()[1] raise TypeError("Error instantiating %r: %s" % (coltype, e)) _ = loads(dumps(inst, -1))
def make_schema(): return Schema(title=TEXT(stored=True, sortable=True), path=ID(stored=True, sortable=True), section=ID(stored=True), checksum=STORED, content=TEXT, priority=COLUMN(columns.NumericColumn("i")))
from whoosh.system import pack_ushort, unpack_ushort from whoosh.system import pack_int, unpack_int, pack_long, unpack_long from whoosh.util.numlists import delta_encode, delta_decode from whoosh.util.numeric import length_to_byte, byte_to_length try: import zlib except ImportError: zlib = None # This byte sequence is written at the start of a posting list to identify the # codec/version WHOOSH3_HEADER_MAGIC = b("W3Bl") # Column type to store field length info LENGTHS_COLUMN = columns.NumericColumn("B", default=0) # Column type to store pointers to vector posting lists VECTOR_COLUMN = columns.NumericColumn("I") # Column type to store vector posting list lengths VECTOR_LEN_COLUMN = columns.NumericColumn("i") # Column type to store values of stored fields STORED_COLUMN = columns.PickleColumn(columns.CompressedBytesColumn()) class W3Codec(base.CodecWithGraph): # File extensions TERMS_EXT = ".trm" # Term index POSTS_EXT = ".pst" # Term postings VPOSTS_EXT = ".vps" # Vector postings COLUMN_EXT = ".col" # Per-document value columns
def default_column(self): return columns.NumericColumn(self.sortable_typecode, default=self.default)