

def dispatchToAnnotate(self):
    if (('indexPhrases' in self.config) and (self.config['indexPhrases'] == False)):
        return
    nextDocumentIndex = 0
    if (self.config['processingStartIndex'] != None):
        nextDocumentIndex = self.config['processingStartIndex']
    endDocumentIndex = (- 1)
    if (self.config['processingEndIndex'] != None):
        endDocumentIndex = self.config['processingEndIndex']
    if ((endDocumentIndex != (- 1)) and (self.processingPageSize > (endDocumentIndex - nextDocumentIndex))):
        self.processingPageSize = ((content - nextDocumentIndex) + 1)
    self.totalDocumentsDispatched = 0
    while True:
        documents = self.esClient.search(index=self.corpusIndex, doc_type=self.corpusType, body={
            'from': nextDocumentIndex,
            'size': self.processingPageSize,
            'query': {
                'match_all': {
                    
                },
            },
            'sort': [{
                '_id': {
                    'order': 'asc',
                },
            }],
        }, fields=['_id'])
        if (len(documents['hits']['hits']) == 0):
            break
        self.totalDocumentsDispatched += len(documents['hits']['hits'])
        self.logger.info((((('Annotating ' + str(nextDocumentIndex)) + ' to ') + str((nextDocumentIndex + len(documents['hits']['hits'])))) + ' documents...'))
        for document in documents['hits']['hits']:
            self.logger.info(('Dispatching document ' + document['_id']))
            content = {
                'documentId': document['_id'],
                'type': 'annotate',
                'count': 1,
                'from': self.dispatcherName,
            }
            self.annotationDispatcher.send(content, self.workerName)
        nextDocumentIndex += len(documents['hits']['hits'])
        if ((endDocumentIndex != (- 1)) and (endDocumentIndex <= nextDocumentIndex)):
            break
    self.logger.info((str(self.totalDocumentsDispatched) + ' documents dispatched'))
    while True:
        message = self.annotationDispatcher.receive()
        if (('documentId' in message['content']) and (message['content']['documentId'] > 0)):
            self.documentsAnnotated += 1
            self.annotationDispatcher.close(message)
            self.logger.info(((((('Annotated document ' + message['content']['documentId']) + ' - ') + str(self.documentsAnnotated)) + '/') + str(self.totalDocumentsDispatched)))
        if (((self.documentsAnnotated + self.documentsNotAnnotated) >= self.totalDocumentsDispatched) and (not self.lastDispatcher)):
            self.controlChannel.send('dying')
            self.annotationDispatcher.end()
            break
    self.__terminate()

dataset/ETHPy150Open pandastrike/bayzee/src/annotation_dispatcher.py AnnotationDispatcher.dispatchToAnnotate/VarMisuse@128/178 `endDocumentIndex`->`content`