Ejemplo n.º 1
0
    def testCachingWorks(self):
        writer = self.getWriter(analyzer=StandardAnalyzer(Version.LUCENE_CURRENT))
        writer.close()
        reader = SlowCompositeReaderWrapper.wrap(self.getReader())
        context = AtomicReaderContext.cast_(reader.getContext())

        class mockFilter(PythonFilter):
            def __init__(self):
                super(mockFilter, self).__init__()
                self._wasCalled = False
            def getDocIdSet(self, context, acceptDocs):
                self._wasCalled = True;
                return FixedBitSet(context.reader().maxDoc())
            def clear(self):
                self._wasCalled = False
            def wasCalled(self):
                return self._wasCalled

        filter = mockFilter()
        cacher = CachingWrapperFilter(filter)

        # first time, nested filter is called
        strongRef = cacher.getDocIdSet(context, context.reader().getLiveDocs())
        self.assert_(filter.wasCalled(), "first time")

        # second time, nested filter should not be called
        filter.clear()
        cacher.getDocIdSet(context, context.reader().getLiveDocs())
        self.assert_(not filter.wasCalled(), "second time")

        reader.close()
Ejemplo n.º 2
0
 def get_fields(self):
     """Returns name of fields in the index."""
     fields = []
     self.open_reader()
     atomic_reader = SlowCompositeReaderWrapper.wrap(self.reader)
     for fieldInfo in atomic_reader.getFieldInfos().iterator():
         fields.append(fieldInfo.name)
     return fields
 def get_fields(self):
     """Returns name of fields in the index."""
     fields = []
     self.open_reader()
     atomic_reader = SlowCompositeReaderWrapper.wrap(self.reader)
     for fieldInfo in atomic_reader.getFieldInfos().iterator():
         fields.append(fieldInfo.name)
     return fields
Ejemplo n.º 4
0
 def num_fields(self):
     """Returns number of fields in the index."""
     self.open_reader()
     atomic_reader = SlowCompositeReaderWrapper.wrap(self.reader)
     return atomic_reader.getFieldInfos().size()
 def num_fields(self):
     """Returns number of fields in the index."""
     self.open_reader()
     atomic_reader = SlowCompositeReaderWrapper.wrap(self.reader)
     return atomic_reader.getFieldInfos().size()