コード例 #1
0
ファイル: whoosh3.py プロジェクト: cylleneus/cylleneus
    def to_bytes(self):
        isinlined = self.is_inlined()

        # Encode the lengths as 0-255 values
        minlength = (
            0 if self._minlength is None else length_to_byte(self._minlength)
        )
        maxlength = length_to_byte(self._maxlength)
        # Convert None values to the out-of-band NO_ID constant so they can be
        # stored as unsigned ints
        minid = 0xFFFFFFFF if self._minid is None else self._minid
        maxid = 0xFFFFFFFF if self._maxid is None else self._maxid

        # Pack the term info into bytes
        st = self._struct.pack(
            isinlined,
            self._weight,
            self._df,
            minlength,
            maxlength,
            self._maxweight,
            minid,
            maxid,
        )

        if isinlined:
            # Postings are inlined - dump them using the pickle protocol
            postbytes = dumps(self._inlined, 2)
        else:
            postbytes = pack_long(self._offset) + pack_int(self._length)
        st += postbytes
        return st
コード例 #2
0
    def to_bytes(self):
        isinlined = self.is_inlined()

        # Encode the lengths as 0-255 values
        minlength = (0 if self._minlength is None
                     else length_to_byte(self._minlength))
        maxlength = length_to_byte(self._maxlength)
        # Convert None values to the out-of-band NO_ID constant so they can be
        # stored as unsigned ints
        minid = 0xffffffff if self._minid is None else self._minid
        maxid = 0xffffffff if self._maxid is None else self._maxid

        # Pack the term info into bytes
        st = self._struct.pack(isinlined, self._weight, self._df,
                               minlength, maxlength, self._maxweight,
                               minid, maxid)

        if isinlined:
            # Postings are inlined - dump them using the pickle protocol
            postbytes = dumps(self._inlined, -1)
        else:
            postbytes = pack_long(self._offset) + pack_int(self._length)
        st += postbytes
        return st
コード例 #3
0
ファイル: structfile.py プロジェクト: ckolumbus/WikidPad-svn
 def write_int(self, n):
     self.file.write(pack_int(n))
コード例 #4
0
ファイル: structfile.py プロジェクト: calebmauer/WikidPad
 def write_string4(self, s):
     self.write(pack_int(len(s)) + s)
コード例 #5
0
ファイル: fst.py プロジェクト: adamhorner/yaki-tng
 def to_bytes(v):
     return pack_int(v)
コード例 #6
0
ファイル: dawg.py プロジェクト: skrieder/microblog
 def to_bytes(v):
     return pack_int(v)
コード例 #7
0
 def write_int(self, n):
     self.file.write(pack_int(n))
コード例 #8
0
 def write_string4(self, s):
     self.write(pack_int(len(s)) + s)