Beispiel #1
0
 def test_search_Every_reverse(self):
     start = EVID.fromDatetime(*Bier_Searching_Tests.test_data[0][0:2])
     end = EVID.fromDatetime(*Bier_Searching_Tests.test_data[-1][0:2])
     period = Period(start, end, False, False)
     resultset = yield searchIndices([self.output.getIndex(),], Every(), period, reverse=True).whenDone()
     results = [EVID(*ev[0]) for ev in resultset.events]
     test_data = sorted([EVID.fromDatetime(ts,offset) for ts,offset,_ in Bier_Searching_Tests.test_data], reverse=True)
     self.assertEqual(results, test_data, "%s != %s" % (
         [str(evid) for evid in results], [str(evid) for evid in test_data]))
Beispiel #2
0
 def test_search_Every(self):
     start = EVID.fromDatetime(*Bier_Searching_Tests.test_data[0][0:2])
     end = EVID.fromDatetime(*Bier_Searching_Tests.test_data[-1][0:2])
     period = Period(start, end, False, False)
     resultset = yield searchIndices([
         self.output.getIndex(),
     ], Every(), period).whenDone()
     results = [EVID(*ev[0]) for ev in resultset.events]
     test_data = [
         EVID.fromDatetime(ts, offset)
         for ts, offset, _ in Bier_Searching_Tests.test_data
     ]
     self.assertEqual(
         results, test_data, "%s != %s" %
         ([str(evid)
           for evid in results], [str(evid) for evid in test_data]))
Beispiel #3
0
        # if lastId is 0, return the id of the latest document
        if lastId == None:
            return QueryResult({'runtime': 0.0, 'lastId': str(EVID.fromDatetime())}, [])
        try:
            lastId = EVID.fromString(lastId)
        except:
            raise QueryExecutionError("invalid lastId '%s'" % str(lastId))
        # check that limit is > 0
        if limit < 1:
            raise QueryExecutionError("limit must be greater than 0")
        query = parseTailQuery(query)
        logger.trace("tail query: %s" % query)
        period = Period(lastId, EVID.fromString(EVID.MAX_ID), True, False)
        logger.trace("tail period: %s" % period)
        # query each index, and return the results
        task = searchIndices(indices, query, period, None, False, fields, limit)
        def _returnTailResult(result, lastId=None):
            if isinstance(result, Failure) and result.check(SearcherError):
                raise QueryExecutionError(str(e))
            events = list(result.events)
            if len(events) > 0:
                lastId = events[-1][0]
            metadata = {'runtime': result.runtime, 'lastId': str(lastId), 'fields': result.fields}
            return QueryResult(metadata, events)
        return task.whenDone().addBoth(_returnTailResult, lastId)

    def showIndex(self, name):
        """
        Return metadata about the specified index.  Currently the only information
        returned is the number of events in the index, the last-modified time (as a
        unix timestamp), and the event ID of the latest event.