1.1 --- a/iixr/positions.py Mon Feb 07 02:05:38 2011 +0100
1.2 +++ b/iixr/positions.py Tue Feb 08 00:08:27 2011 +0100
1.3 @@ -26,6 +26,7 @@
1.4 "Writing position information to files."
1.5
1.6 def reset(self):
1.7 + self.end_record()
1.8 self.last_docnum = None
1.9 self.subtractor = None
1.10
1.11 @@ -56,10 +57,8 @@
1.12 self.subtractor = get_subtractor(docnum)
1.13 docnum_seq = docnum
1.14
1.15 - self.begin_record()
1.16 self.write_sequence_value(docnum_seq)
1.17 self.write_monotonic_sequence(positions)
1.18 - self.end_record()
1.19
1.20 self.last_docnum = docnum
1.21
1.22 @@ -70,6 +69,7 @@
1.23 def reset(self):
1.24 self.last_docnum = None
1.25 self.adder = None
1.26 + self.begin_record()
1.27
1.28 def read_positions(self):
1.29
1.30 @@ -77,8 +77,6 @@
1.31 Read positions, returning a document number and a list of positions.
1.32 """
1.33
1.34 - self.begin_record()
1.35 -
1.36 # Read the document number.
1.37
1.38 docnum = self.read_sequence_value()
1.39 @@ -95,7 +93,6 @@
1.40 self.last_docnum = docnum
1.41
1.42 positions = self.read_monotonic_sequence()
1.43 - self.end_record()
1.44
1.45 return self.last_docnum, positions
1.46
1.47 @@ -104,6 +101,7 @@
1.48 "Writing position index information to files."
1.49
1.50 def reset(self):
1.51 + self.end_record()
1.52 self.last_docnum = None
1.53 self.subtractor = None
1.54 self.last_pos_offset = 0
1.55 @@ -123,11 +121,9 @@
1.56 self.subtractor = get_subtractor(docnum)
1.57 docnum_seq = docnum
1.58
1.59 - self.begin_record()
1.60 self.write_sequence_value(docnum_seq)
1.61 self.write_number(pos_offset - self.last_pos_offset)
1.62 self.write_number(count)
1.63 - self.end_record()
1.64
1.65 self.last_docnum = docnum
1.66 self.last_pos_offset = pos_offset
1.67 @@ -140,6 +136,7 @@
1.68 self.last_docnum = None
1.69 self.adder = None
1.70 self.last_pos_offset = 0
1.71 + self.begin_record()
1.72
1.73 def read_positions(self):
1.74
1.75 @@ -148,8 +145,6 @@
1.76 file, and the number of documents in a section of that file.
1.77 """
1.78
1.79 - self.begin_record()
1.80 -
1.81 # Read the document number.
1.82
1.83 docnum = self.read_sequence_value()
1.84 @@ -167,7 +162,6 @@
1.85 # Read the document count.
1.86
1.87 count = self.read_number()
1.88 - self.end_record()
1.89
1.90 return self.last_docnum, self.last_pos_offset, count
1.91
1.92 @@ -339,14 +333,14 @@
1.93
1.94 self.position_index_writer.write_positions(first_docnum, first_offset, self.interval)
1.95
1.96 - first_offset = self.position_writer.tell()
1.97 - first_docnum = None
1.98 -
1.99 # Reset the position writer so that position readers accessing
1.100 # a section start with the correct document number.
1.101
1.102 self.position_writer.reset()
1.103
1.104 + first_offset = self.position_writer.tell()
1.105 + first_docnum = None
1.106 +
1.107 # Finish writing an index entry for the remaining documents.
1.108
1.109 else: