Uploaded image for project: 'Terrier Core'
  1. Terrier Core
  2. TR-519

getId() should return EOL in (AND|Field|Block|BlockField)IterablePosting after EOL


    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 5.1
    • Component/s: .structures
    • Labels:


      In the BlockIterablePosting class (package org.terrier.structures.postings.bit),
      the getId() public method is inherited from the BasicPostingImpl class (package org.terrier.structures.postings), where it returns the value of the protected member variable id.

      In the implementation of the next() method in the BlockIterablePosting class, if we advance after the end of the posting list, the id variable value is not updated, just returning EOL.

      This means that, when we next() or next(target) at the end of the posting list, and then we invoke getId(), the expected EOL value is not returned, but the useless value of the last docid we moved into.

      A correct implementation of the next() method in the BlockIterablePosting class could be the following (next(target) untouched since it uses next()):

      public int next() throws IOException
      if (numEntries == 0) {
      id = END_OF_LIST;
      } else {
      id += bitFileReader.readGamma();
      tf = bitFileReader.readUnary();
      //TODO: this has a memory allocation for every posting in the posting list. can we reuse an array?
      positions = new int[bitFileReader.readUnary() -1];
      if (positions.length == 0)
      return id;
      positions[0] = bitFileReader.readGamma() -1;
      for(int i=1;i<positions.length;i++)
      positions[i] = positions[i-1] + bitFileReader.readGamma();

      return id;




            • Assignee:
              craigm Craig Macdonald
              nicola.tonellotto Nicola Tonellotto
            • Watchers:
              2 Start watching this issue


              • Created: