Exemplo n.º 1
0
    def _flush_run(self):
        # Called when the memory buffer (of size self.limit) fills up.
        # Sorts the buffer and writes the current buffer to a "run" on disk.

        if self.size > 0:
            tempfd, tempname = tempfile.mkstemp(".run")
            runfile = StructFile(os.fdopen(tempfd, "w+b"))

            self.postings.sort()
            for p in self.postings:
                runfile.write_string2(p)
            runfile.flush()
            runfile.seek(0)

            self.runs.append((runfile, self.count))
            #print "Flushed run:", self.runs

            self.postings = []
            self.size = 0
            self.count = 0
Exemplo n.º 2
0
 def _flush_run(self):
     # Called when the memory buffer (of size self.limit) fills up.
     # Sorts the buffer and writes the current buffer to a "run" on disk.
     
     if self.size > 0:
         tempfd, tempname = tempfile.mkstemp(".run")
         runfile = StructFile(os.fdopen(tempfd, "w+b"))
         
         self.postings.sort()
         for p in self.postings:
             runfile.write_string2(p)
         runfile.flush()
         runfile.seek(0)
         
         self.runs.append((runfile, self.count))
         #print "Flushed run:", self.runs
         
         self.postings = []
         self.size = 0
         self.count = 0