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

Some indexers do not set the IterablePosting class for the DirectIndex

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.5
    • Component/s: .structures
    • Labels:
      None

      Description

      org.terrier.structures.BitPostingIndex.getPostings(BitIndexPointer) is not able to instantiate the postingImplementation when fields are used. The error happens in line 105ff:

      {code}
      if (fieldCount > 0)
      rtr = postingImplementation
      .getConstructor(BitIn.class, Integer.TYPE, DocumentIndex.class, Integer.TYPE)
      .newInstance(file, pointer.getNumberOfEntries(), null, fieldCount);
      else
      rtr = postingImplementation
      .getConstructor(BitIn.class, Integer.TYPE, DocumentIndex.class)
      .newInstance(file, pointer.getNumberOfEntries(), null);
      {code}


      The reason is that per default this constructor is called and thus a BasicIterablePosting is used:

      {code}
      public DirectIndex(Index index, String structureName) throws IOException {
      super(index, structureName, BasicIterablePosting.class);
      docIndex = index.getDocumentIndex();
      }
      {code}

      The solution is to adjust the code as follows:

      {code}
      public DirectIndex(Index index, String structureName) throws IOException {
      super(index, structureName, index.getIntIndexProperty("index.direct.fields.count", 0) > 0 ?
      FieldIterablePosting.class : BasicIterablePosting.class);
      docIndex = index.getDocumentIndex();
      }
      {code}

      The same goes for org.terrier.structures.DirectIndexInputStream.DirectIndexInputStream(Index, String):

      {code}
      public DirectIndexInputStream(Index index, String structureName) throws IOException
      {
      super(index, structureName, (Iterator<DocumentIndexEntry>)index.getIndexStructureInputStream("document"),
      index.getIntIndexProperty("index.direct.fields.count", 0) > 0 ?
      FieldIterablePosting.class : BasicIterablePosting.class);
      }
      {code}

      I didn't check if this problem is also present in additional parts of the code.

        Attachments

          Activity

            People

            • Assignee:
              craigm Craig Macdonald
              Reporter:
              rec Richard Eckart de Castilho
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: