This method is called from the manager. It must return a list or a generator
        of BaseRecord objects.
        When it has nothing else to read, it must set class variable "finished" to True.
329419
def get_next_batch(self):
        
        if self.iterator is None:
            self.iterator = self.iteritems()

        count = 0
        while count < self.batch_size:
            count += 1
            yield next(self.iterator)
        self.logger.debug('Done reading batch')
1184780
def _check_base_classes(base_classes, check_for_type):
    
    return_value = False
    for base in base_classes:
        if base.__name__ == check_for_type:
            return_value = True
            break
        else:
            return_value = _check_base_classes(base.__bases__, check_for_type)
            if return_value is True:
                break

    return return_value
625450
def get_resources(self):
        
        if self.retrieved:
            raise errors.IllegalState('List has already been retrieved.')
        self.retrieved = True
        return objects.ResourceList(self._results, runtime=self._runtime)
736208
public synchronized RecordWriter getRecordWriter(String baseFileName) throws IOException,
	    InterruptedException {

		// Look for record-writer in the cache
		OutputContext context = outputContexts.get(baseFileName);

		// If not in cache, create a new one
		if(context == null) {

			context = new OutputContext();

			OutputFormat mainOutputFormat;

			try {
				mainOutputFormat = ((OutputFormat) ReflectionUtils.newInstance(
				    this.context.getOutputFormatClass(), this.context.getConfiguration()));
			} catch(ClassNotFoundException e1) {
				throw new RuntimeException(e1);
			}

			ProxyOutputCommitter baseOutputCommitter = ((ProxyOutputCommitter) mainOutputFormat
			    .getOutputCommitter(this.context));

			// The trick is to create a new Job for each output
			Configuration c = new Configuration(this.context.getConfiguration());
			Job job = new Job(c);

			Class<?> keyClass = getNamedOutputKeyClass(this.context, baseFileName);
			if(keyClass == null && getDefaultNamedOutputKeyClass(this.context) == null) {
				throw new InvalidNamedOutputException("No pre-configured named output for this name / no default named output format specified.");
			}
			job.setOutputKeyClass(keyClass == null ? getDefaultNamedOutputKeyClass(this.context) : keyClass);

			Class<?> valueClass = getNamedOutputValueClass(this.context, baseFileName);
			job.setOutputValueClass(valueClass == null ? getDefaultNamedOutputValueClass(this.context)
			    : valueClass);

			// Check possible specific context for the output
			setSpecificNamedOutputContext(this.context.getConfiguration(), job, baseFileName);
			TaskAttemptContext taskContext;
			try {
				taskContext = TaskAttemptContextFactory.get(job.getConfiguration(),
				    this.context.getTaskAttemptID());
			} catch(Exception e) {
				throw new IOException(e);
			}

			// First we change the output dir for the new OutputFormat that we will
			// create
			// We put it inside the main output work path -> in case the Job fails,
			// everything will be discarded

			taskContext.getConfiguration().set("mapred.output.dir",
			    baseOutputCommitter.getBaseDir() + "/" + baseFileName);
			// This is for Hadoop 2.0 :
			taskContext.getConfiguration().set("mapreduce.output.fileoutputformat.outputdir",
			    baseOutputCommitter.getBaseDir() + "/" + baseFileName);
			context.taskAttemptContext = taskContext;

			// Load the OutputFormat instance
			String outputFormatFile = getNamedOutputFormatInstanceFile(this.context, baseFileName);
			if(outputFormatFile == null) {
				outputFormatFile = getDefaultNamedOutputFormatInstanceFile(this.context);
			}

			OutputFormat outputFormat = InstancesDistributor.loadInstance(
			    context.taskAttemptContext.getConfiguration(), OutputFormat.class, outputFormatFile, true);
			// We have to create a JobContext for meeting the contract of the
			// OutputFormat
			JobContext jobContext;
			try {
				jobContext = JobContextFactory.get(taskContext.getConfiguration(), taskContext.getJobID());
			} catch(Exception e) {
				throw new IOException(e);
			}

			context.jobContext = jobContext;
			// The contract of the OutputFormat is to check the output specs
			outputFormat.checkOutputSpecs(jobContext);
			// We get the output committer so we can call it later
			context.outputCommitter = outputFormat.getOutputCommitter(taskContext);
			// Save the RecordWriter to cache it
			context.recordWriter = outputFormat.getRecordWriter(taskContext);

			// if counters are enabled, wrap the writer with context
			// to increment counters
			if(countersEnabled) {
				context.recordWriter = new RecordWriterWithCounter(context.recordWriter, baseFileName,
				    this.context);
			}

			outputContexts.put(baseFileName, context);
		}
		return context.recordWriter;
	}
578333
def collapse(self):
        
        results = []

        items = self.items

        for values in items:
            if isinstance(values, BaseCollection):
                values = values.all()

            results += values

        return self.__class__(results)
481502
def loadRecords(self, records):
        
        try:
            if self._running:
                return
            
            self._cancelled = False
            self._running = True
            
            try:
                self.setDatabase(records.database())
            except AttributeError:
                pass
            
            self.startLoading()
            
            # make sure the orb module is loaded, or there is really no point
            if RecordSet is None:
                logger.error('Orb was not loaded.')
            
            # lookup a group of results
            if RecordSet.typecheck(records) and records.groupBy():
                levels = records.groupBy()
                next_levels = levels[1:]
                
                for key, records in records.grouped(levels[0]).items():
                    if self._cancelled:
                        break
                    
                    # PySide Hack! Emitting None across threads will crash Qt
                    #              when in PySide mode.
                    if key == None:
                        key = 'None'
                    
                    self.loadedGroup.emit(key, records, next_levels)
            
            # lookup a list of results, in batched mode
            elif self.isBatched():
                self.loadBatch(records)
                
            # lookup a list of results, not in batched mode
            else:
                records = list(records)
                if self._preloadColumns:
                    for record in curr_records:
                        record.recordValues(self._preloadColumns)
                
                self.loadedRecords[object].emit(records)
            
            self._running = False
            self.finishLoading()
        except ConnectionLostError:
            self.finishLoading()
            self.connectionLost.emit()
        except Interruption:
            self.finishLoading()
        finally:
            self.finishLoading()
1260018
def head(records, head):
    
    logging.info('Applying _head generator: '
                 'limiting results to top ' + head + ' records.')

    if head == '-0':
        for record in records:
            yield record
    elif '-' in head:
        with _record_buffer(records) as r:
            record_count = sum(1 for record in r())
            end_index = max(record_count + int(head), 0)
            for record in itertools.islice(r(), end_index):
                yield record
    else:
        for record in itertools.islice(records, int(head)):
            yield record
1237958
public synchronized void finished()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "finished");
    
    checkEntryParent();
    
    synchronized(parentList)
    {
      //remove the cursor from the list
      //this will set the parent list reference to null and make the
      //cursor seubsequently unusable
      forceRemove();      
    }    
    
    if (tc.isEntryEnabled())
      SibTr.exit(tc, "finished");        
  }
367186
public RunList<R> completedOnly() {
        return filter(new Predicate<R>() {
            public boolean apply(R r) {
                return !r.isBuilding();
            }
        });
    }
435395
def objects(self, json_result=False):
        
        self.rows_num = 0
        query = self.query()
        if not isinstance(query, (orm.Result, list, dict)):
            query = do_(query)
        for record in query:
            self.rows_num += 1
            r = self.object(record, json_result)
            self._cal_sum(record)
            yield r
        total = self._render_sum(True)
        if total:
            yield total
83481
def complete(self):
        """"""
        if Part.count(self) != self.last_part_number + 1:
            raise MultipartMissingParts()

        with db.session.begin_nested():
            self.completed = True
            self.file.readable = True
            self.file.writable = False
        return self
964888
def collectors(self, recurse=True, flags=0):
        
        output = {}
        if recurse and self.inherits():
            schema = orb.system.schema(self.inherits())
            if not schema:
                raise orb.errors.ModelNotFound(schema=self.inherits())
            else:
                iflags = (flags & ~orb.Collector.Flags.Virtual) if flags else ~orb.Collector.Flags.Virtual
                output.update(schema.collectors(recurse=recurse, flags=iflags))
        output.update({c.name(): c for c in self.__collectors.values() if not flags or c.testFlag(flags)})
        return output
998933
def finish(self, blueprint, documents):
        """"""

        # Reset the blueprint
        blueprint.reset()

        # Finish the documents
        finished = []
        for document in documents:
            finished.append(blueprint.finish(document))

        return finished
1099818
def search(self, base, scope, filterstr='(objectClass=*)',
               attrlist=None, limit=None) -> Generator[Tuple[str, dict], None, None]:
        

        _debug("search", base, scope, filterstr, attrlist, limit)

        # first results
        if attrlist is None:
            attrlist = ldap3.ALL_ATTRIBUTES
        elif isinstance(attrlist, set):
            attrlist = list(attrlist)

        def first_results(obj):
            _debug("---> searching ldap", limit)
            obj.search(
                base, filterstr, scope, attributes=attrlist, paged_size=limit)
            return obj.response

        # get the 1st result
        result_list = self._do_with_retry(first_results)

        # Loop over list of search results
        for result_item in result_list:
            # skip searchResRef for now
            if result_item['type'] != "searchResEntry":
                continue
            dn = result_item['dn']
            attributes = result_item['raw_attributes']
            # did we already retrieve this from cache?
            _debug("---> got ldap result", dn)
            _debug("---> yielding", result_item)
            yield (dn, attributes)

        # we are finished - return results, eat cake
        _debug("---> done")
        return
232297
def finish(self):
        
        headers, body = self._prepare_batch_request()

        url = "%s/batch/storage/v1" % self.API_BASE_URL

        # Use the private ``_base_connection`` rather than the property
        # ``_connection``, since the property may be this
        # current batch.
        response = self._client._base_connection._make_request(
            "POST", url, data=body, headers=headers
        )
        responses = list(_unpack_batch_response(response))
        self._finish_futures(responses)
        return responses
1050226
public List<?> range(Value begin, Value end) {
		List<Object> results = new ArrayList<Object>();
		Key[] elementKeys = getElementKeys();
		if (elementKeys != null && elementKeys.length > 0) {
			List<Record> records = fetchSubRecords(elementKeys);
			for (Record record : records) {
				if (record != null && filterBinByRange(record, ListElementBinName, begin, end)) {
					results.add(record.getValue(ListElementBinName));
				}
			}
		}
		return results;
	}
433828
Collection<Exception> finish() {
        return Lists.reverse(finishers).stream()
                .flatMap(f -> f.get().map(Stream::of).orElse(Stream.empty()))
                .collect(Collectors.toList());
    }