Process the given batch of files and pass the results back to the listener as each file is processed.
343701
public static BatchASTFuture analyze(final BatchASTListener listener, final WildcardImportResolver importResolver,
                final Set<String> libraryPaths,
                final Set<String> sourcePaths, Set<Path> sourceFiles)
    {

        final String[] encodings = null;
        final String[] bindingKeys = new String[0];
        final ExecutorService executor = WindupExecutors.newFixedThreadPool(WindupExecutors.getDefaultThreadCount());
        final FileASTRequestor requestor = new FileASTRequestor()
        {
            @Override
            public void acceptAST(String sourcePath, CompilationUnit ast)
            {
                try
                {
                    /*
                     * This super() call doesn't do anything, but we call it just to be nice, in case that ever changes.
                     */
                    super.acceptAST(sourcePath, ast);
                    ReferenceResolvingVisitor visitor = new ReferenceResolvingVisitor(importResolver, ast, sourcePath);
                    ast.accept(visitor);
                    listener.processed(Paths.get(sourcePath), visitor.getJavaClassReferences());
                }
                catch (WindupStopException ex)
                {
                    throw ex;
                }
                catch (Throwable t)
                {
                    listener.failed(Paths.get(sourcePath), t);
                }
            }
        };

        List<List<String>> batches = createBatches(sourceFiles);

        for (final List<String> batch : batches)
        {
            executor.submit(new Callable<Void>()
            {
                @Override
                public Void call() throws Exception
                {
                    ASTParser parser = ASTParser.newParser(AST.JLS8);
                    parser.setBindingsRecovery(false);
                    parser.setResolveBindings(true);
                    Map<String, String> options = JavaCore.getOptions();
                    JavaCore.setComplianceOptions(JavaCore.VERSION_1_8, options);
                    // these options seem to slightly reduce the number of times that JDT aborts on compilation errors
                    options.put(JavaCore.CORE_INCOMPLETE_CLASSPATH, "warning");
                    options.put(JavaCore.COMPILER_PB_ENUM_IDENTIFIER, "warning");
                    options.put(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, "warning");
                    options.put(JavaCore.CORE_CIRCULAR_CLASSPATH, "warning");
                    options.put(JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, "warning");
                    options.put(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION, "warning");
                    options.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, "ignore");
                    options.put(JavaCore.COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT, "warning");
                    options.put(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, "warning");
                    options.put(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE, "warning");

                    parser.setCompilerOptions(options);
                    parser.setEnvironment(libraryPaths.toArray(new String[libraryPaths.size()]),
                                sourcePaths.toArray(new String[sourcePaths.size()]),
                                null,
                                true);

                    parser.createASTs(batch.toArray(new String[batch.size()]), encodings, bindingKeys, requestor, null);
                    return null;
                }
            });
        }

        executor.shutdown();

        return new BatchASTFuture()
        {
            @Override
            public boolean isDone()
            {
                return executor.isTerminated();
            }
        };
    }
119094
private void executeBatchRewrite(Results results,
      final ClientPrepareResult prepareResult, List<ParameterHolder[]> parameterList,
      boolean rewriteValues) throws SQLException {

    cmdPrologue();

    ParameterHolder[] parameters;
    int currentIndex = 0;
    int totalParameterList = parameterList.size();

    try {

      do {

        currentIndex = ComQuery.sendRewriteCmd(writer, prepareResult.getQueryParts(), currentIndex,
            prepareResult.getParamCount(), parameterList, rewriteValues);
        getResult(results);

        if (Thread.currentThread().isInterrupted()) {
          throw new SQLException("Interrupted during batch", INTERRUPTED_EXCEPTION.getSqlState(),
              -1);
        }

      } while (currentIndex < totalParameterList);

    } catch (SQLException sqlEx) {
      throw logQuery.exceptionWithQuery(sqlEx, prepareResult);
    } catch (IOException e) {
      throw handleIoException(e);
    } finally {
      results.setRewritten(rewriteValues);
    }
  }
597308
private void processData(final ResultSet rs,
                             List<DataListener> listeners) {

        try {
            ResultSetMetaData rsmd = rs.getMetaData();
            int colCount = rsmd.getColumnCount();

            int i = 0;

            while (rs.next()) {
                newRow(listeners, i, colCount);
                for (int cellNum = 1; cellNum < colCount + 1; cellNum++) {
                    String cell;

                    int sqlType = rsmd.getColumnType(cellNum);
                    switch (sqlType) {
                        case java.sql.Types.DATE:
                            cell = rs.getDate(cellNum).toString();
                            break;
                        case java.sql.Types.INTEGER:
                        case java.sql.Types.DOUBLE:
                            cell = String.valueOf(rs.getInt(cellNum));
                            break;
                        default:
                            cell = rs.getString(cellNum);
                    }

                    newCell(listeners,
                            i,
                            cellNum - 1,
                            cell,
                            DataListener.NON_MERGED);
                }
                i++;
            }

        } catch (SQLException e) {
            //TODO: you need to throw or handle
        }

        finishData(listeners);
    }
4649
def Run(self):
    """"""
    try:

      self.stats = {}

      self.BeginProcessing()

      processed_count = 0

      for client_info_batch in _IterateAllClients(
          recency_window=self.recency_window):
        for client_info in client_info_batch:
          self.ProcessClientFullInfo(client_info)
        processed_count += len(client_info_batch)
        self.Log("Processed %d clients.", processed_count)
        self.HeartBeat()

      self.FinishProcessing()
      for fd in itervalues(self.stats):
        fd.Close()

      logging.info("%s: processed %d clients.", self.__class__.__name__,
                   processed_count)
    except Exception as e:  # pylint: disable=broad-except
      logging.exception("Error while calculating stats: %s", e)
      raise
499456
@Override
  public void processEvent(QueryBatch batch) {
    try {
      batch.getClient().newDocumentManager().delete( batch.getItems() );
    } catch (Throwable t) {
      for ( BatchFailureListener<Batch<String>> listener : failureListeners ) {
        try {
          listener.processFailure(batch, t);
        } catch (Throwable t2) {
          logger.error("Exception thrown by an onBatchFailure listener", t2);
        }
      }
      for ( BatchFailureListener<QueryBatch> queryBatchFailureListener : queryBatchFailureListeners ) {
        try {
          queryBatchFailureListener.processFailure(batch, t);
        } catch (Throwable t2) {
          logger.error("Exception thrown by an onFailure listener", t2);
        }
      }
    }
  }
1111783
def _process_results():
    """"""
    async = get_current_async()
    callbacks = async.get_callbacks()

    if not isinstance(async.result.payload, AsyncException):
        callback = callbacks.get('success')
    else:
        callback = callbacks.get('error')

        if not callback:
            raise async.result.payload.exception, None, \
                async.result.payload.traceback[2]

    return _execute_callback(async, callback)
199792
def run(self, in_batches):
        
        if len(in_batches) != len(self._batcmd.batch_to_file_s):
            BaseShellOperator._rm_process_input_tmpfiles(self._batcmd.batch_to_file_s)  # [todo] - Removing tmpfiles can be easily forgot. Less lifetime for tmpfile.
            raise AttributeError('len(in_batches) == %d, while %d IN_BATCH* are specified in command below:%s$ %s' %
                                 (len(in_batches), len(self._batcmd.batch_to_file_s), os.linesep, self._batcmd.sh_cmd))

        # prepare & start process (if necessary)
        BaseShellOperator._batches_to_tmpfile(self._in_record_sep, self._in_column_sep, in_batches, self._batcmd.batch_to_file_s)
        if self._process is None:
            self._process = BaseShellOperator._start_process(
                self._batcmd, self._cwd, self._env,
                non_blocking_stdout=True)

        # Begin thread to read from subprocess's stdout.
        # Without this thread, subprocess's output buffer becomes full and no one solves it.
        t_consumer = Thread(target=get_subprocess_output,
                            args=(self._process.stdout, self._batch_done_output, self._subprocess_out_str))
        t_consumer.start()

        # pass batch to subprocess
        BaseShellOperator._batch_to_stdin(self._process, self._in_record_sep, self._in_column_sep,
                                          in_batches, self._batcmd.batch_to_file_s)

        # pass batch-done indicator to subprocess
        self._process.stdin.write(self._batch_done_indicator)

        # get output from subprocess
        t_consumer.join()
        subprocess_out_str       = self._subprocess_out_str[0]
        self._subprocess_out_str = []
        out_batch = BaseShellOperator._out_str_to_batch(subprocess_out_str,
                                                        self._out_recdef, self._out_col_patterns)
        return out_batch
716239
def batch(self, queries):
        
        with self.connection() as cur:
            for sql, vars in queries:

                if self.debug:
                    print(cur.mogrify(query, vars))
                cur.execute(sql, vars)
607311
def process_files():
    

    with enlighten.Manager() as manager:
        with manager.counter(total=SPLINES, desc='Reticulating:', unit='splines') as retic:
            for num in range(SPLINES):  # pylint: disable=unused-variable
                time.sleep(random.uniform(0.1, 0.5))  # Random processing time
                retic.update()

        with manager.counter(total=LLAMAS, desc='Herding:', unit='llamas') as herd:
            for num in range(SPLINES):  # pylint: disable=unused-variable
                time.sleep(random.uniform(0.1, 0.5))  # Random processing time
                herd.update()
121887
public void flush() {
    try {
      ArrayList<Batch> batches = this.incomplete.all();
      int numOutstandingRecords = 0;
      for (Batch batch: batches) {
        numOutstandingRecords += batch.getRecords().size();
      }
      LOG.debug ("Flush called on {} batches with {} records total", batches.size(), numOutstandingRecords);
      for (Batch batch: batches) {
        batch.await();
      }
    } catch (Exception e) {
      LOG.error ("Error happened while flushing batches");
    }
  }
765153
def process(self, tup):
        
        # Append latest Tuple to batches
        group_key = self.group_key(tup)
        self._batches[group_key].append(tup)
1284959
void process() {

        int len = vList.size();

        for (int i = 0; i < len; i++) {
            System.out.print(".");

            String file = (String) vList.elementAt(i);

            if (!processFile(file)) {
                System.out.println("in file " + file + " !");
            }
        }

        System.out.println("");
    }
1053712
def process_batches(self):
        
        for key, batch in iteritems(self._batches):
            self._current_tups = batch
            self._current_key = key
            self.process_batch(key, batch)
            if self.auto_ack:
                for tup in batch:
                    self.ack(tup)
            # Set current batch to [] so that we know it was acked if a
            # later batch raises an exception
            self._current_key = None
            self._batches[key] = []
        self._batches = defaultdict(list)
1109596
def batch(self, methods):
        
        methods = list(methods) # methods can be iterator
        if not methods:
            #accepts also empty list (or generator) - it allows call batch directly with query result (eventually empty)
            return
        queries, callbacks = list(zip(*[m(batch=True) for m in methods]))
        # perform all the operations in one batch
        responses = self.execute("", "POST", requests=queries)
        # perform the callbacks with the response data (updating the existing
        # objets, etc)

        batched_errors = []
        for callback, response in zip(callbacks, responses):
            if "success" in response:
                callback(response["success"])
            else:
                batched_errors.append(response["error"])

        if batched_errors:
            raise core.ParseBatchError(batched_errors)
1093036
public int getNextFiles(final File[] files, final int batchSize) throws IOException {
		int c=0;
		while(c<batchSize) {
			File file=getNextFile();
			if(file==null) break;
			files[c++]=file;
		}
		return c;
	}
1170996
function proceedWithBackup() {
    if (options.resume) {
      // pick up from existing log file from previous run
      downloadRemainingBatches(options.log, db, ee, start, batchesPerDownloadSession, options.parallelism);
    } else {
      // create new log file and process
      spoolchanges(db, options.log, options.bufferSize, ee, function(err) {
        if (err) {
          ee.emit('error', err);
        } else {
          downloadRemainingBatches(options.log, db, ee, start, batchesPerDownloadSession, options.parallelism);
        }
      });
    }
  }
136637
public void startListening() throws FileNotFoundException, ClassNotFoundException, IOException,
        ResourceNotExistingException, TTException {
        mProcessingThread = new Thread() {
            public void run() {
                try {
                    processFileNotifications();
                } catch (InterruptedException | TTException | IOException e) {
                }
            }
        };
        mProcessingThread.start();

        initSessions();
    }