Ejemplo n.º 1
0
    def roundtrip(self, postings, format, astype):
        postfile = self.make_file(astype)
        readback = None
        try:
            fpw = FilePostingWriter(postfile, blocklimit=8)
            fpw.start(format)
            for id, value in postings:
                fpw.write(id, format.encode(value))
            fpw.close()

            postfile = self.open_file(astype)
            fpr = FilePostingReader(postfile, 0, format)
            readback = list(fpr.all_as(astype))
            fpr.close()
        finally:
            self.delete_file(astype)
        return readback
Ejemplo n.º 2
0
 def roundtrip(self, postings, format, astype):
     postfile = self.make_file(astype)
     readback = None
     try:
         fpw = FilePostingWriter(postfile, blocklimit=8)
         fpw.start(format)
         for id, value in postings:
             fpw.write(id, format.encode(value))
         fpw.close()
         
         postfile = self.open_file(astype)
         fpr = FilePostingReader(postfile, 0, format)
         readback = list(fpr.all_as(astype))
         fpr.close()
     finally:
         self.delete_file(astype)
     return readback
Ejemplo n.º 3
0
    def test_readwrite(self):
        format = Frequency(None)
        postings = self.make_postings()

        postfile = self.make_file("readwrite")
        try:
            fpw = FilePostingWriter(postfile, blocklimit=8)
            fpw.start(format)
            for id, freq in postings:
                fpw.write(id, format.encode(freq))
            fpw.close()

            postfile = self.open_file("readwrite")
            fpr = FilePostingReader(postfile, 0, format)
            #self.assertEqual(postings, list(fpr.items_as("frequency")))
            fpr.close()
        finally:
            self.delete_file("readwrite")
Ejemplo n.º 4
0
 def test_readwrite(self):
     format = Frequency(None)
     postings = self.make_postings()
     
     postfile = self.make_file("readwrite")
     try:
         fpw = FilePostingWriter(postfile, blocklimit=8)
         fpw.start(format)
         for id, freq in postings:
             fpw.write(id, format.encode(freq))
         fpw.close()
         
         postfile = self.open_file("readwrite")
         fpr = FilePostingReader(postfile, 0, format)
         #self.assertEqual(postings, list(fpr.items_as("frequency")))
         fpr.close()
     finally:
         self.delete_file("readwrite")